PRC = cipher.prc
OBJS = cipher.o armour.o crypt.o

CC = m68k-palmos-coff-gcc
STRIP = m68k-palmos-coff-strip
AR = m68k-palmos-coff-ar
RANLIB = m68k-palmos-coff-ranlib
PILRC = pilrc
TXT2BITM = txt2bitm
OBJRES = m68k-palmos-coff-obj-res
#BUILDPRC = /usr/local/palm/bin/build-prc
BUILDPRC = /usr/local/m68k-palmos-coff/bin/build-prc

CSFLAGS = -O -S
DEBUGFLAGS=
#DEBUGFLAGS=-g -DDEBUG
CFLAGS = -O1 -g $(DEBUGFLAGS) -Wall -fno-builtin
#LDFLAGS = -L$(PRCTOOLS)

ICONTEXT = "Cipher"
APPID = hk13

all: $(PRC)

remake: clean all

hardreset:
	rm $$HOME/.xcopilot/pilot.ram
	rm $$HOME/.xcopilot/pilot.scratch

.S.o:
	$(CC) $(TARGETFLAGS) -c $<

.c.s:
	$(CC) $(CSFLAGS) $<

$(PRC): code0000.cipher.bin code0001.cipher.bin data0000.cipher.bin bin.res
	$(BUILDPRC) $(PRC) $(ICONTEXT) $(APPID) code0001.cipher.grc code0000.cipher.grc data0000.cipher.grc *.bin pref000*.cipher.grc
	ls -l $(PRC)

code0000.cipher.bin: cipher
	$(OBJRES) cipher

code0001.cipher.bin: code0000.cipher.bin

data0000.cipher.bin: code0000.cipher.bin

bin.res: cipher.rcp cipher.pbitm
	$(PILRC) cipher.rcp .
	$(TXT2BITM) cipher.pbitm
	touch bin.res

cipher: $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) -o cipher
	@#$(STRIP) cipher

clean:
	rm -rf *.[oa] cipher *.bin bin.res *.[pg]rc

backup:
	gtar -cvzf cipher`date +%y%m%d`.gz *.c *.h Makefile *.rcp *.pbitm *.html *.rht

srcdist:
	rm -f cipherXX-src.zip
	zip cipherXX-src.zip *.c *.h Makefile *.pbitm *.rc? *.html pics/cipher.gif pics/null.gif

dist:
	zip cipherXX.zip $(PRC) cipher.html pics/cipher.gif pics/null.gif

cipher.html: cipher.rht
	m4 -P cipher.rht >cipher.html

transfer:
	pilot-xfer /dev/pilot -i $(PRC)
