-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
79 lines (65 loc) · 2.27 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
SHELL = sh
PROJECT_ROOT := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
# GIT_COMMIT := $(shell git rev-parse HEAD)
# GIT_DIRTY := $(if $(shell git status --porcelain),+CHANGES)
# GO_LDFLAGS ?= -X=github.com/seashell/aqueduct/version.GitCommit=$(GIT_COMMIT)$(GIT_DIRTY)
GO_LDFLAGS = ""
CGO_ENABLED ?= 0
# User defined flags
OS := $(or $(OS),$(O)) # (coming soon) Define build target OS, e.g linux
ARCH := $(or $(ARCH),$(A)) # (coming soon) Define build target architecture, e.g amd64
# targets
ALL_TARGETS += linux_amd64 \
default: help
build/linux_amd64/aqueduct: CMD='CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=amd64 \
go build \
-trimpath \
-ldflags $(GO_LDFLAGS) \
-o "$@" '
build/linux_amd64/aqueduct: $(SOURCE_FILES) ## Build aqueduct for linux/amd64
@eval ${CMD}
build/linux_arm64/aqueduct: CMD='CGO_ENABLED=$(CGO_ENABLED) GOOS=linux GOARCH=arm64 \
go build \
-trimpath \
-ldflags $(GO_LDFLAGS) \
-o "$@" '
build/linux_arm64/aqueduct: $(SOURCE_FILES) ## Build aqueduct for linux/amd64
@eval ${CMD}
.PHONY: dev
dev: GOOS=$(shell go env GOOS)
dev: GOARCH=$(shell go env GOARCH)
dev: DEV_TARGET=build/$(GOOS)_$(GOARCH)/aqueduct
dev: ## Build for the current development platform
@echo "==> Removing old development binary..."
@rm -rf $(PROJECT_ROOT)/build
@$(MAKE) ui
@$(MAKE) --no-print-directory $(DEV_TARGET)
.PHONY: ui
ui: ## Generate UI .go bundle
@echo "==> Generating UI bundle..."
@go generate
.PHONY: clean
clean: ## Remove build artifacts
@echo "==> Cleaning build artifacts..."
@rm -rf "$(PROJECT_ROOT)/build/"
HELP_FORMAT=" \033[36m%-25s\033[0m %s\n"
EG_FORMAT=" \033[36m%s\033[0m %s\n"
.PHONY: help
help: ## Display this usage information
@echo "Valid targets:"
@grep -E '^[^ ]+:.*?## .*$$' $(MAKEFILE_LIST) | \
sort | \
awk 'BEGIN {FS = ":.*?## "}; \
{printf $(HELP_FORMAT), $$1, $$2}'
@echo ""
@echo "This host will build the following targets if 'make release' is invoked:"
@echo $(ALL_TARGETS) | sed 's/^/ /'
@echo ""
@echo "Valid flags:"
@grep -E '^[^ ]+ :=.*?## .*$$' $(MAKEFILE_LIST) | \
sort | \
awk 'BEGIN {FS = " :=.*?## "}; \
{printf $(HELP_FORMAT), $$1, $$2}'
@echo ""
@echo "Examples:"
@printf $(EG_FORMAT) "~${PWD}" "$$ make clean"