Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / expat / conftools / PrintPath
blobe8559a3d643e577247214d351ff5320c27f5f15c
1 #!/bin/sh
2 # Look for program[s] somewhere in $PATH.
4 # Options:
5 # -s
6 # Do not print out full pathname. (silent)
7 # -pPATHNAME
8 # Look in PATHNAME instead of $PATH
10 # Usage:
11 # PrintPath [-s] [-pPATHNAME] program [program ...]
13 # Initially written by Jim Jagielski for the Apache configuration mechanism
14 # (with kudos to Kernighan/Pike)
16 # This script falls under the Apache License.
17 # See http://www.apache.org/licenses/LICENSE
20 # Some "constants"
22 pathname=$PATH
23 echo="yes"
26 # Find out what OS we are running for later on
28 os=`(uname) 2>/dev/null`
31 # Parse command line
33 for args in $*
35 case $args in
36 -s ) echo="no" ;;
37 -p* ) pathname="`echo $args | sed 's/^..//'`" ;;
38 * ) programs="$programs $args" ;;
39 esac
40 done
43 # Now we make the adjustments required for OS/2 and everyone
44 # else :)
46 # First of all, all OS/2 programs have the '.exe' extension.
47 # Next, we adjust PATH (or what was given to us as PATH) to
48 # be whitespace separated directories.
49 # Finally, we try to determine the best flag to use for
50 # test/[] to look for an executable file. OS/2 just has '-r'
51 # but with other OSs, we do some funny stuff to check to see
52 # if test/[] knows about -x, which is the preferred flag.
55 if [ "x$os" = "xOS/2" ]
56 then
57 ext=".exe"
58 pathname=`echo -E $pathname |
59 sed 's/^;/.;/
60 s/;;/;.;/g
61 s/;$/;./
62 s/;/ /g
63 s/\\\\/\\//g' `
64 test_exec_flag="-r"
65 else
66 ext="" # No default extensions
67 pathname=`echo $pathname |
68 sed 's/^:/.:/
69 s/::/:.:/g
70 s/:$/:./
71 s/:/ /g' `
72 # Here is how we test to see if test/[] can handle -x
73 testfile="pp.t.$$"
75 cat > $testfile <<ENDTEST
76 #!/bin/sh
77 if [ -x / ] || [ -x /bin ] || [ -x /bin/ls ]; then
78 exit 0
80 exit 1
81 ENDTEST
83 if `/bin/sh $testfile 2>/dev/null`; then
84 test_exec_flag="-x"
85 else
86 test_exec_flag="-r"
88 rm -f $testfile
91 for program in $programs
93 for path in $pathname
95 if [ $test_exec_flag $path/${program}${ext} ] && \
96 [ ! -d $path/${program}${ext} ]; then
97 if [ "x$echo" = "xyes" ]; then
98 echo $path/${program}${ext}
100 exit 0
103 # Next try without extension (if one was used above)
104 if [ "x$ext" != "x" ]; then
105 if [ $test_exec_flag $path/${program} ] && \
106 [ ! -d $path/${program} ]; then
107 if [ "x$echo" = "xyes" ]; then
108 echo $path/${program}
110 exit 0
113 done
114 done
115 exit 1