################################################################################
# Top level makefile
#
# Copyright (c) 2007 MBARI
# MBARI Proprietary Information.  All Rights Reserved
#
# Modified heavily from original Makefile auto-generated by
# the Eclipse Managed Build
################################################################################

#-include ../makefile.init
OLDPATH:=$(PATH)
PATH=$(OLDPATH):~/bin/

# Put this up high to ensure we can set the default target
defaulttarget: all
ifndef MAKECMDGOALS
MAKECMDGOALS = all
endif

XSD_DEST_DIR=/mbari/LRAUV/xsd

RM := rm -rf

# Point to the "root" of the LRAUV project tree.
# This is a really dumb way to do this.  It only works if you call Make
# from the (workspace)/Build level.
PROJECTDIR = $(shell realpath $(shell pwd)/..)

# Someday this will be a much more robust system for enabling and disabling
# "sim" builds.
CFLAGS += -I"$(PROJECTDIR)"
# CFLAGS  += -Werror
FPICFLAG = -fPIC
# Most verbose debugging: -O0 -g3
OPT_DBG_FLAGS = -O -g  # opt/debug flags are overridden for lpc3250 (-Os -g0)
OPT_MIN_DBG_FLAGS = -Os -g1
OPT_MAX_DBG_FLAGS = -O0 -g3 -fbuiltin
EXPORT_OPT = -Wl,-export-dynamic
SHARED_OPT = -shared
#STATIC_OPT = -static
#CFLAGS += $(SIM_CFLAGS)

#CFLAGS += $(OPT_MAX_DBG_FLAGS)
#CXXFLAGS += $(OPT_MAX_DBG_FLAGS)

LIBS =


#
USER_LIBS =

USER_INC =

# LCM type difinitions
LCM_TYPE_INC=-I"../lrauv-lcmtypes/include"
CFLAGS += $(LCM_TYPE_INC)

# Goby stuff, goes before includes
INCLUDE_GOBY=
ifeq ($(findstring goby,$(MAKECMDGOALS)),goby)
INCLUDE_GOBY=yes
endif
ifeq ($(findstring clean,$(MAKECMDGOALS)),clean)
INCLUDE_GOBY=yes
endif

# Gazebo simulation, goes before includes
INCLUDE_GAZEBO=
ifeq ($(findstring clean,$(MAKECMDGOALS)),clean)
INCLUDE_GAZEBO=yes
endif
ifeq ($(findstring gazebo,$(MAKECMDGOALS)),gazebo)
INCLUDE_GAZEBO=yes
endif

# All of the sources participating in the build are defined here
-include sources.mk
-include subdir.mk

-include Lib/aes/subdir.mk
-include Lib/bsdiff/subdir.mk
-include Lib/bzip2/subdir.mk
-include Lib/cJSON/subdir.mk
-include Lib/gzstream/subdir.mk
-include Lib/geotrans/subdir.mk
-include Lib/libmagdev/subdir.mk
-include Lib/lzma/subdir.mk
-include Lib/netcdf/subdir.mk
-include Lib/opencpn/subdir.mk
-include Lib/tinyxml/subdir.mk
-include Lib/zlib/subdir.mk
-include Lib/devmem2/subdir.mk

# Generate LCM type headers
-include lrauv-lcmtypes/subdir.mk

# Need to include units early, as Units.lua used by other modules
-include Source/units/subdir.mk
-include Source/subdir.mk

-include Source/component/subdir.mk
-include Source/data/subdir.mk
-include Source/io/subdir.mk
-include Source/logger/subdir.mk
-include Source/lua/subdir.mk
-include Source/missionScript/subdir.mk
-include Source/module/subdir.mk
-include Source/process/subdir.mk
-include Source/scripting/subdir.mk
-include Source/supervisor/subdir.mk
-include Source/utils/subdir.mk
-include Source/xml/subdir.mk

