This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
backport incpth
[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:.
70?T: xxx dlist i j croak
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)
108 $echo 'extern int foo;' > try.c
109 set X `$cppstdin -v try.c 2>&1 | $awk '/^#include </,/^End of search /'|$cppfilter $grep '/include'`
110 shift
111 if $test $# -gt 0; then
112 incpth="$incpth $*"
113 incpth="`$echo $incpth|$sed 's/^ //'`"
114 for i in $*; do
115 j="`$echo $i|$sed 's,/include$,/lib,'`"
116 if $test -d $j; then
117 libpth="$libpth $j"
118 fi
119 done
120 libpth="`$echo $libpth|$sed 's/^ //'`"
121 for xxx in $libpth $loclibpth $plibpth $glibpth; do
122 if $test -d $xxx; then
123 case " $libpth " in
124 *" $xxx "*) ;;
125 *) libpth="$libpth $xxx";;
126 esac
127 fi
128 done
129 fi
130 $rm -f try.c
131 case "$usrinc" in
132 '') for i in $incpth; do
133 if $test -f $i/errno.h -a -f $i/stdio.h -a -f $i/time.h; then
134 usrinc="$i"
135 break
136 fi
137 done
138 ;;
139 esac
140
141 case "$usecrosscompile" in
142 $define|true|[yY]*)
143 case "$incpth" in
144 '') echo "Incpth not defined." >&4; croak=y ;;
145 *) echo "Using incpth '$incpth'." >&4 ;;
146 esac
147 case "$libpth" in
148 '') echo "Libpth not defined." >&4; croak=y ;;
149 *) echo "Using libpth '$libpth'." >&4 ;;
150 esac
151 case "$usrinc" in
152 '') echo "Usrinc not defined." >&4; croak=y ;;
153 *) echo "Using usrinc $usrinc." >&4 ;;
154 esac
155 case "$croak" in
156 y)
157 if test "X$sysroot" = X; then
158 echo "Cannot continue, aborting." >&4; exit 1
159 else
160 echo "Cross-compiling using sysroot $sysroot, failing to guess inc/lib paths is not fatal" >&4
161 fi
162 ;;
163 esac
164 ;;
165 esac
166 ;;
167esac
168
169: Default value for incpth is just usrinc
170case "$incpth" in
171'') incpth="$usrinc";;
172esac
173
959f3c4c
JH
174: Set private lib path
175case "$plibpth" in
176'') if ./mips; then
177?X: on mips, we DO NOT want /lib, and we want $incpath/usr/lib
9c11722e
MB
178 plibpth="$incpath/usr/lib $sysroot/usr/local/lib $sysroot/usr/ccs/lib"
179 fi;;
959f3c4c
JH
180esac
181case "$libpth" in
182' ') dlist='';;
183'') dlist="$loclibpth $plibpth $glibpth";;
184*) dlist="$libpth";;
185esac
186
187: Now check and see which directories actually exist, avoiding duplicates
959f3c4c
JH
188for xxx in $dlist
189do
190 if $test -d $xxx; then
191 case " $libpth " in
192 *" $xxx "*) ;;
193 *) libpth="$libpth $xxx";;
194 esac
195 fi
196done
197$cat <<'EOM'
198
199Some systems have incompatible or broken versions of libraries. Among
200the directories listed in the question below, please remove any you
201know not to be holding relevant libraries, and add any that are needed.
202Say "none" for none.
203
204EOM
9c11722e
MB
205
206if test "X$sysroot" != X; then
207 $cat <<EOM
208You have set sysroot to $sysroot, please supply the directories excluding sysroot
209
210EOM
211fi
212
959f3c4c
JH
213case "$libpth" in
214'') dflt='none';;
215*)
216?X: strip leading space
217 set X $libpth
218 shift
219 dflt=${1+"$@"}
220 ;;
221esac
222rp="Directories to use for library searches?"
223. ./myread
224case "$ans" in
225none) libpth=' ';;
226*) libpth="$ans";;
227esac
228