#  makefile.optmath
#    (from make_method.jgofs15, a makefile template for JGOFS 1.5 methods)

# Assumes jgofs 1.5 distribution and that this file,
#    along with the sources, is in src/* under the jgofs root.

# Can be run standalone if:
#	1) jgofs_root/opt-build-env has been executed first in context of
#	   this process (ie, source jgofs_root/opt-build-env)
#	2) jgofs.a library has already been built

#   29 Dec 99 clh
#       remove OO_OUTER switch as it is no longer used
#   12 Jan 99 CLH
#	per WJS, add switch USE_DOUBLE for v2.2b
#   7 May 98.  WJS
#	Correct typo in I_LIST.  Correct comment.
#  21 Apr 98.  WJS
#	Define OO_OUTER in case outer_brev is being used
#  15 Apr 98.  WJS
#	Switch method name to optmath
#   3 Apr 98.  WJS
#	makefile.math (comments below from make_method.jgofs15)
#   3 Apr 98.  WJS
#	Use I_LIST instead of individual -Is
#	Fix typo which omitted METHOD_CFLAGS from non-BUTTONIMAGESDIR case
#   2 Oct 97.  WJS
#	Fix typo in -I switch.  Add -I to look in INCDIR

METHBINDIR  = ../../methods
OUTERSRCDIR = ../methods
INCDIR = ../include
SRCDIR = .
LIBDIR  = ../lib

METHOD = ${METHBINDIR}/optmath	# Method name

#	Files which need to be compiled in order to build math
OBJ =   ${OUTERSRCDIR}/outer.c \
	${SRCDIR}/math.c \
	${SRCDIR}/mathexw.c

#	.h files (or other included files) on which inner or outer depend
INCLUDED_FILES = ${INCDIR}/default.h \
		 ${INCDIR}/inner.h \
		 ${INCDIR}/outer.h \
		 ${SRCDIR}/jgmath.h
#	List of directories from .h files in INCLUDED_FILES, separated by
#	-Is (-I ${SRCDIR} is default; included here to show syntax)
#	(Could get rid of -Is if I knew how to parse in make.  Sigh)
I_LIST = -I${INCDIR} -I${SRCDIR}

#	libraries required.  SYSLIB list needs leading -s
LIB_LIST = ${LIBDIR}/jgofs.a
SYSLIB_LIST = -lm

#	Method-specific compilation flags
###  METHOD_CFLAGS = -g

#	Compilation switches
SWITCHES = -DOPTIONS='"${INCDIR}/default.h"' \
	   -DINNEROPTIONS='"${INCDIR}/inner.h"' \
	   -DMYADDR='"${MYADDR}"' \
	   -DOPTIONSERVER='"${OPTIONSERVER}"' \
	   -DINFOSERVER='"${INFOSERVER}"' \
	   -DDIRSERVER='"${DIRSERVER}"' \
	   -DQUOTENOLINK \
	   -DUSE_DOUBLE

#######################

all: ${METHOD}

${METHOD}:${OBJ} ${INCLUDED_FILES} ${LIB_LIST}
	@- test -d ${METHBINDIR} || mkdir ${METHBINDIR}
	$(CC) \
		${CFLAGS} ${METHOD_CFLAGS} \
		${SWITCHES} \
		-DBUTTONIMAGESDIR='"${BUTTONIMAGESDIR}"' \
		${I_LIST} \
		${OBJ} \
		${LIB_LIST} ${SYSLIB_LIST} \
		-o $@

clean:
	-rm ${SRCDIR}/math.o ${SRCDIR}/mathexw.o \
	    ${SRCDIR}/outer.o \
	    ${METHOD}
