/*   Copyright 1991
 *   Eric A. Brewer  and  Chris N. Dellarocas
 *   Massachusetts Institute of Technology
 *
 *   Permission to use, copy, modify, and distribute this program 
 *   for any purpose and without fee is hereby granted, provided  
 *   that this copyright and permission notice appear on all copies
 *   and supporting documentation, the name of M.I.T. not be used
 *   in advertising or publicity pertaining to distribution of the
 *   program without specific prior permission, and notice be given
 *   in supporting documentation that copying and distribution is
 *   by permission of M.I.T.  M.I.T. makes no representations about
 *   the suitability of this software for any purpose.  It is pro-
 *   vided "as is" without express or implied warranty.

 *   Ultrix 4.2 Version
 *
 *   Last modified: $Date ($Author)
 *
 * $Header: /a/quimby.dartmouth.edu/usr/wildcat/dfk/research/parallel/proteus/proteus-V3.01/engine/RCS/SimMake,v 1.3 93/02/26 00:50:17 dfk Exp $
 * $Log:	SimMake,v $
# Revision 1.3  93/02/26  00:50:17  dfk
# my changes for scheduler
# 
# Revision 1.2  93/02/25  23:54:48  dfk
# updated LIBDIRS as per directions
# 
 * Revision 1.19  92/12/17  13:01:24  brewer
 * reset now removes initshared files
 * made cmp command for initshared rule invisible
 * 
 * Revision 1.18  92/12/09  14:13:48  brewer
 * Added cmp -s line to rule for initshared.  This prevents OSmem_internal.o
 * from being recompiled unnecessarily. (Suggested by David Kotz)
 * 
 * Revision 1.17  92/11/25  17:46:27  brewer
 * updated makedepend
 * 
 * Revision 1.16  92/10/08  13:37:29  brewer
 * Added entry for initshared
 * 
 * Revision 1.15  92/09/25  12:25:58  brewer
 * Added CLEANUP macro
 * Added USERLIBS to link command
 * 
 * Revision 1.14  92/09/24  11:53:10  brewer
 * placed rules after "include USERMAKE" to allows cpp definitions to
 * affect the rules.  Added support for makedepend.
 * 
 * Revision 1.13  92/09/23  11:06:07  brewer
 * Added "default: ..." line to set up default target executable
 * 
 * Revision 1.12  92/09/23  10:59:19  brewer
 * Added rule for .S.o
 * Added use of USERMAKE constant
 * 
 * Revision 1.11  92/09/22  13:44:51  brewer
 * Improved reset rule.
 * Added $(SIMULATOR) make macro to allow alternate name for proteus
 * 
 * Revision 1.10  92/04/28  13:59:01  brewer
 * Removed bogus parenthesis from simcalls.c rule.
 * 
 * Revision 1.9  92/04/28  11:31:01  brewer
 * Changed rule for simcalls.c to eliminate generation of file useripi.
 * Also removed dependency on $(userobj).
 * 
 * Revision 1.8  92/04/14  15:09:33  brewer
 * Simplified rule for .s.o -- removed tmp file
 * 
 * Revision 1.7  92/04/08  12:43:24  brewer
 * Removed "tcsh -f -c" strings that were a workaround for an Ultrix bug;
 * we have new workaround used in makesim that avoids pipes by using
 * a temporary file.
 * 
 * Revision 1.6  92/04/02  13:22:20  brewer
 * removed scheduler dependence on rt_rts.hh
 * 
 * Revision 1.5  92/04/01  17:08:27  brewer
 * changed to use standard gcc (v2.0)
 * 
 * Revision 1.4  92/03/10  11:55:18  brewer
 * Changed commented regions to use C-style comments instead of make-style
 * 
 * Revision 1.3  92/02/21  17:59:30  sharon
 * *** empty log message ***
 * 
 * Revision 1.2  92/02/12  15:00:11  brewer
 * added -g flag to CFLAGS
 * 
 * Revision 1.1  92/02/11  16:07:25  brewer
 * Initial revision
 * 
 */

/* undef identifiers that might be directory names */
#undef mips
#undef sparc

.SUFFIXES:
.SUFFIXES: .o .ca .c .l .y .S .s

/* default user libraries */
USERLIBS =

USERH  =  user.h prototypes.h conf.param rt_thread_def.h OS.param \
	cache.h cache.param shmem.h sema.h mem.param thread.h simreq.h

