#
# Sega Saturn Cartridge Firmware Flash Utility
# by cafe-alpha.
# WWW: http://ppcenter.free.fr/pskai/
#
# Made from "Sega Saturn cartridge flash tool", by Anders Montonen.
#
# See LICENSE file for details.
#

CC	=	saturn-sh2-elf-gcc
LD	=	saturn-sh2-elf-gcc
AS	=	saturn-sh2-elf-as
LDFLAGS =	-nostartfiles -T bart.lnk 
FLAGS	=	-Wall -Werror -m2 -mb -Os -fomit-frame-pointer -nostdlib -std=c99 -DSC_COMP_DISABLE

PJ_NAME =	flasher
EXE =	flasher_ARP.bin
CDB =	cd/0.bin
IMG =	flasher_ARP.iso

OBJ =	obj/CRT0.o	\
		obj/main.o	\
		obj/flash.o	\
		obj/conio.o	\
		obj/menu.o	\
		obj/smpc.o	\
		obj/vdp.o	\
		../../satcom_lib/sc_compress.o	\
		obj/romwrap.o

FW =	obj/ARS_181.CMP		\
		obj/ARS_194.CMP		\
		obj/ARS_194C.CMP	\
		obj/ARP_201.CMP		\
		obj/ARP_201D.CMP	\
		obj/ARP_202.CMP		\
		obj/ARP_202C.CMP	\
		obj/GSS_196.CMP		\
		obj/MCP_001.CMP		\
		obj/PS_0830.CMP		\
		obj/PS_0831.CMP		\
		obj/PS_0832A.CMP	\
		obj/PS_0832.CMP

all :	$(EXE)

cd	:	$(IMG)


$(IMG)	:	$(CDB)
		mkisofs -quiet -sysid "SEGA SATURN" -volid "$(PJ_NAME)" -volset "$(PJ_NAME)" -publisher "SEGA ENTERPRISES, LTD." -preparer "SEGA ENTERPRISES, LTD." -appid "$(PJ_NAME)" -abstract "ABS.TXT" -copyright "CPY.TXT" -biblio "BIB.TXT" -generic-boot $(IP_PATH) -full-iso9660-filenames -o $(IMG) cd
		../../tools/ip_header.exe $(IMG) -today -man "CAFE-ALPHA" -autover ../release.h -area "JTUBKAEL" -per "J" -title "SATURN CARTRIDGE FLASHER UTILITYBy cafe-alpha   ppcenter.free.fr" -prod "T-042G"

$(EXE)	:	$(OBJ) $(FW)
		$(LD) $(LDFLAGS) -Wl,-Map=obj/main_elf_exe.map $(OBJ) -L$(LGCC_PATH) -lc -lgcc -o $(EXE)

$(CDB)	:	$(OBJ) $(FW)
		$(LD) $(LDFLAGS) -Wl,-Map=obj/main_elf_cdb.map $(OBJ) -L$(LGCC_PATH) -lc -lgcc -o $(CDB)


obj/%.o :	%.c
		$(CC) -c $< -o $@ $(FLAGS)

obj/%.o :	%.S $(FW)
		$(AS) $< -o $@

obj/%.CMP :	cd/FW/%.BIN
		../../tools/comp.exe -c $< $@

clean	:
		rm -f obj/*.o
		rm -f obj/*.map
		rm -f $(FW)

mrproper:
		rm -f obj/*.o
		rm -f obj/*.map
		rm -f $(FW)
		rm -f $(CDB)
		rm -f $(EXE)
		rm -f $(IMG)

makedir :
		mkdir obj
		mkdir cd

#
# end of makefile
#
