-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
93 lines (73 loc) · 2.93 KB
/
Makefile
File metadata and controls
93 lines (73 loc) · 2.93 KB
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
87
88
89
90
91
92
93
#!make
.PHONY: reportVersion depend clean build all
.DEFAULT: all
.EXPORT_ALL_VARIABLES:
-include .env
cat := $(if $(filter $(OS),Windows_NT),type,cat)
PACKAGE_VERSION := $(shell $(cat) VERSION)
GOLD_FLAGS=-X github.com/cs-shadowbq/falcon_sandbox_submitter/cmd.Version=$(PACKAGE_VERSION)
SILVER_FLAGS :=
# Combine SILVER_FLAGS if Variable not empty
ifdef FALCON_CLIENT_ID
SILVER_FLAGS+=-X github.com/cs-shadowbq/falcon_sandbox_submitter/cmd.buildClientId=${FALCON_CLIENT_ID}
endif
ifdef FALCON_CLIENT_SECRET
SILVER_FLAGS+= -X github.com/cs-shadowbq/falcon_sandbox_submitter/cmd.buildClientSecret=${FALCON_CLIENT_SECRET}
endif
ifdef FALCON_API_BASE_URL
SILVER_FLAGS+= -X github.com/cs-shadowbq/falcon_sandbox_submitter/cmd.buildApiBaseUrl=${FALCON_API_BASE_URL}
endif
BUILD_DOCS := README.md LICENSE example_config.yml
OS := $(shell uname)
ifeq ($(OS), Darwin)
certname := $(shell security find-identity -v -p codesigning | head -1 | tr -d '"' | awk '{ print $$3 }')
else
// assign certname to UNDEFINED
certname := undefined
endif
all: reportVersion depend clean build
reportVersion:
@echo "\033[32mProduct Version $(PACKAGE_VERSION)"
build:
@echo
@echo "\033[32mBuilding ----> \033[m"
env GOOS=linux GOARCH=amd64 go build -ldflags "$(GOLD_FLAGS) ${SILVER_FLAGS}" -o build/falcon_sandbox_linux_amd64 main.go
env GOOS=windows GOARCH=amd64 go build -ldflags "$(GOLD_FLAGS) ${SILVER_FLAGS}" -o build/falcon_sandbox.exe main.go
env GOOS=darwin GOARCH=amd64 go build -ldflags "$(GOLD_FLAGS) ${SILVER_FLAGS}" -o build/falcon_sandbox_darwin_amd64 main.go
clean:
@echo
@echo "\033[32mCleaning Build ----> \033[m"
$(RM) -rf pkg/*
$(RM) -rf build/*
$(RM) -rf tmp/*
depend:
@echo
@echo "\033[32mChecking Build Dependencies ----> \033[m"
ifndef PACKAGE_VERSION
@echo "\033[1;33mPACKAGE_VERSION is not set. In order to build a package I need PACKAGE_VERSION=n\033[m"
exit 1;
endif
ifndef GOPATH
@echo "\033[1;33mGOPATH is not set. This means that you do not have go setup properly on this machine\033[m"
@echo "$$ mkdir ~/gocode";
@echo "$$ echo 'export GOPATH=~/gocode' >> ~/.bash_profile";
@echo "$$ echo 'export PATH=\"\$$GOPATH/bin:\$$PATH\"' >> ~/.bash_profile";
@echo "$$ source ~/.bash_profile";
exit 1;
endif
@type go >/dev/null 2>&1|| { \
echo "\033[1;33mGo is required to build this application\033[m"; \
echo "\033[1;33mIf you are using homebrew on OSX, run\033[m"; \
echo "Recommend: $$ brew install go --cross-compile-all"; \
exit 1; \
}
codesign:
@echo
@echo "\033[32mCodesigning ----> \033[m"
@echo "\033[32mCodesigning with certificate: $(certname)\033[m"
@echo "\033[32mCodesigning build/falcon_sandbox_darwin_amd64\033[m"
@codesign -fs $(certname) build/falcon_sandbox_darwin_amd64
@echo "\033[32mCodesigning build/falcon_sandbox_linux_amd64\033[m"
@codesign -fs $(certname) build/falcon_sandbox_linux_amd64
@echo "\033[32mCodesigning build/falcon_sandbox.exe\033[m"
@codesign -fs $(certname) build/falcon_sandbox.exe