-
Notifications
You must be signed in to change notification settings - Fork 297
/
Makefile
61 lines (48 loc) · 1.63 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
TARGET=./dist
ARCHS=amd64 386
GOOS=windows linux darwin
PACKAGENAME="github.com/k8gege/LadonGo"
COMMIT=`git rev-parse --short HEAD`
DATE=`date +%m/%d/%y`
GOVERSION=`go version | cut -d " " -f 3`
ifdef VERSION
VERSION := $(VERSION)
else
VERSION := dev
endif
LDFLAGS="-X ${PACKAGENAME}/util.GitCommit=${COMMIT} \
-X ${PACKAGENAME}/util.BuildDate=${DATE} \
-X ${PACKAGENAME}/util.GoVersion=${GOVERSION} \
-X ${PACKAGENAME}/util.Version=${VERSION} \
"
.PHONY: help windows linux mac all clean
help: ## Show this help.
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
windows: ## Make Windows x86 and x64 Binaries
@for ARCH in ${ARCHS}; do \
echo "Building for windows $${ARCH}.." ;\
GOOS=windows GOARCH=$${ARCH} go build -a -ldflags ${LDFLAGS} -o ${TARGET}/Ladon_windows_$${ARCH}.exe || exit 1 ;\
done; \
echo "Done."
linux: ## Make Linux x86 and x64 Binaries
@for ARCH in ${ARCHS}; do \
echo "Building for linux $${ARCH}..." ; \
GOOS=linux GOARCH=$${ARCH} go build -a -ldflags ${LDFLAGS} -o ${TARGET}/Ladon_linux_$${ARCH} || exit 1 ;\
done; \
echo "Done."
mac: ## Make Darwin (Mac) x86 and x64 Binaries
@for ARCH in ${ARCHS}; do \
echo "Building for mac $${ARCH}..." ; \
GOOS=darwin GOARCH=$${ARCH} go build -a -ldflags ${LDFLAGS} -o ${TARGET}/Ladon_darwin_$${ARCH} || exit 1 ;\
done; \
echo "Done."
install: ## Install to System
@go build -a -ldflags ${LDFLAGS} -o /usr/local/bin/Ladon
@echo "Done."
@echo "========Test========"
@Ladon
clean: ## Delete any binaries
@rm -f ${TARGET}/* ; \
echo "Done."
all: ## Make Windows, Linux and Mac x86/x64 Binaries
all: clean windows linux mac