MYSOURCES= main.c solve.c read.c write.c tran.c dual.c
YSOURCE= y.tab.c
YOBJECT= ${YSOURCE:.c=.o}
LSOURCE= lex.yy.c
OBJECTS= ${MYSOURCES:.c=.o} ${YOBJECT}
INCLUDES= globals.h defines.h proto.h
TARGET= lp_solve
MANPAGE= ${TARGET}.1
TESTFILES= ex1.lp ex2.lp ex3.lp ex4.lp ex5.lp ex6.lp

# -ll and -lm seems to be enough on most machines.
LIBS= -ll -lm

# change this when you like. They are only used with make install.
INSTALLDIR=/usr/es/bin
MANDIR=/usr/es/man/man1

# for performance reasons be sure to add all possible floating point support
# This is ANSI C code following POSIX standards, be sure to tell your compiler
# when necessary.

# default
#CFLAGS= -O

# you can add a -DREAL=<float type> to the CFLAGS, to change the default float
# type used in lp_solve (double) to float or 'long double'. However, type float
# might be fast on your computer, but it is not accurate enough to solve even
# moderately sized problems without running into numerical problems.
# the use of long doubles does increase the numerical stability of lp_solve,
# if your compiler actually implements them with more bits than a double. But
# it slows down things quite a bit.
#CFLAGS= -O -DREAL='long double'

# Apollo 68040 based: 425[est], DN5500
#CFLAGS= -O -Acpu,mathlib -A ansi
#CFLAGS = -g -A ansi

# HP 9000/7XX or 8XX
CFLAGS= +O3 +Om1 -Aa -D_POSIX_SOURCE +FP VZOUiD

# default for debugging
#CFLAGS= -g

# choose a C compiler. On Sun, you probably want to use gcc
CC= cc

${TARGET} : ${OBJECTS} 
	${CC} -o ${TARGET} ${CFLAGS} ${OBJECTS} ${LIBS}

${OBJECTS} : ${INCLUDES}

main.o : patchlevel.h


${LSOURCE} : lex.l
	lex lex.l

${YSOURCE} : lp.y
	yacc lp.y

${YOBJECT} : ${LSOURCE}

install:
	cp ${TARGET} ${INSTALLDIR}
	cp ${MANPAGE} ${MANDIR}

clean:
	/bin/rm -f ${OBJECTS} ${TARGET} TAGS ${LSOURCE}  ${YSOURCE} *.bak

# the following definitions can be practical if you have the tools

TAGS: ${MYSOURCES} ${INCLUDES}
	etags *.[chly]

${TARGET}.man: ${MANPAGE}
	nroff -man ${MANPAGE} > ${TARGET}.man

test:
	for i in ${TESTFILES}; do\
		./${TARGET} -p < $$i > xxx.tmp;\
		if diff xxx.tmp `basename $$i .lp`.out > /dev/null; then\
			echo "$$i gives the correct result";\
		else\
			echo "$$i gives different result, please check";\
		fi;\
	done;\
	rm xxx.tmp