AFLAGS = # -p   # -p adds profiling info to each procedure
CFLAGS = -g
CPPFLAGS = 
LIBFLAGS =
LIBDIRS = -L/u/dfk/research/parallel/proteus/current/lib
SIMULATOR = proteus
/*
 * -DSEMDEBUG -DDEBUG -DRESUMEDEBUG 
 * -DTHREADDEBUG -DREQDEBUG -DMEMDEBUG -DSPAWNDEBUG -DSEMDEBUG
 * -DCTXSWDEBUG -DRESUMEDEBUG -DNETDEBUG -DFNPTRDEBUG -DINTRDEBUG
 */

/* source list for saber C, not including rt_*_sched.c  */
source = debug.c fatal.c mem.c req_queue.c resume.c simcalls.c simreq.c \
	thread.c main.c ctxsw.S event.c SimQuantum.S \
	shmem.c cache.c sema.c profile.c Profile.S \
	rt_thread.ca OStraps.c rt_thread.aux.c q.c processor.c ipi.c OSmem.ca \
	OSmem_internal.c packet.c rt_random.S \
	intr_queue.c snapshot.c net.c ihandler.c timer.c rt_sched.ca \
	perfspec.c

obj = debug.o fatal.o mem.o req_queue.o resume.o simcalls.o simreq.o \
	thread.o  main.o ctxsw.o event.o SimQuantum.o \
	shmem.o cache.o sema.o profile.o Profile.o \
	rt_thread.o OStraps.o rt_thread.aux.o q.o processor.o ipi.o OSmem.o \
	OSmem_internal.o params.o packet.o rt_random.o \
	intr_queue.o snapshot.o net.o ihandler.o timer.o rt_sched.o \
	perfspec.o

first-target: default

#ifndef USERMAKE
#define USERMAKE "UserMake"
#endif

#include USERMAKE

#ifdef CLEAN
#define CLEANUP @/bin/rm -f $*.[is] aug-$*.s
#else
#define CLEANUP
#endif

/**************************************************************************\
*  Rules
\**************************************************************************/

#ifdef GCC

CC = gcc
CPP = $(CC) -x c -E
CC_NOCPP = $(CC)

.S.o:
	$(CC) $(CFLAGS) -c $*.S

#else /* compile with cc */

CC = cc
CPP = $(CC) -E
CC_NOCPP = $(CC) -nocpp

.S.o:
	cp $*.S $*.s
	$(CC) $(CFLAGS) -c $*.s
	@ /bin/rm -f $*.s

#endif /* ifdef GCC */

.c.o:
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $*.c

.s.o:
	$(CC) $(CFLAGS) -c $*.s

/* catoc does not support "unsigned long long", so we can't use it.
 * (64-bit timestamps use unsigned long long).  This means we lose
 * support for shared-memory language extensions. 
 * See also initshared below.
 */
.ca.o:
/*	$(CPP) $(CPPFLAGS) -D_CA_ $*.ca | catoc -i $*.ca -o $*.i
 *	$(CC_NOCPP) $(CAFLAGS) -S $*.i
 */
	$(CC) -x c $(CAFLAGS) -D_CA_ -S $*.ca
	augment $(AFLAGS) $*.s -o aug-$*.s
	$(CC_NOCPP) $(CAFLAGS) -c aug-$*.s -o $*.o
	CLEANUP

/**************************************************************************\
*  build simulator
\**************************************************************************/

default: $(SIMULATOR)

$(SIMULATOR): $(userobj) $(obj) 
	$(CC) $(CFLAGS) $(CPPFLAGS) -o $(SIMULATOR) \
	$(LIBDIRS) $(obj) $(userobj) $(LIBFLAGS) $(USERLIBS) -lcyc -lcycm -lm

clean:
	/bin/rm -f aug-*.s *.i

reset: clean
	/bin/rm -f *.o $(SIMULATOR) useripi.c *.is initshared initshared.new

depend:
	makedepend -f SimMake $(source)
	
/* save config parameters in params.o */
params.o : *.param
	saveparams *.param
	cc -c params.s

/* always compile req_queue with -O, it is speed critical */
req_queue.o: req_queue.c  /* always compile with -O */
	$(CC) -O -c req_queue.c

