#
#  NOTE: This makefile is designed to place object files and libraries into a
#  platform specific subdirectory.  When adding new files, one must add the
#  file to the "OBJS" list _and_ add a new target (e.g. ${BUILDDIR}/MyNewFile.o)
#  at the bottom of this makefile (see below).  RWC 8/19/02
#
#  ** WARNING **: Dependencies are currently incomplete with regard to headers.
#  To avert problems when modifying header files, force a complete rebuild 
#  by first removing all existing objects files (make clean). RWC 8/19/02
#

include ../make.toplevel

IMINER_LIBRARY=libimcsrc.so
IMINER_BINARY=imcsrc.bin

OBJS = 	${BUILDDIR}/IMCSRCGenerator.o     ${BUILDDIR}/IMKMeansCluster.o \
	${BUILDDIR}/IMLinearRegression.o  ${BUILDDIR}/IMLogisticRegression.o \
	${BUILDDIR}/IMObjects.o           ${BUILDDIR}/main.o

all:	
	../unixdev `pwd` make platform.all

platform.all: platform.update

update:
	../unixdev `pwd` make platform.update

#
# NOTE:  This component is unfinished.  Not sure what the build should do.
#        These targets are illustrative only, and must be reconfigured when
#        the component is reworked. RWC 8/20/02
#
platform.update: platform.dir platform.library platform.binary

platform.binary: $(OBJS)
	$(CXX) -o ${BUILDDIR}/$(IMINER_BINARY) $(OBJS)
	$(STRIP_BIN) ${BUILDDIR}/$(IMINER_LIBRARY).$(REV_NO)

platform.library: $(OBJS)
	$(CXXSHLINK) $(SHNAME)$(IMINER_LIBRARY).$(REV_NO_MAJ) -o ${BUILDDIR}/$(IMINER_LIBRARY).$(REV_NO) $(OBJS)
	$(STRIP_BIN) ${BUILDDIR}/$(IMINER_LIBRARY).$(REV_NO)

clean:
	../unixdev `pwd` make platform.clean

platform.clean:
	rm -f ${UNIXOS}/release/*.o
	rm -f ${UNIXOS}/debug/*.o

platform.dir:
	test -d ${UNIXOS} || mkdir ${UNIXOS}
	test -d ${BUILDDIR} || mkdir ${BUILDDIR}

debug:
	DBG_BUILD=true;export DBG_BUILD;../unixdev `pwd` make platform.debug

platform.debug: platform.dir platform.debug.library platform.debug.binary

platform.debug.binary: $(OBJS)
	$(CXX) -o ${BUILDDIR}/$(IMINER_BINARY) $(OBJS)
	
platform.debug.library: $(OBJS)
	$(CXXSHLINK) $(SHNAME)$(IMINER_LIBRARY).$(REV_NO_MAJ) -o ${BUILDDIR}/$(IMINER_LIBRARY).$(REV_NO) $(OBJS)

install: 
	../unixdev `pwd` make platform.install

install.debug:
	DBG_BUILD=true;export DBG_BUILD;../unixdev `pwd` make platform.install

platform.install:
	test -d ${LIB_DIR} || exit 1
	test -f ${BUILDDIR}/$(IMINER_LIBRARY).$(REV_NO) || exit 1
	cp ${BUILDDIR}/$(IMINER_LIBRARY).$(REV_NO) ${LIB_DIR}
	test -f ${LIB_DIR}/$(IMINER_LIBRARY) || ln -s $(IMINER_LIBRARY).$(REV_NO) ${LIB_DIR}/$(IMINER_LIBRARY)
	test -f ${LIB_DIR}/$(IMINER_LIBRARY).$(REV_NO_MAJ) || ln -s $(IMINER_LIBRARY).$(REV_NO) ${LIB_DIR}/$(IMINER_LIBRARY).$(REV_NO_MAJ)

#-------- OTHER TARGETS TBD ------------

release:
check:
test:
looptest:

#--------- OBJECT DEPENDENCIES ----------

${BUILDDIR}/IMCSRCGenerator.o: IMCSRCGenerator.cxx
	$(CXX) -c $? -o $@

${BUILDDIR}/IMKMeansCluster.o: IMKMeansCluster.c
	$(CC) -c $? -o $@

${BUILDDIR}/IMLinearRegression.o: IMLinearRegression.c
	$(CC) -c $? -o $@

${BUILDDIR}/IMLogisticRegression.o: IMLogisticRegression.c
	$(CC) -c $? -o $@

${BUILDDIR}/IMObjects.o: IMObjects.c
	$(CC) -c $? -o $@

${BUILDDIR}/main.o: main.cxx
	$(CXX) -c $? -o $@
