## Makefile for CryptTest
## See the README file in the parent directory for instructions

## We include all of the crypto types for the shared lib version

SHDEFS = -DHAVE_RAND -DHAVE_SHA -DHAVE_DES -DHAVE_IDEA \
		    -DHAVE_RC4 -DHAVE_RC2 -DHAVE_BF
SHLIBS = -L../shlib -lrand_s -lmd_s -lsha_s -ldes_s -lidea_s \
		    -lrc4_s -lrc2_s -lbf_s

## There isn't room in 32K for all of the crypto to be linked statically,
##   so we need to get rid of SHA and Blowfish.
STDEFS = -DHAVE_RAND -DHAVE_DES -DHAVE_IDEA -DHAVE_RC4 -DHAVE_RC2
STLIBS = -L../lib -lrand -lmd -ldes -lidea -lrc4 -lrc2

## Uncomment one of the following two sections:
##
## For building against the shared libraries and stubs in ../shlib:
##
#  DEFS = $(SHDEFS)
#  LIBS = $(SHLIBS)
##
## For building against the static libraries in ../lib:
##
   DEFS = $(STDEFS)
   LIBS = $(STLIBS)
##

TARGET = CryptTest
APPNAME = "Crypt Test"
APPID = Cryt

OBJS = $(TARGET).o

CC = m68k-palmos-coff-gcc

CFLAGS = -Wall -g -O5 -I../include $(DEFS)

PILOTTTY = /dev/pilot

PILRC = pilrc
TXT2BITM = txt2bitm
OBJRES = m68k-palmos-coff-obj-res
BUILDPRC = build-prc


all: $(TARGET).prc

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

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

$(TARGET).prc: code0000.$(TARGET).grc code0001.$(TARGET).grc data0000.$(TARGET).grc pref0000.$(TARGET).grc rloc0000.$(TARGET).grc bin.res
	$(BUILDPRC) $(TARGET).prc $(APPNAME) $(APPID) code0001.$(TARGET).grc code0000.$(TARGET).grc data0000.$(TARGET).grc *.bin pref0000.$(TARGET).grc rloc0000.$(TARGET).grc

code0000.$(TARGET).grc: $(TARGET)
	$(OBJRES) -rloc $(TARGET)

code0001.$(TARGET).grc: code0000.$(TARGET).grc

data0000.$(TARGET).grc: code0000.$(TARGET).grc

rloc0000.$(TARGET).grc: code0000.$(TARGET).grc

pref0000.$(TARGET).grc: code0000.$(TARGET).grc

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

$(TARGET): $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) -o $(TARGET) $(LIBS)

send: $(TARGET).prc
	pilot-xfer $(PILOTTTY) -i $(TARGET).prc

clean:
	-rm -f *.[oa] $(TARGET) *.bin bin.res *.grc

veryclean: clean
	-rm -f $(TARGET).prc
