-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
130 lines (98 loc) · 3.12 KB
/
Makefile
File metadata and controls
130 lines (98 loc) · 3.12 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
DEL = rm -f
BIN = gbtoolsid
BIN_WIN = $(BIN).exe
BIN_WEB = $(WEBDIR)/$(BIN)_web
TESTOPT =
WEBDIR = web
SRCDIR = src
OBJDIR = obj
MKDIRS = $(OBJDIR) $(BINDIR) $(PACKDIR) $(WEBDIR)
BINS = $(OBJDIR)/$(PROJECTNAME).gb
CSOURCES = $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c)))
OBJS = $(CSOURCES:%.c=$(OBJDIR)/%.o)
all: linux
cleanobj:
$(DEL) $(OBJS)
clean:
$(DEL) $(OBJS) $(BIN_WIN) $(BIN)
# Compile .c files in "src/" to .o object files
$(OBJDIR)/%.o: $(SRCDIR)/%.c
mkdir -p $(OBJDIR)
$(CC) $(CFLAGS) -c $< -o $@
# MacOS uses linux target
macos: linux
# Linux build
linux: CC = gcc
linux: LDFLAGS = -s
linux: $(OBJS)
$(CC) -o $(BIN) $^ $(LDFLAGS)
# Linux MinGW build for Windows
# (static linking to avoid DLL dependencies)
wincross: TARGET=i686-w64-mingw32
wincross: CC = $(TARGET)-g++
wincross: LDFLAGS = -s -static
wincross: $(OBJS)
$(CC) -o $(BIN_WIN) $^ $(LDFLAGS)
macoszip: macos
mkdir -p bin
# -j discards (junks) path to file
zip -j $(BIN)_macos.zip $(BIN) Changelog.md README.md
mv $(BIN)_macos.zip bin
macos_armzip: macos
mkdir -p bin
# -j discards (junks) path to file
zip -j $(BIN)_macos_arm.zip $(BIN) Changelog.md README.md
mv $(BIN)_macos_arm.zip bin
linuxzip: linux
mkdir -p bin
# -j discards (junks) path to file
zip -j $(BIN)_linux.zip $(BIN) Changelog.md README.md
mv $(BIN)_linux.zip bin
linux_armzip: linux
mkdir -p bin
# -j discards (junks) path to file
zip -j $(BIN)_linux_arm.zip $(BIN) Changelog.md README.md
mv $(BIN)_linux_arm.zip bin
wincrosszip: wincross
mkdir -p bin
# -j discards (junks) path to file
zip -j $(BIN)_windows.zip $(BIN_WIN) Changelog.md README.md
mv $(BIN)_windows.zip bin
package:
${MAKE} clean
${MAKE} wincrosszip
${MAKE} clean
${MAKE} linuxzip
# Requires emscripten
web_build: CC = emcc
web_build: CFLAGS = -O2
web_build: LDFLAGS = -s INVOKE_RUN=0 # Don't run main automatically
web_build: LDFLAGS += -s ALLOW_MEMORY_GROWTH=1
web_build: LDFLAGS += -s EXPORTED_FUNCTIONS="['_main', '_malloc', '_free']"
web_build: LDFLAGS += -s EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap']"
web_build: LDFLAGS += -s FORCE_FILESYSTEM=1
web_build: $(OBJS)
$(CC) -o $(BIN_WEB).js $^ $(LDFLAGS)
web_install:
cp -f -r web/* ../gbtoolsid_web/
web:
${MAKE} clean
${MAKE} web_build
.PHONY: test web
test:
mkdir -p test/output
find test/* -iname "*.gb*" -type f | xargs -I {} $(BIN) -pF -oC "{}" > test/output/test_run.csv
diff --brief test/test_ref.csv test/output/test_run.csv
updatetest:
mkdir -p test/output
find test/* -iname "*.gb*" -type f | xargs -I {} $(BIN) -pF -oC "{}" > test/test_ref.csv
runtest-norepo:
mkdir -p test_norepo/output
find test_norepo/* -iname "*.gb*" -type f | xargs -I {} $(BIN) -pF -oC "{}" > test_norepo/output/test_run.csv
diff --brief test_norepo/test_ref.csv test_norepo/output/test_run.csv
updatetest-norepo:
mkdir -p test_norepo/output
find test_norepo/* -iname "*.gb*" -type f | xargs -I {} $(BIN) -pF -oC "{}" > test_norepo/test_ref.csv
# create necessary directories after Makefile is parsed but before build
# info prevents the command from being pasted into the makefile
$(info $(shell mkdir -p $(MKDIRS)))