OBJS= alloc.o reclaim.o allochblk.o misc.o mach_dep.o mark_roots.o heapprof.o
# add rt_allocobj.o for RT version

SRCS= reclaim.c allochblk.c misc.c alloc.c mach_dep.c mark_roots.c

#CFLAGS= -g -I../../include -Aa -D_HPUX_SOURCE -DHEAP_PROF 
#CFLAGS= -g -I../../include -Aa -D_HPUX_SOURCE
CFLAGS= -O -I../../include -Aa -D_HPUX_SOURCE
#LDFLAGS= -g -I../../include -Aa
LDFLAGS= -O -I../../include -Aa

# Set SPECIALCFLAGS to -q nodirect_code on Encore.
# On Sun systems under 4.0, it's probably safer to link with -Bstatic.
# I'm not sure that all static data will otherwise be found.
# It also makes sense to replace -O with -O4, though it doesn't appear
# to make much difference.

SPECIALCFLAGS = -Aa -D_HPUX_SOURCE -I../../include

all: gc.a gctest

$(OBJS): gc.h

all: gc.o gc.a

gc.a: $(OBJS)
	/bin/rm -f gc.a
	ar ru gc.a $(OBJS)

gc.o: $(OBJS)
	-ld -r -o gc.o $(OBJS)

#mach_dep.o: mach_dep.s
#	as -o mach_dep.o mach_dep.s

# mach_dep.c doesn't like optimization
# on a MIPS machine, move mips_mach_dep.s to mach_dep.s and remove
# mach_dep.c as well as the following two lines from this Makefile
mach_dep.o: mach_dep.c
	cc -c ${SPECIALCFLAGS} mach_dep.c

test.o: cons.h test.c

cons.o: cons.h cons.c

# On a MIPS system, the BSD version of libc.a should be used to get
# sigsetmask.  I found it necessary to link against the system V
# library first, to get a working version of fprintf.  But this may have
# been due to my failure to find the right version of stdio.h or some
# such thing.
gctest: test.o cons.o gc.a
	cc $(LDFLAGS) -o gctest test.o cons.o gc.a

setjmp_test: setjmp_test.c gc.h
	cc -o setjmp_test setjmp_test.c

test: setjmp_test gctest
	./setjmp_test
	@echo "WARNING: for GC test to work, all debugging output must be turned off"
	rm -f output-local
	./gctest > output-local
	-diff correct-output output-local > output-diff
	-@test -s output-diff && \
	  echo 'Output of program "gctest" is not correct.  GC does not work.'\
          || echo 'Output of program "gctest" is correct.  GC probably works.' 
	
shar:
	makescript -o gc.shar README Makefile gc.h ${SRCS} test.c cons.c cons.h

clean: 
	/bin/rm -f *.o gctest output-local output-diff setjmp_test

veryclean: clean
	/bin/rm -f gc.a
