-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
98 lines (71 loc) · 2.22 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
DEL = rm -f
BIN = gbtoolsid
BIN_WIN = $(BIN).exe
TESTOPT =
SRCDIR = src
OBJDIR = obj
MKDIRS = $(OBJDIR) $(BINDIR) $(PACKDIR)
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) -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
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
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
.PHONY: test
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)))