Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Makefile for building SEGA Genesis/Megadrive ROMs using the toolchain built
- # by kubilus1 scripts. This Makefile is a modified version of the one supplied
- # with SGDK by Stef.
- # http://gendev.spritesmind.net/forum/viewtopic.php?t=1248
- # Modified by doragasu
- GDK?=/opt/toolchains/gen
- TOOLS= $(GDK)/bin
- BIN= $(GDK)/m68k-elf/bin/
- LIB= $(GDK)/m68k-elf/lib
- PREFIX=m68k-elf-
- LIBSRC= $(GDK)/m68k-elf/src
- LIBINCLUDE= $(GDK)/m68k-elf/include
- LINKSCRIPT= $(GDK)/ldscripts/md.ld
- SRC= src
- RES= res
- INCLUDE= include
- SHELL=sh
- RM= rm
- AR= $(BIN)$(PREFIX)ar
- CC= $(BIN)$(PREFIX)gcc
- LD= $(BIN)$(PREFIX)ld
- ECHO=echo
- OBJCPY= $(BIN)$(PREFIX)objcopy
- ASMZ80= $(TOOLS)/sjasm
- #MACCER= $(TOOLS)/mac68k
- SIZEBND= $(TOOLS)/sizebnd
- BINTOS= $(TOOLS)/bintos
- WAVTORAW= $(TOOLS)/wavtoraw
- PCMTORAW= $(TOOLS)/pcmtoraw
- #GENRES= $(TOOLS)/genres
- #TFMCOM= $(TOOLS)/tfmcom
- NM= $(BIN)$(PREFIX)nm
- MKDIR= mkdir
- #NM2WCH= $(TOOLS)/nm2wch
- ADDR2LINE= $(BIN)$(PREFIX)addr2line
- #OUT2GSRC=$(TOOLS)/out2gsrc
- OPTION=
- SRC_C= $(wildcard *.c)
- SRC_C+= $(wildcard $(SRC)/*.c)
- SRC_S= $(wildcard *.s)
- SRC_S+= $(wildcard $(SRC)/*.s)
- SRC_SZ80= $(wildcard *.s80)
- SRC_SZ80+= $(wildcard $(SRC)/*.s80)
- RES_C= $(wildcard $(RES)/*.c)
- RES_S= $(wildcard $(RES)/*.s)
- RES_BMP= $(wildcard *.bmp)
- RES_BMP+= $(wildcard $(RES)/*.bmp)
- RES_WAV= $(wildcard *.wav)
- RES_WAV+= $(wildcard $(RES)/*.wav)
- RES_WAVPCM= $(wildcard *.wavpcm)
- RES_WAVPCM+= $(wildcard $(RES)/*.wavpcm)
- RES_DAT= $(wildcard *.dat)
- RES_DAT+= $(wildcard $(RES)/*.dat)
- RES_RAW= $(wildcard *.raw)
- RES_RAW+= $(wildcard $(RES)/*.raw)
- RES_PCM= $(wildcard *.pcm)
- RES_PCM+= $(wildcard $(RES)/*.pcm)
- #RES_TFD= $(wildcard *.tfd)
- #RES_TFD+= $(wildcard $(RES)/*.tfd)
- RES_TFC= $(wildcard *.tfc)
- RES_TFC+= $(wildcard $(RES)/*.tfc)
- RES_MVS= $(wildcard *.mvs)
- RES_MVS+= $(wildcard $(RES)/*.mvs)
- RES_EIF= $(wildcard *.eif)
- RES_EIF+= $(wildcard $(RES)/*.eif)
- RES_ESF= $(wildcard *.esf)
- RES_ESF+= $(wildcard $(RES)/*.esf)
- RES_VGM= $(wildcard *.vgm)
- RES_VGM+= $(wildcard $(RES)/*.vgm)
- #RES_RC= $(wildcard *.rc)
- #RES_RC+= $(wildcard $(RES)/*.rc)
- #RES_ASM= $(wildcard *.asm)
- #RES_ASM+= $(wildcard $(RES)/*.asm)
- OBJ= $(RES_BMP:.bmp=.o)
- OBJ+= $(RES_WAV:.wav=.o)
- OBJ+= $(RES_WAVPCM:.wavpcm=.o)
- OBJ+= $(RES_RC:.rc=.o)
- OBJ+= $(RES_ASM:.asm=.o)
- OBJ+= $(RES_DAT:.dat=.o)
- OBJ+= $(RES_RAW:.raw=.o)
- OBJ+= $(RES_PCM:.pcm=.o)
- OBJ+= $(RES_TFD:.tfd=.o)
- OBJ+= $(RES_TFC:.tfc=.o)
- OBJ+= $(RES_MVS:.mvs=.o)
- OBJ+= $(RES_VGM:.vgm=.o)
- OBJ+= $(RES_EIF:.eif=.o)
- OBJ+= $(RES_ESF:.esf=.o)
- OBJ+= $(RES_S:.s=.o)
- OBJ+= $(RES_C:.c=.o)
- OBJ+= $(SRC_SZ80:.s80=.o)
- OBJ+= $(SRC_S:.s=.o)
- OBJ+= $(SRC_C:.c=.o)
- OBJS = $(addprefix out/, $(OBJ))
- INCS= -I$(LIBINCLUDE) -I$(INCLUDE) -I$(SRC) -I$(RES)
- #FLAGS= $(OPTION) -g3 -m68000 -Wall -O1 -fomit-frame-pointer -fno-builtin-memset -fno-builtin-memcpy $(INCS)
- FLAGS= $(OPTION) -m68000 -Wall -O1 -fomit-frame-pointer -fno-builtin-memset -fno-builtin-memcpy $(INCS)
- #FLAGS= $(OPTION) -m68000 -Wall -O3 -fno-web -fno-gcse -fno-unit-at-a-time -fomit-frame-pointer -fno-builtin-memset -fno-builtin-memcpy $(INCS)
- FLAGSZ80= -i$(LIBSRC) -i$(LIBINCLUDE) -i$(SRC) -i$(INCLUDE) -i$(RES)
- release: out/rom.bin
- #debug: out/rom.bin out/rom.wch
- #debugall: out/rom.bin out/rom.wch out/rom.gsrc
- all: release
- default: release
- .PHONY: clean
- clean:
- $(RM) -f $(OBJS) out.lst out/cmd_ out/sega.o out/rom_head.bin out/rom_head.o out/rom.nm out/rom.wch out/rom.out out/rom.bin
- cleanobj:
- $(RM) -f $(OBJS) out/sega.o out/rom_head.bin out/rom_head.o out/rom.out
- out/rom.bin: out/rom.out
- $(OBJCPY) -O binary out/rom.out out/romtmp.bin
- dd if=out/romtmp.bin of=$@ bs=128K conv=sync
- $(RM) -f out/romtmp.bin
- #out/rom.wch: out/rom.out
- # $(NM) -n -S -t x out/rom.out >out/rom.nm
- # $(NM2WCH) out/rom.nm out/rom.wch
- #out/rom.gsrc: out/rom.bin
- # $(OUT2GSRC) i out/rom.bin out/rom.addr
- # $(ADDR2LINE) -e out/rom.out < out/rom.addr > out/rom.gsrc
- out/rom.out: out/sega.o out/cmd_ $(LIB)/libmd.a
- $(CC) -n -T $(LINKSCRIPT) -nostdlib out/sega.o @out/cmd_ -L$(LIB) -lmd -lgcc -o out/rom.out
- $(RM) out/cmd_
- out/cmd_: $(OBJS)
- $(ECHO) "$(OBJS)" > out/cmd_
- out/sega.o: $(LIBSRC)/boot/sega.s out/rom_head.bin
- $(MKDIR) -p out
- $(CC) $(FLAGS) -c $(LIBSRC)/boot/sega.s -o $@
- out/rom_head.bin: out/rom_head.o
- $(LD) -T $(LINKSCRIPT) -nostdlib --oformat binary -o $@ $<
- out/rom_head.o: $(LIBSRC)/boot/rom_head.c
- $(MKDIR) -p out
- $(CC) $(FLAGS) -c $< -o $@
- out/%.o: %.c
- $(MKDIR) -p out
- $(MKDIR) -p out/src
- $(MKDIR) -p out/res
- $(CC) $(FLAGS) -c $< -o $@
- out/%.o: %.s
- $(MKDIR) -p out
- $(MKDIR) -p out/src
- $(MKDIR) -p out/res
- $(CC) $(FLAGS) -c $< -o $@
- #%.asm: %.rc
- # $(GENRES) $< $@
- #%.s: %.asm
- # $(MACCER) -o $@ $<
- %.s: %.bmp
- $(BINTOS) -bmp $<
- %.raw: %.wav
- $(WAVTORAW) $< $@ 16000
- %.pcm: %.wavpcm
- $(WAVTORAW) $< $@ 22050
- %.rawpcm: %.pcm
- $(PCMTORAW) $< $@
- #%.tfc: %.tfd
- # $(TFMCOM) $<
- %.o80: %.s80
- $(ASMZ80) $(FLAGSZ80) $< $@ out.lst
- %.s: %.tfc
- $(BINTOS) -align 32768 $<
- %.s: %.mvs
- $(BINTOS) -align 256 $<
- %.s: %.esf
- $(BINTOS) -align 32768 $<
- %.s: %.eif
- $(BINTOS) -align 256 $<
- %.s: %.vgm
- $(BINTOS) -align 256 $<
- %.s: %.raw
- $(BINTOS) -align 256 -sizealign 256 $<
- %.s: %.rawpcm
- $(BINTOS) -align 128 -sizealign 128 -nullfill 136 $<
- %.s: %.dat
- $(BINTOS) -align 256 -sizealign 256 $<
- %.s: %.o80
- $(BINTOS) $<
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement