##########################################################################
# Copyright 2018 MBARI                                             
##########################################################################
# Summary  : Makefile for MbTrnRecv
#            MbtrnRecv sets up to receive packets from a Reson Data
#            Generator, receives packets, unpacks the data, and stores
#            the latest data in shared memory output.
# Filename : Makefile
# Author   : Rich Henthorn
# Project  : 
# Version  : Version 1.0
# Created  : 01/30/2018
# Archived :
##########################################################################
# Modification History:
#
##########################################################################

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

AUV_BIN_DIR = ../bin

DEBUG 	    = -g
EXCEPTION_HANDLING = -WC,-xs

## OPTIMIZE = -4 -Os
OPTIMIZE = 

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

## Need the -WC,-ei option (or -Wc,-ei), else SharedData::write()
## will SIGSEG. Apparently, autonomy.make was including those options.
## -ei == use an int for all enumerated types. 
##
CFLAGS	   = -c $(DEBUG) $(MAP_OUTPUT) $(OPTIMIZE) -D_QNX -DUNIX -Wc,-ei
CPPFLAGS    = -c $(DEBUG) $(MAP_OUTPUT) $(OPTIMIZE) -D_QNX -DUNIX -WC,-ei \
	         $(EXCEPTION_HANDLING)

INCLUDES    = 	-I.  \
	        -I.. \
	      	-I../utils \
	      	-I../framework  \
		-I../LayeredControl \
		-I../taskIF \
		-I../Simulator \
		-I../DataLog \
		-I../system \
     	-I/usr/include \
		-I../terrainNav \
      -I../G2TerrainNav \
      -I../newmat \
      -I/usr/local/include
# Added last 4 paths above to include TRN client
# 

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

#LIBS        =   ../utils/utils.lib \
#		../framework/auvFramework.lib \
#		../DataLog/dataLog.lib \
#		../taskIF/taskInterfaces.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	    =	MbTrnRecv.o MbTrnRecvOutput.o MbTrnRecvServer.o MbTrnRecvLog.o mbtrn_types.o \
				MbTrnUpd8.o MbTrnUpd8Output.o MbTrnUpd8Server.o MbTrnUpd8Log.o

TARGETS =	mbTrnRecv mbTrnRecvServer mbTrnRecvTest mbTrnRecvTest2 mbtrn_sim \
				mbTrnUpd8 mbTrnUpd8Server mbTrnUpd8Test mbupd_sim


all:		$(TARGETS)

mbTrnRecv:	_mbTrnRecv.o $(OBJS) $(LIBS)
	$(LD) $(LDFLAGS) _mbTrnRecv.o $(OBJS) $(LIBS) -o $@

mbTrnRecvServer:	_mbTrnRecvServer.o $(OBJS) $(LIBS)
	$(LD) $(LDFLAGS) _mbTrnRecvServer.o $(OBJS) $(LIBS) -o $@

mbTrnRecvTest:	_mbTrnRecvTest.o $(OBJS) $(LIBS)
	$(LD) $(LDFLAGS) _mbTrnRecvTest.o $(OBJS) $(LIBS) -o $@

mbTrnRecvTest2:	_mbTrnRecvTest2.o $(OBJS) $(LIBS)
	$(LD) $(LDFLAGS) _mbTrnRecvTest2.o $(OBJS) $(LIBS) -o $@

mbtrn_sim:	mbtrn_sim.o mbtrn_types.o $(LIBS)
	$(LD) $(LDFLAGS) mbtrn_sim.o mbtrn_types.o $(LIBS) -o $@

mbupd_sim:	mbupd_sim.o $(LIBS)
	$(LD) $(LDFLAGS) mbupd_sim.o $(LIBS) -o $@

mbTrnUpd8:	_mbTrnUpd8.o $(OBJS) $(LIBS)
	$(LD) $(LDFLAGS) _mbTrnUpd8.o $(OBJS) $(LIBS) -o $@

mbTrnUpd8Server:	_mbTrnUpd8Server.o $(OBJS) $(LIBS)
	$(LD) $(LDFLAGS) _mbTrnUpd8Server.o $(OBJS) $(LIBS) -o $@

mbTrnUpd8Test:	_mbTrnUpd8Test.o $(OBJS) $(LIBS)
	$(LD) $(LDFLAGS) _mbTrnUpd8Test.o $(OBJS) $(LIBS) -o $@

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 $@

%.d: %.cc
	    @echo Generating dependencies for $?
	    @$(DEPEND_TOOL) $(INCLUDES) $? -f $@ 

%.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

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









# DO NOT DELETE THIS LINE -- make depend depends on it.
