## Makefile for Top Gun SSH
## See the README file for copyright/licensing terms

TARGET = TGssh
APPNAME = "Top Gun SSH"
APPID = TGss

## Set this to the location of pilotSSLeay-1.1
SSLEAY = ../pilotSSLeay-1.1

OBJS = main.o 3des.o crc32.o idea.o packet.o ssh.o

CC = m68k-palmos-coff-gcc
LIBS = -LTGLoginLib -lTGLogin_s \
       -L$(SSLEAY)/shlib -lrsa_s -lbn_s -lrand_s -lmd_s -ldes_s -lidea_s

CFLAGS = -Wall -g -O5 -I$(SSLEAY)/include -ITGLoginLib

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

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

$(TARGET): $(OBJS) TGLoginLib/libTGLogin_s.a
	$(CC) $(CFLAGS) $(OBJS) -o $(TARGET) $(LIBS)

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

clean:
	-rm -f *.o $(TARGET) *.bin bin.res *.grc

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