# (c) 1999-2007 Electronic Arts Inc.

#.silent:
.SUFFIXES: .cpp .c .a .o .elf

all:: libspit.a avi2chunk.elf chimp.elf  chunkify.elf gsr.elf crc.elf imagetohex \
 spit_eg.elf xd.elf math.elf copyr.elf zcut.elf tabs.elf zhelp.elf zfilesize.elf zrename.elf makepad.elf bighead.elf \
 cmp.elf author.elf bingrep.elf bmw.elf gs.elf hashid.elf sleep.elf  bloodhound_eg.elf txt.elf \
 unslash.elf xl.elf sortshp.elf hhmerge.elf uni.elf abstract.elf ztee.elf chunktoavi.elf vid2div.elf sony2dvd.elf dvdmap.elf
#glump.elfhuff.elf

SPITOBJS=spit.o stdgimex.o hashlist.o findfile.o wildmatch.o expr.o range.o ranger.o bloodhound.o
STDLIBS=-lm

# ddraw.a dxguid.a

!IFDEF DEBUG
CCOPTS=-c -O0 -g3 -G0 -fshort-wchar    -xc++ -fno-common -fomit-frame-pointer -fno-rtti -fno-exceptions -ffast-math
LINKOPTS=
!ELSE
CCOPTS=-c -O2 -G0 -fshort-wchar    -xc++ -fno-common -fomit-frame-pointer -fno-rtti -fno-exceptions -ffast-math
LINKOPTS=
!ENDIF

ICL=ppu-lv2-gcc

.cpp.o::
	$(ICL) $(CCOPTS) $<

.c.o::
	$(ICL) $(CCOPTS) $<

.rc.res::
	rc -r $<

.pl.elf::
	echo making perlapp --force
	perlapp --force $*.pl

.o.elf:
	echo linking $*
	ppu-lv2-gcc $(LINKOPTS) -o$*.elf $*.o libspit.a $(STDLIBS)

libspit.a: $(SPITOBJS)
	@echo building spit library
	ppu-lv2-ar -r libspit.a $(SPITOBJS)

imagetohex: imagetohex.elf
avi2chunk: avi2chunk.elf
du: du.elf
cdu: cdu.elf
dvdmap: dvdmap.elf
txt: txt.elf
touch: touch.elf
db: db.elf
fp: fp.elf
ie: ie.elf
crc: crc.elf
acdc: acdc.elf
abstract: abstract.elf
author: author.elf
bingrep: bingrep.elf
bmw: bmw.elf
chunkify: chunkify.elf
cmp: cmp.elf
copyr: copyr.elf
cymbal: cymbal.elf
dis: dis.elf
dvdmap: dvdmap.elf
filestat: filestat.elf
gs: gs.elf
gsr: gsr.elf
hashid: hashid.elf
math: math.elf
sleep: sleep.elf
spit_eg: spit_eg.elf
bloodhound_eg: bloodhound_eg.elf
tabs: tabs.elf
timex: timex.elf
uni: uni.elf
unslash: unslash.elf
url: url.elf
xl: xl.elf
zcut: zcut.elf
zhelp: zhelp.elf
zfilesize: zfilesize.elf
zrename: zrename.elf
zrun: zrun.elf
sortshp: sortshp.elf
hhmerge: hhmerge.elf
whereis: whereis.elf
venom: venom.elf
zcopy: zcopy.elf
ztee: ztee.elf
recurse: recurse.elf
chunktoavi: chunktoavi.elf
vid2div: vid2div.elf
expr_test: expr_test.elf
falloc_test: falloc_test.elf
hash_eg: hash_eg.elf
bighead: bighead.elf
sony2dvd: sony2dvd.elf
makepad: makepad.elf
bighead: bighead.elf

