# Makefile for building reduce.img suitable for embedded use. This
# will always want to run on the current machine!


COMMON=-O2 -I. -DPAGE_BITS=19 -DHAVE_CONFIG_H=1 -DEMBEDDED=1

CC=gcc
CFLAGS=$(COMMON)

S=../../cslbase
R=../../..

VPATH=$(S)

all:	reduce reduce.img image.c

reduce:		arith01.o arith02.o arith03.o arith04.o arith05.o \
		arith06.o arith07.o arith08.o arith09.o arith10.o \
		arith11.o arith12.o bytes.o char.o \
		csl.o cslmpi.o cslread.o eval1.o eval2.o eval3.o \
		eval4.o fasl.o fns1.o fns2.o fns3.o fwin.o gc.o \
		preserve.o print.o restart.o sysfwin.o termed.o \
		stubs.o
	$(CC) $(CFLAGS) arith01.o arith02.o arith03.o arith04.o arith05.o \
		arith06.o arith07.o arith08.o arith09.o arith10.o \
		arith11.o arith12.o bytes.o char.o \
		csl.o cslmpi.o cslread.o eval1.o eval2.o eval3.o \
		eval4.o fasl.o fns1.o fns2.o fns3.o fwin.o gc.o \
		preserve.o print.o restart.o sysfwin.o termed.o \
		stubs.o -lm -ldl -o reduce

.c.o:                                                                          <
	$(CC) $(CFLAGS) -c -o $@ $<

# Create the reduce.img file

reduce.img:	reduce
	-rm -f reduce.img
	./reduce -z -Dno_init_file $(S)/buildreduce.lsp \
		-D@srcdir=$(S) -D@reduce=$(R) -o reduce.img -- image.log

make-image:	../make-image.c
	$(CC) $(CFLAGS) ../make-image.c -o make-image

image.c:	make-image reduce.img
	./make-image
	cp image.c ../reduce-image.c

clean:
	-rm -f *.o reduce hello reduce.img image.log make-image image.c

HEADERS = config.h \
	$(S)/arith.h $(S)/bytes.h $(S)/clsyms.h $(S)/cslerror.h \
	$(S)/cslread.h $(S)/entries.h $(S)/externs.h $(S)/fwin.h \
	$(S)/headers.h $(S)/machine.h $(S)/proc.h $(S)/sockhdr.h \
	$(S)/stream.h $(S)/syscsl.h $(S)/tags.h $(S)/termed.h \
	$(S)/version.h


arith01.o:	$(S)/arith01.c $(HEADERS)
arith02.o:	$(S)/arith02.c $(HEADERS)
arith03.o:	$(S)/arith03.c $(HEADERS)
arith04.o:	$(S)/arith04.c $(HEADERS)
arith05.o:	$(S)/arith05.c $(HEADERS)
arith06.o:	$(S)/arith06.c $(HEADERS)
arith07.o:	$(S)/arith07.c $(HEADERS)
arith08.o:	$(S)/arith08.c $(HEADERS)
arith09.o:	$(S)/arith09.c $(HEADERS)
arith10.o:	$(S)/arith10.c $(HEADERS)
arith11.o:	$(S)/arith11.c $(HEADERS)
arith12.o:	$(S)/arith12.c $(HEADERS)
bytes.o:	$(S)/bytes.c $(HEADERS)
bytes1.o:	$(S)/bytes1.c $(S)/opnames.c $(HEADERS)
char.o:		$(S)/char.c $(HEADERS)
csl.o:		$(S)/csl.c $(HEADERS)
cslmpi.o:	$(S)/cslmpi.c $(S)/mpipack.c $(HEADERS)
cslread.o:	$(S)/cslread.c $(HEADERS)
driver.o:	$(S)/driver.c $(HEADERS)
embedcsl.o:	$(S)/embedcsl.c $(S)/csl.c $(HEADERS)
eval1.o:	$(S)/eval1.c $(HEADERS)
eval2.o:	$(S)/eval2.c $(HEADERS)
eval3.o:	$(S)/eval3.c $(HEADERS)
eval4.o:	$(S)/eval4.c $(HEADERS)
fasl.o:		$(S)/fasl.c $(HEADERS)
fns1.o:		$(S)/fns1.c $(HEADERS)
fns2.o:		$(S)/fns2.c $(HEADERS)
fns3.o:		$(S)/fns3.c $(HEADERS)
fwin.o:		$(S)/fwin.c $(HEADERS)
gc.o:		$(S)/gc.c $(HEADERS)
preserve.o:	$(S)/preserve.c $(HEADERS)
print.o:	$(S)/print.c $(HEADERS)
restart.o:	$(S)/restart.c machineid.c $(HEADERS)
sysfwin.o:	$(S)/sysfwin.c $(HEADERS)
termed.o:	$(S)/termed.c $(HEADERS)

# end of Makefile
