-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMakefile
More file actions
175 lines (143 loc) · 6.3 KB
/
Makefile
File metadata and controls
175 lines (143 loc) · 6.3 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
DEL = rm -f
SRCDIR = src
OBJDIR = obj
BINDIR = bin
WEBDIR = web
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)$(EXE_EXT)
WEB_BIN = $(WEBDIR)/romusage_web
PACKFILES = $(BIN) Changelog.md README.md LICENSE
PACKBASENAME = romusage$(EXTRA_FNAME)
# 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: EXE_EXT = .exe
wincross: TARGET=i686-w64-mingw32
wincross: CC = $(TARGET)-g++
wincross: LDFLAGS = -s -static
wincross: $(COBJ)
$(CC) -o $(BIN) $^ $(LDFLAGS)
# Maxos uses linux target
macos: linux
# Linux build
linux: CC = gcc
linux: LDFLAGS = -s
linux: $(COBJ)
$(CC) -o $(BIN) $^ $(LDFLAGS)
# 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', '_set_option_is_web_mode']"
web_build: LDFLAGS += -s EXPORTED_RUNTIME_METHODS="['ccall', 'cwrap']"
web_build: LDFLAGS += -s FORCE_FILESYSTEM=1
web_build: $(COBJ)
$(CC) -o $(WEB_BIN).js $^ $(LDFLAGS)
web:
${MAKE} clean
${MAKE} web_build
cleanobj:
$(DEL) $(COBJ)
clean:
$(DEL) $(COBJ) $(BIN) $(BIN)
macos-x64-zip: macos
mkdir -p $(PACKDIR)
strip $(BIN)
# -j discards (junks) path to file
zip -j $(PACKBASENAME)-macos-x64.zip $(PACKFILES)
mv $(PACKBASENAME)-macos-x64.zip $(PACKDIR)
macos-arm64-zip: macos
mkdir -p $(PACKDIR)
strip $(BIN)
# -j discards (junks) path to file
zip -j $(PACKBASENAME)-macos-arm64.zip $(PACKFILES)
mv $(PACKBASENAME)-macos-arm64.zip $(PACKDIR)
linuxzip: linux
mkdir -p $(PACKDIR)
strip $(BIN)
# -j discards (junks) path to file
zip -j $(PACKBASENAME)-linux.zip $(PACKFILES)
mv $(PACKBASENAME)-linux.zip $(PACKDIR)
linux-arm-zip: linux
mkdir -p $(PACKDIR)
strip $(BIN)
# -j discards (junks) path to file
zip -j $(PACKBASENAME)-linux_arm.zip $(PACKFILES)
mv $(PACKBASENAME)-linux_arm.zip $(PACKDIR)
wincrosszip: EXE_EXT = .exe
wincrosszip: wincross
mkdir -p $(PACKDIR)
strip $(BIN)
# -j discards (junks) path to file
zip -j $(PACKBASENAME)-windows.zip $(PACKFILES)
mv $(PACKBASENAME)-windows.zip $(PACKDIR)
package:
${MAKE} clean
${MAKE} wincrosszip
${MAKE} clean
${MAKE} wincrosszip DRAG_AND_DROP_MODE=TRUE
${MAKE} clean
${MAKE} linuxzip
.PHONY: test web
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)))