#!/bin/csh -ef
# $Id: list_paths,v 1.1 2003/06/13 15:38:02 jla Exp $
#-----------------------------------------------------------------------
#              list_paths: CVS administrative script
#
# AUTHOR: V. Balaji (vb@gfdl.gov)
#         SGI/GFDL Princeton University
#
# This program 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.
#
# This program 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.
#
# For the full text of the GNU General Public License,
# write to: Free Software Foundation, Inc.,
#           675 Mass Ave, Cambridge, MA 02139, USA.
#-----------------------------------------------------------------------
# script to be run from the CVSROOT/modules file to create path lists
# $1 contains the name of the archive being checked out
# this script creates two files:
# path_names contains all the source files ( *.{c,C,f,F,fh,f90,F90,h,H,inc} )
# path_names.html contains all the doc files ( *.{html,ps,txt}, README, readme )
# NOTE: if these files exist, they are appended to.
#       This is necessary, since for aliases that checkout multiple
#       directories you need to keep the results from earlier checkouts.
#       This could yield unexpected results if you use the same working
#       directory for different experiments using different modules. You
#       must remove these files if beginning a fresh experiment.

unset noclobber
if( $?DEBUG )echo Running $0 in $cwd, args $*

set src=.`basename $0`.src.lst doc=.`basename $0`.doc.lst
touch path_names	# create the file if it doesn't exist
cp path_names $src
find $* -type f \
 \( -name \*.c   \
 -o -name \*.C   \
 -o -name \*.f   \
 -o -name \*.fh  \
 -o -name \*.F   \
 -o -name \*.f90 \
 -o -name \*.F90 \
 -o -name \*.h   \
 -o -name \*.H   \
 -o -name \*.inc \
 \) -print >> $src
sort -u $src > path_names
echo "A list of the files you checked out is in the file path_names ..."

touch $doc	# create the file if it doesn't exist
find $* -type f \
 \( -name \*.html \
 -o -name \*.ps   \
 -o -name \*.txt  \
 -o -name readme  \
 -o -name read_me \
 -o -name README  \
 \) -print > $src
if( -z $src )exit
# $src has non-zero size (i.e some doc exists)
cat $src >> $doc

#write path_names.html file
echo "<title>Documentation in current working directory</title>"           > path_names.html
echo "<h1>Documentation in current working directory</h1>"                >> path_names.html
sort -u $doc | awk '{print "<p><a href=\"" $1 "\">" $1 "</a>"}'           >> path_names.html
echo '<p><hr><small>This file was automatically generated by list_paths.' >> path_names.html
echo '$Revision: 1.1 $ $Date: 2003/06/13 15:38:02 $'                      >> path_names.html

echo "Documentation on the files you checked out is accessible on the web at"
echo "file://localhost$cwd/path_names.html ..."
