LIBS		=	test_sup.o -lGc -lthreads -lmach -lgen -lm

OBJDSC_OFILES =	ObjPtrIttr.o ObjDesc.o ObjHead.o
GCLIB_OFILES =	GcHeap.o GcHeapRep1.o GcHeapRep2.o GcHeapRep3.o GcHeapRep4.o \
		gc_glob.o glob_list_tmp.o \
		GcHeap_debug.o AllocPoint.o \
		GcHeap_ipc.o NullMsgServer.o NullMsgUser.o \
		OnePortMsgServer.o OnePortMsgUser.o excServer.o \
		Monitor.o
GEN_OFILES =	Time.o misc_math.o debug.o primes.o

VPATH =	/afs/cs/user/dld/gc/concurrent:/afs/cs/user/dld/gc/obj_desc
INCLDIRS = -I/afs/cs/user/dld/gc/concurrent -I/afs/cs/user/dld/gc/obj_desc
CFRONTSRC =	/usr/dld/GC/c++/cfront
DEBUG_CCFLAGS 	= 	-I. $(INCLDIRS) -DPERF_MEAS=2 -g
PROD_CCFLAGS 	= 	-DNO_INSERT_DEBUG_CODE -DNDEBUG -DPRODUCTION \
			-I. $(INCLDIRS) -DPERF_MEAS=2
PROD3_CCFLAGS 	= 	-DNO_INSERT_DEBUG_CODE -DNDEBUG -DPRODUCTION \
			-I. $(INCLDIRS) -DPERF_MEAS=3
PROF_CCFLAGS	=	$(PROD_CCFLAGS) -p

CC	=	CC $(PROD_CCFLAGS)


all:		libGc.a gc_glob.x.h kill_mut_task \
		obj_desc_support obj_desc_tests gc_tests

obj_desc_tests:	test_ObjPtrIttr test_ObjHead

obj_desc_support:	interpret

gc_tests:	test1 test2 test3 test4 test5 test6 test7 test7new

#this is the default -- makes for debugging.
att:
	$(MAKE) CC="/usr/dld/bin/CC $(DEBUG_CCFLAGS) -g" \
		CCFLAGS="$(DEBUG_CCFLAGS)" atttarg
	

attprod:
	$(MAKE) CC="/usr/dld/bin/CC $(PROD_CCFLAGS) -O" \
		CCFLAGS="$(PROD_CCFLAGS)" atttarg

attprod3:
	$(MAKE) CC="/usr/dld/bin/CC $(PROD3_CCFLAGS) -O" \
		CCFLAGS="$(PROD3_CCFLAGS)" atttarg

attprof:
	$(MAKE) CC="/usr/dld/bin/CC $(PROF_CCFLAGS) -O" \
		CCFLAGS="$(PROF_CCFLAGS)" atttarg

atttarg:	attobj gc_glob.x.h kill_mut_task

attobj: $(GCLIB_OFILES) $(OBJDSC_OFILES) $(GEN_OFILES) 
	/bin/rm -f libGc.a
	ar q libGc.a $(GCLIB_OFILES) $(OBJDSC_OFILES) $(GEN_OFILES)
	ranlib libGc.a

libGc.att.a:
	$(MAKE) CC="/usr/misc/bin/CC $(CCFLAGS)" libGc.a

libGc.a:	$(GCLIB_OFILES) $(OBJDSC_OFILES)
	/bin/rm -f libGc.a
	ar q libGc.a $(GCLIB_OFILES) $(OBJDSC_OFILES)
	ranlib libGc.a


# Source file dependencies.

# ObjDesc Files.
ObjHead.c:	ObjHead.h

ObjHead.h:	ObjHead_inlines.h

ObjPtrIttr.c:	ObjPtrIttr.h

ObjPtrIttr.h:	ObjHead.h ObjDesc.h ObjPtrIttr_inlines.h

ObjDesc.c:	ObjDesc.h ObjPtrIttr.h

ObjDesc.h:	ObjDesc_inlines.h


# Concurrent GcHeap files.
GcHeap.c:	GcHeap.h GcHeapRep.h

GcHeapRep.h:	gc_misc.h ObjHead.h ObjPtrIttr.h AllocPoint.h

GcHeapRep1.c:	GcHeap_debug.h GcHeapRep.h GcHeap_ipc.h mutex_macros.h

GcHeapRep2.c:	GcHeap_debug.h GcHeapRep.h Monitor.h mutex_macros.h

GcHeapRep3.c:	GcHeap_debug.h GcHeapRep.h GcHeap_ipc.h exc.h mutex_macros.h

GcHeapRep4.c:	GcHeap_debug.h GcHeapRep.h GcHeap_ipc.h GcHeapRep_inlines.h \
		Monitor.h mutex_macros.h

AllocPoint.c:	AllocPoint.c AllocPoint.h AllocPoint_inlines.h GcHeapRep.h


GcHeap_debug.c:	GcHeap_debug.h GcHeapRep.h GcHeap_debug_inlines.h \
		mutex_macros.h

GcHeap_ipc.c:	GcHeap_ipc.h

GcHeap_ipc.h:	NullMsg.h OnePortMsg.h

Monitor.c:	Monitor.h

bug:		bug.o
	CC -o bug bug.o -lGc -lthreads -lmach