-include Source/bitModule/subdir.mk
-include Source/controlModule/subdir.mk
-include Source/derivationModule/subdir.mk
-include Source/dockModule/subdir.mk
-include Source/estimationModule/subdir.mk
-include Source/navigationModule/subdir.mk
-include Source/guidanceModule/subdir.mk
-include Source/sampleModule/subdir.mk
-include Source/scienceModule/subdir.mk
-include Source/sensorModule/subdir.mk
-include Source/servoModule/subdir.mk
-include Source/simulatorModule/subdir.mk
ifdef INCLUDE_GAZEBO
-include Source/simulatorModule/gzTests/subdir.mk
endif
-include Source/triggerModule/subdir.mk

-include objects.mk

# Default Host Build
AR=ar
CXX=g++ -std=c++98
CC=gcc
RANLIB=ranlib
LUAEX=lua
ifeq "$(shell which lua5.1 > /dev/null; echo $$?)" "0"
LUAEX=lua5.1
endif
echo "lua executable: $LUAEX"

# Set the HDF5_SERIAL environment variable
# to enable compilation using libhdf5_serial.
# This is currently needed only for Ubuntu 16.04
#   HDF5_SERIAL=1 make
# The following line sets it automatically:
ifneq ("","$(wildcard /usr/lib/x86_64-linux-gnu/hdf5/serial)")
HDF5_SERIAL=1
endif

ifdef HDF5_SERIAL
LIBHDF5_SERIAL = -L"/usr/lib/x86_64-linux-gnu/hdf5/serial" -lhdf5_serial
else
LIBHDF5_SERIAL =
endif

ifeq ($(findstring all,$(MAKECMDGOALS)),all)
CFLAGS  += -D__FASTSIM
LUACMDGOALS = all
HDF5_NETCDF_LIB=-lhdf5 -lhdf5_hl $(LIBHDF5_SERIAL) -lnetcdf
endif
ifeq ($(findstring unserialize,$(MAKECMDGOALS)),unserialize)
HDF5_NETCDF_LIB=-lhdf5 -lhdf5_hl $(LIBHDF5_SERIAL) -lnetcdf
endif

# Experimental Build
ifeq ($(findstring experimental,$(MAKECMDGOALS)),experimental)
-include Source/experimentalModule/subdir.mk
endif

# 4.1 Build
ifeq ($(findstring 4.1,$(MAKECMDGOALS)),4.1)
CXX=g++-4.1
CC=gcc-4.1
CFLAGS  += -D__FASTSIM
LUACMDGOALS = 4.1
endif

# 4.2 Build
ifeq ($(findstring 4.2,$(MAKECMDGOALS)),4.2)
CXX=g++-4.2
CC=gcc-4.2
CFLAGS  += -D__FASTSIM
LUACMDGOALS = 4.2
endif

# Mac OS-X Build
ifeq ($(findstring macosx,$(MAKECMDGOALS)),macosx)
OLDPATH:=$(PATH)
PATH=$(OLDPATH):/sw/bin/
EXPORT_OPT =
SHARED_OPT += -bundle -bundle_loader ../bin/LRAUV
STATIC_OPT =
FPICFLAG += -fno-common
CFLAGS  += -D__FASTSIM -D_DARWIN_C_SOURCE
LUACMDGOALS = macosx
endif

# LPC3SIM Build
ifeq ($(findstring lpc3sim,$(MAKECMDGOALS)),lpc3sim)
OLDPATH:=$(PATH)
PATH=$(OLDPATH):/usr/local/arm/gnu/release-3.4.0-vfp/bin:/usr/local/arm/uboot/u-boot-1.1.1/tools
AR=ar
CXX=g++
CC=gcc
RANLIB=ranlib
CFLAGS  += -D__FASTSIM
LUACMDGOALS = lpc3sim
HDF5_NETCDF_LIB=
endif

# LPC3180 Build
ifeq ($(findstring lpc3180,$(MAKECMDGOALS)),lpc3180)
TARGET = LPC3180_TARGET
# Needed for building lpc3180 target within eclipse
OLDPATH:=$(PATH)
PATH=$(OLDPATH):/usr/local/arm/gnu/release-3.4.0-vfp/bin:/usr/local/arm/uboot/u-boot-1.1.1/tools
AR=arm-linux-ar
CXX=arm-linux-g++
CC=arm-linux-gcc
CROSS=arm-linux
RANLIB=arm-linux-ranlib
LUACMDGOALS = lpc3180
HDF5_NETCDF_LIB=
endif

# LPC3250 Build
ifeq ($(findstring lpc3250,$(MAKECMDGOALS)),lpc3250)
TARGET = LPC3180_TARGET
OLDPATH:=$(PATH)
PATH=$(OLDPATH):/opt/nxp/gcc-4.3.2-glibc-2.7/bin/
AR=arm-vfp-linux-gnu-ar
CXX=arm-vfp-linux-gnu-g++
CC=arm-vfp-linux-gnu-gcc
CROSS=arm-vfp-linux-gnu
RANLIB=arm-vfp-linux-gnu-ranlib
FPICFLAG =
LUACMDGOALS = lpc3250
HDF5_NETCDF_LIB=
LIBS += \
-L"../Lib/lpc3250_bsp/usr/lib/" \
-L"${LRAUVROOT}/usr/lib/" \
`pkg-config --libs lcm`
INCS += \
-I"../Lib/lpc3250_bsp/usr/include/" \
-I"${LRAUVROOT}/usr/include/"
CFLAGS += -I"/mbari/LRAUV/Tools/linuxi64/cross-compile-tools/include"
# Override optimization/debug flags
OPT_DBG_FLAGS = -Os -g0
else
LIBS += \
-L"/usr/lib/"
INCS += \
-I"/usr/include/" -I"/usr/local/include/"
endif

# LPC3250 Build

CFLAGS  += -D__$(TARGET)

ifneq ($(MAKECMDGOALS),clean)
ifneq ($(strip $(C_DEPS)),)
-include $(C_DEPS)
endif
ifneq ($(strip $(CXX_DEPS)),)
-include $(CXX_DEPS)
endif
ifneq ($(strip $(CPP_DEPS)),)
-include $(CPP_DEPS)
endif
ifneq ($(strip $(CC_DEPS)),)
-include $(CC_DEPS)
endif
ifneq ($(strip $(C_UPPER_DEPS)),)
-include $(C_UPPER_DEPS)
endif
ifneq ($(strip $(C++_DEPS)),)
-include $(C++_DEPS)
endif
endif

ifdef INCLUDE_GAZEBO
CXX=g++ -std=c++1z
LUACMDGOALS = all
HDF5_NETCDF_LIB=-lhdf5 -lhdf5_hl $(LIBHDF5_SERIAL) -lnetcdf
# Override optimization/debug flags
OPT_DBG_FLAGS = -Os -g0
# TODO: Currently hardcoding relative protobuf path to external Gazebo plugin
# workspace in an assumed location true within docker_gz Dockerfile
CFLAGS  += \
-D__FASTSIM \
-D__GAZEBO \
`pkg-config --cflags-only-I gz-sim7` \
`pkg-config --cflags-only-I gz-transport12` \
`pkg-config --cflags-only-I gz-math7` \
`pkg-config --cflags-only-I gz-msgs9` \
`pkg-config --cflags-only-I gz-common5` \
-I$(LRAUV_WS)/install/include
LIBS += \
`pkg-config --libs gz-sim7` \
`pkg-config --libs gz-transport12` \
`pkg-config --libs gz-math7` \
`pkg-config --libs gz-msgs9` \
`pkg-config --libs gz-common5` \
-L$(LRAUV_WS)/install/lib \
-llrauv_gazebo_messages \
-llrauv_system_tests_support
endif

