-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
39 lines (29 loc) · 1.01 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
.PHONY: clean
VERSION := $(if ${CDS_SEMVER},${CDS_SEMVER},snapshot)
TARGET_DIR = ./dist
TARGET_BIN = os-ansible-inventory
TARGET_LDFLAGS = -ldflags "-X github.com/ovh/cds/sdk.VERSION=$(VERSION)"
TARGET_OS = linux
TARGET_ARCH = $(if ${ARCH},${ARCH},amd64 arm 386)
GO_BUILD = go build -v
GO_LINT = ${GOPATH}/bin/gometalinter
$(TARGET_DIR):
$(info create $(TARGET_DIR) directory)
@mkdir -p $(TARGET_DIR)
$(GO_LINT):
go get -u github.com/alecthomas/gometalinter
default: build
clean:
@rm -rf $(TARGET_DIR)
build: $(TARGET_DIR)
@for GOOS in $(TARGET_OS); do \
for GOARCH in $(TARGET_ARCH); do \
EXTENSION=""; \
if test "$$GOOS" = "windows" ; then EXTENSION=".exe"; fi; \
echo Compiling $(TARGET_DIR)/$(TARGET_BIN)-$$GOOS-$$GOARCH$$EXTENSION $(VERSION); \
GOOS=$$GOOS GOARCH=$$GOARCH $(GO_BUILD) $(TARGET_LDFLAGS) -o $(TARGET_DIR)/$(TARGET_BIN)-$$GOOS-$$GOARCH$$EXTENSION; \
done; \
done
lint: $(GO_LINT)
$(GO_LINT) --install --force
$(GO_LINT) --fast --tests --vendor --disable=gas --disable=gotype ./...