Rewrite. Add '-d <dir>' param for updating a Makefile in a subdir. Fix objdir case of no Makefile present in directory.

This commit is contained in:
slamm%netscape.com 1999-08-20 14:47:53 +00:00
Родитель cba383801d
Коммит 7fedeb241d
1 изменённых файлов: 51 добавлений и 22 удалений

Просмотреть файл

@ -29,41 +29,70 @@
# Send comments, improvements, bugs to ramiro@netscape.com
#
root_path=`pwd`
update_makefile_usage() {
_progname=`expr //$0 : '.*/\(.*\)'`
cat <<END_USAGE 2>&1
# Make sure a Makefile exists
basemakefile=$root_path/Makefile
Usage: $_progname [-h -u] [<keyword>]
-d <dir> Subdir to update
-h Print usage
END_USAGE
}
if [ -f $basemakefile ]
# Parse the command-line options
#
subdir=
while getopts d:h OPT; do
case $OPT in
d) # Make sure "subdir" has exactly one ending slash
subdir=`echo $OPTARG | sed 's/\/$//;'`"/" ;;
\?|h) update_makefile_usage
exit 1
;;
esac
done
# find_depth: Pull the value of DEPTH out of Makefile (or Makefile.in)
find_depth() {
egrep '^DEPTH[ ]*=[ ]*\.' $1 | awk -F= '{ print $2; }'
}
# The Makefile to create
target_makefile=`pwd`"/${subdir}Makefile"
# Use $(DEPTH) in the Makefile or Makefile.in to determine the depth
if [ -f Makefile ]
then
makefile=$basemakefile
elif [ -f $root_path/Makefile.in ]
depth=`find_depth Makefile`
elif [ -f Makefile.in ]
then
makefile=$root_path/Makefile.in
depth=`find_depth Makefile.in`
elif [ -f ../Makefile ]
then
depth="../"`find_depth Makefile`
else
echo
echo "There ain't no 'Makefile' or 'Makefile.in' over here: $pwd"
echo
exit
echo
echo "There ain't no 'Makefile' or 'Makefile.in' over here: $pwd"
echo
exit
fi
# Use DEPTH in the Makefile to determine the depth
depth=`egrep '^DEPTH[ ]*=[ ]*\.' $makefile | awk -F= '{ print $2; }'`
# 'cd' to the root of the tree
# 'cd' to the root of the tree to run "config.status" there
cd $depth
root_path=`pwd`
# Strip the tree root off the Makefile's path
basemakefile=`expr $basemakefile : $root_path'/\(.*\)'`
#
root_path=`pwd`
target_makefile=`expr $target_makefile : $root_path'/\(.*\)'`
# Make sure config.status exists
#
if [ -f config.status ]
then
CONFIG_FILES=$basemakefile ./config.status
CONFIG_FILES=$target_makefile ./config.status
else
echo
echo "There ain't no 'config.status' over here: $pwd"
echo
echo
echo "There ain't no 'config.status' over here: $pwd"
echo
fi