comparison Makefile @ 2053:3414a4423de1 segacd

Merge from default
author Michael Pavone <pavone@retrodev.com>
date Sat, 15 Jan 2022 13:15:21 -0800
parents 5dacaef602a7 33f454232aee
children 70260f6051dd
comparison
equal deleted inserted replaced
1692:5dacaef602a7 2053:3414a4423de1
1 #disable built-in rules
2 .SUFFIXES :
3
1 ifndef OS 4 ifndef OS
2 OS:=$(shell uname -s) 5 OS:=$(shell uname -s)
3 endif 6 endif
4 FIXUP:=true 7 FIXUP:=true
5 8
9 BUNDLED_LIBZ:=zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/gzclose.o zlib/gzlib.o zlib/gzread.o\
10 zlib/gzwrite.o zlib/infback.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o zlib/uncompr.o zlib/zutil.o
11
6 ifeq ($(OS),Windows) 12 ifeq ($(OS),Windows)
7 ifndef SDL2_PREFIX 13
8 SDL2_PREFIX:="sdl/i686-w64-mingw32"
9 endif
10 ifndef GLEW_PREFIX
11 GLEW_PREFIX:=glew 14 GLEW_PREFIX:=glew
12 endif
13 ifndef GLEW32S_LIB
14 GLEW32S_LIB:=$(GLEW_PREFIX)/lib/Release/Win32/glew32s.lib
15 endif
16
17 MEM:=mem_win.o 15 MEM:=mem_win.o
18 TERMINAL:=terminal_win.o 16 TERMINAL:=terminal_win.o
19 FONT:=nuklear_ui/font_win.o 17 FONT:=nuklear_ui/font_win.o
20 NET:=net_win.o 18 NET:=net_win.o
21 EXE:=.exe 19 EXE:=.exe
20 SO:=dll
21 CPU:=i686
22 ifeq ($(CPU),i686)
22 CC:=i686-w64-mingw32-gcc-win32 23 CC:=i686-w64-mingw32-gcc-win32
23 CFLAGS:=-std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -I"$(SDL2_PREFIX)/include/SDL2" -I"$(GLEW_PREFIX)/include" -DGLEW_STATIC 24 WINDRES:=i686-w64-mingw32-windres
24 LDFLAGS:= $(GLEW32S_LIB) -L"$(SDL2_PREFIX)/lib" -lm -lmingw32 -lSDL2main -lSDL2 -lws2_32 -lopengl32 -lglu32 -mwindows 25 GLUDIR:=Win32
25 CPU:=i686 26 SDL2_PREFIX:="sdl/i686-w64-mingw32"
27 else
28 CC:=x86_64-w64-mingw32-gcc-win32
29 WINDRES:=x86_64-w64-mingw32-windres
30 SDL2_PREFIX:="sdl/x86_64-w64-mingw32"
31 GLUDIR:=x64
32 endif
33 GLEW32S_LIB:=$(GLEW_PREFIX)/lib/Release/$(GLUDIR)/glew32s.lib
34 CFLAGS:=-std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -Wpointer-arith -Werror=pointer-arith
35 LDFLAGS:=-lm -lmingw32 -lws2_32 -mwindows
36 ifneq ($(MAKECMDGOALS),libblastem.dll)
37 CFLAGS+= -I"$(SDL2_PREFIX)/include/SDL2" -I"$(GLEW_PREFIX)/include" -DGLEW_STATIC
38 LDFLAGS+= $(GLEW32S_LIB) -L"$(SDL2_PREFIX)/lib" -lSDL2main -lSDL2 -lopengl32 -lglu32
39 endif
40 LIBZOBJS=$(BUNDLED_LIBZ)
26 41
27 else 42 else
28 43
29 MEM:=mem.o 44 MEM:=mem.o
30 TERMINAL:=terminal.o 45 TERMINAL:=terminal.o
31 NET:=net.o 46 NET:=net.o
32 EXE:= 47 EXE:=
33 48
34 HAS_PROC:=$(shell if [ -d /proc ]; then /bin/echo -e -DHAS_PROC; fi) 49 HAS_PROC:=$(shell if [ -d /proc ]; then /bin/echo -e -DHAS_PROC; fi)
35 CFLAGS:=-std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -Wno-unused-value $(HAS_PROC) -DHAVE_UNISTD_H 50 CFLAGS:=-std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -Wno-unused-value -Wpointer-arith -Werror=pointer-arith $(HAS_PROC) -DHAVE_UNISTD_H
36 51
37 ifeq ($(OS),Darwin) 52 ifeq ($(OS),Darwin)
38 LIBS=sdl2 glew 53 LIBS=sdl2 glew
39 FONT:=nuklear_ui/font_mac.o 54 FONT:=nuklear_ui/font_mac.o
55 SO:=dylib
56 else
57 SO:=so
58
59 ifdef USE_FBDEV
60 LIBS=alsa
61 ifndef NOGL
62 LIBS+=glesv2 egl
63 endif
64 CFLAGS+= -DUSE_GLES -DUSE_FBDEV -pthread
40 else 65 else
41 ifdef USE_GLES 66 ifdef USE_GLES
42 LIBS=sdl2 glesv2 67 LIBS=sdl2 glesv2
43 CFLAGS+= -DUSE_GLES 68 CFLAGS+= -DUSE_GLES
44 else 69 else
45 LIBS=sdl2 glew gl 70 LIBS=sdl2 glew gl
46 endif #USE_GLES 71 endif #USE_GLES
72 endif #USE_FBDEV
47 FONT:=nuklear_ui/font.o 73 FONT:=nuklear_ui/font.o
48 endif #Darwin 74 endif #Darwin
75
76 ifdef HOST_ZLIB
77 LIBS+= zlib
78 LIBZOBJS=
79 else
80 LIBZOBJS=$(BUNDLED_LIBZ)
81 endif
49 82
50 ifeq ($(OS),Darwin) 83 ifeq ($(OS),Darwin)
51 #This should really be based on whether or not the C compiler is clang rather than based on the OS 84 #This should really be based on whether or not the C compiler is clang rather than based on the OS
52 CFLAGS+= -Wno-logical-op-parentheses 85 CFLAGS+= -Wno-logical-op-parentheses
53 endif 86 endif
61 CFLAGS+= -DGLEW_STATIC -Iglew/include 94 CFLAGS+= -DGLEW_STATIC -Iglew/include
62 LDFLAGS:=-lm glew/lib/libGLEW.a 95 LDFLAGS:=-lm glew/lib/libGLEW.a
63 endif 96 endif
64 97
65 ifeq ($(OS),Darwin) 98 ifeq ($(OS),Darwin)
66 CFLAGS+= -IFrameworks/SDL2.framework/Headers 99 SDL_INCLUDE_PATH:=Frameworks/SDL2.framework/Headers
67 LDFLAGS+= -FFrameworks -framework SDL2 -framework OpenGL -framework AppKit 100 CFLAGS+= -mmacosx-version-min=10.10
101 LDFLAGS+= -FFrameworks -framework SDL2 -framework OpenGL -framework AppKit -mmacosx-version-min=10.10
68 FIXUP:=install_name_tool -change @rpath/SDL2.framework/Versions/A/SDL2 @executable_path/Frameworks/SDL2.framework/Versions/A/SDL2 102 FIXUP:=install_name_tool -change @rpath/SDL2.framework/Versions/A/SDL2 @executable_path/Frameworks/SDL2.framework/Versions/A/SDL2
69 else 103 else
70 CFLAGS+= -Isdl/include 104 SDL_INCLUDE_PATH:=sdl/include
71 LDFLAGS+= -Wl,-rpath='$$ORIGIN/lib' -Llib -lSDL2 105 LDFLAGS+= -Wl,-rpath='$$ORIGIN/lib' -Llib -lSDL2
72 ifndef USE_GLES 106 ifndef USE_GLES
73 LDFLAGS+= $(shell pkg-config --libs gl) 107 LDFLAGS+= $(shell pkg-config --libs gl)
74 endif 108 endif
75 endif #Darwin 109 endif #Darwin
76 110 CFLAGS+= -I$(SDL_INCLUDE_PATH)
111
112 else
113 ifeq ($(MAKECMDGOALS),libblastem.$(SO))
114 LDFLAGS:=-lm
77 else 115 else
78 CFLAGS:=$(shell pkg-config --cflags-only-I $(LIBS)) $(CFLAGS) 116 CFLAGS:=$(shell pkg-config --cflags-only-I $(LIBS)) $(CFLAGS)
79 LDFLAGS:=-lm $(shell pkg-config --libs $(LIBS)) 117 LDFLAGS:=-lm $(shell pkg-config --libs $(LIBS))
118 ifdef USE_FBDEV
119 LDFLAGS+= -pthread
120 endif
121 endif #libblastem.so
80 122
81 ifeq ($(OS),Darwin) 123 ifeq ($(OS),Darwin)
82 LDFLAGS+= -framework OpenGL -framework AppKit 124 LDFLAGS+= -framework OpenGL -framework AppKit
83 endif 125 endif
84 126
103 ifdef Z80_LOG_ADDRESS 145 ifdef Z80_LOG_ADDRESS
104 CFLAGS+= -DZ80_LOG_ADDRESS 146 CFLAGS+= -DZ80_LOG_ADDRESS
105 endif 147 endif
106 148
107 ifdef PROFILE 149 ifdef PROFILE
108 LDFLAGS+= -Wl,--no-as-needed -lprofiler -Wl,--as-needed 150 PROFFLAGS:= -Wl,--no-as-needed -lprofiler -Wl,--as-needed
151 CFLAGS+= -g3
109 endif 152 endif
110 ifdef NOGL 153 ifdef NOGL
111 CFLAGS+= -DDISABLE_OPENGL 154 CFLAGS+= -DDISABLE_OPENGL
112 NONUKLEAR:=1
113 endif 155 endif
114 156
115 ifdef M68030 157 ifdef M68030
116 CFLAGS+= -DM68030 158 CFLAGS+= -DM68030
117 endif 159 endif
134 CPU:=i686 176 CPU:=i686
135 endif 177 endif
136 endif 178 endif
137 179
138 TRANSOBJS=gen.o backend.o $(MEM) arena.o tern.o 180 TRANSOBJS=gen.o backend.o $(MEM) arena.o tern.o
139 M68KOBJS=68kinst.o m68k_core.o 181 M68KOBJS=68kinst.o
182
183 ifdef NEW_CORE
184 Z80OBJS=z80.o z80inst.o
185 M68KOBJS+= m68k.o
186 CFLAGS+= -DNEW_CORE
187 else
188 Z80OBJS=z80inst.o z80_to_x86.o
140 ifeq ($(CPU),x86_64) 189 ifeq ($(CPU),x86_64)
141 M68KOBJS+= m68k_core_x86.o 190 M68KOBJS+= m68k_core.o m68k_core_x86.o
142 TRANSOBJS+= gen_x86.o backend_x86.o 191 TRANSOBJS+= gen_x86.o backend_x86.o
143 else 192 else
144 ifeq ($(CPU),i686) 193 ifeq ($(CPU),i686)
145 M68KOBJS+= m68k_core_x86.o 194 M68KOBJS+= m68k_core.o m68k_core_x86.o
146 TRANSOBJS+= gen_x86.o backend_x86.o 195 TRANSOBJS+= gen_x86.o backend_x86.o
147 endif 196 endif
148 endif 197 endif
149 198 endif
150 Z80OBJS=z80inst.o z80_to_x86.o 199 AUDIOOBJS=ym2612.o psg.o wave.o vgm.o event_log.o render_audio.o
151 AUDIOOBJS=ym2612.o psg.o wave.o
152 CONFIGOBJS=config.o tern.o util.o paths.o 200 CONFIGOBJS=config.o tern.o util.o paths.o
153 NUKLEAROBJS=$(FONT) nuklear_ui/blastem_nuklear.o nuklear_ui/sfnt.o controller_info.o 201 NUKLEAROBJS=$(FONT) nuklear_ui/blastem_nuklear.o nuklear_ui/sfnt.o
154 RENDEROBJS=render_sdl.o ppm.o 202 RENDEROBJS=ppm.o controller_info.o
155 LIBZOBJS=zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/gzclose.o zlib/gzlib.o zlib/gzread.o\ 203 ifdef USE_FBDEV
156 zlib/gzwrite.o zlib/infback.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o zlib/uncompr.o zlib/zutil.o 204 RENDEROBJS+= render_fbdev.o
205 else
206 RENDEROBJS+= render_sdl.o
207 endif
157 208
158 ifdef NOZLIB 209 ifdef NOZLIB
159 CFLAGS+= -DDISABLE_ZLIB 210 CFLAGS+= -DDISABLE_ZLIB
160 else 211 else
161 RENDEROBJS+= $(LIBZOBJS) png.o 212 RENDEROBJS+= $(LIBZOBJS) png.o
162 endif 213 endif
163 214
164 MAINOBJS=blastem.o system.o genesis.o debug.o gdb_remote.o vdp.o $(RENDEROBJS) io.o romdb.o hash.o menu.o xband.o \ 215 MAINOBJS=blastem.o system.o genesis.o debug.o gdb_remote.o vdp.o $(RENDEROBJS) io.o romdb.o hash.o menu.o xband.o \
165 realtec.o i2c.o nor.o sega_mapper.o multi_game.o megawifi.o $(NET) serialize.o $(TERMINAL) $(CONFIGOBJS) gst.o \ 216 realtec.o i2c.o nor.o sega_mapper.o multi_game.o megawifi.o $(NET) serialize.o $(TERMINAL) $(CONFIGOBJS) gst.o \
166 $(M68KOBJS) $(TRANSOBJS) $(AUDIOOBJS) saves.o zip.o bindings.o jcart.o segacd.o 217 $(M68KOBJS) $(TRANSOBJS) $(AUDIOOBJS) saves.o zip.o bindings.o jcart.o gen_player.o segacd.o
218
219 LIBOBJS=libblastem.o system.o genesis.o debug.o gdb_remote.o vdp.o io.o romdb.o hash.o xband.o realtec.o \
220 i2c.o nor.o sega_mapper.o multi_game.o megawifi.o $(NET) serialize.o $(TERMINAL) $(CONFIGOBJS) gst.o \
221 $(M68KOBJS) $(TRANSOBJS) $(AUDIOOBJS) saves.o jcart.o rom.db.o gen_player.o segacd.o $(LIBZOBJS)
167 222
168 ifdef NONUKLEAR 223 ifdef NONUKLEAR
169 CFLAGS+= -DDISABLE_NUKLEAR 224 CFLAGS+= -DDISABLE_NUKLEAR
170 else 225 else
171 MAINOBJS+= $(NUKLEAROBJS) 226 MAINOBJS+= $(NUKLEAROBJS)
185 240
186 ifdef NOZ80 241 ifdef NOZ80
187 CFLAGS+=-DNO_Z80 242 CFLAGS+=-DNO_Z80
188 else 243 else
189 MAINOBJS+= sms.o $(Z80OBJS) 244 MAINOBJS+= sms.o $(Z80OBJS)
245 LIBOBJS+= sms.o $(Z80OBJS)
190 endif 246 endif
191 247
192 ifeq ($(OS),Windows) 248 ifeq ($(OS),Windows)
193 MAINOBJS+= res.o 249 MAINOBJS+= res.o
194 endif 250 endif
195 251
196 ALL=dis$(EXE) zdis$(EXE) stateview$(EXE) vgmplay$(EXE) blastem$(EXE) 252 ifdef CONFIG_PATH
253 CFLAGS+= -DCONFIG_PATH='"'$(CONFIG_PATH)'"'
254 endif
255
256 ifdef DATA_PATH
257 CFLAGS+= -DDATA_PATH='"'$(DATA_PATH)'"'
258 endif
259
260 ifdef FONT_PATH
261 CFLAGS+= -DFONT_PATH='"'$(FONT_PATH)'"'
262 endif
263
264 ALL=dis$(EXE) zdis$(EXE) vgmplay$(EXE) blastem$(EXE)
197 ifneq ($(OS),Windows) 265 ifneq ($(OS),Windows)
198 ALL+= termhelper 266 ALL+= termhelper
199 endif 267 endif
200 268
269 ifeq ($(MAKECMDGOALS),libblastem.$(SO))
270 CFLAGS+= -fpic -DIS_LIB
271 endif
272
201 all : $(ALL) 273 all : $(ALL)
202 274
275 libblastem.$(SO) : $(LIBOBJS)
276 $(CC) -shared -o $@ $^ $(LDFLAGS)
277
203 blastem$(EXE) : $(MAINOBJS) 278 blastem$(EXE) : $(MAINOBJS)
204 $(CC) -o $@ $^ $(LDFLAGS) 279 $(CC) -o $@ $^ $(LDFLAGS) $(PROFFLAGS)
205 $(FIXUP) ./$@ 280 $(FIXUP) ./$@
206 281
207 blastjag$(EXE) : jaguar.o jag_video.o $(RENDEROBJS) serialize.o $(M68KOBJS) $(TRANSOBJS) $(CONFIGOBJS) 282 blastjag$(EXE) : jaguar.o jag_video.o $(RENDEROBJS) serialize.o $(M68KOBJS) $(TRANSOBJS) $(CONFIGOBJS)
208 $(CC) -o $@ $^ $(LDFLAGS) 283 $(CC) -o $@ $^ $(LDFLAGS)
209 284
285 termhelper : termhelper.o
286 $(CC) -o $@ $^ $(LDFLAGS)
287
210 dis$(EXE) : dis.o 68kinst.o tern.o vos_program_module.o 288 dis$(EXE) : dis.o 68kinst.o tern.o vos_program_module.o
211 $(CC) -o $@ $^ $(OPT) 289 $(CC) -o $@ $^ $(OPT)
212 290
213 jagdis : jagdis.o jagcpu.o tern.o 291 jagdis : jagdis.o jagcpu.o tern.o
214 $(CC) -o $@ $^ 292 $(CC) -o $@ $^
218 296
219 libemu68k.a : $(M68KOBJS) $(TRANSOBJS) 297 libemu68k.a : $(M68KOBJS) $(TRANSOBJS)
220 ar rcs libemu68k.a $(M68KOBJS) $(TRANSOBJS) 298 ar rcs libemu68k.a $(M68KOBJS) $(TRANSOBJS)
221 299
222 trans : trans.o serialize.o $(M68KOBJS) $(TRANSOBJS) util.o 300 trans : trans.o serialize.o $(M68KOBJS) $(TRANSOBJS) util.o
223 $(CC) -o trans trans.o $(M68KOBJS) $(TRANSOBJS) util.o $(OPT) 301 $(CC) -o $@ $^ $(OPT)
224 302
225 transz80 : transz80.o $(Z80OBJS) $(TRANSOBJS) 303 transz80 : transz80.o $(Z80OBJS) $(TRANSOBJS)
226 $(CC) -o transz80 transz80.o $(Z80OBJS) $(TRANSOBJS) 304 $(CC) -o transz80 transz80.o $(Z80OBJS) $(TRANSOBJS)
227 305
228 ztestrun : ztestrun.o serialize.o $(Z80OBJS) $(TRANSOBJS) 306 ztestrun : ztestrun.o serialize.o $(Z80OBJS) $(TRANSOBJS)
229 $(CC) -o ztestrun ztestrun.o $(Z80OBJS) $(TRANSOBJS) $(OPT) 307 $(CC) -o ztestrun $^ $(OPT)
230 308
231 ztestgen : ztestgen.o z80inst.o 309 ztestgen : ztestgen.o z80inst.o
232 $(CC) -ggdb -o ztestgen ztestgen.o z80inst.o 310 $(CC) -ggdb -o ztestgen ztestgen.o z80inst.o
233
234 stateview$(EXE) : stateview.o vdp.o $(RENDEROBJS) serialize.o $(CONFIGOBJS) gst.o
235 $(CC) -o $@ $^ $(LDFLAGS)
236 $(FIXUP) ./$@
237 311
238 vgmplay$(EXE) : vgmplay.o $(RENDEROBJS) serialize.o $(CONFIGOBJS) $(AUDIOOBJS) 312 vgmplay$(EXE) : vgmplay.o $(RENDEROBJS) serialize.o $(CONFIGOBJS) $(AUDIOOBJS)
239 $(CC) -o $@ $^ $(LDFLAGS) 313 $(CC) -o $@ $^ $(LDFLAGS)
240 $(FIXUP) ./$@ 314 $(FIXUP) ./$@
241 315
242 blastcpm : blastcpm.o util.o serialize.o $(Z80OBJS) $(TRANSOBJS) 316 blastcpm : blastcpm.o util.o serialize.o $(Z80OBJS) $(TRANSOBJS)
243 $(CC) -o $@ $^ $(OPT) 317 $(CC) -o $@ $^ $(OPT) $(PROFFLAGS)
244 318
245 test : test.o vdp.o 319 test : test.o vdp.o
246 $(CC) -o test test.o vdp.o 320 $(CC) -o test test.o vdp.o
247 321
248 testgst : testgst.o gst.o 322 testgst : testgst.o gst.o
263 offsets : offsets.c z80_to_x86.h m68k_core.h 337 offsets : offsets.c z80_to_x86.h m68k_core.h
264 $(CC) -o offsets offsets.c 338 $(CC) -o offsets offsets.c
265 339
266 vos_prog_info : vos_prog_info.o vos_program_module.o 340 vos_prog_info : vos_prog_info.o vos_program_module.o
267 $(CC) -o vos_prog_info vos_prog_info.o vos_program_module.o 341 $(CC) -o vos_prog_info vos_prog_info.o vos_program_module.o
342
343 m68k.c : m68k.cpu cpu_dsl.py
344 ./cpu_dsl.py -d call $< > $@
345
346 %.c : %.cpu cpu_dsl.py
347 ./cpu_dsl.py -d goto $< > $@
348
349 %.db.c : %.db
350 sed $< -e 's/"/\\"/g' -e 's/^\(.*\)$$/"\1\\n"/' -e'1s/^\(.*\)$$/const char $(shell echo $< | tr '.' '_')_data[] = \1/' -e '$$s/^\(.*\)$$/\1;/' > $@
268 351
269 %.o : %.S 352 %.o : %.S
270 $(CC) -c -o $@ $< 353 $(CC) -c -o $@ $<
271 354
272 %.o : %.c 355 %.o : %.c
282 ./img2tiles.py -s $< $@ 365 ./img2tiles.py -s $< $@
283 366
284 %.bin : %.s68 367 %.bin : %.s68
285 vasmm68k_mot -Fbin -m68000 -no-opt -spaces -o $@ -L $@.list $< 368 vasmm68k_mot -Fbin -m68000 -no-opt -spaces -o $@ -L $@.list $<
286 369
370 %.md : %.s68
371 vasmm68k_mot -Fbin -m68000 -no-opt -spaces -o $@ -L $@.list $<
372
287 %.bin : %.sz8 373 %.bin : %.sz8
288 vasmz80_mot -Fbin -spaces -o $@ $< 374 vasmz80_mot -Fbin -spaces -o $@ $<
289 res.o : blastem.rc 375 res.o : blastem.rc
290 i686-w64-mingw32-windres blastem.rc res.o 376 $(WINDRES) blastem.rc res.o
291 377
292 arrow.tiles : arrow.png 378 arrow.tiles : arrow.png
293 cursor.tiles : cursor.png 379 cursor.tiles : cursor.png
294 font_interlace_variable.tiles : font_interlace_variable.png 380 font_interlace_variable.tiles : font_interlace_variable.png
295 button.tiles : button.png 381 button.tiles : button.png
296 font.tiles : font.png 382 font.tiles : font.png
297 383
298 menu.bin : font_interlace_variable.tiles arrow.tiles cursor.tiles button.tiles font.tiles 384 menu.bin : font_interlace_variable.tiles arrow.tiles cursor.tiles button.tiles font.tiles
385 tmss.md : font.tiles
299 386
300 clean : 387 clean :
301 rm -rf $(ALL) trans ztestrun ztestgen *.o nuklear_ui/*.o zlib/*.o 388 rm -rf $(ALL) trans ztestrun ztestgen *.o nuklear_ui/*.o zlib/*.o