forked from apmckinlay/gsuneido
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
105 lines (90 loc) · 2.49 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# requires sh on path (e.g. from MinGW)
BUILT=$(shell date "+%b %-d %Y %R")
GO = go
GOOS = $(shell go env GOOS)
GOARCH = $(shell go env GOARCH)
OUTPUT = gs_$(GOOS)_$(GOARCH)
BUILD = build -buildvcs=true -trimpath -o $(OUTPUT)
LDFLAGS = -s -w -X 'main.builtDate=$(BUILT)'
ifdef PATHEXT
# Windows stuff
BUILD = build -buildvcs=true -trimpath
OUTPUT = gsuneido.exe gsuneido.com gsport.exe
GUIFLAGS = $(LDFLAGS) -X main.mode=gui -H windowsgui
CONSOLE = $(GO) $(BUILD) -o gsuneido.com -ldflags "$(LDFLAGS)" -tags com
PORTABLE = export CGO_ENABLED=0 ; $(GO) $(BUILD) -o gsport.exe \
-ldflags "$(LDFLAGS)" -tags portable
CSIDE = $(GO) run cmd/deps/deps.go
endif
build:
@$(CSIDE)
@$(GO) version
@rm -f $(OUTPUT)
ifdef PATHEXT
$(GO) $(BUILD) -v -ldflags "$(GUIFLAGS)"
$(CONSOLE)
$(PORTABLE)
else
export CGO_ENABLED=0 ; $(GO) $(BUILD) -v -ldflags "$(LDFLAGS)"
endif
gsuneido:
@$(CSIDE)
@rm -f gsuneido.exe
$(GO) $(BUILD) -v -ldflags "$(GUIFLAGS)"
race:
ifdef PATHEXT
@$(CSIDE)
$(GO) $(BUILD) -v -ldflags "$(GUIFLAGS)" -race -o race/
$(PORTABLE) -race -o race/gsport.exe
else
$(GO) $(BUILD) -v -ldflags "$(LDFLAGS)" -race -o race/$(OUTPUT)
endif
portable:
# a Windows version without the Windows stuff
$(PORTABLE)
arm:
export CGO_ENABLED=0 GOARCH=arm64 GOOS=linux ; $(GO) build -buildvcs=true \
-trimpath -o gs_linux_arm64 -v -ldflags "$(LDFLAGS)"
test:
$(GO) test -short ./...
racetest:
$(GO) test -race -short -count=1 ./...
zap:
$(GO) build -ldflags "-s -w" ./cmd/zap
generate:
$(GO) generate -x ./...
clean:
rm -f $(OUTPUT)
$(GO) clean -cache -testcache
# need 64 bit windres e.g. from mingw64
# if this fails with: 'c:\Program' is not recognized
# copy the command line and run it manually
gsuneido_windows.syso : res/suneido.rc res/suneido.manifest
windres -F pe-x86-64 -o gsuneido_windows.syso res/suneido.rc
release:
./gsuneido -dump stdlib
./gsuneido -dump suneidoc
./gsuneido -dump imagebook
-mkdir release
cp stdlib.su suneidoc.su imagebook.su release
cd release && \
rm suneido.db ; \
../gsuneido -load stdlib && \
../gsuneido -load suneidoc && \
../gsuneido -load imagebook
help:
@echo "make [target]"
@echo "build"
@echo " build gsuneido"
@echo "gsuneido"
@echo " build gsuneido executable"
@echo "portable"
@echo " build windows gsport"
@echo "arm"
@echo " build arm linux executable"
@echo "test"
@echo " run tests"
@echo "clean"
@echo " remove built files"
.PHONY : build gsuneido portable test generate clean zap race racetest release \
help arm