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 =

CFLAGS	    = -c $(DEBUG) $(MAP_OUTPUT) $(OPTIMIZE) -D_QNX -DUNIX  
CPPFLAGS    = -c $(DEBUG) $(MAP_OUTPUT) $(OPTIMIZE) -D_QNX -DUNIX \
	         $(EXCEPTION_HANDLING)

INCLUDES    = -I.  \
	      -I../ \
	      -I../utils \
	      -I../framework \
              -I../stlport \
	      -I../system \
	      -I../taskIF \
	      -I../DataLog \
	      -I../Simulator \
	      -I/usr/include           

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

LIBS        =   ../utils/utils.lib \
		../DataLog/dataLog.lib \
		../taskIF/taskInterfaces.lib \
		../framework/auvFramework.lib

OBJS	=	Ack.o \
		ModemMessage.o \
		MMRecipient.o \
		MMAhrs.o \
		MMActiveBehavior.o \
		MMAlarm.o \
		MMBehavior.o \
		MMDepthSensor.o \
		MMDriver.o \
		MMDropWeight.o \
		MMDvl.o \
		MMHoming.o \
		MMGps.o \
		MMMultiLeica.o \
		MMNavigation.o \
		MMTailcone.o \
		MMOas.o \
		MMSvs.o \
		MMPower.o \
		MMString.o \
		MMServer.o \
		MMNmea.o \
		MMRtcm.o \
		MMUtils.o \
		MMUSBL.o \
		MMMissionInfo.o \
		MMMissionName.o \
		MMLN250.o \
		MMSeacat.o \
		MMSeabirdSBE25.o \
		MMSas21.o \
		MMBluefinBattery.o \
		MMAgentRequest.o \
		MMDynamicControl.o \
		MMDeviceInfo.o \
		MMPhins.o \
		MMEnvironmental.o \
		MMFluorometer.o \
		Modem.o \
		ModemBroker.o \
		ModemFork.o \
		ModemSerial.o \
		ModemSocket.o \
		RemoteAgentCommand.o \
		RemoteAgentDriver.o \
		RemoteAgentOutput.o \
		RemoteAgentServer.o

TARGETS	=  	remoteAgentServer \
		remoteAgentDriver \
		poinker
#		remoteLog \
#		packer \
#		restartSupervisor

TARGET_LIBS =	remoteAgent.lib 

-include ../autonomy.make # this file contains the general
                       # modifications we want to apply to
                       # all the modules 


all:		$(TARGETS) $(TARGET_LIBS)
#all:		 remoteAgent.lib remoteAgentDriver remoteAgentServer

%: _%.o $(LIBS)
	$(LD) $(LDFLAGS) -g  $(^F) \
	 -o $(OUTDIR)/$(@F)

#remoteLog:  _remoteLog.o RemoteLog.o
#	$(LD) $(LDFLAGS) $(^F) $(LIBS) -o $(OUTDIR)/$(@F)

remoteAgent.lib: $(OBJS) 
	   $(AR) remoteAgent.lib -+ $(^F)

testModem:	_.o $(OBJS)
	$(LD) $(LDFLAGS) $(^F) $(LIBS) -o $(@F)

remoteAgentDriver: _remoteAgentDriver.o remoteAgent.lib
	$(LD) $(LDFLAGS) $(^F) $(LIBS) -o $(@F)

remoteAgentServer: _remoteAgentServer.o remoteAgent.lib
	$(LD) $(LDFLAGS) $(^F) $(LIBS) -o $(@F)

poinker: _poinker.o
	$(LD) $(LDFLAGS) $(^F) $(LIBS) -o $(@F)


#	cp packer $(OUTDIR)/packer
#	chmod 777 $(OUTDIR)/packer
#	cp restartSupervisor $(OUTDIR)/restartSupervisor
#	chmod 777 $(OUTDIR)/restartSupervisor


#ifeq "$(BUILDTYPE)" "debug"
#RemoteAgentDriver.o: RemoteAgentDriver.cc
#	@echo "Compiling $< (special compile line)"
#	$(CC) $(CPPFLAGS) $(STANDARD_INCLUDES) $(INCLUDES) -S -ms -M RemoteAgentDriver.cc -o RemoteAgentDriver.o
#	@mv RemoteAgentDriver.o $(OUTDIR)/
#	@rm -f remoteAgentDriver.S
#	@echo
#endif

##########################################################################
# 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 *.err $(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.