-include ../makefile.defs

include tethysl.mk


ASTYLEOPTS = --style=ansi -pUDZn

XSD += $(XSD_DEST_DIR)/Tethys.xsd $(XSD_DEST_DIR)/Command.xsd

# Add inputs and outputs from these tool invocations to the build variables

# all Target
all: ../bin/LRAUV ../bin/bsdiff ../bin/devmem2 ../bin/bspatch ../bin/encDump ../bin/process_nav ../bin/benthoschat ../bin/sbd ../bin/tty2hex ../bin/LRAUVTest ../bin/unserialize ../bin/SimDaemon ../bin/ESPClientTest $(MODULES) $(LUA) $(USER_AR) tx

# all+goby Target
all+goby: all



# 4.1 Target
4.1: all ../bin/LRAUVTest

# 4.2 Target
4.2: all ../bin/LRAUVTest

# OS-X Target
macosx: all

# epxerimental Target
experimental: all

# lpc3sim Target
lpc3sim: ../bin/LRAUV $(MODULES) $(LUA) $(USER_AR)

# lpc3180 Target
lpc3180: ../bin/LRAUV $(MODULES) $(LUA) $(USER_AR)

# lpc3250 Target
lpc3250: ../bin/LRAUV ../bin/process_nav ../bin/benthoschat ../bin/sbd ../bin/tty2hex ../bin/bsdiff ../bin/bspatch ../bin/devmem2 $(MODULES) $(LUA) $(USER_AR) tx

# lpc3250+goby Target
lpc3250+goby: lpc3250

# lpc3250test Target
lpc3250test: lpc3250 ../bin/LRAUVTest ../bin/encDump

# process_nav Target
process_nav: ../bin/process_nav

# bethoschat Target
benthoschat: ../bin/benthoschat

# sbd Target
sbd: ../bin/sbd

# tty2hex Target
tty2hex: ../bin/tty2hex

# simdaemon Target
simdaemon: ../bin/SimDaemon

# unserialize Target
unserialize: ../bin/unserialize

# gazebo Target
gazebo: lcmtypes ../bin/LRAUV ../bin/SimDaemon $(GZ_TEST_EXECUTABLES) $(MODULES) $(LUA) $(USER_AR) tx

# Tool invocations

CFLAGS += -D_GIT_DESCRIBE=\"$(shell git describe 2>/dev/null)\"
CFLAGS += -D_GIT_HASH=\"$(shell git log -1 --format="%H")\"


../bin/LRAUV: init $(MAIN_OBJS) $(OBJS) $(USER_OBJS) $(USER_AR) Lib/lua/liblua.a Lua/Tethys.lua
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	$(CXX) -o "$@" $(EXPORT_OPT) $(MAIN_OBJS) $(OBJS) $(USER_OBJS) $(USER_AR) $(USER_LIBS) $(LIBS) Lib/lua/liblua.a
	@echo 'Finished building target: $@'
	@echo ' '

../bin/LRAUVTest: init $(TESTS) $(TEST_OBJS) $(PREREQUISITES) $(MODULE_OBJS) $(OBJS) $(USER_OBJS) $(USER_LIBS) $(USER_AR) ../bin/LRAUV Lib/lua/liblua.a
	@echo 'Building target: $@'
	@echo 'Ruynning cxxtestgen.py: $@'
	../Tools/cxxtest/cxxtestgen.py -o LRAUVTest.cpp --runner=StderrPrinter $(TESTS)
	@echo 'Invoking: GCC C++ Compiler'
	$(CXX) -I"../Source" -I"../Tools/cxxtest" $(OPT_DBG_FLAGS) -Wall -c $(CFLAGS) -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o"LRAUVTest.o" "LRAUVTest.cpp"
	@echo 'Invoking: GCC C++ Linker'

	$(CXX) -o "$@" $(EXPORT_OPT) LRAUVTest.o $(TEST_OBJS) $(OBJS) $(MODULE_OBJS) $(USER_OBJS) $(USER_AR) $(USER_LIBS) $(LIBS) $(HDF5_NETCDF_LIB) -lssl -lcrypto Lib/lua/liblua.a $(MODULE_LIBS)

	@echo 'Finished building target: $@'
	@echo ' '

