-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
39 lines (30 loc) · 1.15 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
# VARIABLES
PACKAGE="github.com/mtenrero/k8sconfigmap-azappservice"
BINARY_NAME="k8sconfigmap-azappservice"
COMPILE_PATH="./build/"
EXECUTABLES = git go find pwd
PLATFORMS=darwin linux windows
ARCHITECTURES=386 amd64
default: usage
clean: ## Trash binary files
@echo "--> cleaning..."
@go clean || (echo "Unable to clean project" && exit 1)
@rm -rf $(GOPATH)/bin/$(BINARY_NAME) 2> /dev/null
@echo "Clean OK"
test: ## Run all tests
@echo "--> testing..."
@go test -v $(PACKAGE)/...
install: clean ## Compile sources and build binary
@echo "--> installing..."
@go install $(PACKAGE) || (echo "Compilation error" && exit 1)
@echo "Install OK"
run: install ## Run your application
@echo "--> running application..."
@$(GOPATH)/bin/$(BINARY_NAME)
build:
go build ${LDFLAGS} -o ${BINARY_NAME}
build_all:
$(foreach GOOS, $(PLATFORMS),\
$(foreach GOARCH, $(ARCHITECTURES), $(shell export GOOS=$(GOOS); export GOARCH=$(GOARCH); go build -v -o $(COMPILE_PATH)$(BINARY_NAME)-$(GOOS)-$(GOARCH))))
usage: ## List available targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'