# (C) 2003 XDA Developers  itsme@xs4all.nl
#
# $Header$
#
# note: commands should contain forward slashes
#       double quoted strings may contain dos-type backslashes in paths
#
# currently you have to manually switch the '300' and '420' in this file
# to switch between a ppc2002/ce3.00 and ppc2003/ce4.20 version of testpi.exe
#
out=../build
obj=../build/ce-extrom

include ../local.mak


# /Zi /Od /Fd"$(out)" for debugging
# /O2      for release
cflags=/nologo /W3 /O2 /c /Fo"$(obj)/" $(pb420incs) /I "..\include" /I "../dll" /I "../common"  /EHsc /I "../include/msvc"
targetdefs=/D "ARM" /D "_ARM_" /D "ARMV4"
platformdefs=/D _WIN32_WCE=420 /D "WIN32_PLATFORM_PSPC=310" /D UNDER_CE=420
cdefs=$(targetdefs) $(platformdefs) /D "UNICODE" /D "_UNICODE" /D "NDEBUG"
cdefs+=/D _CRT_SECURE_NO_WARNINGS /D _SECURE_SCL=0 /D _HAS_ITERATOR_DEBUGGING=0
dlldefs=/D "_USRDLL"

# linker flags
lddllflags=/entry:"_DllMainCRTStartup" /dll 
ldexeflags=/entry:"WinMainCRTStartup" /debug
ldplatformflags=/subsystem:windowsce,3.00 /align:"4096" 
ldflags=/nologo /base:"0x00100000" /stack:0x10000,0x1000 $(celdtargetflags) $(ldplatformflags)
libpaths=/libpath:"$(ppclib)" /libpath:"$(celib)"

# rc flags
rcflags= /l 0x409 /d UNDER_CE=300 /d _WIN32_WCE=300 /d UNICODE /d _UNICODE /d NDEBUG /d WIN32_PLATFORM_PSPC=310 /d ARM /d _ARM_ 

all: $(obj) $(out)/unlockextrom.exe
$(obj):
	mkdir -p $(obj)

$(obj)/debug.obj: ../common/debug.cpp
	@"$(cecc)" $(cflags) $(cdefs) $^
$(obj)/stringutils.obj: ../common/stringutils.cpp
	@"$(cecc)" $(cflags) $(cdefs) $^
$(obj)/vectorutils.obj: ../common/vectorutils.cpp
	@"$(cecc)" $(cflags) $(cdefs) $^

$(obj)/unlockextrom.obj: unlockextrom.cpp
	@"$(cecc)" $(cflags) $(cdefs) $^
$(obj)/unlockextrom.res: unlockextrom.rc
	@"$(rc)" $(rcflags) /fo$@ /r $^

$(out)/unlockextrom.exe: $(obj)/unlockextrom.obj $(obj)/debug.obj $(obj)/stringutils.obj $(obj)/unlockextrom.res
	@"$(celd)" $(libpaths) $(ldflags) $(extralibs) coredll.lib corelibc.lib /out:$@ $^


clean:
	-rm $(out)/unlockextrom.*
	rm -rf $(obj)

