#!/bin/sh
# @(#) $Revision: 1.8 $
# @(#) RCS control in //prime.corp/usr/local/src/cmd/prime/src/re_comp.sh
#
# re_comp - recompile siv progs for the sets
#
# usage:
#	re_comp [topdir]
#
#	optional top level directory to work from
#
# Copyright (C) 1997 Landon Curt Noll, all rights reserved.
#
# Permission to use, copy, modify, and distribute this software and
# its documentation for any purpose is hereby granted, provided that
# the above copyright, this permission notice, and the disclaimer
# below appear in all of the following:
#
#         * supporting documentation
#         * source copies
#         * source works derived from this source
#
# THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
# EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
# USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
# Landon Curt Noll <chongo was here> /\oo/\
#
# chongo@{toad,sgi}.com		Share and Enjoy!

# parse args
#
TOPDIR=/usr/local/lib/map
if [ $# -eq 1 ]; then
    TOPDIR="$1"
fi
if [ ! -d "$TOPDIR" ]; then
    echo "$0: $TOPDIR is not a top level directory" 1>&2
    exit 1
fi
cd "$TOPDIR"
if [ ! -f src/build.mk ]; then
    echo "$0: src/build.mk not found under $TOPDIR" 1>&2
    exit 2
fi
if [ ! -d set ]; then
    echo "$0: set is not a directory under $TOPDIR" 1>&2
    exit 3
fi
cd set

# remake each set
#
ls -1F . | grep / | grep -v '[A-Z]' | sed -e 's;/$;;' | while read setname; do
    echo "recompiling $setname"
    (cd "$setname"; 
     make -f "../../src/build.mk" setup all SETNAME="${setname}" TOPDIR="${TOPDIR}")
done