/* Regenerate initshared when users object files change.
 * We're careful not to touch initshared unless there are changes.
 * cmp -s ...  line due to David Kotz.
 * NOTE: we don't support shared-memory extensions any more (see catoc
 * above).  Thus, catis is not necessary.
 */
initshared: $(userobj) mk_initshared
/*	catis $(userobj) | sort -u | awk -f mk_initshared > initshared.new */
	awk -f mk_initshared < /dev/null > initshared.new
	-cmp -s initshared initshared.new || mv initshared.new initshared

/**************************************************************************\
*  Dependencies
\**************************************************************************/

/* conservative dependencies -- used for only some parameter settings */
net.o: net.exact.c net.model.c alewife.exact_net.c alewife.model_net.c
shmem.o: shmem.cache.c shmem.nocache.c
cache.o: cache.bus.c cache.net.c

/*
# DO NOT DELETE THIS LINE -- make depend depends on it. */

debug.o: /usr/include/signal.h /usr/include/ansi_compat.h /usr/include/syms.h
debug.o: /usr/include/mips/cpu.h /usr/include/malloc.h sim.h
debug.o: /usr/include/stdio.h common.h /usr/include/assert.h prototypes.h
debug.o: conf.param rt_thread_def.h OS.param monitorswitch.h simreq.h
debug.o: processor.h thread.h
fatal.o: /usr/include/stdio.h /usr/include/ansi_compat.h sim.h common.h
fatal.o: /usr/include/assert.h prototypes.h conf.h conf.param event.h
fatal.o: events.h thread.h rt_thread_def.h OS.param monitorswitch.h
fatal.o: /usr/include/varargs.h
mem.o: sim.h /usr/include/stdio.h /usr/include/ansi_compat.h common.h
mem.o: /usr/include/assert.h prototypes.h sim.param mem.h
req_queue.o: /usr/include/stdio.h /usr/include/ansi_compat.h sim.h common.h
req_queue.o: /usr/include/assert.h prototypes.h conf.param rt_thread_def.h
req_queue.o: OS.param monitorswitch.h thread.h simcalls.h sim.param simreq.h
req_queue.o: cache.param
resume.o: sim.h /usr/include/stdio.h /usr/include/ansi_compat.h common.h
resume.o: /usr/include/assert.h prototypes.h conf.h conf.param event.h
resume.o: events.h rt_thread_def.h OS.param monitorswitch.h simreq.h
resume.o: processor.h simcalls.h sim.param thread.h intreq.h net.param
simcalls.o: sim.h /usr/include/stdio.h /usr/include/ansi_compat.h common.h
simcalls.o: /usr/include/assert.h prototypes.h conf.h conf.param event.h
simcalls.o: events.h simcalls.h sim.param simreq.h cache.param
simreq.o: sim.h /usr/include/stdio.h /usr/include/ansi_compat.h common.h
simreq.o: /usr/include/assert.h prototypes.h conf.h conf.param event.h
simreq.o: events.h rt_thread_def.h OS.param monitorswitch.h simcalls.h
simreq.o: sim.param simreq.h processor.h thread.h
thread.o: user.h sim.h /usr/include/stdio.h /usr/include/ansi_compat.h
thread.o: common.h /usr/include/assert.h prototypes.h conf.param
thread.o: rt_thread_def.h OS.param monitorswitch.h cache.h cache.param
thread.o: shmem.h mem.param sema.h thread.h simreq.h processor.h intreq.h
thread.o: net.param mem.h q.h event.h events.h
main.o: /usr/include/stdlib.h /usr/include/ansi_compat.h
main.o: /usr/include/signal.h /usr/include/string.h /usr/include/math.h
main.o: time.h dfk.h proteus.h user.h sim.h /usr/include/stdio.h common.h
main.o: /usr/include/assert.h prototypes.h conf.param rt_thread_def.h
main.o: OS.param monitorswitch.h cache.h cache.param shmem.h mem.param sema.h
main.o: thread.h conf.h event.h events.h simreq.h processor.h simcalls.h
main.o: sim.param intreq.h net.param packet.h net.h
event.o: /usr/include/stdio.h /usr/include/ansi_compat.h
event.o: /usr/include/sys/types.h /usr/include/unistd.h /usr/include/errno.h
event.o: /usr/include/string.h /usr/include/malloc.h common.h event.h
event.o: events.h
shmem.o: sim.h /usr/include/stdio.h /usr/include/ansi_compat.h common.h
shmem.o: /usr/include/assert.h prototypes.h conf.h conf.param event.h
shmem.o: events.h rt_thread_def.h OS.param monitorswitch.h cache.h
shmem.o: cache.param shmem.h mem.param shmem.nocache.c net.h net.param sema.h
shmem.o: simcalls.h sim.param simreq.h processor.h thread.h packet.h
shmem.o: shmem.common.c shmem.calls.c
cache.o: conf.param sim.h /usr/include/stdio.h /usr/include/ansi_compat.h
cache.o: common.h /usr/include/assert.h prototypes.h event.h events.h cache.h
cache.o: cache.param
sema.o: user.h sim.h /usr/include/stdio.h /usr/include/ansi_compat.h common.h
sema.o: /usr/include/assert.h prototypes.h conf.param rt_thread_def.h
sema.o: OS.param monitorswitch.h cache.h cache.param shmem.h mem.param sema.h
sema.o: thread.h simcalls.h sim.param simreq.h processor.h q.h event.h
sema.o: events.h sema.ttset.c
profile.o: /usr/include/stdio.h /usr/include/ansi_compat.h
profile.o: /usr/include/stdlib.h /usr/include/ctype.h /usr/include/string.h
profile.o: /usr/include/malloc.h /usr/include/filehdr.h /usr/include/syms.h
profile.o: /usr/include/ldfcn.h sim.h common.h /usr/include/assert.h
profile.o: prototypes.h conf.param rt_thread_def.h OS.param monitorswitch.h
profile.o: event.h events.h thread.h profile.h
rt_thread.o: user.h sim.h /usr/include/stdio.h /usr/include/ansi_compat.h
rt_thread.o: common.h /usr/include/assert.h prototypes.h conf.param
rt_thread.o: rt_thread_def.h OS.param monitorswitch.h cache.h cache.param
rt_thread.o: shmem.h mem.param sema.h thread.h simreq.h processor.h
rt_thread.o: simcalls.h sim.param event.h events.h net.h net.param mem.h q.h
rt_thread.o: intreq.h rt_rqtime.h
OStraps.o: mem.param sim.h /usr/include/stdio.h /usr/include/ansi_compat.h
OStraps.o: common.h /usr/include/assert.h prototypes.h conf.h conf.param
OStraps.o: event.h events.h rt_thread_def.h OS.param monitorswitch.h simreq.h
OStraps.o: processor.h thread.h cache.h cache.param shmem.h
rt_thread.aux.o: user.h sim.h /usr/include/stdio.h /usr/include/ansi_compat.h
rt_thread.aux.o: common.h /usr/include/assert.h prototypes.h conf.param
rt_thread.aux.o: rt_thread_def.h OS.param monitorswitch.h cache.h cache.param
rt_thread.aux.o: shmem.h mem.param sema.h thread.h conf.h event.h events.h
rt_thread.aux.o: simreq.h processor.h simcalls.h sim.param mem.h perfspec.h
q.o: sim.h /usr/include/stdio.h /usr/include/ansi_compat.h common.h
q.o: /usr/include/assert.h prototypes.h conf.h conf.param event.h events.h
q.o: rt_thread_def.h OS.param monitorswitch.h cache.h cache.param shmem.h
q.o: mem.param sema.h q.h
processor.o: sim.h /usr/include/stdio.h /usr/include/ansi_compat.h common.h
processor.o: /usr/include/assert.h prototypes.h conf.h conf.param event.h
processor.o: events.h rt_thread_def.h OS.param monitorswitch.h simreq.h
processor.o: processor.h thread.h simcalls.h sim.param q.h shmem.h mem.param
processor.o: cache.h cache.param
ipi.o: /usr/include/stdio.h /usr/include/ansi_compat.h /usr/include/string.h
ipi.o: /usr/include/signal.h sim.h common.h /usr/include/assert.h
ipi.o: prototypes.h conf.h conf.param event.h events.h rt_thread_def.h
ipi.o: OS.param monitorswitch.h simreq.h processor.h simcalls.h sim.param
ipi.o: cache.h cache.param shmem.h mem.param sema.h thread.h intreq.h
ipi.o: net.param net.h packet.h ipi.param
OSmem.o: OSmem.h user.h sim.h /usr/include/stdio.h /usr/include/ansi_compat.h
OSmem.o: common.h /usr/include/assert.h prototypes.h conf.param
OSmem.o: rt_thread_def.h OS.param monitorswitch.h cache.h cache.param shmem.h
OSmem.o: mem.param sema.h thread.h event.h events.h /usr/include/sys/types.h
OSmem.o: OSmem.common.h /usr/include/malloc.h /usr/include/stdlib.h
OSmem_internal.o: OSmem.h user.h sim.h /usr/include/stdio.h
OSmem_internal.o: /usr/include/ansi_compat.h common.h /usr/include/assert.h
OSmem_internal.o: prototypes.h conf.param rt_thread_def.h OS.param
OSmem_internal.o: monitorswitch.h cache.h cache.param shmem.h mem.param
OSmem_internal.o: sema.h thread.h event.h events.h /usr/include/sys/types.h
OSmem_internal.o: OSmem.common.h /usr/include/malloc.h /usr/include/stdlib.h
OSmem_internal.o: initshared
packet.o: sim.h /usr/include/stdio.h /usr/include/ansi_compat.h common.h
packet.o: /usr/include/assert.h prototypes.h simcalls.h sim.param simreq.h
packet.o: conf.param cache.h cache.param net.h net.param packet.h
packet.o: /usr/include/varargs.h
intr_queue.o: net.param /usr/include/stdio.h /usr/include/ansi_compat.h sim.h
intr_queue.o: common.h /usr/include/assert.h prototypes.h conf.h conf.param
intr_queue.o: event.h events.h rt_thread_def.h OS.param monitorswitch.h
intr_queue.o: intreq.h thread.h
snapshot.o: /usr/include/stdlib.h /usr/include/ansi_compat.h
snapshot.o: /usr/include/signal.h /usr/include/string.h /usr/include/math.h
snapshot.o: /usr/include/ctype.h user.h sim.h /usr/include/stdio.h common.h
snapshot.o: /usr/include/assert.h prototypes.h conf.param rt_thread_def.h
snapshot.o: OS.param monitorswitch.h cache.h cache.param shmem.h mem.param
snapshot.o: sema.h thread.h processor.h intreq.h net.param simcalls.h
snapshot.o: sim.param simreq.h q.h packet.h net.h event.h events.h
net.o: sim.h /usr/include/stdio.h /usr/include/ansi_compat.h common.h
net.o: /usr/include/assert.h prototypes.h conf.h conf.param event.h events.h
net.o: rt_thread_def.h OS.param monitorswitch.h net.h net.param net.model.c
net.o: simcalls.h sim.param simreq.h thread.h processor.h cache.h cache.param
net.o: shmem.h mem.param sema.h packet.h /usr/include/malloc.h
ihandler.o: sim.h /usr/include/stdio.h /usr/include/ansi_compat.h common.h
ihandler.o: /usr/include/assert.h prototypes.h conf.h conf.param event.h
ihandler.o: events.h simreq.h rt_thread_def.h OS.param monitorswitch.h
ihandler.o: processor.h thread.h mem.param sema.h shmem.h cache.h cache.param
ihandler.o: intreq.h net.param simcalls.h sim.param ipi.param
timer.o: sim.h /usr/include/stdio.h /usr/include/ansi_compat.h common.h
timer.o: /usr/include/assert.h prototypes.h conf.h conf.param event.h
timer.o: events.h rt_thread_def.h OS.param monitorswitch.h simreq.h
timer.o: processor.h thread.h simcalls.h sim.param
rt_sched.o: OS.param rt_FCFS_sched.ca user.h sim.h /usr/include/stdio.h
rt_sched.o: /usr/include/ansi_compat.h common.h /usr/include/assert.h
rt_sched.o: prototypes.h conf.param rt_thread_def.h monitorswitch.h cache.h
rt_sched.o: cache.param shmem.h mem.param sema.h thread.h
perfspec.o: sim.h /usr/include/stdio.h /usr/include/ansi_compat.h common.h
perfspec.o: /usr/include/assert.h prototypes.h user.h conf.param
perfspec.o: rt_thread_def.h OS.param monitorswitch.h cache.h cache.param
perfspec.o: shmem.h mem.param sema.h thread.h specevents.h rqtime.h
