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

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 = dbmain.c ant.c symregress.c neural.c multiplex.c blobsample.c rand.c \
	discrgame.c
OBJS = dbmain.o ant.o symregress.o neural.o multiplex.o blobsample.o rand.o \
	discrgame.o

APPS = antJohnMuir antSantaFe antLosAltos symregress neural multi03 multi06 \
	multi11 blobsample rand discrGameX discrGameO discrGameCo
DEBUG = antJMdebug antSFdebug antLAdebug symregdebug neuraldebug \
	multi3debug multi6debug multi11debug blobsampdebug randdebug \
	dGameXdebug dGameOdebug

MV = mv

all: $(APPS)

debug: $(DEBUG)

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

antJMdebug: ant.c dbmain.o lib/libgeppetto.a
	$(CC) -o antJMdebug $(CFLAGS) -DJOHN_MUIR -DDEBUG_ANT ant.c \
		dbmain.o $(LIBS)

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

antSFdebug: ant.c dbmain.o lib/libgeppetto.a
	$(CC) -o antSFdebug $(CFLAGS) -DSANTA_FE -DDEBUG_ANT ant.c \
		dbmain.o $(LIBS)

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

antLAdebug: ant.c dbmain.o lib/libgeppetto.a
	$(CC) -o antLAdebug $(CFLAGS) -DLOS_ALTOS_HILLS -DDEBUG_ANT ant.c \
		dbmain.o $(LIBS)

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

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

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

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

multi03: multiplex.c lib/libgeppetto.a
	$(CC) -o multi03 $(CFLAGS) -DMULTIPLEX=3 multiplex.c $(LIBS)

multi3debug: multiplex.c dbmain.o lib/libgeppetto.a
	$(CC) -o multi3debug $(CFLAGS) -DMULTIPLEX=3 -DDEBUG_MULTIPLEX \
		multiplex.c dbmain.o $(LIBS)

multi06: multiplex.c lib/libgeppetto.a
	$(CC) -o multi06 $(CFLAGS) -DMULTIPLEX=6 multiplex.c $(LIBS)

multi6debug: multiplex.c dbmain.o lib/libgeppetto.a
	$(CC) -o multi6debug $(CFLAGS) -DMULTIPLEX=6 -DDEBUG_MULTIPLEX \
		multiplex.c dbmain.o $(LIBS)

multi11: multiplex.c lib/libgeppetto.a
	$(CC) -o multi11 $(CFLAGS) -DMULTIPLEX=11 multiplex.c $(LIBS)

multi11debug: multiplex.c dbmain.o lib/libgeppetto.a
	$(CC) -o multi11debug $(CFLAGS) -DMULTIPLEX=11 -DDEBUG_MULTIPLEX \
		multiplex.c dbmain.o $(LIBS)

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

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

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

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

discrGameX: discrgame.c lib/libgeppetto.a
	$(CC) -o discrGameX $(CFLAGS) -DPLAYER_X discrgame.c $(LIBS)

dGameXdebug: discrgame.c dbmain.o  lib/libgeppetto.a
	$(CC) -o dGameXdebug $(CFLAGS) -DPLAYER_X -DDEBUG_DISCRETEGAME \
		discrgame.c dbmain.o $(LIBS)

discrGameO: discrgame.c lib/libgeppetto.a
	$(CC) -o discrGameO $(CFLAGS) -DPLAYER_O discrgame.c \
		$(LIBS)

dGameOdebug: discrgame.c dbmain.o lib/libgeppetto.a
	$(CC) -o dGameOdebug $(CFLAGS)-DPLAYER_O -DDEBUG_DISCRETEGAME \
		discrgame.c dbmain.o $(LIBS)

discrGameCo: discrgame.c lib/libgeppetto.a
	$(CC) -o discrGameCo $(CFLAGS) -DBOTH_PLAYERS discrgame.c \
		$(LIBS)

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

clean:
	rm -f a.out core $(APPS) $(DEBUG) $(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) -- $(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

ant.o: geppetto.h
ant.o: include/pmrand.h include/compiler.h include/objectlist.h
ant.o: include/genlist.h include/charstring.h
ant.o: include/object.h include/objtypes.h include/result.h
ant.o: include/resultlist.h include/blob.h include/constntsrc.h
ant.o: include/constant.h include/variable.h include/operatrsrc.h
ant.o: include/operator.h include/global.h include/program.h
ant.o: include/population.h include/proto.h
symregress.o: geppetto.h
symregress.o: include/pmrand.h include/compiler.h include/objectlist.h
symregress.o: include/genlist.h include/charstring.h
symregress.o: include/object.h include/objtypes.h include/result.h
symregress.o: include/resultlist.h include/blob.h include/constntsrc.h
symregress.o: include/constant.h include/variable.h include/operatrsrc.h
symregress.o: include/operator.h include/global.h include/program.h
symregress.o: include/population.h 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/operator.h include/global.h include/program.h
neural.o: include/population.h include/proto.h
multiplex.o: geppetto.h include/pmrand.h include/compiler.h
multiplex.o: include/objectlist.h include/genlist.h include/charstring.h
multiplex.o: include/object.h include/objtypes.h
multiplex.o: include/result.h include/resultlist.h include/blob.h
multiplex.o: include/constntsrc.h include/constant.h include/variable.h
multiplex.o: include/operatrsrc.h include/operator.h include/global.h
multiplex.o: include/program.h include/population.h include/proto.h
blobsample.o: geppetto.h
blobsample.o: include/pmrand.h include/compiler.h include/objectlist.h
blobsample.o: include/genlist.h include/charstring.h
blobsample.o: include/object.h include/objtypes.h include/result.h
blobsample.o: include/resultlist.h include/blob.h include/constntsrc.h
blobsample.o: include/constant.h include/variable.h include/operatrsrc.h
blobsample.o: include/operator.h include/global.h include/program.h
blobsample.o: include/population.h include/proto.h
rand.o: geppetto.h include/pmrand.h include/compiler.h include/objectlist.h
rand.o: include/genlist.h include/charstring.h
rand.o: include/object.h include/objtypes.h include/result.h
rand.o: include/resultlist.h include/blob.h include/constntsrc.h
rand.o: include/constant.h include/variable.h include/operatrsrc.h
rand.o: include/operator.h include/global.h include/program.h
rand.o: include/population.h include/proto.h
discrgame.o: geppetto.h include/pmrand.h include/compiler.h
discrgame.o: include/objectlist.h include/genlist.h include/charstring.h
discrgame.o: include/object.h include/objtypes.h
discrgame.o: include/result.h include/resultlist.h include/blob.h
discrgame.o: include/constntsrc.h include/constant.h include/variable.h
discrgame.o: include/operatrsrc.h include/operator.h include/global.h
discrgame.o: include/program.h include/population.h include/proto.h
