
# define this stuff if you want to compile in malloc debugging code
#
# MALLOCINCS = -I/usr/sww/include/dbmalloc
# MALLOCLIBS = -L/usr/sww/lib -ldbmalloc

DEFINES = -DKEEP_ALLOCATED_MEMORY # -DTRACK_BREED_TYPE -DDEBUG_POP_CODE
INCLUDES = -Iinclude -I../include $(MALLOCINCS)

CC = gcc
CDEBUGFLAGS=-g -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wwrite-strings \
	-Wconversion -Wstrict-prototypes -Wmissing-prototypes # -Wcast-align
# CDEBUGFLAGS=-pg
# CDEBUGFLAGS = -O2

CFLAGS = $(CDEBUGFLAGS) $(DEFINES) $(INCLUDES)
LIBS = -Llib -lgeppetto $(MALLOCLIBS) -lm

DEPEND = makedepend

SRCS = ant.c symregress.c neural.c multi11.c blobsample.c rand.c
OBJS = ant.c symregress.o neural.o multi11.o blobsample.o rand.c

APPS = ant symregress neural multi11 blobsample rand
DEBUG = antdebug symregdebug neuraldebug multi11debug blobsampdebug randdebug

MV = mv

all: $(APPS)

debug: $(DEBUG)

ant: main.o ant.o lib/libgeppetto.a
	$(CC) -o ant $(CFLAGS) main.o ant.o $(LIBS)

antdebug: ant.c lib/libgeppetto.a
	$(CC) -o antdebug $(CFLAGS) -DDEBUG_ANT ant.c $(LIBS)

symregress: main.o symregress.o lib/libgeppetto.a
	$(CC) -o symregress $(CFLAGS) main.o symregress.o $(LIBS)

symregdebug: symregress.c lib/libgeppetto.a
	$(CC) -o symregdebug $(CFLAGS) -DDEBUG_SYMREGRESS symregress.c $(LIBS)

neural: main.o neural.o lib/libgeppetto.a
	$(CC) -o neural $(CFLAGS) main.o neural.o $(LIBS)

neuraldebug: neural.c lib/libgeppetto.a
	$(CC) -o neuraldebug $(CFLAGS) -DDEBUG_NEURAL neural.c $(LIBS)

multi11: main.o multi11.o lib/libgeppetto.a
	$(CC) -o multi11 $(CFLAGS) main.o multi11.o $(LIBS)

multi11debug: multi11.c lib/libgeppetto.a
	$(CC) -o multi11debug $(CFLAGS) -DDEBUG_MULTI11 multi11.c $(LIBS)

blobsample: main.o blobsample.o lib/libgeppetto.a
	$(CC) -o blobsample $(CFLAGS) main.o blobsample.o $(LIBS)

blobsampdebug: blobsample.c lib/libgeppetto.a
	$(CC) -o blobsampdebug $(CFLAGS) -DDEBUG_BLOBSAMPLE blobsample.c $(LIBS)

rand: main.o rand.o lib/libgeppetto.a
	$(CC) -o rand $(CFLAGS) main.o rand.o $(LIBS)

randdebug: rand.c lib/libgeppetto.a
	$(CC) -o randdebug $(CFLAGS) -DDEBUG_RAND rand.c $(LIBS)

lib/libgeppetto.a:
	(cd lib; make CC="$(CC)" CFLAGS="$(CFLAGS)" LIBS="$(LIBS)" libgeppetto.a)

clean:
	rm -f a.out core $(APPS) $(DEBUG) main.o $(OBJS) Makefile.bak *~ \
		*.xgraph ckpt.debug
	rm -f include/*~
	(cd lib; make clean)

# this 'depend' ignores system include files to increase Makefile portability
#
depend::
	$(DEPEND) -s "# DO NOT DELETE" -- $(DEFINES) $(INCLUDES) -- main.c \
		$(SRCS)
	sed -e '/# DO NOT DELETE/,$$ s/ \/[a-zA-Z0-9./]*//g' -e '/\.o:$$/d' \
		< Makefile > Makefile.new && mv -f Makefile.new Makefile

###########################################################################
# dependencies generated by makedepend
#
# DO NOT DELETE

main.o: geppetto.h include/pmrand.h include/compiler.h include/objectlist.h
main.o: include/genlist.h include/charstring.h include/object.h
main.o: include/objtypes.h include/result.h include/resultlist.h
main.o: include/blob.h include/constntsrc.h include/constant.h
main.o: include/variable.h include/operatrsrc.h include/interface.h
main.o: include/program.h include/population.h include/proto.h
symregress.o: geppetto.h include/pmrand.h include/compiler.h
symregress.o: include/objectlist.h include/genlist.h include/charstring.h
symregress.o: include/object.h include/objtypes.h
symregress.o: include/result.h include/resultlist.h include/blob.h
symregress.o: include/constntsrc.h include/constant.h include/variable.h
symregress.o: include/operatrsrc.h include/interface.h include/program.h
symregress.o: include/proto.h
neural.o: geppetto.h include/pmrand.h include/compiler.h include/objectlist.h
neural.o: include/genlist.h include/charstring.h
neural.o: include/object.h include/objtypes.h include/result.h
neural.o: include/resultlist.h include/blob.h include/constntsrc.h
neural.o: include/constant.h include/variable.h include/operatrsrc.h
neural.o: include/interface.h include/program.h include/proto.h
multi11.o: geppetto.h include/pmrand.h include/compiler.h
multi11.o: include/objectlist.h include/genlist.h include/charstring.h
multi11.o: include/object.h include/objtypes.h
multi11.o: include/result.h include/resultlist.h include/blob.h
multi11.o: include/constntsrc.h include/constant.h include/variable.h
multi11.o: include/operatrsrc.h include/interface.h include/program.h
multi11.o: include/proto.h
blobsample.o: geppetto.h include/pmrand.h include/compiler.h
blobsample.o: include/objectlist.h include/genlist.h include/charstring.h
blobsample.o: include/object.h include/objtypes.h
blobsample.o: include/result.h include/resultlist.h include/blob.h
blobsample.o: include/constntsrc.h include/constant.h include/variable.h
blobsample.o: include/operatrsrc.h include/interface.h include/program.h
blobsample.o: include/proto.h
