# 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/build-env has been executed first in context of
#          this process (ie, source jgofs_root/build-env)
#       2) jgofs.a library has already been built

#  30 Aug 04.  WJS
#	JDBFUNCDEFNS_H_DEPENDS
#  17 Jul 04.  WJS
#	Return to the more precise distinction between compilation and linking
#	  courtesy of gcc's preference.  Libraries (and dependencies on
#	  libraries) belong in link commands (and image dependencies), not
#	  compilation commands (and object dependencies)
#	Mods to take advantage of new build stuff (add ${CONFIG_FILE}, etc
#	  dependencies; build optdefgb, etc).  CONFIG_FILE (eg, build-env)
#	  is used to force builds in addition to its natural dependency role
#	Mod to use outer_make_macros.include
#  28 Apr 04.  WJS
#	Rework OUTER_COMPILE symbol defn
#	Get outer.h from OUTERINCDIR, & define that to OUTERSRCDIR
#  18 Feb 04.  WJS
#	"standardize" - outer from src/methods assumed to have .brev;
#	  lots of stuff assumed in jgofs.a, etc
#   4 Dec 03.  WJS
#	Add core.h to dependency list
#   2 Oct 97.  WJS
#       Fix typo in -I switch.  Add -I to look in OUTERSRCDIR

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

#   Set to place w/no .h files.  To use, define location when make file invoked
#   This location searched first.  NB: it's not in any dependencies
TESTINCDIR = /
#   where lib .h files are (or other .h files that are NOT in this distribution)
MASTERINCDIR = ../include
#   where outer.h is
OUTERINCDIR = ${OUTERSRCDIR}
#   local .h files expected in SRCDIR

METHODNAME = stats
METHOD = ${METHBINDIR}/${OPT}${METHODNAME}

I_LIST = -I${TESTINCDIR} -I${OUTERINCDIR} -I${SRCDIR} -I${MASTERINCDIR}

#	OPTIONS, INNEROPTIONS macros needed by outer_make_macro.include
OPTIONS = ${MASTERINCDIR}/default.h
INNEROPTIONS = ${MASTERINCDIR}/inner.h

PER_METHOD_OUTER = ${SRCDIR}/outer_${METHODNAME}
OUTER_SOURCE = ${PER_METHOD_OUTER}.c
OUTER_OBJECT = ${PER_METHOD_OUTER}.o

#	Non-outer files which need to be compiled in order to build stats
OBJ =	${SRCDIR}/stats.c 

#       libraries required
LIB_LIST = ${LIBDIR}/jgofs.a
SYSLIB_LIST = -lm

#       Method-specific compilation flags
METHOD_CFLAGS = -g

#       Inner compilation switches
INNER_SWITCHES = -DOPTIONS='"${OPTIONS}"' \
           -DINNEROPTIONS='"${INNEROPTIONS}"'

include ${MASTERINCDIR}/h_file_dependency_macros.include
include ${OUTERSRCDIR}/outer_make_macros.include

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

all: ${METHOD} ${CONFIG_FILE}

${METHOD}:${OBJ} ${OUTER_OBJECT} \
	  ${LIB_LIST} ${OUTER_LIB_LIST} \
	  ${UTILS_H_DEPENDS} ${PATH_INFO_H_DEPENDS} ${JDBFUNCDEFNS_H_DEPENDS} \
	  ${OPTIONS} ${INNEROPTIONS} \
	  ${CONFIG_FILE}
	@- test -d ${METHBINDIR} || mkdir ${METHBINDIR}
	$(CC) \
		${METHOD_CFLAGS} ${ADDL_CFLAGS} \
		${INNER_SWITCHES} ${ADDL_SWITCHES} \
		${I_LIST} \
		${OBJ} ${OUTER_OBJECT} ${OUTER_LIB_LIST} \
		${LIB_LIST} ${SYSLIB_LIST} \
	-o $@

OUTER_COMPILE =	${OUTER_COMPILE_SWITCHES} \
		-DUSE_DOUBLE \
		-c ${OUTER_SOURCE} \
		-o ${OUTER_OBJECT}

${OUTER_OBJECT}:${OUTER_SOURCE} \
		${OUTER_H_DEPENDS} \
		${CONFIG_FILE}
	$(CC) ${OUTER_COMPILE}

${OUTER_SOURCE}:${OUTERSRCDIR}/outer.c ${CONFIG_FILE}
	cp ${OUTERSRCDIR}/outer.c ${OUTER_SOURCE}
