##########################################################################
# Copyright 1999 MBARI                                             
##########################################################################
# Summary  : Makefile for Drop Weight Driver
# Filename : Makefile
# Author   : Andrew Pearce
# Project  : 
# Version  : Version 1.0
# Created  : 12/06/99
# Modified : 12/06/99
# Archived :
##########################################################################
# Modification History:
# $Header$
#
##########################################################################

CC	    = cc
CCPP	    = cc
LD	    = cc
AR 	    = wlib
DEPEND_TOOL = makedepend

DEBUG 	    = -g
EXCEPTION_HANDLING = -WC,-xs

## OPTIMIZE = -4 -Os
OPTIMIZE = 

## MAP_OUTPUT = -S -ms -M
MAP_OUTPUT =

AUV_BIN_DIR = ../bin

CFLAGS	    = -c $(DEBUG) $(MAP_OUTPUT) $(OPTIMIZE) -WC,-ei -DAUTONOMY -Wc,-ei -D_QNX -DUNIX  
CPPFLAGS    = -c $(DEBUG) $(MAP_OUTPUT) $(OPTIMIZE) -WC,-ei -DAUTONOMY -Wc,-ei -D_QNX -DUNIX \
	         $(EXCEPTION_HANDLING)

INCLUDES    = -I.  \
	      -I.. \
	      -I../utils \
	      -I../framework \
	      -I../taskIF \
	      -I../DataLog \
	      -I../LayeredControl \
	      -I../terrainNav \
	      -I../G2TerrainNav \
	      -I../MbTrnRecv \
	      -I/usr/include \
	      -I/usr/local/include \
              -I../stlport \
	      -I../newmat
#	      -I/usr/watcom/10.6/usr/include \

LDFLAGS	    = -g -lmqueue
#LIBPATH	    = /usr/lib:../lib

LIBS        =   ../utils/utils.lib \
		../taskIF/taskInterfaces.lib \
		../DataLog/dataLog.lib \
		../framework/auvFramework.lib \
		../terrainNav/terrainNav.lib \
		/usr/local/lib/libnetcdf.a \
		../newmat/libnewmat.a \
		/usr/local/lib/gctpc/geolib.a


OBJS	    =	TerrainAidDriver.o \
		TerrainAidLog.o \
		TerrainAidOutput.o \
		TerrainAidServer.o \
		Replay.o

SAOBJS	    =	sa-TerrainAidDriver.o \
		TerrainAidLog.o \
		TerrainAidOutput.o

TARGETS =	terrainAid.lib terrainAidDriver sa-terrainAidDriver \
		terrainAidServer \
		test_client \
		mbTrnClient \
		trn_replay \
		terrainAidTest \
		logToMbTrn

-include ../autonomy.make # required for autonomy code

all:		$(OBJS) $(TARGETS)

terrainAid.lib: 	$(OBJS)
		$(AR) terrainAid.lib +- $(OBJS)

# ^$  ==  list prerequisites
# Example, $^  ==  _terrainAidDriver.o $(OBJS) $(LIBS)

terrainAidDriver:  _terrainAidDriver.o $(OBJS) $(LIBS) 
	$(LD) $(LDFLAGS) $^ -L/usr/local/lib -o $@

sa-terrainAidDriver:  _terrainAidDriver.o $(SAOBJS) $(LIBS) 
	$(LD) $(LDFLAGS) $^ -L/usr/local/lib -o $@

#TerrainNav.o:	TerrainNav.cpp
#	true
#TerrainMap.o:	TerrainMap.cpp
#	true

terrainAidServer:  _terrainAidServer.o $(LIBS) $(OBJS)
	$(LD) $(LDFLAGS) $^ -o $@

test_client:  test_client.o $(LIBS) $(OBJS) 
	$(LD) $(LDFLAGS) $^ -o $@

mbTrnClient:  mbTrnClient.o $(LIBS) $(OBJS) 
	$(LD) $(LDFLAGS) $^ -o $@

trn_replay:  trn_replay.o $(LIBS) $(OBJS) 
	$(LD) $(LDFLAGS) $^ -o $@

terrainAidTest:  _terrainAidTest.o $(LIBS) $(OBJS) 
	$(LD) $(LDFLAGS) $^ -o $@

logToMbTrn:	logToMbTrn.o $(LIBS)

install:
		cp -fnv $(TARGETS)	$(AUV_BIN_DIR)/. 



##########################################################################
# Do not modify anything below this line unless absolutely necessary

.SUFFIXES:
.SUFFIXES:	.o .c .cc .d .idl

%.d: %.c
	    @echo Generating dependencies for $?
	    @$(DEPEND_TOOL) $(INCLUDES) $? -f $@.tmp
	    @mv $@.tmp $@
%.d: %.cc
	    @echo Generating dependencies for $?
	    @$(DEPEND_TOOL) $(INCLUDES) $? -f $@.tmp
	    @mv $@.tmp $@
%.o: %.c 
	    $(CC) $(CFLAGS) $(INCLUDES) $< -o $@	
	    @echo
%.o: %.cc
	    $(CCPP) $(CPPFLAGS) $(INCLUDES) $< -o $@
	    @echo

DEST	    = .

MAKEFILE    = Makefile

include       $(OBJS:.o=.d)

depend:	

clean:
	rm -f core *.o $(OBJS:.o=.d) *.lib *.yy *.tab.* $(TARGETS)

update:
	cvs update $(CC_SRCS) $MAKEFILE

commit:
	cvs commit $(CC_SRCS) $MAKEFILE

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