# $Id: Makefile,v 1.6 2002/12/11 17:34:07 mankoff Exp $

#
# Makefile for Schizophrenic
#

# Add .bin to the list of suffixes that make recognizes
.SUFFIXES:  .bin

HACK        = schizophrenic
HACKNAME    = "Schizophrenic"
HACKID      = Schz  # make sure this matches what's in the source files
HACKSRC     = code03e8.c code07d0.c# 1000 and 2000 as per HackMaster API
HACKRES     = $(HACK).rcp resource.h
VERSION 	= 0.2.beta# keep up-to-date with the resource file
OTHER_SRC   = change_hotsync_name.c

CC      = m68k-palmos-gcc
OBJRES  = m68k-palmos-obj-res
CFLAGS  = -O2 -Wall
DIST = $(HACK)-$(VERSION)

all:    $(HACK).prc

HACKBIN = $(HACKSRC:.c=.bin)

# This rule builds a standalone code resource (.bin) from a C source file
.c.bin:
	$(CC) $(CFLAGS) -nostartfiles -o $(*F) $< $(OTHER_SRC)
	$(OBJRES) $(*F)
	chmod a-x $(*F)
	mv code0001.$(*F).grc $@

# Make the PRC file.
$(HACK).prc: hackresbin $(HACKBIN)
	build-prc --no-check -t HACK $@ $(HACKNAME) $(HACKID) *.bin
	echo ' '
	ls -Foph $@

# make the resources
hackresbin: 
	pilrc $(HACK).rcp
	touch $@

$(HACKBIN): $(HACK).h resource.h

clean:
	rm -f *.grc *.bin *.prc *.s hackresbin *.asm *.hexdump \
			$(HACK) change_hotsync_name *.zip *.tar.gz \
			$(HACK).html code03e8 code07d0 *~

# make a zip and gzipped tarball of the source
# not anymore: (HTML-ify the code for distribution) 
dist: all
	mkdir $(DIST)
	cp *.c *.h *.rcp *.prc *.TXT Makefile $(DIST)
	zip -rq $(DIST).zip $(DIST)
	tar -czf $(DIST).tar.gz $(DIST)
	rm -fR $(DIST)
#	enscript -C -G -o $(HACK).html -W html --color --pretty-print $(HACK).c
