# If you need to change this to gcc or pcc or whatever, go ahead.
CC =		cc

# Uncommenting NO_LEAKFINDER makes the program *not* check for memory leaks.
# The default, once leakfinder is installed, is to check.
#NO_LEAKFINDER =	-DNO_LEAKFINDER

# Most of these compiler flags are for adding extra checks. If your
# compiler doesn't support them, feel free to get rid of them.
CFLAGS =	-g -ansi -pedantic -U__STRICT_ANSI__ -D_GNU_SOURCE -Wall -Wpointer-arith -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wconversion -Wno-long-long -Wno-cast-qual $(DEBUG) $(NO_LEAKFINDER)

LDFLAGS =	-g

all:		examples bic

examples:	examples.c ../liblmin.h ../leakfinder.h ../liblmin.a
	$(CC) $(CFLAGS) examples.c $(LDFLAGS) -L.. -llmin -lm -o examples

bic:		bic.o bic_scan.o ../liblmin.a
	$(CC) $(LDFLAGS) bic.o bic_scan.o -L.. -llmin -lm -o bic
bic.o:		bic.c bigint.h
	$(CC) $(CFLAGS) -I.. -c bic.c
bic.c bic.h:	bic.y
	bison -d -o bic.c bic.y
bigint.h:     bigint.lisp ../txt_to_h
	../txt_to_h bigint.lisp > bigint.h
bic_scan.o:	bic_scan.c bic.h
	$(CC) $(CFLAGS) -I.. -c bic_scan.c

test:		../lmin
	../lmin rational.lisp complex.lisp bigint.lisp test.lisp

clean:
	rm -f examples bic bic.c bic.h bigint.h *.o *.a core core.* *.core
