-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
87 lines (63 loc) · 1.81 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
MAIN := main.go
PUFCTLVER := 0.0.0
DATE := $(shell date --iso)
BINARY := pufctl
LINUX := linux
DARWIN := darwin
WINDOWS := windows
ARCH := amd64
GOARCH := GOARCH=${ARCH}
GOOS := GOOS=
BUILDCMD := go build
PUFCTLPKG := github.com/hsnodgrass/pufctl/internal
define quickbuildcmd
echo "Performing $(1) quick build..."
${GOOS}$(1) ${GOARCH} ${BUILDCMD} -o bin/$(1)/$(2) ${MAIN}
endef
define cleancmd
echo "Deleting $(1) binaries..."
rm -rf bin/$(1)/*
endef
define releasecmd
echo "Compiling pufctl version ${PUFCTLVER} release binary for $(1)..."
mkdir -p release/$(1)/
${GOOS}$(1) ${GOARCH} ${BUILDCMD} \
-ldflags="-X '${PUFCTLPKG}/version.Ver=${PUFCTLVER}' -X '${PUFCTLPKG}/version.OS=$(1)' -X '${PUFCTLPKG}/version.Arch=${ARCH}' -X '${PUFCTLPKG}/version.Time=$(3)'" \
-o release/$(1)/$(2) ${MAIN}
endef
define checksumcmd
echo "Creating sha256 checksum for release binary $(2)..."
$(shell sha256sum release/$(1)/$(2) > release/$(1)/sha256checksum.txt)
endef
build: nixbuild darbuild winbuild
nixbuild:
@$(call quickbuildcmd,${LINUX},${BINARY})
darbuild:
@$(call quickbuildcmd,${DARWIN},${BINARY})
winbuild:
@$(call quickbuildcmd,${WINDOWS},${BINARY}.exe)
clean: nixclean darclean winclean
nixclean:
@$(call cleancmd,${LINUX})
darclean:
@$(call cleancmd,${DARWIN})
winclean:
@$(call cleancmd,${WINDOWS})
run:
@go run ${MAIN}
checksum: nixchecksum darchecksum winchecksum
nixchecksum:
@$(call checksumcmd,${LINUX},${BINARY})
darchecksum:
@$(call checksumcmd,${DARWIN},${BINARY})
winchecksum:
@$(call checksumcmd,${WINDOWS},${BINARY}.exe)
sign:
gon -log-level=info ./gon.json
release: nixrelease darrelease winrelease checksum
nixrelease:
@$(call releasecmd,${LINUX},${BINARY},$(DATE))
darrelease:
@$(call releasecmd,${DARWIN},${BINARY},$(DATE))
winrelease:
@$(call releasecmd,${WINDOWS},${BINARY}.exe,$(DATE))