diff --git a/Makefile b/Makefile index bc2c4d0..652fc3d 100644 --- a/Makefile +++ b/Makefile @@ -68,7 +68,21 @@ INCS:= -I$(INCLUDE) -I$(SRC) -I$(RES) -I$(INCLUDE_LIB) -I$(RES_LIB) DEFAULT_FLAGS= $(EXTRA_FLAGS) -DSGDK_GCC -m68000 -Wall -Wextra -Wno-shift-negative-value -Wno-main -Wno-unused-parameter -fno-builtin -fms-extensions $(INCS) -B$(BIN) FLAGSZ80:= -i$(SRC) -i$(INCLUDE) -i$(RES) -i$(SRC_LIB) -i$(INCLUDE_LIB) -i$(INCLUDE_LIB)/snd -release: FLAGS= $(DEFAULT_FLAGS) -O3 -fuse-linker-plugin -fno-web -fno-gcse -fno-unit-at-a-time -fomit-frame-pointer -flto +EXTRA_FLAGS:=-DBUILD='"$(BUILD)"' \ + -Wl,--wrap=SYS_enableInts \ + -Wl,--wrap=SYS_disableInts \ + -Werror \ + -Wextra + +ifeq ($(ROM_TYPE), MEGAWIFI) + EXTRA_FLAGS += -DMEGAWIFI + LTO_FLAGS:= +else + LTO_FLAGS:=-flto +endif + +release: FLAGS= $(DEFAULT_FLAGS) -O3 -fuse-linker-plugin -fno-web -fno-gcse \ + -fno-unit-at-a-time -fomit-frame-pointer $(LTO_FLAGS) release: CFLAGS= $(FLAGS) release: AFLAGS= $(FLAGS) release: LIBMD= $(LIB)/libmd.a @@ -116,7 +130,8 @@ cleanobj: $(RM) -f $(OBJS) out/sega.o out/rom_head.bin out/rom_head.o out/rom.out clean: cleanobj cleanres cleanlst cleandep - $(RM) -f out.lst out/cmd_ out/symbol.txt out/rom.nm out/rom.wch out/rom.bin + $(RM) -f out.lst out/symbol.txt out/rom.nm out/rom.wch out/rom.bin out/rom.s + $(MAKE) -C tests clean-target cleanrelease: clean @@ -132,22 +147,18 @@ cleanDebug: cleandebug cleanAsm: cleanasm pre-build: - $(MKDIR) -p $(SRC)/boot - $(MKDIR) -p out + @$(MKDIR) -p $(SRC)/boot + @$(MKDIR) -p out out/rom.bin: out/rom.out $(OBJCPY) -O binary out/rom.out out/rom.bin - $(SIZEBND) out/rom.bin -sizealign 131072 -checksum + $(SIZEBND) out/rom.bin -sizealign 524288 -checksum out/symbol.txt: out/rom.out $(NM) $(LTO_PLUGIN) -n out/rom.out > out/symbol.txt -out/rom.out: out/sega.o out/cmd_ $(LIBMD) - $(CC) -m68000 -B$(BIN) -n -T $(GDK)/md.ld -nostdlib out/sega.o @out/cmd_ $(LIBMD) $(LIBGCC) -o out/rom.out -Wl,--gc-sections -flto - $(RM) out/cmd_ - -out/cmd_: $(OBJS) - $(ECHO) "$(OBJS)" > out/cmd_ +out/rom.out: out/sega.o $(OBJS) $(LIBMD) + $(CC) -m68000 -B$(BIN) -n -T $(GDK)/md.ld -nostdlib out/sega.o $(OBJS) $(LIBMD) $(LIBGCC) -o out/rom.out -Wl,--gc-sections -flto out/sega.o: $(SRC)/boot/sega.s out/rom_head.bin $(CC) -x assembler-with-cpp -Wa,--register-prefix-optional,--bitwise-or $(AFLAGS) -c $(SRC)/boot/sega.s -o $@ @@ -194,44 +205,12 @@ out/%.o: %.rs %.s: %.o80 $(BINTOS) $< -EXTRA_FLAGS:=-DBUILD='"$(BUILD)"' \ - -Wl,--wrap=SYS_enableInts \ - -Wl,--wrap=SYS_disableInts \ - -Werror \ - -Wextra - -ifeq ($(ROM_TYPE), MEGAWIFI) - EXTRA_FLAGS += -DMEGAWIFI - LTO_FLAGS:= -else - LTO_FLAGS:=-flto -endif - res/samples: wget "https://github.com/rhargreaves/mega-drive-pcm-samples/releases/download/v1/samples.zip" \ -O temp.zip unzip temp.zip -d res/samples rm temp.zip -debug: FLAGS= $(DEFAULT_FLAGS) -O1 -DDEBUG=1 -debug: CFLAGS= $(FLAGS) -ggdb -debug: AFLAGS= $(FLAGS) -debug: LIBMD= $(LIB)/libmd_debug.a -debug: pre-build out/rom.bin out/rom.out out/symbol.txt - -release: FLAGS= $(DEFAULT_FLAGS) -O3 -fuse-linker-plugin -fno-web -fno-gcse \ - -fno-unit-at-a-time -fomit-frame-pointer $(LTO_FLAGS) -release: LIBMD= $(LIB)/libmd.a -release: pre-build out/rom.bin out/symbol.txt - -clean: cleanobj cleanres cleanlst cleandep - $(RM) -f out.lst out/cmd_ out/symbol.txt out/rom.nm out/rom.wch out/rom.bin out/rom.s - $(MAKE) -C tests clean-target - -out/rom.bin: out/rom.out - $(OBJCPY) -O binary out/rom.out out/rom.bin - $(SIZEBND) out/rom.bin -sizealign 524288 -checksum - out/rom.s: out/rom.out m68k-elf-objdump -D -S $^ > $@