# See Source/scienceModule/ESPClientTest.cpp
../bin/ESPClientTest: init ../Source/scienceModule/ESPClientTest.cpp Source/scienceModule/ESPComm.o Source/scienceModule/ESPClient.o $(OBJS) $(USER_OBJS) $(USER_LIBS) $(USER_AR) Lib/lua/liblua.a Lua/Tethys.lua
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	$(CXX) -o "$@" $(EXPORT_OPT) -I../Source ../Source/scienceModule/ESPClientTest.cpp Source/scienceModule/ESPComm.o Source/scienceModule/ESPClient.o $(OBJS) $(USER_OBJS) $(USER_LIBS) $(USER_AR) $(LIBS) Lib/lua/liblua.a
	@echo 'Finished building target: $@'
	@echo ' '

../bin/uriTest: ../Source/data/uriTest.cpp Source/data/ElementURI.o $(OBJS) $(USER_OBJS) $(USER_LIBS) $(USER_AR) Lib/lua/liblua.a Lua/Tethys.lua
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	$(CXX) -o "$@" $(EXPORT_OPT) -I../Source ../Source/data/uriTest.cpp  $(OBJS) $(USER_OBJS) $(USER_AR) $(USER_LIBS) $(LIBS) Lib/lua/liblua.a
	@echo 'Finished building target: $@'
	@echo ' '

../bin/unserialize: $(UNSERIALIZE_BUILD_OBJS)
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	$(CXX) -o "$@" $(UNSERIALIZE_BUILD_OBJS) -lpthread -ldl -llcm $(HDF5_NETCDF_LIB) $(STATIC_OPT)
	@echo 'Finished building target: $@'
	@echo ' '

../bin/process_nav: init $(PROCESS_NAV_OBJS) $(OBJS) $(USER_OBJS) $(USER_LIBS) $(USER_AR) Lib/lua/liblua.a
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	$(CXX) -o "$@" $(PROCESS_NAV_OBJS) $(OBJS) $(USER_OBJS) $(USER_LIBS) $(USER_AR) $(LIBS) Lib/lua/liblua.a -lpthread -ldl -lrt `pkg-config --libs lcm`
	@echo 'Finished building target: $@'
	@echo ' '

../bin/benthoschat: $(BENTHOS_CHAT_OBJS)
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	$(CXX) -o "$@" $(BENTHOS_CHAT_OBJS) $(LIBS) -lpthread -ldl -lrt -lncurses $(STATIC_OPT)
	@echo 'Finished building target: $@'
	@echo ' '

../bin/sbd: $(SBD_OBJS) $(AES_OBJS) $(ZLIB_OBJS)
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	$(CXX) -o "$@" $(SBD_OBJS) $(AES_OBJS) $(ZLIB_OBJS) $(STATIC_OPT)
	@echo 'Finished building target: $@'
	@echo ' '

../bin/tty2hex: $(TTY2HEX_OBJS)
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	$(CXX) -o "$@" $(TTY2HEX_OBJS) $(STATIC_OPT)
	@echo 'Finished building target: $@'
	@echo ' '

../bin/bsdiff: $(BSDIFF_OBJS) $(BZIP_OBJS)
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	$(CXX) $(OPT_MIN_DBG_FLAGS) -o "$@" $(BSDIFF_OBJS) $(BZIP_OBJS) $(STATIC_OPT)
	@echo 'Finished building target: $@'
	@echo ' '

