# vdlaunch Makefile
#

#CONFIG=RELEASE
CONFIG=DEBUG


ifneq ($(CONFIG),RELEASE)
	CFLAGS=-DPALMOS -DNEWGCC -DASMV -Wall -Werror -g -O0
	OPT_SPEED=
	OPT_DEF=
else
	CFLAGS=-DPALMOS -DNEWGCC -DASMV -DERROR_CHECK_LEVEL=1
	OPT_SPEED=-O3
	OPT_DEF=-O2
endif

#  Target ALL
all : ./Release/vdlaunch.prc

#  Target Clean
clean :
	cd ./Release/ && \
	rm -f *.bin bin.res *~ *.grc *.xxx *.prc *.o *.ld *.s *.d vdlaunch.prc vdlaunch

#  Rule for building sourcefile vdlaunch.c
./Release/vdlaunch.o : vdlaunch.c vdlaunch.h
	@echo "Compiling vdlaunch.c..." && \
	m68k-palmos-gcc -palmos4.0 $(CFLAGS) $(OPT_SPEED) -o./Release/vdlaunch.o -c vdlaunch.c -MD
	@mv  vdlaunch.d ./Release/vdlaunch.d

#  Rules for multilink preparations
#./Release/vdlaunch_s.o : ./vdlaunch-sections.s
#	@echo "Compiling the ASM stubs..." && \
#	m68k-palmos-gcc -c -o ./Release/vdlaunch_s.o vdlaunch-sections.s

#./vdlaunch-sections.s ./vdlainch-sections.ld : ./vdlaunch.def
#	@echo "Processing the definition file..." && \
#	m68k-palmos-multigen vdlaunch.def

#  Rule for building resources
./Release/*.bin : vdlaunch.rcp vdlaunch_res.h
	@echo "Compiling resource vdlaunch.rcp..." && \
	pilrc ${PILRCDEFINES} -q vdlaunch.rcp ./Release/

#  Rule for Linking the project
./Release/vdlaunch : ./Release/vdlaunch.o 
	@echo "Linking..." && \
	m68k-palmos-gcc ./Release/vdlaunch.o -palmos4.0 -g -o "$@"

#  Rule for building PRCFile
./Release/vdlaunch.prc : vdlaunch.def ./Release/vdlaunch ./Release/*.bin
	@echo "Building PRC, compilation flags used $(CFLAGS) $(OPT_SPEED)" && \
	cd ./Release/ && \
	build-prc ../vdlaunch.def vdlaunch *.bin && \


