# -*- mode: Makefile; -*-
# Makefile for XWConfig4
# Copyright 2000 by Eric House (fixin@peak.org).  All rights reserved.
#
# 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


TARGET = xwconfig.prc
NAME = "XWConfig4"
ROOTNAME = $(NAME)
TYPE = appl
APPID = "XWc4"

OBJS = xwconfig.o colorprf.o ../palmutil.o ../../common/palm/strutils.o
LIBS =

PALMINCL = /usr/local/pilot/m68k-palmos-coff/include/PalmOS35
INCLUDES += -I$(PALMINCL) \
	-I$(PALMINCL)/Core \
	-I$(PALMINCL)/Core/Hardware \
	-I$(PALMINCL)/Core/System \
	-I$(PALMINCL)/Core/System/Unix \
	-I$(PALMINCL)/Core/UI \
	-I$(PALMINCL)/Dynamic \
	-I$(PALMINCL)/Libraries \
	-I../../common \
	-I../

PALM_TOOLS_PREFIX = $(shell echo $$PALM_TOOLS_PREFIX)
PALM_TOOLS_PREFIX ?= m68k-palmos-

CC = $(PALM_TOOLS_PREFIX)gcc
MULTILINK = $(PALM_TOOLS_PREFIX)multilink
PAR = par

MULTILINK_OPTIONS = -basename $(ROOTNAME) -segmentsize 27k -stdlib -g \
	-deadstrip -verbose -gdb-script app.gdb

CFLAGS = -Wall -g -O2 -nostdinc $(INCLUDES)
PILRC = pilrc
PILOTXFER = pilot-xfer

all: $(TARGET)

.S.o:
	$(CC) $(TARGETFLAGS) -c $<

.c.s:
	$(CC) $(CSFLAGS) $<

$(TARGET): objs.prc res.prc 
	$(PAR) -c -a 'resource|backup' $@ $(NAME) $(TYPE) $(APPID) $^

objs.prc: $(OBJS)
	@rm -f *.grc *.bin
	$(MULTILINK) $(MULTILINK_OPTIONS) $(OBJS)
	$(PAR) -c -a resource $@ Code rsrc rsrc *.grc
	@rm -f *.grc *.bin

res.prc: xwconfig.rcp 
	$(PILRC) $< >/dev/null
	$(PAR) -c -a 'resource' $@ Rsrc rsrc rsrc *.bin
	rm -f $< *.bin

xwconfig.rcp: xwconfig.rcp.pre xwconfig.h
	gcc -x c -E -P $(MYDEFINES) $< > $@

bin.res: $(TARGET).rcp $(TARGET).pbm
	$(PILRC) $(TARGET).rcp .
	touch bin.res

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

depend:
	makedepend -Y -I. *.c

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

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

tags:
	etags *.c *.h
