# ***************************************************************
#     Remember to source opt-build-env first, if you are building 
#  any sub-set of these files outside of toplevel opt-build procedure 
# ***************************************************************
#
# makefile for JGOFS OPTIONSERVER methods used from methods/

# 11 Jan 08.  WJS
#      Merge 5 Dec 06 mods into this file.  The comments about def
# don't directly apply.  This make file should be changed to use the new
# outer build.  However, comments say that "the same outer should be
# used for all", so (to quote the 5 Dec comment) "the problems that led
# to per-method outers shouldn't apply"
#      Not clear that any of this software works, anyway.
##   5 Dec 06.  WJS
##     Change location of outer.h
##     Note: this file should be changed to use a per-def outer source
##     similar to the way other methods are built.  Since def is the only method
##     in src/methods that does NOT do it this way, outer.o is uniquely used by
##     def, and the problems that led to per-method outers shouldn't apply
#  11 Mar 05.  WJS
#       Add err_stub_methods per mods to dct, etc.  See
#     err_stub_methods.c for comments.
# updated for v1.5 JGOFS software clh, November 4, 1998
#
#
#               ${METHBINDIR}optdyn   \
#${METHBINDIR}dyn:dyn.o outer.o svan.o ${LIBDIR}jgofs.a
#	$(CC) dyn.o outer.o ${LIBDIR}jgofs.a  svan.o -lm  -o $@
#dyn.o:dyn.c
#svan.o:svan.c
#
TOPLEVEL =  ../../
LIBDIR = ../lib/
INCDIR = ../include/
METHBINDIR  = ${TOPLEVEL}methods/
OUTERSRCDIR = ../methods/
OUTERINCDIR = ${OUTERSRCDIR}
SRCDIR = ./
SWITCHES =	-DMYADDR='"${MYADDR}"' \
		-DOPTIONSERVER='"${OPTIONSERVER}"' \
		-DINFOSERVER='"${INFOSERVER}"' \
		-DDIRSERVER='"${DIRSERVER}"' \
		-DBUTTONIMAGESDIR='"${BUTTONIMAGESDIR}"'
#
# make outer.o in this directory for all targets to use
#
TODO = ${METHBINDIR}optmap    \
       ${METHBINDIR}coastline \
       ${METHBINDIR}grid      \
       ${SRCDIR}outer.o

all: ${TODO}

${METHBINDIR}optmap:${SRCDIR}map.o \
			${SRCDIR}remap.o \
			${SRCDIR}outer.o \
			${LIBDIR}err_stub_methods.o \
			${LIBDIR}jgofs.a
	$(CC)   ${SRCDIR}map.o \
		${SRCDIR}remap.o \
		${SRCDIR}outer.o \
		${LIBDIR}err_stub_methods.o \
		${LIBDIR}jgofs.a -lm -o $@

${SRCDIR}map.o:${SRCDIR}map.c
	$(CC) -c -DOPTIONS='"${INCDIR}default.h"'  \
		 -DINNEROPTIONS='"${INCDIR}inner.h"' \
		 -I${INCDIR} \
		 ${SRCDIR}map.c
	
${SRCDIR}remap.o:${SRCDIR}remap.c

${METHBINDIR}coastline:${SRCDIR}coast.o \
		${SRCDIR}outer.o \
		${LIBDIR}jgofs.a
	$(CC) ${SRCDIR}coast.o \
		${SRCDIR}outer.o \
		${LIBDIR}jgofs.a -o $@
${SRCDIR}coast.o:${SRCDIR}coast.c

${METHBINDIR}grid: ${SRCDIR}grid.o
	$(CC) ${SRCDIR}grid.o -o $@
${SRCDIR}grid.o:${SRCDIR}grid.c

${SRCDIR}outer.o: ${OUTERSRCDIR}outer.c \
		${OUTERINCDIR}outer.h \
		${INCDIR}default.h
	$(CC) ${CFLAGS} -c \
		-DOPTIONS='"${INCDIR}default.h"' \
		-I${OUTERINCDIR} -I${INCDIR} \
		${SWITCHES} \
		${OUTERSRCDIR}outer.c \
		${LIBDIR}jgofs.a -o $@

clean:
#   Wonder if clean should get rid of outer.o as well
	-rm ${SRCDIR}map.o     \
	    ${SRCDIR}remap.o   \
	    ${SRCDIR}coast.o   \
	    ${SRCDIR}grid.o    \
	${TODO}
