# flags for fpc, for instance -n or -t
FPFLAGS = -tmatchpat -treplpat
# load time flags for the c compiler, e.g. -lfp, -L/usr/lib
FPRTS = `ldpath` -lfp
# flags for the c compiler, for instance -g or -O
CFLAGS =
# which c compiler, fp compiler, make program
C = gcc
F = fpc
M = gmake
# installation information: bin directory, lib directory
BIN = /unc/biagioni/bin/${ARCH}
LIB = /usr/softlab/contrib/lib/${ARCH}
# .c files derived from .fp files and object files
# the .c files are needed because otherwise make doesn't know how
# to go from the .fp file to the .o file
LEXSRCS = map.c mapl.c fplstd.c 
LEXOBJS = map.o mapl.o fplstd.o 
# the files to be removed when making clean
# (in addition to *.c *.o *.gen *.run *.res)
REMFILS = mapl.fp mapg.fp map mapl mapg core ${LIBS}
# the following options are for profiling; uncomment them, then "make monitor"
#FPRTS = lib.o set.o store.o fpformat.o fp.o
#CFLAGS = -pg
#LIBS = lib.fp set.fp store.fp fpformat.fp

.SUFFIXES: .fp .c .o .lex .grm

.fp.o:
	$F ${FPFLAGS} $*.fp
	$C ${CFLAGS} -c $*.c
	rm $*.c

.lex.fp:
	fplex $*.lex > $*.fp

.grm.fp:
	school $*.grm > $*.fp

test: map
	map < input

mapl.o: mapl.fp
	$F -m -i ${FPFLAGS} $*.fp
	$C ${CFLAGS} -c $*.c
	rm $*.c

map.o: map.fp
	$F -m ${FPFLAGS} $*.fp
	$C ${CFLAGS} -c $*.c
	rm $*.c

mapg.o: mapg.fp
	$F -m ${FPFLAGS} $*.fp
	$C ${CFLAGS} -c $*.c
	rm $*.c

map: map.o
	$C -o map map.o $(LIBS) $(FPRTS)

mapg: mapg.o parse.o
	$C -o mapg mapg.o parse.o $(LIBS) $(FPRTS)

fplstd.o: fplstd.fp
	fpc fplstd.fp
	$C -c fplstd.c
	rm fplstd.c

mapl: mapl.o fplstd.o
	$C -o mapl mapl.o fplstd.o $(LIBS) $(FPRTS)

clean:
	/bin/rm -f $(REMFILS) *.c *.o