../bin/bspatch: $(BSPATCH_OBJS) $(BZIP_OBJS)
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	$(CXX) $(OPT_MIN_DBG_FLAGS) -o "$@" $(BSPATCH_OBJS) $(BZIP_OBJS) $(STATIC_OPT)
	@echo 'Finished building target: $@'
	@echo ' '

../bin/encDump: $(ECNTEST_OBJS) $(OPENCPN_OBJS)
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	$(CXX) -o "$@" $(ECNTEST_OBJS) $(OPENCPN_OBJS)
	@echo 'Finished building target: $@'
	@echo ' '

../bin/devmem2: $(DEVMEM2_OBJS)
	@echo 'Building target: $@'
	@echo 'Invoking: GCC C++ Linker'
	$(CXX) $(OPT_MIN_DBG_FLAGS) -o "$@" $(DEVMEM2_OBJS) $(STATIC_OPT)
	@echo 'Finished building target: $@'
	@echo ' '

Lib/lua/liblua.a:
	@echo 'Building target; $@'
	cd Lib/lua/; $(MAKE) $(LUACMDGOALS)
	@echo 'Finished building target: $@'
	@echo ' '

Lua/Tethys.lua: ../Source/lua/Tethys.src.lua
	@echo 'Copying Lua source file: $<'
	cp $< ../$@
	@echo 'Testing Lua source file: $@'
	cd ..; lua -e 'package.path = package.path .. ";./Lua/?.lua"' $@
	@echo 'Finished copying and testing Lua source file: $@'
	@echo ' '

$(XSD_DEST_DIR)/Tethys.xsd: ../Source/xml/Tethys.src.xsd
	@echo 'Copying Xml schema: $<'
	cp $< $@
	@echo 'Finished copying Xml schema: $@'
	@echo ' '

$(XSD_DEST_DIR)/Command.xsd: ../Source/xml/Command.src.xsd
	@echo 'Copying Xml schema: $<'
	cp $< $@
	if [ -d ../../TethysAdmin/war/WEB-INF/xml ]; then cp $< ../../TethysAdmin/war/WEB-INF/xml/Command.xsd; fi
	@echo 'Finished copying Xml schema: $@'
	@echo ' '

# Other Targets
init:
	mkdir -p ../Data
	@echo 'Finished building target: $@'
	@echo ' '

clean: tx-clean
	-$(RM) $(C_DEPS)$(CXX_DEPS)$(CPP_DEPS)$(OBJS) $(USER_AR)$(COMPONENT_OBJS)$(CC_DEPS)$(EXECUTABLES)$(C_UPPER_DEPS)$(C++_DEPS) ../Source/svn.h ../bin/LRAUV ../bin/LRAUVTest ../bin/benthoschat ../bin/sbd ../bin/process_nav ../bin/tty2hex ../bin/bsdiff ../bin/bspatch ../bin/encDump ../bin/SimDaemon ../bin/devmem2 ../bin/ESPClientTest $(MODULES) $(LUA) $(CLEAN_OBJS) $(MAIN_OBJS) LRAUVTest.cpp LRAUVTest.o ../Lua/Tethys.lua ../bin/unserialize lua luac liblua.a ifParser ../bin/lcmtypes.jar ../bin/SpiceClient
	-@echo ' '

distclean: clean
	cd Lib/lua/; $(MAKE) clean
	rm -vf `find . -name "*.d"`
	rm -vf `find . -name "*.o"`
	rm -vf `find . -name "*.so"`

copyToPallas:
	rsync -rvPhv --delete --times --files-from=copyTo.list ../ pallas:/mnt/mmc/LRAUV
# Note: this requires an RSA key be generated and sent to the target listed above

copyToPallasMinor:
	scp -Cpr ../bin ../Config ../Missions ../Modules root@lrauv-pallas.shore.mbari.org:/mnt/mmc/LRAUV/

