This repository has been archived by the owner on May 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
107 lines (86 loc) · 3.4 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
PROJECT_NAME=fabric8-starter
PACKAGE_NAME:=github.com/fabric8-services/$(PROJECT_NAME)
CUR_DIR=$(shell pwd)
TMP_PATH=$(CUR_DIR)/tmp
INSTALL_PREFIX=$(CUR_DIR)/bin
VENDOR_DIR=vendor
# declares variable that are OS-sensitive
SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
ifeq ($(OS),Windows_NT)
include $(SELF_DIR)Makefile.win
else
include $(SELF_DIR)Makefile.lnx
endif
# -------------------------------------------------------------------
# help!
# -------------------------------------------------------------------
.PHONY: help
help: ## Print this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
# -------------------------------------------------------------------
# required tools
# -------------------------------------------------------------------
# Find all required tools:
GIT_BIN := $(shell command -v $(GIT_BIN_NAME) 2> /dev/null)
DEP_BIN_DIR := $(TMP_PATH)/bin
DEP_BIN := $(DEP_BIN_DIR)/$(DEP_BIN_NAME)
DEP_VERSION=v0.4.1
GO_BIN := $(shell command -v $(GO_BIN_NAME) 2> /dev/null)
$(INSTALL_PREFIX):
mkdir -p $(INSTALL_PREFIX)
$(TMP_PATH):
mkdir -p $(TMP_PATH)
.PHONY: prebuild-check
prebuild-check: $(TMP_PATH) $(INSTALL_PREFIX)
# Check that all tools where found
ifndef GIT_BIN
$(error The "$(GIT_BIN_NAME)" executable could not be found in your PATH)
endif
ifndef DEP_BIN
$(error The "$(DEP_BIN_NAME)" executable could not be found in your PATH)
endif
ifndef GO_BIN
$(error The "$(GO_BIN_NAME)" executable could not be found in your PATH)
endif
# -------------------------------------------------------------------
# deps
# -------------------------------------------------------------------
$(DEP_BIN_DIR):
mkdir -p $(DEP_BIN_DIR)
.PHONY: deps
deps: $(DEP_BIN) $(VENDOR_DIR) ## Download the build dependencies.
# install dep in a the tmp/bin dir of the repo
$(DEP_BIN): $(DEP_BIN_DIR)
@echo "Installing 'dep' $(DEP_VERSION) at '$(DEP_BIN_DIR)'..."
mkdir -p $(DEP_BIN_DIR)
ifeq ($(UNAME_S),Darwin)
@curl -L -s https://github.com/golang/dep/releases/download/$(DEP_VERSION)/dep-darwin-amd64 -o $(DEP_BIN)
@cd $(DEP_BIN_DIR) && \
curl -L -s https://github.com/golang/dep/releases/download/$(DEP_VERSION)/dep-darwin-amd64.sha256 -o $(DEP_BIN_DIR)/dep-darwin-amd64.sha256 && \
echo "1544afdd4d543574ef8eabed343d683f7211202a65380f8b32035d07ce0c45ef dep" > dep-darwin-amd64.sha256 && \
shasum -a 256 --check dep-darwin-amd64.sha256
else
@curl -L -s https://github.com/golang/dep/releases/download/$(DEP_VERSION)/dep-linux-amd64 -o $(DEP_BIN)
@cd $(DEP_BIN_DIR) && \
echo "31144e465e52ffbc0035248a10ddea61a09bf28b00784fd3fdd9882c8cbb2315 dep" > dep-linux-amd64.sha256 && \
sha256sum -c dep-linux-amd64.sha256
endif
@chmod +x $(DEP_BIN)
$(VENDOR_DIR): Gopkg.toml
@echo "checking dependencies with $(DEP_BIN_NAME)"
@$(DEP_BIN) ensure -v
.PHONY: build
build: deps generate-assets ## Build the binary
ifeq ($(OS),Windows_NT)
go build -v $(LDFLAGS) -o "$(shell cygpath --windows '$(BINARY_BIN)')"
else
go build -v $(LDFLAGS) -o $(BINARY_BIN)
endif
BINDATA_BIN:=$(VENDOR_DIR)/github.com/go-bindata/go-bindata/go-bindata/$(BINDATA_NAME)
.PHONY: generate-assets
generate-assets: prebuild-check $(BINDATA_BIN) ## Generate the assets file
$(BINDATA_BIN) -pkg bootstrap -o bootstrap/bindata.go assets/...
$(BINDATA_BIN): deps
cd $(VENDOR_DIR)/github.com/go-bindata/go-bindata/go-bindata && \
go build -o $(BINDATA_NAME) . && \
chmod u+x $(BINDATA_NAME)