summaryrefslogtreecommitdiff
path: root/U/Loc.U
diff options
context:
space:
mode:
Diffstat (limited to 'U/Loc.U')
-rw-r--r--U/Loc.U260
1 files changed, 260 insertions, 0 deletions
diff --git a/U/Loc.U b/U/Loc.U
new file mode 100644
index 0000000000..79096ef45f
--- /dev/null
+++ b/U/Loc.U
@@ -0,0 +1,260 @@
+?X: These units are based on the ones supplied with dist-3.0
+?X: patchlevel 22. They have been changed or enhanced to work with
+?X: perl5alpha. I would appreciate hearing about any changes,
+?X: corrections, or enhancements.
+?X: Andy Dougherty doughera@lafcol.lafayette.edu
+?X: Dept. of Physics
+?X: Lafayette College
+?X: Easton, PA 18042-1782
+?X: Sat Apr 2 15:45:17 EST 1994
+?RCS: $Id: Loc.U,v 3.0.1.3 1994/01/24 14:01:44 ram Exp $
+?RCS:
+?RCS: Copyright (c) 1991-1993, Raphael Manfredi
+?RCS:
+?RCS: You may redistribute only under the terms of the Artistic Licence,
+?RCS: as specified in the README file that comes with the distribution.
+?RCS: You may reuse parts of this distribution only within the terms of
+?RCS: that same Artistic Licence; a copy of which may be found at the root
+?RCS: of the source tree for dist 3.0.
+?RCS: $Log: Loc.U,v $
+?RCS: Revision 3.0.1.3 1994/01/24 14:01:44 ram
+?RCS: patch16: added metalint hint on changed PATH variable
+?RCS:
+?RCS: Revision 3.0.1.2 1993/12/15 08:16:52 ram
+?RCS: patch15: now set _test variable when test is built-in
+?RCS: patch15: fixed rare cases where echo is not needed
+?RCS:
+?RCS: Revision 3.0.1.1 1993/09/13 15:47:13 ram
+?RCS: patch10: test program not always in /bin/test (WAD)
+?RCS:
+?RCS: Revision 3.0 1993/08/18 12:05:05 ram
+?RCS: Baseline for dist 3.0 netwide release.
+?RCS:
+?X:
+?X: This unit produces a shell script "loc" which can be used to find out
+?X: where in a list of directories something is. It then uses loc to
+?X: determine the location of commonly used programs. It leaves loc sitting
+?X: around for other Configure units to use, but arranges for its demise
+?X: at the end of Configure.
+?X:
+?X: To add a new program to find, add it both to the ?MAKE: line and to either
+?X: the loclist or trylist variable.
+?X:
+?X: I put startsh at the end of the dependency list, in order to avoid the
+?X: loading of the spitshell unit before the instructions.
+?X:
+?MAKE:Loc Mcc awk bash bison byacc cat chgrp chmod chown compress cp cpio \
+ cpp csh date echo egrep emacs expr find flex gcc grep inews ksh \
+ less line lint ln lp lpr ls mail mailx make mkdir more mv nroff \
+ perl pg pmake pr rm rmail sed sendmail sh shar sleep smail sort \
+ submit tail tar tbl test touch tr troff uname uniq uuname vi \
+ zcat: eunicefix n c Instruct Myread startsh
+?MAKE: -pick weed $@ %<
+?LINT:describe Loc Mcc awk bash bison byacc cat chgrp chmod chown compress \
+ cp cpio cpp csh date echo egrep emacs expr find flex gcc grep \
+ inews ksh less line lint ln lp lpr ls mail mailx make mkdir more \
+ mv nroff perl pg pmake pr rm rmail sed sendmail sh shar sleep \
+ smail sort submit tail tar tbl test touch tr troff uname uniq \
+ uuname vi zcat
+?V::pth loclist trylist
+?T:thing xxx dir file say _test
+?LINT:change PATH
+: find out where common programs are
+echo " "
+echo "Locating common programs..." >&4
+cat <<EOSC >loc
+$startsh
+case \$# in
+0) exit 1;;
+esac
+thing=\$1
+shift
+dflt=\$1
+shift
+for dir in \$*; do
+ case "\$thing" in
+ .)
+ if test -d \$dir/\$thing; then
+ echo \$dir
+ exit 0
+ fi
+ ;;
+ *)
+ if test -f \$dir/\$thing; then
+ echo \$dir/\$thing
+ exit 0
+ elif test -f \$dir/\$thing.exe; then
+ : on Eunice apparently
+ echo \$dir/\$thing
+ exit 0
+ fi
+ ;;
+ esac
+done
+echo \$dflt
+exit 1
+EOSC
+chmod +x loc
+$eunicefix loc
+loclist="
+?awk:awk
+?cat:cat
+?chgrp:chgrp
+?chmod:chmod
+?chown:chown
+?cp:cp
+?echo:echo
+?expr:expr
+?grep:grep
+?ln:ln
+?ls:ls
+?make:make
+?mkdir:mkdir
+?mv:mv
+?rm:rm
+?sed:sed
+?sleep:sleep
+?sort:sort
+?tail:tail
+?touch:touch
+?tr:tr
+?uniq:uniq
+"
+trylist="
+?Mcc:Mcc
+?bash:bash
+?bison:bison
+?byacc:byacc
+?compress:compress
+?cpio:cpio
+?cpp:cpp
+?csh:csh
+?date:date
+?egrep:egrep
+?emacs:emacs
+?find:find
+?flex:flex
+?gcc:gcc
+?inews:inews
+?ksh:ksh
+?less:less
+?line:line
+?lint:lint
+?lp:lp
+?lpr:lpr
+?mail:mail
+?mailx:mailx
+?more:more
+?nroff:nroff
+?perl:perl
+?pg:pg
+?pmake:pmake
+?pr:pr
+?rmail:rmail
+?sendmail:sendmail
+?sh:sh
+?shar:shar
+?smail:smail
+?submit:submit
+?tar:tar
+?tbl:tbl
+?test:test
+?troff:troff
+?uname:uname
+?uuname:uuname
+?vi:vi
+?zcat:zcat
+"
+?LINT:set Loc Mcc awk bash bison byacc cat chgrp chmod chown compress cp cpio cpp \
+ csh date echo egrep emacs expr flex gcc grep inews ksh less line lint ln \
+ lp lpr ls mail mailx make mkdir more mv nroff perl pg pmake pr rm rmail \
+ sed sendmail sh shar sleep smail sort submit tail tar tbl test touch tr \
+ troff uname uniq uuname vi zcat
+pth=`echo $PATH | sed -e 's/:/ /g'`
+pth="$pth /lib /usr/lib"
+for file in $loclist; do
+ xxx=`./loc $file $file $pth`
+ eval $file=$xxx
+ eval _$file=$xxx
+ case "$xxx" in
+ /*)
+ echo $file is in $xxx.
+ ;;
+ *)
+ echo "I don't know where $file is. I hope it's in everyone's PATH."
+ ;;
+ esac
+done
+echo " "
+echo "Don't worry if any of the following aren't found..."
+say=offhand
+for file in $trylist; do
+ xxx=`./loc $file $file $pth`
+ eval $file=$xxx
+ eval _$file=$xxx
+ case "$xxx" in
+ /*)
+ echo $file is in $xxx.
+ ;;
+ *)
+ echo "I don't see $file out there, $say."
+ say=either
+ ;;
+ esac
+done
+case "$egrep" in
+egrep)
+ echo "Substituting grep for egrep."
+ egrep=$grep
+ ;;
+esac
+case "$test" in
+test)
+ echo "Hopefully test is built into your sh."
+ ;;
+*)
+ if sh -c "PATH= test true" >/dev/null 2>&1; then
+ echo "Using the test built into your sh."
+?X:
+?X: We need to set both test and _test, since Oldconfig.U will use the _test
+?X: value to systematically restore computed paths, which may be wrong if
+?X: we choose to load an old config.sh generated on another platform.
+?X:
+ test=test
+ _test=test
+ fi
+ ;;
+esac
+?LINT:change n c
+case "$echo" in
+echo)
+ echo "Hopefully echo is built into your sh."
+ ;;
+?X: For those rare cases where we don't need $echo...
+'') ;;
+*)
+ echo " "
+echo "Checking compatibility between $echo and builtin echo (if any)..." >&4
+ $echo $n "hi there$c" >foo1
+ echo $n "hi there$c" >foo2
+ if cmp foo1 foo2 >/dev/null 2>&1; then
+ echo "They are compatible. In fact, they may be identical."
+ else
+ case "$n" in
+ '-n') n='' c='\c';;
+ *) n='-n' c='';;
+ esac
+ cat <<FOO
+They are not compatible! You are probably running ksh on a non-USG system.
+I'll have to use $echo instead of the builtin, since Bourne shell doesn't
+have echo built in and we may have to run some Bourne shell scripts. That
+means I'll have to use '$n$c' to suppress newlines now. Life is ridiculous.
+
+FOO
+ $echo $n "The star should be here-->$c"
+ $echo "*"
+ fi
+ $rm -f foo1 foo2
+ ;;
+esac
+