# Copyright (c) 1993 Xerox Corporation.  All rights reserved.
# Redefining srcdir allows object code for the nonPCR version of the collector
# to be generated in different directories
srcdir = .
VPATH = $(srcdir)

OBJS= alloc.o reclaim.o allochblk.o misc.o mach←dep.o os←dep.o mark←roots.o headers.o mark.o obj←map.o black←list.o finalize.o new←hblk.o real←malloc.o dynamic←load.o debug←malloc.o malloc.o stubborn.o checksums.o

CSRCS= reclaim.c allochblk.c misc.c alloc.c mach←dep.c os←dep.c mark←roots.c headers.c mark.c obj←map.c pcr←interface.c black←list.c finalize.c new←hblk.c real←malloc.c dynamic←load.c debug←malloc.c malloc.c stubborn.c checksums.c

SRCS= $(CSRCS) mips←mach←dep.s rs6000←mach←dep.s alpha←mach←dep.s gc.h gc←headers.h gc←private.h config.h gc←inline.h gc.man if←mach.c if←not←there.c

# The following is irrelevant on most systems.  But a few
# versions of make otherwise fork the shell specified in
# the SHELL environment variable.
SHELL= /bin/sh

CC= cc
CFLAGS= -O -DSILENT
# Setjmp←test may yield overly optimistic results when compiled
# without optimization.
# -DSILENT disables statistics printing, and improves performance.
# -DCHECKSUMS reports on erroneously clear dirty bits, and unexpectedly
# altered stubborn objects, at substantial performance cost.
# -DFIND←LEAK causes the collector to assume that all inaccessible
# objects should have been explicitly deallocated, and reports exceptions

SPECIALCFLAGS = 
# Alternative flags to the C compiler for mach←dep.c.
# Mach←dep.c often doesn't like optimization, and it's
# not time-critical anyway.
# Set SPECIALCFLAGS to -q nodirect←code on Encore.

default: pcr

all: gc.a gctest

pcr: PCR-Makefile gc←private.h gc←headers.h gc.h config.h mach←dep.o $(SRCS)
	make -f PCR-Makefile
	
depend: PCR-Makefile
	make -f PCR-Makefile depend

$(OBJS) test.o: $(srcdir)/gc←private.h $(srcdir)/gc←headers.h $(srcdir)/gc.h $(srcdir)/config.h

gc.a: $(OBJS)
	ar ru gc.a $(OBJS)
	ranlib gc.a || cat /dev/null
#	ignore ranlib failure; that usually means it doesn't exist, and isn't needed

mach←dep.o: $(srcdir)/mach←dep.c $(srcdir)/mips←mach←dep.s $(srcdir)/rs6000←mach←dep.s if←mach if←not←there
	rm -f mach←dep.o
	./if←mach MIPS "" as -o mach←dep.o $(srcdir)/mips←mach←dep.s
	./if←mach RS6000 "" as -o mach←dep.o $(srcdir)/rs6000←mach←dep.s
	./if←mach ALPHA "" as -o mach←dep.o $(srcdir)/alpha←mach←dep.s
	./if←not←there mach←dep.o $(CC) -c $(SPECIALCFLAGS) $(srcdir)/mach←dep.c

if←mach: $(srcdir)/if←mach.c $(srcdir)/config.h
	$(CC) $(CFLAGS) -o if←mach $(srcdir)/if←mach.c

if←not←there: $(srcdir)/if←not←there.c
	$(CC) $(CFLAGS) -o if←not←there $(srcdir)/if←not←there.c

clean: 
	rm -f gc.a test.o gctest output-local output-diff $(OBJS) pcr←interface.o \
	      setjmp←test  mon.out gmon.out a.out core if←not←there if←mach depend makedep eddep
	-rm -f *~

gctest: test.o gc.a if←mach if←not←there
	rm -f gctest
	./if←mach ALPHA "" $(CC) $(CFLAGS) -o gctest -non←shared test.o gc.a
	./if←not←there gctest $(CC) $(CFLAGS) -o gctest test.o gc.a

# If an optimized setjmp←test generates a segmentation fault,
# odds are your compiler is broken.  Gctest may still work.
# Try compiling setjmp←test unoptimized.
setjmp←test: $(srcdir)/setjmp←test.c $(srcdir)/gc.h if←mach if←not←there
	rm -f setjmp←test
	./if←mach ALPHA "" $(CC) $(CFLAGS) -o setjmp←test -non←shared $(srcdir)/setjmp←test.c
	./if←not←there setjmp←test $(CC) $(CFLAGS) -o setjmp←test $(srcdir)/setjmp←test.c

test: setjmp←test gctest
	./setjmp←test
	./gctest

tar:
	tar cvf gc.tar $(SRCS) Makefile PCR-Makefile OS2←MAKEFILE README test.c setjmp←test.c
	compress gc.tar

lint: $(CSRCS) test.c
	lint -DLINT $(CSRCS) test.c | egrep -v "possible pointer alignment problem|abort|exit|sbrk|mprotect|syscall"

# DO NOT DELETE THIS LINE