-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (39 loc) · 1.95 KB
/
Makefile
File metadata and controls
53 lines (39 loc) · 1.95 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
version = v0.8.0
final = false
ifeq ($(final),false)
tag = nightly
ifeq ($(shell git tag --points-at HEAD | grep -Fx $(tag)),$(tag))
version := $(version)-nightly
else
version := $(version)-preview
endif
endif
goBinary = go
gcflags = -c 3 -B -wb=false -l -l -l -l
ldflags = -s -w
ldflags_version = $(ldflags) -X 'github.com/jetsetilly/test7800/version.number=$(version)'
### support targets
.PHONY: all tidy generate
all:
@echo "use 'release' to build release binary"
tidy:
# goimports is not part of the standard Go distribution so we won't won't
# require this in any of the other targets
goimports -w .
generate:
@$(goBinary) generate ./...
### release building
.PHONY: version_check release
version_check :
ifndef version
$(error version is undefined)
endif
release: version_check generate
$(goBinary) build -pgo=auto -gcflags "$(gcflags)" -trimpath -ldflags "$(ldflags_version)" -tags="release"
mv test7800 test7800_$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
### cross compilation for windows (tested when cross compiling from Linux)
.PHONY: cross_windows_release
cross_windows_release: version_check generate
CGO_ENABLED="1" CC="/usr/bin/x86_64-w64-mingw32-gcc" CXX="/usr/bin/x86_64-w64-mingw32-g++" GOOS="windows" GOARCH="amd64" CGO_LDFLAGS="-static -static-libgcc -static-libstdc++ -L/usr/local/x86_64-w64-mingw32/lib" $(goBinary) build -pgo=auto -tags "static imguifreetype release" -gcflags "$(gcflags)" -trimpath -ldflags "$(ldflags_version) -H=windowsgui" -o test7800_windows_amd64.exe .
cross_windows_terminal_release: version_check generate
CGO_ENABLED="1" CC="/usr/bin/x86_64-w64-mingw32-gcc" CXX="/usr/bin/x86_64-w64-mingw32-g++" GOOS="windows" GOARCH="amd64" CGO_LDFLAGS="-static -static-libgcc -static-libstdc++ -L/usr/local/x86_64-w64-mingw32/lib" $(goBinary) build -pgo=auto -tags "static imguifreetype release" -gcflags "$(gcflags)" -trimpath -ldflags "$(ldflags_version) -H=windows" -o test7800_windows_amd64_terminal.exe .