Mercurial > repos > blastem
diff 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 |
line wrap: on
line diff
--- a/Makefile Sat Jan 05 00:58:08 2019 -0800 +++ b/Makefile Sat Jan 15 13:15:21 2022 -0800 @@ -1,28 +1,43 @@ +#disable built-in rules +.SUFFIXES : + ifndef OS OS:=$(shell uname -s) endif FIXUP:=true +BUNDLED_LIBZ:=zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/gzclose.o zlib/gzlib.o zlib/gzread.o\ + zlib/gzwrite.o zlib/infback.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o zlib/uncompr.o zlib/zutil.o + ifeq ($(OS),Windows) -ifndef SDL2_PREFIX -SDL2_PREFIX:="sdl/i686-w64-mingw32" -endif -ifndef GLEW_PREFIX + GLEW_PREFIX:=glew -endif -ifndef GLEW32S_LIB -GLEW32S_LIB:=$(GLEW_PREFIX)/lib/Release/Win32/glew32s.lib -endif - MEM:=mem_win.o TERMINAL:=terminal_win.o FONT:=nuklear_ui/font_win.o NET:=net_win.o EXE:=.exe +SO:=dll +CPU:=i686 +ifeq ($(CPU),i686) CC:=i686-w64-mingw32-gcc-win32 -CFLAGS:=-std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -I"$(SDL2_PREFIX)/include/SDL2" -I"$(GLEW_PREFIX)/include" -DGLEW_STATIC -LDFLAGS:= $(GLEW32S_LIB) -L"$(SDL2_PREFIX)/lib" -lm -lmingw32 -lSDL2main -lSDL2 -lws2_32 -lopengl32 -lglu32 -mwindows -CPU:=i686 +WINDRES:=i686-w64-mingw32-windres +GLUDIR:=Win32 +SDL2_PREFIX:="sdl/i686-w64-mingw32" +else +CC:=x86_64-w64-mingw32-gcc-win32 +WINDRES:=x86_64-w64-mingw32-windres +SDL2_PREFIX:="sdl/x86_64-w64-mingw32" +GLUDIR:=x64 +endif +GLEW32S_LIB:=$(GLEW_PREFIX)/lib/Release/$(GLUDIR)/glew32s.lib +CFLAGS:=-std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -Wpointer-arith -Werror=pointer-arith +LDFLAGS:=-lm -lmingw32 -lws2_32 -mwindows +ifneq ($(MAKECMDGOALS),libblastem.dll) +CFLAGS+= -I"$(SDL2_PREFIX)/include/SDL2" -I"$(GLEW_PREFIX)/include" -DGLEW_STATIC +LDFLAGS+= $(GLEW32S_LIB) -L"$(SDL2_PREFIX)/lib" -lSDL2main -lSDL2 -lopengl32 -lglu32 +endif +LIBZOBJS=$(BUNDLED_LIBZ) else @@ -32,11 +47,21 @@ EXE:= HAS_PROC:=$(shell if [ -d /proc ]; then /bin/echo -e -DHAS_PROC; fi) -CFLAGS:=-std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -Wno-unused-value $(HAS_PROC) -DHAVE_UNISTD_H +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 ifeq ($(OS),Darwin) LIBS=sdl2 glew FONT:=nuklear_ui/font_mac.o +SO:=dylib +else +SO:=so + +ifdef USE_FBDEV +LIBS=alsa +ifndef NOGL +LIBS+=glesv2 egl +endif +CFLAGS+= -DUSE_GLES -DUSE_FBDEV -pthread else ifdef USE_GLES LIBS=sdl2 glesv2 @@ -44,9 +69,17 @@ else LIBS=sdl2 glew gl endif #USE_GLES +endif #USE_FBDEV FONT:=nuklear_ui/font.o endif #Darwin +ifdef HOST_ZLIB +LIBS+= zlib +LIBZOBJS= +else +LIBZOBJS=$(BUNDLED_LIBZ) +endif + ifeq ($(OS),Darwin) #This should really be based on whether or not the C compiler is clang rather than based on the OS CFLAGS+= -Wno-logical-op-parentheses @@ -63,20 +96,29 @@ endif ifeq ($(OS),Darwin) -CFLAGS+= -IFrameworks/SDL2.framework/Headers -LDFLAGS+= -FFrameworks -framework SDL2 -framework OpenGL -framework AppKit +SDL_INCLUDE_PATH:=Frameworks/SDL2.framework/Headers +CFLAGS+= -mmacosx-version-min=10.10 +LDFLAGS+= -FFrameworks -framework SDL2 -framework OpenGL -framework AppKit -mmacosx-version-min=10.10 FIXUP:=install_name_tool -change @rpath/SDL2.framework/Versions/A/SDL2 @executable_path/Frameworks/SDL2.framework/Versions/A/SDL2 else -CFLAGS+= -Isdl/include +SDL_INCLUDE_PATH:=sdl/include LDFLAGS+= -Wl,-rpath='$$ORIGIN/lib' -Llib -lSDL2 ifndef USE_GLES LDFLAGS+= $(shell pkg-config --libs gl) endif endif #Darwin +CFLAGS+= -I$(SDL_INCLUDE_PATH) else +ifeq ($(MAKECMDGOALS),libblastem.$(SO)) +LDFLAGS:=-lm +else CFLAGS:=$(shell pkg-config --cflags-only-I $(LIBS)) $(CFLAGS) LDFLAGS:=-lm $(shell pkg-config --libs $(LIBS)) +ifdef USE_FBDEV +LDFLAGS+= -pthread +endif +endif #libblastem.so ifeq ($(OS),Darwin) LDFLAGS+= -framework OpenGL -framework AppKit @@ -105,11 +147,11 @@ endif ifdef PROFILE -LDFLAGS+= -Wl,--no-as-needed -lprofiler -Wl,--as-needed +PROFFLAGS:= -Wl,--no-as-needed -lprofiler -Wl,--as-needed +CFLAGS+= -g3 endif ifdef NOGL CFLAGS+= -DDISABLE_OPENGL -NONUKLEAR:=1 endif ifdef M68030 @@ -136,24 +178,33 @@ endif TRANSOBJS=gen.o backend.o $(MEM) arena.o tern.o -M68KOBJS=68kinst.o m68k_core.o +M68KOBJS=68kinst.o + +ifdef NEW_CORE +Z80OBJS=z80.o z80inst.o +M68KOBJS+= m68k.o +CFLAGS+= -DNEW_CORE +else +Z80OBJS=z80inst.o z80_to_x86.o ifeq ($(CPU),x86_64) -M68KOBJS+= m68k_core_x86.o +M68KOBJS+= m68k_core.o m68k_core_x86.o TRANSOBJS+= gen_x86.o backend_x86.o else ifeq ($(CPU),i686) -M68KOBJS+= m68k_core_x86.o +M68KOBJS+= m68k_core.o m68k_core_x86.o TRANSOBJS+= gen_x86.o backend_x86.o endif endif - -Z80OBJS=z80inst.o z80_to_x86.o -AUDIOOBJS=ym2612.o psg.o wave.o +endif +AUDIOOBJS=ym2612.o psg.o wave.o vgm.o event_log.o render_audio.o CONFIGOBJS=config.o tern.o util.o paths.o -NUKLEAROBJS=$(FONT) nuklear_ui/blastem_nuklear.o nuklear_ui/sfnt.o controller_info.o -RENDEROBJS=render_sdl.o ppm.o -LIBZOBJS=zlib/adler32.o zlib/compress.o zlib/crc32.o zlib/deflate.o zlib/gzclose.o zlib/gzlib.o zlib/gzread.o\ - zlib/gzwrite.o zlib/infback.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o zlib/trees.o zlib/uncompr.o zlib/zutil.o +NUKLEAROBJS=$(FONT) nuklear_ui/blastem_nuklear.o nuklear_ui/sfnt.o +RENDEROBJS=ppm.o controller_info.o +ifdef USE_FBDEV +RENDEROBJS+= render_fbdev.o +else +RENDEROBJS+= render_sdl.o +endif ifdef NOZLIB CFLAGS+= -DDISABLE_ZLIB @@ -163,7 +214,11 @@ 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 \ realtec.o i2c.o nor.o sega_mapper.o multi_game.o megawifi.o $(NET) serialize.o $(TERMINAL) $(CONFIGOBJS) gst.o \ - $(M68KOBJS) $(TRANSOBJS) $(AUDIOOBJS) saves.o zip.o bindings.o jcart.o segacd.o + $(M68KOBJS) $(TRANSOBJS) $(AUDIOOBJS) saves.o zip.o bindings.o jcart.o gen_player.o segacd.o + +LIBOBJS=libblastem.o system.o genesis.o debug.o gdb_remote.o vdp.o io.o romdb.o hash.o xband.o realtec.o \ + i2c.o nor.o sega_mapper.o multi_game.o megawifi.o $(NET) serialize.o $(TERMINAL) $(CONFIGOBJS) gst.o \ + $(M68KOBJS) $(TRANSOBJS) $(AUDIOOBJS) saves.o jcart.o rom.db.o gen_player.o segacd.o $(LIBZOBJS) ifdef NONUKLEAR CFLAGS+= -DDISABLE_NUKLEAR @@ -187,26 +242,49 @@ CFLAGS+=-DNO_Z80 else MAINOBJS+= sms.o $(Z80OBJS) +LIBOBJS+= sms.o $(Z80OBJS) endif ifeq ($(OS),Windows) MAINOBJS+= res.o endif -ALL=dis$(EXE) zdis$(EXE) stateview$(EXE) vgmplay$(EXE) blastem$(EXE) +ifdef CONFIG_PATH +CFLAGS+= -DCONFIG_PATH='"'$(CONFIG_PATH)'"' +endif + +ifdef DATA_PATH +CFLAGS+= -DDATA_PATH='"'$(DATA_PATH)'"' +endif + +ifdef FONT_PATH +CFLAGS+= -DFONT_PATH='"'$(FONT_PATH)'"' +endif + +ALL=dis$(EXE) zdis$(EXE) vgmplay$(EXE) blastem$(EXE) ifneq ($(OS),Windows) ALL+= termhelper endif +ifeq ($(MAKECMDGOALS),libblastem.$(SO)) +CFLAGS+= -fpic -DIS_LIB +endif + all : $(ALL) +libblastem.$(SO) : $(LIBOBJS) + $(CC) -shared -o $@ $^ $(LDFLAGS) + blastem$(EXE) : $(MAINOBJS) - $(CC) -o $@ $^ $(LDFLAGS) + $(CC) -o $@ $^ $(LDFLAGS) $(PROFFLAGS) $(FIXUP) ./$@ blastjag$(EXE) : jaguar.o jag_video.o $(RENDEROBJS) serialize.o $(M68KOBJS) $(TRANSOBJS) $(CONFIGOBJS) $(CC) -o $@ $^ $(LDFLAGS) +termhelper : termhelper.o + $(CC) -o $@ $^ $(LDFLAGS) + dis$(EXE) : dis.o 68kinst.o tern.o vos_program_module.o $(CC) -o $@ $^ $(OPT) @@ -220,27 +298,23 @@ ar rcs libemu68k.a $(M68KOBJS) $(TRANSOBJS) trans : trans.o serialize.o $(M68KOBJS) $(TRANSOBJS) util.o - $(CC) -o trans trans.o $(M68KOBJS) $(TRANSOBJS) util.o $(OPT) + $(CC) -o $@ $^ $(OPT) transz80 : transz80.o $(Z80OBJS) $(TRANSOBJS) $(CC) -o transz80 transz80.o $(Z80OBJS) $(TRANSOBJS) ztestrun : ztestrun.o serialize.o $(Z80OBJS) $(TRANSOBJS) - $(CC) -o ztestrun ztestrun.o $(Z80OBJS) $(TRANSOBJS) $(OPT) + $(CC) -o ztestrun $^ $(OPT) ztestgen : ztestgen.o z80inst.o $(CC) -ggdb -o ztestgen ztestgen.o z80inst.o -stateview$(EXE) : stateview.o vdp.o $(RENDEROBJS) serialize.o $(CONFIGOBJS) gst.o - $(CC) -o $@ $^ $(LDFLAGS) - $(FIXUP) ./$@ - vgmplay$(EXE) : vgmplay.o $(RENDEROBJS) serialize.o $(CONFIGOBJS) $(AUDIOOBJS) $(CC) -o $@ $^ $(LDFLAGS) $(FIXUP) ./$@ blastcpm : blastcpm.o util.o serialize.o $(Z80OBJS) $(TRANSOBJS) - $(CC) -o $@ $^ $(OPT) + $(CC) -o $@ $^ $(OPT) $(PROFFLAGS) test : test.o vdp.o $(CC) -o test test.o vdp.o @@ -266,6 +340,15 @@ vos_prog_info : vos_prog_info.o vos_program_module.o $(CC) -o vos_prog_info vos_prog_info.o vos_program_module.o +m68k.c : m68k.cpu cpu_dsl.py + ./cpu_dsl.py -d call $< > $@ + +%.c : %.cpu cpu_dsl.py + ./cpu_dsl.py -d goto $< > $@ + +%.db.c : %.db + sed $< -e 's/"/\\"/g' -e 's/^\(.*\)$$/"\1\\n"/' -e'1s/^\(.*\)$$/const char $(shell echo $< | tr '.' '_')_data[] = \1/' -e '$$s/^\(.*\)$$/\1;/' > $@ + %.o : %.S $(CC) -c -o $@ $< @@ -284,10 +367,13 @@ %.bin : %.s68 vasmm68k_mot -Fbin -m68000 -no-opt -spaces -o $@ -L $@.list $< +%.md : %.s68 + vasmm68k_mot -Fbin -m68000 -no-opt -spaces -o $@ -L $@.list $< + %.bin : %.sz8 vasmz80_mot -Fbin -spaces -o $@ $< res.o : blastem.rc - i686-w64-mingw32-windres blastem.rc res.o + $(WINDRES) blastem.rc res.o arrow.tiles : arrow.png cursor.tiles : cursor.png @@ -296,6 +382,7 @@ font.tiles : font.png menu.bin : font_interlace_variable.tiles arrow.tiles cursor.tiles button.tiles font.tiles +tmss.md : font.tiles clean : rm -rf $(ALL) trans ztestrun ztestgen *.o nuklear_ui/*.o zlib/*.o