###############################################################################
#                                                                             #
#   Copyright 2005 University of Cambridge Computer Laboratory.               #
#                                                                             #
#   This file is part of Nprobe.                                              #
#                                                                             #
#   Nprobe is free software; you can redistribute it and/or modify            #
#   it under the terms of the GNU General Public License as published by      #
#   the Free Software Foundation; either version 2 of the License, or         #
#   (at your option) any later version.                                       #
#                                                                             #
#   Nprobe is distributed in the hope that it will be useful,                 #
#   but WITHOUT ANY WARRANTY; without even the implied warranty of            #
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             #
#   GNU General Public License for more details.                              #
#                                                                             #
#   You should have received a copy of the GNU General Public License         #
#   along with Nprobe; if not, write to the Free Software                     #
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA #
#                                                                             #
###############################################################################

#
# Where to find various stuff
#

# Archive root
NPROBE_ROOT = ..

# Import all relative paths defined at top level
include $(NPROBE_ROOT)/Makefile.paths

all depend tidy clean very_clean clobber update_install install: force
	$(MAKE) -C $(ANAL_DIR) $(MFLAGS) $@
	$(MAKE) -C $(ANAL_SCRIPT_DIR) $(MFLAGS) $@
	$(MAKE) -C $(ANAL_NUT_BOLT_DIR) $(MFLAGS) $@
	$(MAKE) -C $(ANAL_TOOL_DIR) $(MFLAGS) $@
	$(MAKE) -C $(ANAL_UTILITY_DIR) $(MFLAGS) $@
	$(MAKE) -C $(NPROBE_FMAGIC_DIR) $(MFLAGS) $@
	$(MAKE) -C $(PLOTTER_DIR) $(MFLAGS) $@
	$(MAKE) -C $(PCAP_DIR) $(MFLAGS) $@

test_clean:
	$(MAKE) -C $(ANAL_DIR) $(MFLAGS) $@
	rm -rf $(TEST_DATA_DUMP_DIR)/np_rets

paths paths_raw: force
	$(MAKE) -C $(ANAL_DIR) $(MFLAGS) $@

setup: all install paths

setup_raw: all paths_raw

analysis_test: all install
	@echo '** Testing analysis **'	
	if [ ! -f $(REP_TEST_DATA) ];\
		then \
			echo 'Unzipping data file'; \
			gunzip -c $(REP_TEST_DATA).gz \
				> $(REP_TEST_DATA); \
	else \
		sleep 2; \
	fi
	@($(INSTALL_BIN_DIR)/np_obtree.py -r1000 $(REP_TEST_DATA) \
	&& $(INSTALL_BIN_DIR)/np_tcp.py -r1000 $(REP_TEST_DATA) \
	&& $(INSTALL_BIN_DIR)/np_rets.py -sr $(REP_TEST_DATA)) \
	  || (echo; echo  **Ensure PATHS are set up correctly**; \
		$(MAKE) -C $(ANAL_DIR) -s --no-print-directory paths)

plotter_test: install
	@$(PLOTTER_DIR)/np_plot.py $(TEST_DATA_PLOTTER_DIR) \
	  || (echo; echo  **Ensure PATHS are set up correctly**; \
		$(MAKE) -C $(ANAL_DIR) -s --no-print-directory paths)

np_rets_test: all install
	echo foo
	@$(INSTALL_BIN_DIR)/np_rets.py $(REP_FILE) \
	  || (echo; echo  **Ensure PATHS are set up correctly**; \
		$(MAKE) -C $(ANAL_DIR) -s --no-print-directory paths)

force:
