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

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

SRCS= $(CSRCS) mips←mach←dep.s rs6000←mach←dep.s interface.c 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
# Setjmp←test may yield overly optimistic results when compiled
# without optimization.

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.

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
	make -f PCR-Makefile

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

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: mach←dep.c mips←mach←dep.s rs6000←mach←dep.s if←mach if←not←there
	rm -f mach←dep.o
	./if←mach MIPS "" as -o mach←dep.o mips←mach←dep.s
	./if←mach RS6000 "" as -o mach←dep.o rs6000←mach←dep.s
	./if←not←there mach←dep.o $(CC) -c $(SPECIALCFLAGS) mach←dep.c

if←mach: if←mach.c config.h
	$(CC) $(CFLAGS) -o if←mach if←mach.c
	
if←not←there: if←not←there.c
	$(CC) $(CFLAGS) -o if←not←there if←not←there.c

clean: 
	rm -f gc.a test.o gctest output-local output-diff $(OBJS) \
	      setjmp←test  mon.out gmon.out a.out core
	-rm -f *~

gctest: test.o gc.a
	$(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: setjmp←test.c gc.h
	$(CC) $(CFLAGS) -o setjmp←test 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 $(CSRCS) test.c | egrep -v "possible pointer alignment problem|abort|exit"