imagetohex.elf: imagetohex.o	 libspit.a
avi2chunk.elf:	avi2chunk.o  libspit.a
touch.elf:		touch.o
txt.elf:		txt.o			 libspit.a
db.elf: 		db.o			 libspit.a
fp.elf: 		fp.o			 libspit.a
ie.elf: 		ie.o			 libspit.a
crc.elf:		crc.o			 libspit.a
acdc.elf:		acdc.o		 libspit.a
abstract.elf:	abstract.o	   libspit.a
author.elf: 	author.o	   libspit.a
bingrep.elf:	bingrep.o	   libspit.a
bmw.elf:		bmw.o			 libspit.a
chunkify.elf:	chunkify.o	   libspit.a
cmp.elf:		cmp.o			 libspit.a
copyr.elf:		copyr.o 	   libspit.a
cymbal.elf: 	 cymbal.o	   libspit.a
dis.elf:		dis.o			 libspit.a
dvdmap.elf: 	dvdmap.o
e.elf:			e.o 			 libspit.a
gs.elf: 		gs.o			 libspit.a
gsr.elf:		gsr.o			 libspit.a
hashid.elf: 	 hashid.o	   libspit.a
math.elf:		math.o		 libspit.a
sleep.elf:		sleep.o 	   libspit.a
spit_eg.elf:	spit_eg.o	   libspit.a
bloodhound_eg.elf: bloodhound_eg.o libspit.a
tabs.elf:		tabs.o		 libspit.a
timex.elf:		timex.o 	   libspit.a
uni.elf:		uni.o		   libspit.a
unslash.elf:	unslash.o	   libspit.a
url.elf:		url.o			 libspit.a
xl.elf: 		xl.o			 libspit.a
zcut.elf:		zcut.o		 libspit.a
zhelp.elf:		zhelp.o 	   libspit.a
zfilesize.elf:	zfilesize.o    libspit.a
zrename.elf:	zrename.o	   libspit.a
zrun.elf:		zrun.o		 libspit.a
sortshp.elf:	sortshp.o	   libspit.a
hhmerge.elf:	hhmerge.o	   libspit.a
venom.elf:		venom.o 	   libspit.a
zcopy.elf:		zcopy.o 	   libspit.a
ztee.elf:		ztee.o		   libspit.a
recurse.elf:	recurse.o
chunktoavi.elf: chunktoavi.o	 libspit.a
vid2div.elf:	vid2div.o		 libspit.a
expr_test.elf:	expr_test.o  libspit.a
hash_eg.elf:	hash_eg.o		 libspit.a
bighead.elf:	bighead.o
sony2dvd.elf:	sony2dvd.o
makepad.elf:	makepad.o
bighead.elf:	bighead.o

timex.o: zrun.cpp
gs.o: gsr.cpp
spit.o: spit.h falloc.h

du.elf: du.pl
	perlapp --force du.pl

cdu cdu.elf: cdu.pl
	perlapp --force cdu.pl

paddvd paddvd.elf: paddvd.pl
	perlapp --force paddvd.pl

cymbal cymbal.elf: cymbal.o $(SPITOBJS)
	ppu-lv2-gcc  $(LINKOPTS) -ocymbal.elf cymbal.o $(SPITOBJS) $(STDLIBS)

huff huff.elf: huff.o huffbest.o huffu.o huffview.o $(SPITOBJS)
	ppu-lv2-gcc  $(LINKOPTS) -ohuff.elf huff.o $(SPITOBJS) huffbest.o huffview.o huffu.o libcodex.a $(STDLIBS)

chimp chimp.elf: chimp.o $(SPITOBJS)
	ppu-lv2-gcc  $(LINKOPTS) -ochimp.elf chimp.o $(SPITOBJS) $(STDLIBS)

xd xd.elf: xd.o $(SPITOBJS)
	ppu-lv2-gcc  $(LINKOPTS) -oxd.elf xd.o $(SPITOBJS) $(STDLIBS)

whereis whereis.elf: whereis.o whereis_tool.o $(SPITOBJS)
	ppu-lv2-gcc  $(LINKOPTS) -owhereis.elf whereis.o whereis_tool.o $(SPITOBJS) $(STDLIBS) mpr.a vfw32.a

#	@cl /clr /LD whereis.cpp winmm.a user32.a gdi32.a advapi32.a mpr.a vfw32.a

glump glump.elf: glump.o $(SPITOBJS)
	ppu-lv2-gcc  $(LINKOPTS) -oglump.elf glump.o $(SPITOBJS) libcodex.a $(STDLIBS)

rifft rifft.elf: rifft.o ansi.o stdgimex.o
	ppu-lv2-gcc  $(LINKOPTS) -orifft.elf rifft.o ansi.o stdgimex.o $(STDLIBS)
