# Make a Forth    wilbaden 94-08-14
# Just say "make".

# Make a choice or make your own.  (Let me know about your own.)

#M4 = m4
#M4 = pdm4
M4 = /usr/5bin/m4

CC = gcc
#CC = cc

BIN = $$HOME/bin

PLATFORM =
#PLATFORM = cli.c

OPTIONS =
#OPTIONS = -DFLOAT

#EXTRA = fp-load
EXTRA =

CUSTOM =

#CFLAGS =
CFLAGS = -D__GNU__

#ELECTIVES =
ELECTIVES = path $$HOME/macro4th/lib/
#ELECTIVES = path ../lib/
#ELECTIVES = path ::lib:
#ELECTIVES = path ..\lib\

all:	aforth

# Make This Forth Step 1: make clean.

clean:
	rm -f fo.c fo foo* rth.m4 hi.tmp aforth.c aforth core *.o

# Make This Forth Step 2: make fo.c.

fo.c:	fo.m4 llfc.m4 custom.m4
	$(M4) $(OPTIONS) fo.m4 > fo.c

# Make This Forth Step 3: make fo.

fo:	fo.c fo.h kernel.c $(PLATFORM) $(CUSTOM)
	$(CC) $(CFLAGS) fo.c kernel.c $(PLATFORM) $(CUSTOM) -o fo

# You now have This Forth

# Make A Forth Step 1: make rth.m4

rth.m4:	fo rth save-4th
	fo rth $(ELECTIVES) $(EXTRA) save-4th
	rm -f hi.tmp

# Make A Forth Step 2: make aforth.c.

aforth.c:	rth.m4
	rm -f aforth.c
	$(M4) -DEXTENDED $(OPTIONS) fo.m4 > aforth.c

# Make A Forth Step 3: make aforth.

aforth:	aforth.c fo.h kernel.c $(PLATFORM) $(CUSTOM)
	$(CC) $(CFLAGS) aforth.c kernel.c $(PLATFORM) $(CUSTOM) -o aforth

# Superrogatory.

tidy:
	rm -f fo.c foo* rth.4th hi.tmp

install: aforth tidy
	rm -f fo
	mv -f aforth $(BIN)
