# Makefile
# Copyright (C) 1999-2000 Ben Darnell
# This file is a part of ThoughtStream,
# which is distributed under the GNU GPL.

TARGET = thoughtstream
APPNAME = "ThoughtStream"
APPID = "ThSt"
VERSION=0.4.3

OBJS = thoughtstream.o mainform.o mindform.o wrappers.o idea.o \
	noteform.o linkform.o urlform.o searchform.o prefsform.o linkaware.o \
	lmform.o mindrefform.o fieldform.o browseform.o
LIBS =

CC = m68k-palmos-coff-gcc

#CFLAGS = -Wall -g -O2
CFLAGS = -Wall -g -DNO_LINKSIMPLE -O2

PILRC = pilrc
OBJRES = m68k-palmos-coff-obj-res
NM = m68k-palmos-coff-nm
BUILDPRC = build-prc
PILOTXFER = pilot-xfer

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) $(TARGET)

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

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

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

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

bin.res: $(TARGET).rcp $(TARGET).bmp
	$(PILRC) $(TARGET).rcp .
	echo -n ab > Link0001.bin
	touch bin.res

$(TARGET): $(OBJS)
	$(CC) -g $(OBJS) -o $(TARGET) $(LIBS)
	! $(NM) -u $(TARGET) | grep .

send: $(TARGET).prc
	$(PILOTXFER) -i $(TARGET).prc

depend:
	makedepend -Y -I. *.c

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

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

backup:
	tar czvf $(HOME)/backup/thoughtstream/palmos-$(shell date +%Y%m%d).tar.gz .

dist:
	zip thoughtstream-palmos-$(VERSION).zip thoughtstream.prc readme.txt COPYING
	zip thoughtstream-palmos-source-$(VERSION).zip ChangeLog Makefile *.c *.h *.rcp *.bmp
