# For use on HPLWBC to produce rom version

OBJ=	resume532.o debugger.o express.o debugutil.o disasm.o ioutil.o \
	init532.o dblib.o pf.o newreg.o vaddr.o download.o scsi_low.o scsi_hi.o
SRC0=	LOG debugger.c express.c disasm.c 
SRC1=	ioutil.c debugutil.c \
	init532.c pf.c newreg.c vaddr.c download.c scsi_low.c scsi_hi.c
SRC2=	resume532.s dblib.s \
	dasm.h das32k.h debugger.h machine.h \
	Makefile version

GCCDIR = /usr/local/bin
GCCLIB = /usr/local/lib/32k

CC = $(GCCDIR)/gcc
LD = $(GCCLIB)/ld
AS = $(GCCLIB)/as
INCL = -I. -I../../include -I..
CFLAGS = -O -c

# LSC		1 if compiling with Lightspeed C on the Mac
# GCC		1 if compiling with GCC (can use const)
# STANDALONE	1 if compiling ROM version
# UNIX		1 if compiling to run under UNIX

#
# Empty SCSI device table (really, one default entry)
#
DCL = -DLSC=0 -DGCC=1 -DSTANDALONE=1 -DUNIX=0
#
# SCSI Device table for OMTI floppy/winchester interface board
#
#DCL = -DLSC=0 -DGCC=1 -DSTANDALONE=1 -DUNIX=0 -DOMTI

.c.o:
	$(CC) $(CFLAGS) $(DCL) $(INCL) $*.c

.s.o:
	$(AS) $*.s

# ROM version, text loads at 0, data at 0xa000
rom_db: $(OBJ)
	sed -e "s/XXX/`date`/" version > version.c
	$(CC) $(CFLAGS) $(DCL) $(INCL) version.c
	$(LD) -o rom_db -T 10000000 -D 1000 $(OBJ) version.o

image.hex: rom_db
	dd if=rom_db of=image bs=1024 skip=1
	intelhex < image > image.hex

# RAM version, text at 0x200000, data following text
# For experimentation.  Requires changes to resume532.s so that it does
# not overwrite itself initializing RAM parity.  Use at own risk.
ram_db: $(OBJ)
	sed -e "s/XXX/`date`/" version > version.c
	$(CC) $(CFLAGS) $(DCL) $(INCL) version.c
	$(LD) -o ram_db -T 200000 $(OBJ) version.o

db_shar:
	shar $(SRC0) > Shar/db_shar0
	shar $(SRC1) > Shar/db_shar1
	shar $(SRC2) > Shar/db_shar2

tar:
	tar -cvf - $(SRC0) $(SRC1) $(SRC2) image | compress -b13 > db.tar.Z
