-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
63 lines (45 loc) · 1.45 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
CC=go
RM=rm
MV=mv
SOURCEDIR=.
SOURCES := $(shell find $(SOURCEDIR) -name '*.go')
#GOPATH=$(SOURCEDIR)/
GOOS=linux
GOARCH=amd64
#GOARCH=arm
GOARM=7
VERSION=1
BUILD_TIME=`date +%FT%T%z`
BUILD_COMPILATION=`date +%F`
EXEC=kml
PACKAGES :=
LIBS=
LDFLAGS=-buildmode=archive
.DEFAULT_GOAL:= $(EXEC)
$(EXEC): organize $(SOURCES)
@echo " Compilation des sources ${BUILD_TIME}"
@if [ "arm" = "${GOARCH}" ]; then\
GOPATH=$(PWD)/../.. GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM} go build ${LDFLAGS} -o ${EXEC}-${VERSION}_${BUILD_COMPILATION}.a $(SOURCEDIR)/;\
else\
GOPATH=$(PWD)/../.. GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM} go build ${LDFLAGS} -o ${EXEC}-${VERSION}_${BUILD_COMPILATION}.a $(SOURCEDIR)/;\
fi
@echo " ${EXEC}-${VERSION}.a generated."
deps: init
@echo " Download packages"
@$(foreach element,$(PACKAGES),go get -d -v $(element);)
organize: deps
@echo " Go FMT"
@$(foreach element,$(SOURCES),go fmt $(element);)
init: clean
@echo " Init of the project"
execute:
./${EXEC}-${VERSION}
clean:
@if [ -f "${EXEC}-${VERSION}_${BUILD_COMPILATION}.a" ] ; then rm ${EXEC}-${VERSION}_${BUILD_COMPILATION}.a ; fi
@echo " Nettoyage effectuee"
package: ${EXEC}
@zip -r ${EXEC}-${GOOS}-${GOARCH}-${VERSION}.zip ./${EXEC}-${VERSION}_${BUILD_COMPILATION}.a
@echo " Archive ${EXEC}-${GOOS}-${GOARCH}-${VERSION}.zip created"
audit: ${EXEC}
@go tool vet -all -shadow ./
@echo " Audit effectue"