# Note: this requires an RSA key be generated and sent to the target listed above
copy-to-brizo:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ brizo:/mnt/mmc/LRAUV
copy-to-brizo-cell:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ brizo-cell:/mnt/mmc/LRAUV
copy-to-pontus:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ pontus:/mnt/mmc/LRAUV
copy-to-pontus-cell:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ pontus-cell:/mnt/mmc/LRAUV
copy-to-triton:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ triton:/mnt/mmc/LRAUV
copy-to-triton-cell:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ triton-cell:/mnt/mmc/LRAUV
copy-to-galene:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ galene:/mnt/mmc/LRAUV
copy-to-galene-cell:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ galene-cell:/mnt/mmc/LRAUV
copy-to-whoidhs:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ whoidhs:/mnt/mmc/LRAUV
copy-to-whoidhs-cell:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ whoidhs-cell:/mnt/mmc/LRAUV
copy-to-ahi:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ ahi:/mnt/mmc/LRAUV
copy-to-ahi-cell:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ ahi-cell:/mnt/mmc/LRAUV
copy-to-aku:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ aku:/mnt/mmc/LRAUV
copy-to-aku-cell:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ aku-cell:/mnt/mmc/LRAUV
copy-to-daphne:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ daphne:/mnt/mmc/LRAUV
copy-to-daphne-cell:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ daphne-cell:/mnt/mmc/LRAUV
copy-to-makai:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ makai:/mnt/mmc/LRAUV
copy-to-makai-cell:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ makai-cell:/mnt/mmc/LRAUV
copy-to-opah:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ opah:/mnt/mmc/LRAUV
copy-to-opah-cell:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ opah-cell:/mnt/mmc/LRAUV
copy-to-tethys:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ tethys:/mnt/mmc/LRAUV
copy-to-tethys-cell:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ tethys-cell:/mnt/mmc/LRAUV
copy-to-polaris-cell:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ polaris-cell:/mnt/mmc/LRAUV
copy-to-stella-cell:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ stella-cell:/mnt/mmc/LRAUV
copy-to-pyxis-cell:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ pyxis-cell:/mnt/mmc/LRAUV
copy-to-melia:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ melia:/mnt/mmc/LRAUV
copy-to-melia-cell:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ melia-cell:/mnt/mmc/LRAUV
copy-to-lrauv-lcm:
	rsync -rvPhv --delete --times --files-from=copyTo.list --exclude-from=exclude.list ../ root@lrauv-lcm:/mnt/mmc/LRAUV

cxxcheck:
	bash ../Tools/runCxxchecker.sh

doxygen:
	cd ../Documentation; doxygen -u LRAUV.doxyfile 2>&1 1> /dev/null
	cd ../Documentation; doxygen LRAUV.doxyfile

doxygenpdf:
	cd ../Documentation; doxygen -u LRAUV.doxyfile 2>&1 1> /dev/null
	cd ../Documentation; sed "s/GENERATE_LATEX\s*=\s*NO/GENERATE_LATEX         = YES/" LRAUV.doxyfile | doxygen -
	cd ../Documentation/latex; \
	    pdflatex refman.tex; \
	    makeindex refman.idx; \
	    pdflatex refman.tex; \
	    latex_count=5 ; \
	    while egrep -s 'Rerun (LaTeX|to get cross-references right)' refman.log && [ $$latex_count -gt 0 ] ;\
	        do \
	            echo "Rerunning latex...." ;\
	            pdflatex refman.tex ;\
	            latex_count=`expr $$latex_count - 1` ;\
	        done
	mv ../Documentation/latex/refman.pdf ../Documentation/html/tethys.pdf

pretty-code:
	perl make_pretty.pl ../Source

pretty-missions: schema tl-prettify
	cd ../;Tools/xmlformat/prettyMissions.py

# No pretty missions as part of general pretty target. Use pretty-missions target
pretty: schema pretty-code

schema: $(XSD)

.PHONY: all tx tx-all tx1 tx-clean tl-prettify tl-check-pretty tl-lint clean dependents
.SECONDARY:

-include ../makefile.targets
