##########################################################################
# Copyright 1999 MBARI                                             
##########################################################################
# Summary  : Makefile for Layered Control and Behaviors
# 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) -D_QNX -DUNIX  
CPPFLAGS    = -c $(DEBUG) $(MAP_OUTPUT) $(OPTIMIZE) -D_QNX -DUNIX \
	         $(EXCEPTION_HANDLING)

INCLUDES    = -I.. \
	      -I../utils \
	      -I../framework \
	      -I../DataLog \
	      -I../Navigation \
	      -I../Supervisor \
	      -I../benthos \
	      -I../taskIF \
	      -I../VcsServer \
	      -I../VehicleConfiguration \
	      -I/usr/include           

LDFLAGS	    = -g -lmqueue

LIBPATH	    = /usr/lib:../lib

LIBS        =   ../utils/utils.lib \
		../framework/auvFramework.lib \
		../DataLog/dataLog.lib \
		../taskIF/taskInterfaces.lib \
		../Supervisor/SupervisorOutput.o \
		/usr/local/lib/gctpc/geolib.a



OBJS	    =	AcousticAbort.o \
		ArmTheGulper.o \
		Ascend.o \
		Avoid.o \
		ChirpFin.o \
		DepthEnvelope.o \
		Descend.o \
		DropTheWeight.o \
		FireTheGulper.o \
		Delta_T.o \
		DropWeightSafeMode.o \
		Behavior.o \
		BehaviorFactory.o \
		BuoyLaunch.o \
		Cathx.o \
		CARL.o \
		Circle.o \
		CurrentBuoy.o \
		DownloadData.o \
		DynoCommand.o \
		DynoLayeredControl.o \
		DynoLayeredControlServer.o \
		GetGPS.o \
		HorizontalModeAttribute.o \
                IpsStartProfile.o \
                IpsStopProfile.o \
		kearfottBehavior.o \
		VerticalModeAttribute.o \
		Launch.o \
		LayeredControl.o \
		LayeredControlInput.o \
		LayeredControlOutput.o \
		LayeredControlServer.o \
		LowAltitudeFollowing.o \
		LowAltitudeFollowingOn.o \
		LowAltitudeFollowingOff.o \
		MissionClock.o \
		MissionPlan.o \
		MissionPlanServer.o \
		MissionTimeAttribute.o \
		MissionTimer.o \
		reson.o \
		RotateBuoy.o \
		RotateCarousel.o \
		RotateToLaunchPosition.o \
		SetControlGains.o \
		SetElevator.o \
		SetRudder.o \
		Setpoint.o \
		SetDepth.o \
		StartSurvey.o \
		StartCamera.o \
		StopCamera.o \
		trnBehavior.o \
		Undock.o \
		Waypoint.o \
		WaypointYoyo.o \
		WaypointDepth.o \
		WaypointHoming.o \
		WaypointWall.o WaypointWallLog.o \
		WaypointWallEscape.o \
		WaypointBottom.o WaypointBottomLog.o \
		WaypointTempYoyo.o \
		Yoyo.o \
		Zigzag.o \
		AcousticUpdate.o \
		edgetech.o 


TARGETS =	layeredControl \
		layeredControlServer \
		abortTest \
		bdoc \
		checkplan \
		edgetechTest

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

all:		$(TARGETS)

layeredControl:	_layeredControl.o \
			missionPlan.tab.o \
			missionPlan.yy.o \
			$(OBJS) $(LIBS)
	 	$(LD) $(LDFLAGS) _layeredControl.o \
		    missionPlan.tab.o missionPlan.yy.o $(OBJS) $(LIBS) -o $@

layeredControlServer:	_layeredControlServer.o \
			missionPlan.tab.o \
			missionPlan.yy.o \
			$(OBJS) $(LIBS)
	 	$(LD) $(LDFLAGS) _layeredControlServer.o \
		    missionPlan.tab.o missionPlan.yy.o $(OBJS) $(LIBS) -o $@


bdoc:	bdoc.o missionPlan.tab.o	missionPlan.yy.o \
		    $(OBJS) $(LIBS)

	 	$(LD) $(LDFLAGS) bdoc.o \
		    missionPlan.tab.o missionPlan.yy.o $(OBJS) $(LIBS) -o $@


abortTest:	abortTest.o $(LIBS)

edgetechTest:	edgetechTest.o

parseTest:	parseTest.o missionPlan.tab.o missionPlan.yy.o $(OBJS) $(LIBS)

checkplan:	checkplan.o missionPlan.tab.o missionPlan.yy.o $(OBJS) $(LIBS)

testplan:	testplan.o missionPlan.tab.o missionPlan.yy.o $(OBJS) $(LIBS)


# Stuff generated by Lex-Yacc 
missionPlan.tab.cc:	missionPlan.y
	yacc -b missionPlan -d -v missionPlan.y
	mv missionPlan.tab.c missionPlan.tab.cc

missionPlan.yy.cc: 	missionPlan.l
	lex missionPlan.l
	mv lex.yy.c missionPlan.yy.cc

workSite.tab.cc:	workSite.y
	yacc -b workSite -d -v workSite.y
	mv workSite.tab.c workSite.tab.cc

workSite.yy.cc: 	workSite.l
	lex workSite.l
	mv lex.yy.c workSite.yy.cc

parseAttributes.tab.cc:	parseAttributes.y
	yacc -b parseAttributes -d -v parseAttributes.y
	mv parseAttributes.tab.c parseAttributes.tab.cc

attributes.yy.cc:	attributes.l
	lex attributes.l
	mv lex.yy.c attributes.yy.cc


install:	$(TARGETS)
		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

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









