# Set this to your favorite C Compiler that understands ANSI
CC       = gcc

# Set these to be whatever flags you want to pass to your compiler
CFLAGS   = -O

# set this to the AR flags as appropriate for your system
ARFLAGS  = r

# Point this to the directory where the soar sources exist if you need to
# compile them (to remake the library).
SOAR_DIR = src

# Point this to the direcotory wher the source for the convert program
# exists.
CONV_DIR = convert

# Point this at the lib dir where you libsoar.a exists on your system
# or where you want it to exist if you are initially installing this.
LIB_DIR  = lib

# Point this to where you want the convert and soar executables to exist
BIN_DIR  = bin

# Point this to the directory where user written files to be linked against
# the Soar library exist
USER_DIR = user

# This contains the list of all files in the soar library
SOAR_SRC = ${SOAR_DIR}/decide.c ${SOAR_DIR}/hooks.c ${SOAR_DIR}/interface.c \
           ${SOAR_DIR}/io.c ${SOAR_DIR}/lexer.c ${SOAR_DIR}/main.c \
           ${SOAR_DIR}/mem.c ${SOAR_DIR}/parser.c ${SOAR_DIR}/print.c \
           ${SOAR_DIR}/production.c ${SOAR_DIR}/recmem.c ${SOAR_DIR}/rete.c \
           ${SOAR_DIR}/rhsfun.c ${SOAR_DIR}/symtab.c ${SOAR_DIR}/tilde.c \
           ${SOAR_DIR}/trace.c
SOAR_OBJ = ${SOAR_DIR}/decide.o ${SOAR_DIR}/hooks.o ${SOAR_DIR}/interface.o \
           ${SOAR_DIR}/io.o ${SOAR_DIR}/lexer.o ${SOAR_DIR}/main.o \
           ${SOAR_DIR}/mem.o ${SOAR_DIR}/parser.o ${SOAR_DIR}/print.o \
           ${SOAR_DIR}/production.o ${SOAR_DIR}/recmem.o ${SOAR_DIR}/rete.o \
           ${SOAR_DIR}/rhsfun.o ${SOAR_DIR}/symtab.o ${SOAR_DIR}/tilde.o \
           ${SOAR_DIR}/trace.o

# List of all files to create the convert program
CONV_SRC = ${CONV_DIR}/convert.c
CONV_OBJ = ${CONV_DIR}/convert.o

# the header file on which all soar6 source depends
HEADERS	 = ${SOAR_DIR}/soar.h

# All the user defined C files.  Whenever you want to link in a new file, you
# must add it to this line as ${USER_DIR}/<filename.c>
USER_SRC =
# All the user defined C files.  Whenever you want to link in a new file, you
# must add it to this line as ${USER_DIR}/<filename.o>
USER_OBJ = 

# Describe which files should be used to build the soar library.
LIB_SRC  = ${SOAR_SRC}
LIB_OBJ  = ${SOAR_OBJ}

LIBS     = -lsoar

all: soar_obj convert
#all: lib soar_lib convert


clean:
	${RM} -rf ${USER_OBJ} ${SOAR_OBJ} ${CONV_OBJ}

clobber: clean
	${RM} -rf ${LIB_DIR}/libsoar.a ${BIN_DIR}/soar ${BIN_DIR}/convert

.c.o:
	${CC} ${CFLAGS} -o $@ -c $<

# This doesn't depend on the soarlib so that it can be pre-compiled
# and exist externally.
soar_lib: lib ${USER_OBJ}
	${CC} -o ${BIN_DIR}/soar ${USER_OBJ} -L${LIB_DIR} ${LIBS}

soar_obj: ${SOAR_OBJ} ${USER_OBJ}
	${CC} -o ${BIN_DIR}/soar ${SOAR_OBJ} ${USER_OBJ}

lib: ${LIB_OBJ}
	${AR} ${ARFLAGS} ${LIB_DIR}/libsoar.a ${LIB_OBJ}
	ranlib ${LIB_DIR}/libsoar.a

convert: ${CONV_OBJ}
	${CC} -o ${BIN_DIR}/convert ${CONV_OBJ}

${SOAR_OBJ}: ${HEADERS}
