#
# makefile for the c30 simulator library
#
# Author: Brian L. Evans
# Version: @(#)make.template	1.13	12/13/97

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

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

# Turn on the simulator flag
USERFLAGS = -DUTSIM3X

# Define QUANTIFY
QUANTIFY = quantify

# Put the libc30sim directory in the include path
INCL = -I$(ROOT)/src/libc30sim -I$(ROOT)/src/libc30asm

HDRS = dsk_cmds.h ut_cmds.h 

SRCS = c30sim.cc $(HDRS:.h=.cc)

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

LIBFILES = $(LIBDIR)/libc30sim.a $(LIBDIR)/libc30asm.a

C30_DEPEND = $(OBJS) $(LIBFILES)

# link against the c30 library
LIBS += -L$(LIBDIR) -lc30sim -lc30asm

# 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 c30sim

install:	c30sim $(BINDIR)/c30sim

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

c30sim:	$(C30_DEPEND)
	$(PURELINK) $(LINKER) $(LINKFLAGS) $(OBJS) $(LIBS) -o $@

c30sim.debug:	$(C30_DEPEND)
	$(PURELINK) $(LINKER) $(LINKFLAGS_D) $(OBJS) $(LIBS) -o $@

c30sim.debug.purify:	$(C30_DEPEND)
	$(PURIFY) $(LINKER) $(LINKFLAGS_D) $(OBJS) $(LIBS) -o $@

c30sim.debug.quantify:	$(C30_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.
