This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
RE: [perl #26136] localtime(3) calls tzset(3), but localtime_r(3) may not.
[metaconfig.git] / U / modified / libc.U
CommitLineData
959f3c4c
JH
1?RCS: $Id: libc.U,v 3.0.1.10 1997/02/28 15:56:48 ram Exp $
2?RCS:
3?RCS: Copyright (c) 1991-1993, Raphael Manfredi
4?RCS:
5?RCS: You may redistribute only under the terms of the Artistic Licence,
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
8?RCS: that same Artistic Licence; a copy of which may be found at the root
9?RCS: of the source tree for dist 3.0.
10?RCS:
11?RCS: $Log: libc.U,v $
12?RCS: Revision 3.0.1.10 1997/02/28 15:56:48 ram
13?RCS: patch61: replaced .a with $_a all over the place
14?RCS: patch61: added support for HPUX-10 nm output
15?RCS:
16?RCS: Revision 3.0.1.9 1995/07/25 14:11:56 ram
17?RCS: patch56: now knows about OS/2 platforms
18?RCS:
19?RCS: Revision 3.0.1.8 1995/05/12 12:20:47 ram
20?RCS: patch54: made sure only most recent version of shared lib is picked
21?RCS: patch54: final "nm -p" check now uses xscan and xrun like everybody
22?RCS: patch54: can now grok linux nm output with lead __IO (ADO)
23?RCS: patch54: added support for linux ELF output, using 'W' for alias (ADO)
24?RCS:
25?RCS: Revision 3.0.1.7 1994/10/29 16:23:40 ram
26?RCS: patch36: now looks for shared libraries before anything else (ADO)
27?RCS: patch36: added new nm output format (ADO)
28?RCS:
29?RCS: Revision 3.0.1.6 1994/08/29 16:28:10 ram
30?RCS: patch32: added I-type symbols for nm output parsing on Linux
31?RCS:
32?RCS: Revision 3.0.1.5 1994/06/20 07:03:24 ram
33?RCS: patch30: checks are now presented by succession of if/elif
34?RCS: patch30: uniformized checks for shared objects with new so symbol
35?RCS:
36?RCS: Revision 3.0.1.4 1994/05/06 15:06:33 ram
37?RCS: patch23: added shared library knowledge (ADO and WED)
38?RCS:
39?RCS: Revision 3.0.1.3 1994/01/24 14:12:17 ram
40?RCS: patch16: can now export nm_extract as an internal-use only variable
41?RCS:
42?RCS: Revision 3.0.1.2 1993/09/13 16:09:03 ram
43?RCS: patch10: added special handling for Apollo systems (WAD)
44?RCS:
45?RCS: Revision 3.0.1.1 1993/08/27 14:40:03 ram
46?RCS: patch7: added entry for /usr/shlib/libc.so (OSF/1 machines)
47?RCS:
48?RCS: Revision 3.0 1993/08/18 12:08:57 ram
49?RCS: Baseline for dist 3.0 netwide release.
50?RCS:
51?MAKE:libc +nm_extract: echo n c rm test grep Getfile Myread Oldconfig Loc \
52 sed libs incpath libpth ar runnm nm nm_opt nm_so_opt contains xlibpth \
a3e4b67c 53 so _a _o osname trnl tr sort uniq
959f3c4c
JH
54?MAKE: -pick add $@ %<
55?S:libc:
56?S: This variable contains the location of the C library.
57?S:.
58?S:nm_extract:
59?S: This variable holds the name of the extraction command used to process
60?S: the output of nm and yield the list of defined symbols. It is used
61?S: internally by Configure.
62?S:.
63?T:thislib try libnames xxx xscan xrun thisname com tans file
64?F:!libnames
bf7497fb 65?LINT:extern PASE
04c4183c 66?LINT:extern libnames
e7e30831 67?LINT:change libnames
959f3c4c 68?LINT:change nm_opt
04c4183c 69?INIT:libnames=''
959f3c4c
JH
70case "$runnm" in
71true)
72?X: indentation is wrong on purpose--RAM
73: get list of predefined functions in a handy place
74echo " "
75case "$libc" in
76'') libc=unknown
77 case "$libs" in
78 *-lc_s*) libc=`./loc libc_s$_a $libc $libpth`
79 esac
80 ;;
81esac
959f3c4c
JH
82case "$libs" in
83'') ;;
84*) for thislib in $libs; do
85 case "$thislib" in
86 -lc|-lc_s)
87 : Handle C library specially below.
88 ;;
89 -l*)
90 thislib=`echo $thislib | $sed -e 's/^-l//'`
91 if try=`./loc lib$thislib.$so.'*' X $libpth`; $test -f "$try"; then
92 :
93 elif try=`./loc lib$thislib.$so X $libpth`; $test -f "$try"; then
94 :
95 elif try=`./loc lib$thislib$_a X $libpth`; $test -f "$try"; then
96 :
97 elif try=`./loc $thislib$_a X $libpth`; $test -f "$try"; then
98 :
99 elif try=`./loc lib$thislib X $libpth`; $test -f "$try"; then
100 :
101 elif try=`./loc $thislib X $libpth`; $test -f "$try"; then
102 :
103 elif try=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$try"; then
104 :
105 else
106 try=''
107 fi
108 libnames="$libnames $try"
109 ;;
110 *) libnames="$libnames $thislib" ;;
111 esac
112 done
113 ;;
114esac
115?X:
116?X: Some systems (e.g. DG/UX) use "environmental" links, which make the test
117?X: -f fail. Ditto for symbolic links. So in order to reliably check the
118?X: existence of a file, we use test -r. It will still fail with DG/UX links
119?X: though, but at least it will detect symbolic links. At some strategic
120?X: points, we make use of (test -h), using a sub-shell in case builtin test
121?X: does not implement the -h check for symbolic links. This makes it
122?X: possible to preset libc in a hint file for instance and have it show up
123?X: as-is in the question.
124?X:
125xxx=normal
126case "$libc" in
127unknown)
128?X:
129?X: The sed below transforms .so.9 .so.12 into something like .so.0009 .so.0012,
130?X: then sorts on it to allow keeping .so.12 instead of .so.9 as the latest
131?X: up-to-date library. The initial filename (before sed munging, saved in hold
132?X: space via 'h') is appended via 'G' before sorting, then the leading munged
133?X: part is removed after sorting. Nice efficient work from Tye McQueen.
134?X: The initial blurfl is here to prevent the trailing pipe from producing an
135?X: empty string, causing Configure to output all its set variables!
136?X:
137 set /lib/libc.$so
138 for xxx in $libpth; do
139 $test -r $1 || set $xxx/libc.$so
140 : The messy sed command sorts on library version numbers.
141 $test -r $1 || \
142 set `echo blurfl; echo $xxx/libc.$so.[0-9]* | \
143 tr ' ' $trnl | egrep -v '\.[A-Za-z]*$' | $sed -e '
144 h
145 s/[0-9][0-9]*/0000&/g
146 s/0*\([0-9][0-9][0-9][0-9][0-9]\)/\1/g
147 G
148 s/\n/ /' | \
a3e4b67c 149 $sort | $sed -e 's/^.* //'`
959f3c4c
JH
150 eval set \$$#
151 done
152 $test -r $1 || set /usr/ccs/lib/libc.$so
153 $test -r $1 || set /lib/libsys_s$_a
154 ;;
155*)
156?X: ensure the test below for the (shared) C library will fail
157 set blurfl
158 ;;
159esac
160if $test -r "$1"; then
161 echo "Your (shared) C library seems to be in $1."
162 libc="$1"
163elif $test -r /lib/libc && $test -r /lib/clib; then
164?X:
165?X: Apollo has its C library in /lib/clib AND /lib/libc
166?X: not to mention its math library in /lib/syslib...
167?X:
168 echo "Your C library seems to be in both /lib/clib and /lib/libc."
169 xxx=apollo
170 libc='/lib/clib /lib/libc'
171 if $test -r /lib/syslib; then
172 echo "(Your math library is in /lib/syslib.)"
173?X: Put syslib in libc -- not quite right, but won't hurt
174 libc="$libc /lib/syslib"
175 fi
176elif $test -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
177 echo "Your C library seems to be in $libc, as you said before."
178?X: For mips, and...
179elif $test -r $incpath/usr/lib/libc$_a; then
180 libc=$incpath/usr/lib/libc$_a;
181 echo "Your C library seems to be in $libc. That's fine."
182elif $test -r /lib/libc$_a; then
183 libc=/lib/libc$_a;
184 echo "Your C library seems to be in $libc. You're normal."
185else
186 if tans=`./loc libc$_a blurfl/dyick $libpth`; $test -r "$tans"; then
187 :
188 elif tans=`./loc libc blurfl/dyick $libpth`; $test -r "$tans"; then
189 libnames="$libnames "`./loc clib blurfl/dyick $libpth`
190 elif tans=`./loc clib blurfl/dyick $libpth`; $test -r "$tans"; then
191 :
192 elif tans=`./loc Slibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
193 :
194 elif tans=`./loc Mlibc$_a blurfl/dyick $xlibpth`; $test -r "$tans"; then
195 :
196 else
197 tans=`./loc Llibc$_a blurfl/dyick $xlibpth`
198 fi
199 if $test -r "$tans"; then
200 echo "Your C library seems to be in $tans, of all places."
201 libc=$tans
202 else
203 libc='blurfl'
204 fi
205fi
206if $test $xxx = apollo -o -r "$libc" || (test -h "$libc") >/dev/null 2>&1; then
207 dflt="$libc"
208 cat <<EOM
209
210If the guess above is wrong (which it might be if you're using a strange
211compiler, or your machine supports multiple models), you can override it here.
212
213EOM
214else
215 dflt=''
a3e4b67c 216 echo $libpth | $tr ' ' $trnl | $sort | $uniq > libpath
959f3c4c
JH
217 cat >&4 <<EOM
218I can't seem to find your C library. I've looked in the following places:
219
220EOM
221 $sed 's/^/ /' libpath
222 cat <<EOM
223
224None of these seems to contain your C library. I need to get its name...
225
226EOM
227fi
228fn=f
229rp='Where is your C library?'
230. ./getfile
231libc="$ans"
232
233echo " "
a3e4b67c 234echo $libc $libnames | $tr ' ' $trnl | $sort | $uniq > libnames
959f3c4c
JH
235set X `cat libnames`
236shift
237xxx=files
238case $# in 1) xxx=file; esac
239echo "Extracting names from the following $xxx for later perusal:" >&4
240echo " "
241$sed 's/^/ /' libnames >&4
242echo " "
243$echo $n "This may take a while...$c" >&4
244
245?X:
246?X: Linux may need the special Dynamic option to nm for shared libraries.
247?X: In general, this is stored in the nm_so_opt variable.
248?X: Unfortunately, that option may be fatal on non-shared libraries.
249?X:
250for file in $*; do
251 case $file in
252 *$so*) $nm $nm_so_opt $nm_opt $file 2>/dev/null;;
253 *) $nm $nm_opt $file 2>/dev/null;;
254 esac
255done >libc.tmp
256
257$echo $n ".$c"
258?X:
259?X: To accelerate processing, we look at the correct 'sed' command
260?X: by using a small subset of libc.tmp, i.e. fprintf function.
261?X: When we know which sed command to use, do the name extraction
262?X:
263$grep fprintf libc.tmp > libc.ptf
264?X:
265?X: In order to ehance readability and save some space, we define
266?X: some variables that will be "eval"ed.
267?X:
268xscan='eval "<libc.ptf $com >libc.list"; $echo $n ".$c" >&4'
9f542ee7 269xrun='eval "<libc.tmp $com >libc.list"; echo "done." >&4'
959f3c4c
JH
270?X: BSD-like output, I and W types added for Linux
271?X: Some versions of Linux include a leading __IO in the symbol name.
272?X: HPUX10 reportedly has trailing spaces, though I'm suprised it has
273?X: BSD-like output. (AD).
274xxx='[ADTSIW]'
868ab49f 275if com="$sed -n -e 's/__IO//' -e 's/^.* $xxx *//p'";\
959f3c4c
JH
276 eval $xscan;\
277 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
278 eval $xrun
279?X: SYSV-like output
280elif com="$sed -n -e 's/^__*//' -e 's/^\([a-zA-Z_0-9$]*\).*xtern.*/\1/p'";\
281 eval $xscan;\
282 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
283 eval $xrun
284elif com="$sed -n -e '/|UNDEF/d' -e '/FUNC..GL/s/^.*|__*//p'";\
285 eval $xscan;\
286 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
287 eval $xrun
288elif com="$sed -n -e 's/^.* D __*//p' -e 's/^.* D //p'";\
289 eval $xscan;\
290 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
291 eval $xrun
292elif com="$sed -n -e 's/^_//' -e 's/^\([a-zA-Z_0-9]*\).*xtern.*text.*/\1/p'";\
293 eval $xscan;\
294 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
295 eval $xrun
296elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p'";\
297 eval $xscan;\
298 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
299 eval $xrun
300elif com="$grep '|' | $sed -n -e '/|COMMON/d' -e '/|DATA/d' \
301 -e '/ file/d' -e 's/^\([^ ]*\).*/\1/p'";\
302 eval $xscan;\
303 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
304 eval $xrun
305elif com="$sed -n -e 's/^.*|FUNC |GLOB .*|//p' -e 's/^.*|FUNC |WEAK .*|//p'";\
306 eval $xscan;\
307 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
308 eval $xrun
309?X: mips nm output (sysV)
310elif com="$sed -n -e 's/^__//' -e '/|Undef/d' -e '/|Proc/s/ .*//p'";\
311 eval $xscan;\
312 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
313 eval $xrun
314elif com="$sed -n -e 's/^.*|Proc .*|Text *| *//p'";\
315 eval $xscan;\
316 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
317 eval $xrun
318elif com="$sed -n -e '/Def. Text/s/.* \([^ ]*\)\$/\1/p'";\
319 eval $xscan;\
320 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
321 eval $xrun
322?X: OS/2 nm output
323elif com="$sed -n -e 's/^[-0-9a-f ]*_\(.*\)=.*/\1/p'";\
324 eval $xscan;\
325 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
326 eval $xrun
327elif com="$sed -n -e 's/.*\.text n\ \ \ \.//p'";\
328 eval $xscan;\
329 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
330 eval $xrun
331?X: AIX nm output
332elif com="sed -n -e 's/^__.*//' -e 's/[ ]*D[ ]*[0-9]*.*//p'";\
333 eval $xscan;\
334 $contains '^fprintf$' libc.list >/dev/null 2>&1; then
335 eval $xrun
336else
337 $nm -p $* 2>/dev/null >libc.tmp
338 $grep fprintf libc.tmp > libc.ptf
339 if com="$sed -n -e 's/^.* [ADTSIW] *_[_.]*//p' -e 's/^.* [ADTSIW] //p'";\
340 eval $xscan; $contains '^fprintf$' libc.list >/dev/null 2>&1
341 then
342 nm_opt='-p'
343 eval $xrun
344 else
345 echo " "
346 echo "$nm didn't seem to work right. Trying $ar instead..." >&4
347 com=''
348 if $ar t $libc > libc.tmp && $contains '^fprintf$' libc.tmp >/dev/null 2>&1; then
349 for thisname in $libnames $libc; do
350 $ar t $thisname >>libc.tmp
351 done
352 $sed -e "s/\\$_o\$//" < libc.tmp > libc.list
353 echo "Ok." >&4
354 elif test "X$osname" = "Xos2" && $ar tv $libc > libc.tmp; then
355 # Repeat libc to extract forwarders to DLL entries too
356 for thisname in $libnames $libc; do
357 $ar tv $thisname >>libc.tmp
358 # Revision 50 of EMX has bug in $ar.
359 # it will not extract forwarders to DLL entries
360 # Use emximp which will extract exactly them.
361 emximp -o tmp.imp $thisname \
362 2>/dev/null && \
363 $sed -e 's/^\([_a-zA-Z0-9]*\) .*$/\1/p' \
364 < tmp.imp >>libc.tmp
365 $rm tmp.imp
366 done
367 $sed -e "s/\\$_o\$//" -e 's/^ \+//' < libc.tmp > libc.list
368 echo "Ok." >&4
369 else
370 echo "$ar didn't seem to work right." >&4
371 echo "Maybe this is a Cray...trying bld instead..." >&4
372 if bld t $libc | $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" > libc.list
373 then
374 for thisname in $libnames; do
375 bld t $libnames | \
376 $sed -e 's/.*\///' -e "s/\\$_o:.*\$//" >>libc.list
377 $ar t $thisname >>libc.tmp
378 done
379 echo "Ok." >&4
380 else
381 echo "That didn't work either. Giving up." >&4
382 exit 1
383 fi
384 fi
385 fi
386fi
387nm_extract="$com"
a7eb1db8
MB
388case "$PASE" in
389define)
390 echo " "
391 echo "Since you are compiling for PASE, extracting more symbols from libc.a ...">&4
392 dump -Tv /lib/libc.a | awk '$7 == "/unix" {print $5 " " $8}' | grep "^SV" | awk '{print $2}' >> libc.list
393 ;;
394*) if $test -f /lib/syscalls.exp; then
959f3c4c
JH
395 echo " "
396 echo "Also extracting names from /lib/syscalls.exp for good ole AIX..." >&4
57c0dc72 397 $sed -n 's/^\([^ ]*\)[ ]*syscall[0-9]*[ ]*$/\1/p' /lib/syscalls.exp >>libc.list
a7eb1db8
MB
398 fi
399 ;;
400esac
959f3c4c
JH
401;;
402esac
403$rm -f libnames libpath
404