#
# makefile for the sim56800 command-line interface to an MC56800
# instruction set architecture simulator
#
# Author: Brian L. Evans
# Version: @(#)make.template	1.6	06/30/98

ROOT = ..
VPATH = $(ROOT)/src
BINDIR = $(ROOT)/bin.$(PTARCH)
LIBDIR = $(ROOT)/lib.$(PTARCH)

# get configuration info
CONFIG=$(ROOT)/mk/config-$(PTARCH).mk
include $(CONFIG)

# Turn on compilation flags
USERFLAGS = -DUNIX -DBIG_ENDIAN=1 -DFULLSIM=1 -DGUI=0

# Define QUANTIFY
QUANTIFY = quantify

# Add to the include path
C_INCL = -I$(ROOT)/mcoffinc

HDRS = \
gsig800.h \
hostio.h \
proto568.h \
protocom.h \
rgcom.h \
rgir.h \
rgsim.h \
simcom.h \
simdev.h \
simusr.h \
utsim.h \
vcx_utls.h \
vstruct.h

SRCS = \
sim56800.c \
dsp56800.c \
simglob.c \
scrmgr.c \
utsim.c

OBJS = $(SRCS:.c=.o)

LIBFILES = \
$(LIBDIR)/libwwsim.a \
$(LIBDIR)/libww56800.a \
$(LIBDIR)/libcm56800.a

SIM568_DEPEND = $(OBJS) $(LIBFILES)

# link against the c30 library
LIBS += -L$(LIBDIR) -lwwsim -lww56800 -lcm56800 -lm -lcurses -ltermcap

# force static compilation
ifeq ($(CC),gcc)
LINKFLAGS += -static
else
LINKFLAGS += $(CC_STATIC)
endif

# common.mk wants this, otherwise we get multiple targets for $(LIBDIR)/$(LIB)
LIB = foo

all:	makefile sim56800

install:	sim56800 $(BINDIR)/sim56800

$(BINDIR)/sim56800:	sim56800
	echo "Linking sim56800 into $(BINDIR)"
	rm -f $(BINDIR)/sim56800
	ln sim56800 $(BINDIR)

sim56800:	$(SIM568_DEPEND)
	$(PURELINK) $(LINKER) $(LINKFLAGS) $(OBJS) $(LIBS) -o $@

sim56800.debug:	$(SIM568_DEPEND)
	$(PURELINK) $(LINKER) $(LINKFLAGS_D) $(OBJS) $(LIBS) -o $@

sim56800.debug.purify:	$(SIM568_DEPEND)
	$(PURIFY) $(LINKER) $(LINKFLAGS_D) $(OBJS) $(LIBS) -o $@

sim56800.debug.quantify:	$(SIM568_DEPEND)
	$(QUANTIFY) $(LINKER) $(LINKFLAGS_D) $(OBJS) $(LIBS) -o $@

# include common definitions, rules
include $(ROOT)/mk/common.mk

# Don't add anything after the next line; makedepend will zap it.
# DO NOT DELETE THIS LINE -- make depend depends on it.

sim56800.o: sim56800.c utsim.h simcom.h ../mcoffinc/coreaddr.h \
 ../mcoffinc/maout.h ../mcoffinc/filehdr.h ../mcoffinc/aouthdr.h \
 ../mcoffinc/scnhdr.h ../mcoffinc/reloc.h ../mcoffinc/linenum.h \
 ../mcoffinc/syms.h ../mcoffinc/storclas.h simdev.h vstruct.h \
 vcx_utls.h simusr.h hostio.h rgsim.h rgir.h rgcom.h protocom.h \
 proto568.h
dsp56800.o: dsp56800.c simcom.h ../mcoffinc/coreaddr.h \
 ../mcoffinc/maout.h ../mcoffinc/filehdr.h ../mcoffinc/aouthdr.h \
 ../mcoffinc/scnhdr.h ../mcoffinc/reloc.h ../mcoffinc/linenum.h \
 ../mcoffinc/syms.h ../mcoffinc/storclas.h simdev.h vstruct.h \
 vcx_utls.h simusr.h hostio.h rgsim.h rgir.h rgcom.h gsig800.h
simglob.o: simglob.c simcom.h ../mcoffinc/coreaddr.h \
 ../mcoffinc/maout.h ../mcoffinc/filehdr.h ../mcoffinc/aouthdr.h \
 ../mcoffinc/scnhdr.h ../mcoffinc/reloc.h ../mcoffinc/linenum.h \
 ../mcoffinc/syms.h ../mcoffinc/storclas.h simusr.h hostio.h rgsim.h \
 rgir.h rgcom.h simdev.h vstruct.h vcx_utls.h
scrmgr.o: scrmgr.c utsim.h simcom.h ../mcoffinc/coreaddr.h \
 ../mcoffinc/maout.h ../mcoffinc/filehdr.h ../mcoffinc/aouthdr.h \
 ../mcoffinc/scnhdr.h ../mcoffinc/reloc.h ../mcoffinc/linenum.h \
 ../mcoffinc/syms.h ../mcoffinc/storclas.h simdev.h vstruct.h \
 vcx_utls.h simusr.h hostio.h rgsim.h rgir.h rgcom.h protocom.h
utsim.o: utsim.c utsim.h
