# ****************************************************************
# $Source: /home/CVS/Sieve/Makefile,v $
# $Author: hmueller $
# $Date: 1999/10/20 13:31:51 $
# $Revision: 1.1.1.1 $
# ****************************************************************
# OS      : Palm OS 1.0
# Compiler : prc-tools Version 0.5.0 (GCC 2.7, EGCS-2.91)
# Copyright: Holger Mueller <hmueller@bigfoot.com>
#            http://hmueller.purespace.de/pilot
# Notes    : Makefile for "Sieve"
# 
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the license, or (at your
# option) any later version.
#      
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
# Public License for more details.
#      
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 675 Mass Ave, Cambridge, MA 02139, USA.
#
# ****************************************************************

TARGET	= Sieve

SHELL	= /bin/sh

ifeq ($(OSTYPE), linux)
  GCC_PATH	= /usr/local/m68k-palmos-coff
  PERL_PATH	= /usr/bin
else
  GCC_PATH	= e:/cygpilot
  PERL_PATH	= e:/usr/local/perl/bin
endif
#GCC_EXEC_PREFIX = e:\\cygpilot\\lib\\gcc-lib\\

## programms
GCC	= $(GCC_PATH)/bin/m68k-palmos-coff-gcc
LNK	= $(GCC)
PILRC	= $(GCC_PATH)/bin/pilrc
TXT2BITM = $(GCC_PATH)/bin/txt2bitm
OBJRES	= $(GCC_PATH)/bin/m68k-palmos-coff-obj-res
#BUILDPRC = $(GCC_PATH)/bin/build-prc
BUILDPRC = $(PERL_PATH)/perl $(GCC_PATH)/tools/build-prc.perl
ECHO	= echo

## flags, flags and more ...
VERBOSE	= #-v
DEFINES = #-DDEBUG
INCLUDE	= 
CFLAGS	= -O2 $(VERBOSE) $(DEFINES) -Wall
LFLAGS	= $(VERBOSE)

APPICONTEXT = "Sieve"
APPID = Siev


## C-Files
CFILES	= main.c

OBJ = $(CFILES:.c=.o)


ifeq (.depend,$(wildcard .depend))
all: appres $(TARGET).prc

## include the generated dependencies
include .depend
else
all:
	@$(ECHO) No dependencies found. Please enter \\n\\tmake dep\\nfirst.
endif


### Application ###
$(TARGET).prc: code0001.$(TARGET).grc appres/tver0001.bin
	$(BUILDPRC) $(TARGET).prc $(APPICONTEXT) appl $(APPID) code0001.$(TARGET).grc code0000.$(TARGET).grc data0000.$(TARGET).grc appres/*.bin pref0000.$(TARGET).grc

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

appres/tver0001.bin $(TARGET).h: $(TARGET).rcp
	$(PILRC) -H $(TARGET).h $(TARGET).rcp appres

$(TARGET): $(TARGET).h $(OBJ)
	$(LNK) -o $(TARGET) $(OBJ) $(LFLAGS)

%.o: %.c
	$(GCC) -c $(CFLAGS) $(INCLUDE) $<


## create directories
appres:
	if [ ! -d appres ]; then mkdir appres; fi


## make all dependencies using gcc ;-)
depend dep:
	touch 01010000 $(TARGET).h
	$(GCC) -M $(INCLUDE) $(CFILES) > .depend

## remove all generated files
distclean clobber: clean
	-rm -f $(TARGET).prc .depend $(TARGET).h

## remove all temporary files
clean:
	-rm -rf *.[oa] *.bin *.grc *.trap 
	-rm -rf $(TARGET) $(TARGET).res appres/*.bin

## EOF