# The below fixes a C++ bug.  (Use AT&T cfront here always...)
gc_glob.o:	gc_glob.c gc_glob.h
	/usr/misc/bin/CC $(INCLDIRS) -c +i gc_glob.c
	sed -e "s/^struct GcHeap __gch ;/struct GcHeap __gch = 0;/" \
		gc_glob..c > gc_glob.2.c
	cc -c -g gc_glob.2.c
	/bin/mv -f gc_glob.2.o gc_glob.o
	/bin/rm -f gc_glob.2.c gc_glob..c


gc_glob.h:	GcHeap.h ObjHead.h

gc_glob.x.h:	gc_glob.h GcHeap.h ObjHead.h
	/bin/rm -f gc_glob_temp.c
	/bin/cp gc_glob.h gc_glob_temp.c
	/usr/misc/bin/CC -E $(CCFLAGS) -DABRIDGED \
		gc_glob_temp.c > gc_glob.x.h
	/bin/rm -f gc_glob_temp.c

#	/usr/misc/bin/CC -UPRODUCTION -DABRIDGED -DPERF_MEAS=2 $(INCLDIRS) \
#		-E gc_glob_temp.c > gc_glob.x.h
#	/bin/rm -f gc_glob_temp.c


# This is all Mig stuff.
NullMsg.h:	null_msg.defs
	mig null_msg.defs

NullMsgServer.c:	null_msg.defs
	mig null_msg.defs

NullMsgUser.c:		null_msg.defs
	mig null_msg.defs

OnePortMsg.h:	one_port_msg.defs
	mig one_port_msg.defs

OnePortMsgServer.c:	one_port_msg.defs
	mig one_port_msg.defs

OnePortMsgUser.c:	one_port_msg.defs
	mig one_port_msg.defs

excServer.c:	exc.defs
	mig exc.defs
	sed -e 's/\#define	TypeCheck 1/\#define	TypeCheck 0/' \
		excServer.c > excServer.c.tmp
	/bin/mv -f excServer.c.tmp excServer.c

# We need a AT&T 1.2 versions of genlib's Time.o, misc_math.o, and debug.o
Time.o:		genlib-src/Time.c
	$(CC) -I. -c genlib-src/Time.c

misc_math.o:	genlib-src/misc_math.c
	$(CC) -I. -c genlib-src/misc_math.c

debug.o:	genlib-src/debug.c
	$(CC) -I.  -c genlib-src/debug.c

primes.o:	genlib-src/primes.c
	$(CC) -I.  -c genlib-src/primes.c
		


#test programs.

test_sup.c:	test_sup.h

interpret:	interpret.o print_od_str.o
	$(CC) -o interpret interpret.o print_od_str.o \
		 ObjPtrIttr.o ObjHead.o ObjDesc.o

interpret.c:	ObjDesc.h

test_ObjPtrIttr:	test_ObjPtrIttr.o ObjPtrIttr.o ObjHead.o ObjDesc.o \
			print_od_str.o
	$(CC) -o test_ObjPtrIttr test_ObjPtrIttr.o \
		ObjPtrIttr.o ObjHead.o ObjDesc.o print_od_str.o \
		Time.o misc_math.o

test_ObjPtrIttr.c:	ObjPtrIttr.h ObjDesc.h

print_od_str.c:		ObjDesc.h


test_ObjHead:	test_ObjHead.o ObjHead.o
	$(CC) -o test_ObjHead test_ObjHead.o ObjHead.o

test1:		test1.o test_sup.o the_lib
	$(CC) -o test1 test1.o $(LIBS)
test1.c:	test_sup.h

test2:		test2.o test_sup.o the_lib
	$(CC) -o test2 test2.o $(LIBS)
test2.c:	test_sup.h

test3:		test3.o test_sup.o the_lib
	$(CC) -o test3 test3.o $(LIBS)
test3.c:	test_sup.h

test4:		test4.o test_sup.o the_lib
	$(CC) -o test4 test4.o $(LIBS)
test4.c:	test_sup.h

test5:		test5.o test_sup.o the_lib
	$(CC) -o test5 test5.o $(LIBS)
test5.c:	test_sup.h

test6:		test6.o test_sup.o the_lib
	$(CC) -o test6 test6.o $(LIBS)
test6.c:	test_sup.h

test7:		test7.o test_sup.o the_lib
	$(CC) -o test7 test7.o $(LIBS)
test7.c:	test_sup.h ObjDesc.h

test7new:	test7new.o test_sup.o the_lib
	$(CC) -o test7new test7new.o $(LIBS)
test7new.c:	test_sup.h ObjDesc.h

test20:		test20.o  the_lib
	$(CC) -o test20 test20.o $(LIBS)
test20.c:	ObjPtrIttr.h

kill_mut_task:	kill_mut_task.c
	/usr/misc/bin/CC -o kill_mut_task $(INCLDIRS) kill_mut_task.c \
	-lGc -lmach

kill_mut_task.c:	GcHeap_ipc.h

baseline:	baseline.o
	/usr/misc/bin/CC -o baseline baseline.o -lGc -lthreads -lmach

baseline.o:	baseline.c
	/usr/misc/bin/CC -c $(INCLDIRS) +i baseline.c

baseline2:	baseline2.c
	/usr/misc/bin/CC -o baseline2 $(INCLDIRS) baseline2.c \
	-lGc -lthreads -lmach

