##==========================================================================
##
## Copyright 2000, 2002 The Regents of the University of California
## All Rights Reserved
##
## Permission to use, copy, modify and distribute any part of this Makefile
## for educational, research and non-profit purposes, without fee, and without
## a written agreement is hereby granted, provided that the above copyright
## notice, this paragraph and the following paragraphs appear in all copies.
##
## Those desiring to incorporate this into commercial products or use for
## commercial purposes should contact the
##
##      Technology Transfer Office, University of California, San Diego,
##      9500 Gilman Drive, La Jolla, CA 92093-0910
##      Ph: (619) 534-5815, FAX: (619) 534-7345.
##
## IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
## DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
## LOST PROFITS, ARISING OUT OF THE USE OF THIS MAKEFILE, EVEN IF THE
## UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
## THE MAKEFILE, PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND THE
## UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
## UPDATES, ENHANCEMENTS, OR MODIFICATIONS. THE UNIVERSITY OF CALIFORNIA MAKES
## NO REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER IMPLIED OR
## EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR THAT THE USE OF THE
## SKITTERTRACES WILL NOT INFRINGE ANY PATENT, TRADEMARK OR OTHER RIGHTS.
##
## Makefile is developed by Bradley L. Huffaker at the University of
## California, San Diego under the Cooperative Association for
## Internet Data Analysis (CAIDA) Program. Support for this effort is
## provided by DARPA grant N66001-98-2-8922 and by CAIDA members.
##==========================================================================

NAME=sk_analysis_dump

LIBS=@LIBS@
CXXFLAGS=@CXXFLAGS@ -Wall -Wno-non-template-friend -I. -Inetacuity_api
CXX=@CXX@
ASFINDERDIR=@ASFINDERDIR@

ANALYSIS_DEPS=@ANALYSIS_DEPS@

#-----------------------------------------------------------
# Suffixes
.SUFFIXES: .c

.c.o: 
	${CXX} -c -o $@ $< ${CXXFLAGS}

all: $(NAME) libsea/skitter2walrus
#----------------------- sk_analysis_dump ------------------
# Skitter Path Dump with some basic Analysis
$(NAME): ${ANALYSIS_DEPS}
	${CXX} -o $(NAME) ${ANALYSIS_DEPS} ${LIBS}


sk_analysis_dump.o: sk_analysis_dump.cc

@NETACUITY_BUILD@

zfstream.o:zfstream.cc zfstream.h

PrintHeaderComments.c:createPrintHeaderComments.pl OUTPUT 
	caida-config/fixperl createPrintHeaderComments.pl
	perl ./createPrintHeaderComments.pl OUTPUT > PrintHeaderComments.c

PrintHeaderComments.o: PrintHeaderComments.c PrintHeaderComments.h

#----------------------- skitter2walrus ------------------
libsea/skitter2walrus: libsea/skitter2walrus.pl
	cd libsea && \
	    ../caida-config/fixperl -Dasfinder_dir="$(ASFINDERDIR)" \
		skitter2walrus.pl

#----------------------- Release ------------------
LIBSEA=libsea/
RELEASE_FILES= $(SRCDIST)/${NAME}.cc $(SRCDIST)/Makefile.in $(SRCDIST)/README \
        $(SRCDIST)/${LIBSEA}Heap.pm $(SRCDIST)/${LIBSEA}skitter2walrus.pl \
        $(SRCDIST)/${LIBSEA}LibSeaGraphWriter.pl \
	$(SRCDIST)/zfstream-gcc2 $(SRCDIST)/zfstream-iso14882
SRCDIST=$(NAME)-$(VER)

srcdist: 
	@if test "x$(VER)" = "x"; then \
	    echo "To make a source release, use a command of the form:"; \
	    echo "  make srcdist VER=<release_version> [REV=<cvs_revision>]"; \
	    echo "For example:"; \
	    echo "  make srcdist VER=2.0.1 REV=sk_analysis_dump-2-0-1"; \
	    echo "REV defaults to 'HEAD'."; \
	    false; \
	fi
	if [ -d $(SRCDIST) ] ; then \
	    rm -rf $(SRCDIST); \
	fi
	REV="$(REV)" cvs export -r$${REV:-HEAD} -d $(SRCDIST) skitter-sample
	cd $(SRCDIST) && \
	    { test -d caida-config || cvs export -rHEAD caida-config; } && \
	    autoconf
	tar -cf $(SRCDIST).tar $(SRCDIST)
	if [ -f ${SRCDIST}.tar.gz ] ; \
	    then rm ${SRCDIST}.tar.gz; \
	fi
	gzip $(SRCDIST).tar

release:srcdist
	scp -r ${SRCDIST}.tar.gz ${RELEASE_FILES} \
            cider:public_html/tools/skitter/sample_code

clean:
	-rm -f *.o @NETACUITY_O@ PrintHeaderComments.c

cleandist:clean
	-rm -rf $(NAME)-*

realclean:cleandist
	CLEAN_FILES="${NAME} config.status config.cache config.log";\
	for filename in *.in ; do \
	    CLEAN_FILES=$$CLEAN_FILES' '`basename $$filename .in`;\
	done;\
	rm -f $$CLEAN_FILES;


