# Makefile --
#
#       Makefile for TopGun MediaBoard
#
# Copyright (c) 1998-2002 The Regents of the University of California.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# A. Redistributions of source code must retain the above copyright notice,
#    this list of conditions and the following disclaimer.
# B. Redistributions in binary form must reproduce the above copyright notice,
#    this list of conditions and the following disclaimer in the documentation
#    and/or other materials provided with the distribution.
# C. Neither the names of the copyright holders nor the names of its
#    contributors may be used to endorse or promote products derived from this
#    software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# $Header: /usr/mash/src/repository/mash/mash-1/tgmb/client/Makefile,v 1.6 2002/02/03 04:17:39 lim Exp $


TARGET = mediapad
APPNAME = "MediaPad"
APPID = TGmb


TGMB_OBJ = \
	tgmb-app.o \
	tgmb-event.o \
	tgmb-prefs.o \
	tgmb-canv.o \
	tgmb-conn.o \
	win-2bit.o \
	tgmb-more-app.o \
	tgmb-session.o \
	tg-app.o \
	tgmb-as1.o \
	tgmb-cmd.o \
	tgmb-page.o \
	tg-hash.o

#	tgmb-prefs.o \
#	tgmb-event.o \
#	tgmb-canv.o \
#	tgmb-cache.o \
#	tgmb-conn.o \
#	tgmb-session.o \
#	tgmb-pagelist.o \
#	tgmb-page.o

TG_OBJ =


ifeq ($(BOGUS),)
	OBJS = $(TG_OBJ) $(TGMB_OBJ)
	LIBS =
	CC = m68k-palmos-coff-gcc
	CXX = m68k-palmos-coff-gcc
else
	OBJS = bogus.o $(TGMB_OBJ) $(TG_OBJ)
	LIBS = -ldbmalloc -ltcl -lm
	CC = bogus_gcc
	CXX = bogus_gcc
endif


CFLAGS = -Wall -g -O2 -DNDEBUG
CXXFLAGS = -Wall -g -O2 -fshort-enums -fverbose-asm -DNDEBUG

PILOTTTY = /dev/pilot

PILRC = pilrc
PPMTOTBMP = ppmtoTbmp
OBJRES = m68k-palmos-coff-obj-res
BUILDPRC = build-prc


all: $(TARGET).prc

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

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

.cc.s:
	$(CXX) $(CXXFLAGS) -S $<

#.c.o:
#	$(CC) $(CFLAGS) $<

#.cc.o:
#	$(CXX) $(CXXFLAGS) $<

%.long.s: %.s
	sed -e 's/bsr.w __mulsi3/jsr __mulsi3/' <$< >$@

#tg-app.o: tg-app.long.s
#	$(CXX) $(CXXFLAGS) -c tg-app.long.s -o $@
#win-2bit.o: win-2bit.c
#	$(CXX) $(CXXFLAGS) -fpic -c win-2bit.c -o $@

resource.cc: tgmb-resource.h tgmb-app.rcp rcgen.pl
	perl rcgen.pl -i tgmb-app.rcp >$@

bogus.o: bogus.cc resource.cc
	$(CXX) BOGUS $(CXXFLAGS) -c -o $@ bogus.cc

bogus: mb_page.o bogus.o
	g++ $(CXXFLAGS) -o $@ $^

$(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

rloc0000.$(TARGET).grc: code0000.$(TARGET).grc

bin.res: tgmb-app.rcp tgmb-resource.h tgmb.pbm
	$(PILRC) tgmb-app.rcp .
	$(PPMTOTBMP) tgmb.pbm > tAIB03e8.bin
	$(PPMTOTBMP) tgmb.pbm > Tbmp0500.bin
	touch bin.res

$(TARGET): $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) -o $(TARGET) $(LIBS)
	! m68k-palmos-coff-nm -u $(TARGET) | grep .

send: $(TARGET).prc
	pilot-xfer $(PILOTTTY) -i $(TARGET).prc

clean:
	-rm -f *.[oas] $(TARGET) *.bin bin.res *.grc

veryclean: clean
	-rm -f $(TARGET).prc pilot1024.ram scratchpad

depend:
	makedepend -Y -- $(CXXFLAGS) -- $(OBJS:.o=.cc)

# DO NOT DELETE

