-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
151 lines (123 loc) · 5.47 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
DEL = rm -f
SRCDIR = src
OBJDIR = obj
BINDIR = bin
PACKDIR = package
MKDIRS = $(OBJDIR) $(BINDIR) $(PACKDIR)
# Add all c source files from $(SRCDIR)
# Create the object files in $(OBJDIR)
CFILES = $(wildcard $(SRCDIR)/*.c)
COBJ = $(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(CFILES))
ifdef DRAG_AND_DROP_MODE
EXTRA_FNAME = _drag_and_drop
CFLAGS+= -DDRAG_AND_DROP_MODE
endif
BIN = $(BINDIR)/romusage$(EXTRA_FNAME)
BIN_WIN = $(BIN).exe
# ignore package dicrectory that conflicts with rule target
.PHONY: package
all: linux
# Compile .c to .o in a separate directory
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) -c $< -o $@
# 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: $(COBJ)
$(CC) -o $(BIN_WIN) $^ $(LDFLAGS)
# Maxos uses linux target
macos: linux
# Linux build
linux: CC = gcc
linux: LDFLAGS = -s
linux: $(COBJ)
$(CC) -o $(BIN) $^ $(LDFLAGS)
cleanobj:
$(DEL) $(COBJ)
clean:
$(DEL) $(COBJ) $(BIN_WIN) $(BIN)
macos-x64-zip: macos
mkdir -p $(PACKDIR)
strip $(BIN)
# -j discards (junks) path to file
zip -j $(BIN)-macos-x64.zip $(BIN)
mv $(BIN)-macos-x64.zip $(PACKDIR)
# cp $(BIN) $(PACKDIR)
macos-arm64-zip: macos
mkdir -p $(PACKDIR)
strip $(BIN)
# -j discards (junks) path to file
zip -j $(BIN)-macos-arm64.zip $(BIN)
mv $(BIN)-macos-arm64.zip $(PACKDIR)
# cp $(BIN) $(PACKDIR)
linuxzip: linux
mkdir -p $(PACKDIR)
strip $(BIN)
# -j discards (junks) path to file
zip -j $(BIN)-linux.zip $(BIN)
mv $(BIN)-linux.zip $(PACKDIR)
# cp $(BIN) $(PACKDIR)
wincrosszip: wincross
mkdir -p $(PACKDIR)
strip $(BIN_WIN)
# -j discards (junks) path to file
zip -j $(BIN)-windows.zip $(BIN_WIN)
mv $(BIN)-windows.zip $(PACKDIR)
# cp $(BIN_WIN) $(PACKDIR)
package:
${MAKE} clean
${MAKE} wincrosszip
${MAKE} clean
${MAKE} wincrosszip DRAG_AND_DROP_MODE=TRUE
${MAKE} clean
${MAKE} linuxzip
.PHONY: test
test:
echo "see test-norepo"
updatetest:
echo "see updatetest-norepo"
test-norepo:
mkdir -p test_norepo/output
rm -f test_norepo/output/test_run.txt
# GB
$(BIN) test_norepo/gb/autobanks_gb.map -g -smROM -B >> test_norepo/output/test_run.txt 2>&1
$(BIN) test_norepo/gb/autobanks_gb.map -g -B >> test_norepo/output/test_run.txt 2>&1
$(BIN) test_norepo/gb/autobanks_gb.map -g -smROM >> test_norepo/output/test_run.txt 2>&1
find test_norepo/gb/* -iname "*.map" -type f | xargs -I {} $(BIN) -g -a "{}" >> test_norepo/output/test_run.txt 2>&1
find test_norepo/gb/* -iname "*.noi" -type f | xargs -I {} $(BIN) -g -a "{}" >> test_norepo/output/test_run.txt 2>&1
find test_norepo/gb/* -iname "*.ihx" -type f | xargs -I {} $(BIN) -g -a "{}" >> test_norepo/output/test_run.txt 2>&1
find test_norepo/gb/* -iname "*.cdb" -type f | xargs -I {} $(BIN) -g -a "{}" >> test_norepo/output/test_run.txt 2>&1
find test_norepo/gb/* -iname "*.gb" -type f | xargs -I {} $(BIN) -g -a "{}" >> test_norepo/output/test_run.txt 2>&1
# GG
find test_norepo/smsgg/* -iname "*.map" -type f | xargs -I {} $(BIN) -p:SMS_GG -g -a "{}" >> test_norepo/output/test_run.txt 2>&1
find test_norepo/smsgg/* -iname "*.noi" -type f | xargs -I {} $(BIN) -p:SMS_GG -g -a "{}" >> test_norepo/output/test_run.txt 2>&1
find test_norepo/smsgg/* -iname "*.gg" -type f | xargs -I {} $(BIN) -p:SMS_GG -g -a "{}" >> test_norepo/output/test_run.txt 2>&1
# NES
find test_norepo/nes/* -iname "*.map" -type f | xargs -I {} $(BIN) -p:NES1 -g -a "{}" >> test_norepo/output/test_run.txt 2>&1
find test_norepo/nes/* -iname "*.noi" -type f | xargs -I {} $(BIN) -p:NES1 -g -a "{}" >> test_norepo/output/test_run.txt 2>&1
diff --brief test_norepo/output/test_ref.txt test_norepo/output/test_run.txt
test-norepo-diff:
diff test_norepo/output/test_ref.txt test_norepo/output/test_run.txt
updatetest-norepo:
rm -f test_norepo/output/test_ref.txt
# GB
$(BIN) test_norepo/gb/autobanks_gb.map -g -smROM -B >> test_norepo/output/test_ref.txt 2>&1
$(BIN) test_norepo/gb/autobanks_gb.map -g -B >> test_norepo/output/test_ref.txt 2>&1
$(BIN) test_norepo/gb/autobanks_gb.map -g -smROM >> test_norepo/output/test_ref.txt 2>&1
find test_norepo/gb/* -iname "*.map" -type f | xargs -I {} $(BIN) -g -a "{}" >> test_norepo/output/test_ref.txt 2>&1
find test_norepo/gb/* -iname "*.noi" -type f | xargs -I {} $(BIN) -g -a "{}" >> test_norepo/output/test_ref.txt 2>&1
find test_norepo/gb/* -iname "*.ihx" -type f | xargs -I {} $(BIN) -g -a "{}" >> test_norepo/output/test_ref.txt 2>&1
find test_norepo/gb/* -iname "*.cdb" -type f | xargs -I {} $(BIN) -g -a "{}" >> test_norepo/output/test_ref.txt 2>&1
find test_norepo/gb/* -iname "*.gb" -type f | xargs -I {} $(BIN) -g -a "{}" >> test_norepo/output/test_ref.txt 2>&1
# GG
find test_norepo/smsgg/* -iname "*.map" -type f | xargs -I {} $(BIN) -p:SMS_GG -g -a "{}" >> test_norepo/output/test_ref.txt 2>&1
find test_norepo/smsgg/* -iname "*.noi" -type f | xargs -I {} $(BIN) -p:SMS_GG -g -a "{}" >> test_norepo/output/test_ref.txt 2>&1
find test_norepo/smsgg/* -iname "*.gg" -type f | xargs -I {} $(BIN) -p:SMS_GG -g -a "{}" >> test_norepo/output/test_ref.txt 2>&1
# NES
find test_norepo/nes/* -iname "*.map" -type f | xargs -I {} $(BIN) -p:NES1 -g -a "{}" >> test_norepo/output/test_ref.txt 2>&1
find test_norepo/nes/* -iname "*.noi" -type f | xargs -I {} $(BIN) -p:NES1 -g -a "{}" >> test_norepo/output/test_ref.txt 2>&1
# 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)))