#
# this is a GNUmakefile.  It must be processed with GNU make.
#

#TARGET_ARCH=
TOP= /cis/homes/thoth/work/iac++

# you should define the make variables LOBJS and HEADERS before the
# include directive.  LOBJS is a list of Library OBJects that belong
# in libiac++.a.  HEADERS is a list of public header files that belong
# in iac++/include.

#LOBJS= ValueSet.o
#HEADERS= ValueSet.h
#REGTESTS= ${basename ${wildcard test2??.c}}

#include /cis/vision/src/iac++/src/gnumake.templ

#all: ${REGTESTS}

#WORKLIB= ${TOP}/lib/libiacc++.a

#lib: ${LOBJS}
#	ar r ${WORKLIB} ${LOBJS}
#	ranlib ${WORKLIB}
#	touch lib

IACCDIR = /cis/research/iac++/new

IACCINCLUDES = -I${IACCDIR}/include

CCC=/local/bin/CC -pg
INCLUDEFLAGS= -I. ${IACCINCLUDES}
CDEBUGFLAGS=-g
CCFLAGS= ${CDEBUGFLAGS} ${INCLUDEFLAGS}
LDDIRS= -L${IACCDIR}/lib
LDLIBS= -liac++ -lcomplex -lm /usr/lib/debug/malloc.o /usr/lib/debug/mallocmap.o
LDFLAGS= ${LDDIRS} # ${LDLIBS}

COMPILE.cc=$(CCC) $(CCFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
LINK.cc=$(CCC) $(CCFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)

# Testing:
#LDLIBS= -L${TOP}/lib/ -liac++ -lcomplex -lm /usr/lib/debug/malloc.o /usr/lib/debug/mallocmap.o
#INCS= -I${TOP}/include

#test%.c: test.h
#	${LINK.cc} -o $@ $< ${LDLIBS}

test%: test%.o 
	${LINK.cc} -o $@ $< ${LDLIBS}

test%.o: test%.c test.h
	${COMPILE.cc} ${OUTPUT_OPTION} $<

create:
	for x in test???.c ; \
		do \
			y=`basename $$x .c` ;    \
			gnumake $$y ;            \
			$$y 1>$$y.expected 2>&1; \
			rm -f $$y ;              \
		done

test:
	for x in test???.c; \
		do \
			y=`basename $$x .c` ;     \
			gnumake $$y ;             \
			$$y 1>$$y.out 2>&1;       \
			rm -f $$y ;		  \
			if test -f $$y.out;	\
			then diff $$y.expected $$y.out 1> $$y.diff 2>&1; \
				if test -s $$y.diff;	\
				then echo "DIFFs on TEST $$y" ;	\
				else rm $$y.diff	;\
				fi;	\
			fi;	\
		done

compare:
	for x in test???.expected; \
	do \
		y=`basename $$x .expected`; \
		cmp $$x $$y.out;             \
	done

diffs:
	for x in test???.diff1; \
	do \
		echo $$x;	\
		more $$x;             \
	done

# sample program target:
# test1 only needs test1.o and the library.  The defaults will
# build this without a rule
#
#all: test1 test2
#
#T2OBJS= test2.o frob.o
#test2: ${T2OBJS}
#	${CCC} -o $@ ${CCFLAGS} ${CPPFLAGS} ${LDFLAGS} ${T2OBJS} ${LDLIBS}

# the gnumake.templ has a few targets that everyone will use
#
# all: install the header files, build the LOBJS and add them
# to the library
#
# headers-force: force the header files to be copied into include
#
# headers: used by all to install the header files when changed
#
# lib: used by all to add LOBJS to the libwork.a.  libwork.a is
# your own personal copy of the libiac++.a that only contains the
# parts you are working on.
#
# reallib: this puts your LOBJS into the real libiac++ so that
# everyone else can use them.  Make sure they work first.
#
# clean:: removes all .o and ~ files.  You may define additional
# clean targets to remove other files that you may have generated.
#
# spotless:: the same as clean, but more so.  It should remove
# binaries.  You should define additional spotless targets that
# remove your test binaries and other files that aren't deleted
# by clean.



