#        Copyright 1993, Center for Computer Vision and Visualization,
#        University of Florida.  All rights reserved.
#
# this is a GNUmakefile.  It must be processed with GNU make.
#

TARGET_ARCH=
TOP=../..

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

LOBJS= IntPoint.o DblPoint.o
HEADERS= Point.h IntPoint.h DblPoint.h
DISTFILES = GNUmakefile Point_c.m4 Point.h Point_h.m4 defines.m4

include ${TOP}/src/gnumake.templ

# The above include of gnumake.templ introduces 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 ../../lib/libiac++.a.  libiac++.a is
# your own personal copy of the system libiac++.a that only contains the
# parts you are working on.  ../../librelease.a is a pointer to the
# shared version of /cis/vision/src/iac++/lib/libiac++.a -- rule of thumb:
# NEVER MODIFIY librelease.a -- modify libiac++.a instead.
#
# 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.

REGTESTS= $(basename $(wildcard test???.C))

Tests= ${REGTESTS} test-addition test-concatenation  # test-indexing test-rounding test-relationals 


all: ${TESTS}

M4_FILES= Point_c.m4 Point_h.m4 defines.m4

source:			IntPoint.c IntPoint.h DblPoint.c DblPoint.h

IntPoint.c:	defines.m4 Point_c.m4
	rm -f $@
	${M4} -DINTPOINT defines.m4 Point_c.m4 | cat -s > $@
	chmod a-w $@

IntPoint.h:	defines.m4 Point_h.m4
	rm -f $@
	${M4} -DINTPOINT defines.m4 Point_h.m4 | cat -s > $@
	chmod a-w $@

DblPoint.c:	defines.m4 Point_c.m4
	rm -f $@
	${M4} -DDOUBLEPOINT defines.m4 Point_c.m4 | cat -s > $@
	chmod a-w $@

DblPoint.h:	defines.m4 Point_h.m4
	rm -f $@
	${M4} -DDOUBLEPOINT defines.m4 Point_h.m4 | cat -s > $@
	chmod a-w $@

test%.C: test.h
test%.o: test%.C test.h

IntPoint.o: IntPoint.h ${INCDIR}/ia.h
DblPoint.o: DblPoint.h ${INCDIR}/ia.h

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

test-addition:	test-addition.o lib
	${LINK.cc} -o $@ test-addition.o ${LDLIBS}

test-concatenation:	test-concatenation.o lib
	${LINK.cc} -o $@ test-concatenation.o ${LDLIBS}

test-relationals:	test-relationals.o lib
	${LINK.cc} -o $@ test-relationals.o ${LDLIBS}

test-rounding:	test-rounding.o lib
	${LINK.cc} -o $@ test-rounding.o ${LDLIBS}

test-indexing:	test-indexing.o lib
	${LINK.cc} -o $@ test-indexing.o ${LDLIBS}

create-expected:
	${/bin/csh foreach x (test???)\
                    gnumake \$x ;\
                    \$x >& \$x.expected;\
                    rm \$x\
                   end;
	}

#test:
#	${shell for x in ${REGTESTS}\
#	           do gnumake \$x ;\
#                     \$x >& \$x.out;\
#                     rm $x;\
#                     cmp \$x.out \$x.expected\
#                  done
#	}
                  
clean::
	rm -f ${LOBJS} *.o *~
# dependencies
DblPoint.o : DblPoint.c DblPoint.h ../../include/ia.h Point.h IntPoint.h 
IntPoint.o : IntPoint.c IntPoint.h ../../include/ia.h Point.h 
