#
# Consortium Release 4
# 
# $Id: Makefile.dist,v 1.5 1997/08/12 20:10:27 wfs Exp $
# ------------------------------------------------------------------------
# 
# Copyright (c) 1996 The Regents of the University of Michigan
# All Rights Reserved
#  
# License to use, copy, modify, and distribute this software and its
# documentation can be obtained from Merit at the University of Michigan.
# 
# 	Merit GateDaemon Project
# 	4251 Plymouth Road, Suite C
# 	Ann Arbor, MI 48105
# 
# THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
# EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF 
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE REGENTS OF THE
# UNIVERSITY OF MICHIGAN AND MERIT DO NOT WARRANT THAT THE
# FUNCTIONS CONTAINED IN THE SOFTWARE WILL MEET LICENSEE'S REQUIREMENTS OR
# THAT OPERATION WILL BE UNINTERRUPTED OR ERROR FREE. The Regents of the
# University of Michigan and Merit shall not be liable for
# any special, indirect, incidental or consequential damages with respect
# to any claim by Licensee or any third party arising from use of the
# software. GateDaemon was originated and developed through release 3.0
# by Cornell University and its collaborators.
# 
# Please forward bug fixes, enhancements and questions to the
# gated mailing list: gated-people@gated.merit.edu.
# 
# ------------------------------------------------------------------------
# 
# Copyright (c) 1990,1991,1992,1993,1994,1995 by Cornell University.
#     All rights reserved.
# 
# THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
# LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS FOR A PARTICULAR PURPOSE.
# 
# GateD is based on Kirton's EGP, UC Berkeley's routing
# daemon	 (routed), and DCN's HELLO routing Protocol.
# Development of GateD has been supported in part by the
# National Science Foundation.
# 
# ------------------------------------------------------------------------
# 
# Portions of this software may fall under the following
# copyrights:
# 
# Copyright (c) 1988 Regents of the University of California.
# All rights reserved.
# 
# Redistribution and use in source and binary forms are
# permitted provided that the above copyright notice and
# this paragraph are duplicated in all such forms and that
# any documentation, advertising materials, and other
# materials related to such distribution and use
# acknowledge that the software was developed by the
# University of California, Berkeley.  The name of the
# University may not be used to endorse or promote
# products derived from this software without specific
# prior written permission.  THIS SOFTWARE IS PROVIDED
# ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
#	Makefile for gated root directory
#

TARDIR		=	tar
TMPDIR		=	/tmp
TARNAME		=	gated-${VERSION}
TMPFILE		=	${TMPDIR}/make-gated.$$$$
DISTFILE	=	${TARNAME}.tar.gz
TESTFILE	=	tar/gated.tar.test
MAILTO		=	nobody
FTPDIR		=	/afs/merit.net/group/Gated/share/Public/external_html/new_web/code/code/private/gated
HTMLDIR		=	 /afs/merit/group/Gated/share/Public/html/release/gated/${VERSION}
EXTERNAL_HTML	=	/afs/merit/group/Gated/share/Public/external_html/new_web/code/code/gated/${VERSION}
SUPPORTDIR	=	/afs/merit.net/group/Gated/share/Public/external_html/new_web/support/bugs/gated/${VERSION}
RELDIR		=	/afs/merit.net/group/Gated/share/Public/external_html/new_web/code/release/gated/${VERSION}
COMPONENTS	=	util/components.release
MAN_PAGES	=	gated gdc ripquery ospf_monitor

true:;

announce:	ftp ${COMPONENTS}
	-sed 	-e 's/%list%/${LIST}/' \
		-e 's/%release%/${VERSION_L}/' \
		-e 's/%version%/${VERSION}/' \
		< ${COMPONENTS} > ${TMPFILE} ; \
		comp -form ${TMPFILE} ; \
		rm -f ${TMPFILE}
			
