## Makefile for PalmCounter
## $Id: Makefile,v 1.10 2000/10/07 16:11:16 bodo Exp $

ifndef DEBUG
# Set this to 1 if you want a
# debugging version
# If declared in the environment that values will be used!
DEBUG=1
#DEBUG=0
endif

# Set this to 1 if you want the
# memory leak detection
# ONLY ENABLE THIS IF YOU KNOW WHAT YOU'RE DOING
DEBUG_MEMORY_LEAK=0

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

# There shouldn't be anything to change below this line
################################################################

TARGET = pcount
VERSION = 0.1.6
APPNAME = "PalmCounter"
APPID = bbPC

ifeq ($(DEBUG_MEMORY_LEAK), 1)
DEBUG=1
endif

OBJS = $(TARGET).o

ifeq ($(DEBUG_MEMORY_LEAK), 1)
OBJS += pilotcrc.o
endif

LIBS =

CFLAGS = -Wall

ifeq ($(DEBUG), 1)
CFLAGS += -g
endif

CFLAGS += -O2 -DAPPID=\'$(APPID)\'

ifeq ($DEBUG_MEMORY_LEAK), 1)
CFLAGS += -DDEBUG_MEMORY_LEAK
endif

ifeq ($(DEBUG), 0)
CFLAGS +=  -DERROR_CHECK_LEVEL=ERROR_CHECK_NONE
endif

# Rules
################################################################

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).pbitm
	$(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

copy: $(TARGET).prc
	cp -f pcount.prc $(HOME)/pilot/rom30/

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

clobber: veryclean
	-rm -f *~ $(TARGET)-$(VERSION).tar.gz $(TARGET)-$(VERSION).zip

dist: $(TARGET).prc
	tar -czf $(TARGET)-$(VERSION).tar.gz COPYING Makefile README \
		callback.h pcount.c pcount.h pcount.pbitm \
		pcount.prc pcount.rcp pcountRsc.h pilotcrc.c
	zip $(TARGET)-$(VERSION).zip  COPYING Makefile README \
		callback.h pcount.c pcount.h pcount.pbitm \
		pcount.prc pcount.rcp pcountRsc.h pilotcrc.c
