This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
/\=/ does not require \ even in older awk
[metaconfig.git] / U / modified / libpth.U
CommitLineData
9b04e79a 1?RCS: $Id: libpth.U 1 2006-08-24 12:32:52Z rmanfredi $
959f3c4c 2?RCS:
9b04e79a 3?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
4c42341b 4?RCS:
65a32477 5?RCS: You may redistribute only under the terms of the Artistic License,
959f3c4c
JH
6?RCS: as specified in the README file that comes with the distribution.
7?RCS: You may reuse parts of this distribution only within the terms of
65a32477 8?RCS: that same Artistic License; a copy of which may be found at the root
9b04e79a 9?RCS: of the source tree for dist 4.0.
959f3c4c
JH
10?RCS:
11?RCS: $Log: libpth.U,v $
12?RCS: Revision 3.0.1.6 1997/02/28 16:08:49 ram
13?RCS: patch61: new loclibpth variable
14?RCS:
15?RCS: Revision 3.0.1.5 1995/01/11 15:31:30 ram
16?RCS: patch45: call ./mips instead of just mips (WED)
17?RCS:
18?RCS: Revision 3.0.1.4 1994/08/29 16:29:15 ram
19?RCS: patch32: added /lib/pa1.1 for HP-UX specially tuned PA-RISC libs (ADO)
20?RCS: patch32: fixed information message, making it clearer (ADO)
21?RCS:
22?RCS: Revision 3.0.1.3 1994/06/20 07:03:54 ram
23?RCS: patch30: added /usr/shlib to glibpth for shared-only libraries
24?RCS:
25?RCS: Revision 3.0.1.2 1994/05/13 15:26:57 ram
26?RCS: patch27: fixed a typo (libpth -> glibpth)
27?RCS:
28?RCS: Revision 3.0.1.1 1994/05/06 15:07:53 ram
29?RCS: patch23: now asks for library directories to be searched (ADO)
30?RCS:
31?RCS: Revision 3.0 1993/08/18 12:09:02 ram
32?RCS: Baseline for dist 3.0 netwide release.
33?RCS:
34?X:
35?X: This unit initializes the path for C library lookup.
36?X:
3af75476
MB
37?MAKE:libpth glibpth xlibpth plibpth loclibpth incpth: \
38 usrinc incpath test cat Myread Oldconfig sysroot osname \
39 ccname echo cppstdin awk grep sed rm usecrosscompile
959f3c4c
JH
40?MAKE: -pick add $@ %<
41?S:libpth:
42?S: This variable holds the general path (space-separated) used to find
43?S: libraries. It is intended to be used by other units.
44?S:.
45?S:glibpth:
46?S: This variable holds the general path (space-separated) used to
47?S: find libraries. It may contain directories that do not exist on
48?S: this platform, libpth is the cleaned-up version.
49?S:.
50?S:xlibpth:
51?S: This variable holds extra path (space-separated) used to find
52?S: libraries on this platform, for example CPU-specific libraries
53?S: (on multi-CPU platforms) may be listed here.
54?S:.
55?S:loclibpth:
56?S: This variable holds the paths (space-separated) used to find local
57?S: libraries. It is prepended to libpth, and is intended to be easily
58?S: set from the command line.
59?S:.
60?S:plibpth:
61?S: Holds the private path used by Configure to find out the libraries.
62?S: Its value is prepend to libpth. This variable takes care of special
63?S: machines, like the mips. Usually, it should be empty.
64?S:.
3af75476
MB
65?S:incpth:
66?S: This variable must precede the normal include path to get the
67?S: right one, as in "$incpath/usr/include" or "$incpath/usr/lib".
68?S: Value can be "" or "/bsd43" on mips.
69?S:.
d3ce47a2 70?T: xxx dlist i j croak realpath inclibpth
3af75476
MB
71?LINT:extern incpth
72?LINT:change usrinc
959f3c4c
JH
73?INIT:: change the next line if compiling for Xenix/286 on Xenix/386
74?INIT:xlibpth='/usr/lib/386 /lib/386'
959f3c4c
JH
75?INIT:: Possible local library directories to search.
76?INIT:loclibpth="/usr/local/lib /opt/local/lib /usr/gnu/lib"
77?INIT:loclibpth="$loclibpth /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib"
78?INIT:
79?INIT:: general looking path for locating libraries
2402c448 80?INIT:glibpth="/lib /usr/lib $xlibpth"
959f3c4c 81?INIT:glibpth="$glibpth /usr/ccs/lib /usr/ucblib /usr/local/lib"
d12857d9
JH
82?X: /shlib is for Digital Unix 4.0
83?X: /usr/shlib is for OSF/1 systems.
4ee071c7
JH
84?INIT:test -f /usr/shlib/libc.so && glibpth="/usr/shlib $glibpth"
85?INIT:test -f /shlib/libc.so && glibpth="/shlib $glibpth"
956c4d8a 86?INIT:test -d /usr/lib64 && glibpth="$glibpth /lib64 /usr/lib64 /usr/local/lib64"
959f3c4c
JH
87?INIT:
88?INIT:: Private path used by Configure to find libraries. Its value
89?INIT:: is prepended to libpth. This variable takes care of special
90?INIT:: machines, like the mips. Usually, it should be empty.
91?INIT:plibpth=''
92?INIT:
3af75476
MB
93?X:cppfilter is later used in Findhdr.U, but we not want to expose it to config.h
94?T:cppfilter
95: Adjust cppfilter for path component separator
96case "$osname" in
97vos) cppfilter="tr '\\\\>' '/' |" ;; # path component separator is >
98os2) cppfilter="sed -e 's|\\\\\\\\|/|g' |" ;; # path component separator is \
99*) cppfilter='' ;;
100esac
101
102: Use gcc to determine libpth and incpth
103# If using gcc or clang, we can get better values for libpth, incpth
104# and usrinc directly from the compiler.
105# Note that ccname for clang is also gcc.
106case "$ccname" in
107 gcc)
ecbeb19a 108 realpath=`which realpath 2>/dev/null | sed 's/no realpath in.*//'`
3af75476
MB
109 $echo 'extern int foo;' > try.c
110 set X `$cppstdin -v try.c 2>&1 | $awk '/^#include </,/^End of search /'|$cppfilter $grep '/include'`
111 shift
d3ce47a2 112 inclibpth=""
3af75476 113 if $test $# -gt 0; then
3af75476 114 for i in $*; do
ecbeb19a
MB
115 case $realpath in
116 */realpath) i=`$realpath $i` ;;
117 esac
118 incpth="$incpth $i"
119 j="`$echo $i | $sed 's,/include[^/]*,/lib,'`"
3af75476 120 if $test -d $j; then
ecbeb19a 121 inclibpth="$inclibpth $j"
3af75476
MB
122 fi
123 done
ecbeb19a
MB
124 incpth="`$echo $incpth | $sed 's/^ //'`"
125 for xxx in $inclibpth $loclibpth $plibpth $glibpth; do
3af75476 126 if $test -d $xxx; then
ecbeb19a
MB
127 case $realpath in
128 */realpath) xxx=`$realpath $xxx` ;;
129 esac
3af75476
MB
130 case " $libpth " in
131 *" $xxx "*) ;;
132 *) libpth="$libpth $xxx";;
133 esac
134 fi
135 done
ecbeb19a 136 libpth="`$echo $libpth | $sed 's/^ //'`"
3af75476
MB
137 fi
138 $rm -f try.c
139 case "$usrinc" in
140 '') for i in $incpth; do
141 if $test -f $i/errno.h -a -f $i/stdio.h -a -f $i/time.h; then
142 usrinc="$i"
143 break
144 fi
145 done
146 ;;
147 esac
148
149 case "$usecrosscompile" in
150 $define|true|[yY]*)
151 case "$incpth" in
152 '') echo "Incpth not defined." >&4; croak=y ;;
153 *) echo "Using incpth '$incpth'." >&4 ;;
154 esac
155 case "$libpth" in
156 '') echo "Libpth not defined." >&4; croak=y ;;
157 *) echo "Using libpth '$libpth'." >&4 ;;
158 esac
159 case "$usrinc" in
160 '') echo "Usrinc not defined." >&4; croak=y ;;
161 *) echo "Using usrinc $usrinc." >&4 ;;
162 esac
163 case "$croak" in
164 y)
165 if test "X$sysroot" = X; then
166 echo "Cannot continue, aborting." >&4; exit 1
167 else
168 echo "Cross-compiling using sysroot $sysroot, failing to guess inc/lib paths is not fatal" >&4
169 fi
170 ;;
171 esac
172 ;;
173 esac
174 ;;
175esac
176
177: Default value for incpth is just usrinc
178case "$incpth" in
179'') incpth="$usrinc";;
180esac
181
959f3c4c
JH
182: Set private lib path
183case "$plibpth" in
184'') if ./mips; then
185?X: on mips, we DO NOT want /lib, and we want $incpath/usr/lib
9c11722e
MB
186 plibpth="$incpath/usr/lib $sysroot/usr/local/lib $sysroot/usr/ccs/lib"
187 fi;;
959f3c4c
JH
188esac
189case "$libpth" in
190' ') dlist='';;
191'') dlist="$loclibpth $plibpth $glibpth";;
192*) dlist="$libpth";;
193esac
194
195: Now check and see which directories actually exist, avoiding duplicates
959f3c4c
JH
196for xxx in $dlist
197do
198 if $test -d $xxx; then
199 case " $libpth " in
200 *" $xxx "*) ;;
201 *) libpth="$libpth $xxx";;
202 esac
203 fi
204done
205$cat <<'EOM'
206
207Some systems have incompatible or broken versions of libraries. Among
208the directories listed in the question below, please remove any you
209know not to be holding relevant libraries, and add any that are needed.
210Say "none" for none.
211
212EOM
9c11722e
MB
213
214if test "X$sysroot" != X; then
215 $cat <<EOM
216You have set sysroot to $sysroot, please supply the directories excluding sysroot
217
218EOM
219fi
220
959f3c4c
JH
221case "$libpth" in
222'') dflt='none';;
223*)
224?X: strip leading space
225 set X $libpth
226 shift
227 dflt=${1+"$@"}
228 ;;
229esac
230rp="Directories to use for library searches?"
231. ./myread
232case "$ans" in
233none) libpth=' ';;
234*) libpth="$ans";;
235esac
236