ftp:	dist
	cd ${FTPDIR} && rm -rf ${TARNAME}*
	mv ${TARDIR}/${TARNAME}* ${FTPDIR}
	cd ${FTPDIR} && zcat ${DISTFILE} | tar -xpf -
	-cd ${FTPDIR} && chmod -R u=rwX,g=rwX,o=rX ${TARNAME}*
	@if [ -d ${FTPDIR}/.cap ]; then \
		cd ${FTPDIR} ; \
		rm -rf .cap/${TARNAME}* ; \
		echo "Name=Gated ${VERSION_L} Distribution (Compressed Tar)" > .cap/${DISTFILE} ; \
		echo 'Type=9' >> .cap/${DISTFILE} ; \
		echo "Name=Gated ${VERSION_L} Source Tree" > .cap/${TARNAME} ; \
		echo 'Type=1' >> .cap/${TARNAME} ; \
		for file in ${DISTFILE}u*; do \
			echo "Type=-" > .cap/$${file} ; \
		done \
	fi
	echo "ftpdir html = ${FTPDIR}"
	@if [ -d ${FTPDIR}/html ]; then \
		cd ${FTPDIR}/html ; \
		rm -f ${TARNAME} ; \
		ln -s ${FTPDIR}/${TARNAME}/doc ${TARNAME} ; \
	fi
	echo "after encodes"
	cd ${EXTERNAL_HTML}  && rm -rf * 
	mv ${HTMLDIR}/* ${EXTERNAL_HTML}	
	cd ${SUPPORTDIR} && rm -rf *
	ln -s ${EXTERNAL_HTML}/*.html .
	cd ${RELDIR} && rm -rf *
	ln -s ${EXTERNAL_HTML}/*.html .	

dist:	${TARDIR}/${TARNAME}.tar.gzu
	cd ${TARDIR} ; split ${TARNAME}.tar.gzu ${TARNAME}.tar.gzus.

mail:	${TARDIR}/${TARNAME}.tar.gzu
	mail -s ${TARNAME}.tar.gzu ${MAILTO} < ${TARDIR}/${TARNAME}.tar.gzu
	exit

${TARDIR}/${TARNAME}.tar.gzu:	${TARDIR}/${TARNAME}.tar.gz
	cd ${TARDIR} ; uuencode ${TARNAME}.tar.gz ${TARNAME}.tar.gz > ${TARNAME}.tar.gzu
	
${TARDIR}/${TARNAME}.tar.gz:	copyright
	rm -r -f ${TARDIR} ; mkdir ${TARDIR}
	@rm -r -f ${TMPDIR}/${TARNAME}
	@echo "Exporting ${VERSION}"
	cd ${TMPDIR} ; cvs export -r release-${VERSION}-RELEASE -d ${TARNAME} gated-pub
	echo "tarname = ${TARNAME}  tmpdir = ${TMPDIR}"
	@echo "Cleaning distribution tree"
	@find ${TMPDIR}/${TARNAME} \( -name \*.save -o -name \*.orig -o -name \*.old -o -name \*~ -o -name _\* \) -print \
		> ${TMPFILE} ; \
		xargs rm < ${TMPFILE} ; \
		rm ${TMPFILE}
	@echo "Setting groups and modes"
	@echo "tmpdir = ${TMPDIR}  tarname = ${TARNAME} "
	@chgrp -R bgp ${TMPDIR}/${TARNAME}
	@-chmod -R u=rwX,go=rX ${TMPDIR}/${TARNAME}
	@echo "Creating and compressing tar file"
	@echo ${TMPDIR}

# tar and gzip the release
# 
 
	( cd ${TMPDIR} ; tar cf - ${TARNAME} ) | gzip -c > ${TARDIR}/${TARNAME}.tar.gz
	echo "after tar tmpdir = ${TMPDIR} tarname = ${TARNAME}"
	@rm -r -f ${TMPDIR}/${TARNAME}

checkout:	true
	cvs checkout -d . gated

version:	true
	@echo ${VERSION} | awk '{ \
		out = version[n = split($$0, version, "_")] + 1 ; \
		while (--n) { out = version[n] "_" out ; } \
		print out ; \
	}' | tee src/VERSION
	@cvs commit -m`cat src/VERSION` CHANGES
	@cd src ; cvs commit -m`cat VERSION` VERSION
	@cd src ; $(MAKE) $(MFLAGS) build_depend ; cvs commit -m`cat VERSION` util/Depends
	@cvs -Q tag `cat src/VERSION`

unversion:	true
	@cvs -Q tag -d `cat src/VERSION`
	@echo ${VERSION} | awk '{ \
		out = version[n = split($$0, version, "_")] - 1 ; \
		while (--n) { out = version[n] "_" out ; } \
		print out ; \
	}' | tee src/VERSION

commit:	true
	@cvs commit

copyright:	true
#	@cd util; $(MAKE) $(MFLAGS)
