## Makefile for Virtual MCSE

TARGET = vmcse
APPNAME = "Virtual MCSE"
APPID = "MSCE" # typo'd when registering the APPID :)
VERSION = "0.6"

OBJS = $(TARGET).o
LIBS =

CC = m68k-palmos-coff-gcc

CFLAGS = -Wall -g -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 *.bmp
	$(PILRC) $(TARGET).rcp .
	touch bin.res

$(TARGET): $(OBJS)
	$(CC) $(CFLAGS) $(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 MANIFEST *.zip *.tar.gz

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

dist: srcdist bindist

bindist: $(TARGET).zip

$(TARGET).zip: README $(TARGET).prc
	zip $@ $^

srcdist: $(TARGET)-$(VERSION).tar.gz

$(TARGET)-$(VERSION).tar.gz: clean
	@ls | sed s:^:$(TARGET)-$(VERSION)/: > MANIFEST
	@(cd ..; ln -s $(TARGET) $(TARGET)-$(VERSION))
	(cd ..; tar -zcvf $(TARGET)/$@ `cat $(TARGET)/MANIFEST` $(TARGET)-$(VERSION)/MANIFEST)
	@(cd ..; rm $(TARGET)-$(VERSION))
	

