This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Backport all Configure patches 17671 .. 17881
[metaconfig.git] / U / modified / usenm.U
1 ?RCS: $Id: usenm.U,v 3.0.1.1 1997/02/28 16:26:40 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: usenm.U,v $
12 ?RCS: Revision 3.0.1.1  1997/02/28  16:26:40  ram
13 ?RCS: patch61: don't use nm with the GNU C library
14 ?RCS: patch61: added support for Linux shared libs
15 ?RCS:
16 ?RCS: Revision 3.0  1993/08/18  12:09:57  ram
17 ?RCS: Baseline for dist 3.0 netwide release.
18 ?RCS:
19 ?MAKE:usenm runnm nm_opt nm_so_opt: cat test Myread Oldconfig myuname grep \
20         nm d_gnulibc osname egrep rsrc
21 ?MAKE:  -pick add $@ %<
22 ?S:usenm:
23 ?S:     This variable contains 'true' or 'false' depending whether the
24 ?S:     nm extraction is wanted or not.
25 ?S:.
26 ?S:runnm:
27 ?S:     This variable contains 'true' or 'false' depending whether the
28 ?S:     nm extraction should be performed or not, according to the value
29 ?S:     of usenm and the flags on the Configure command line.
30 ?S:.
31 ?S:nm_opt:
32 ?S:     This variable holds the options that may be necessary for nm.
33 ?S:.
34 ?S:nm_so_opt:
35 ?S:     This variable holds the options that may be necessary for nm
36 ?S:     to work on a shared library but that can not be used on an
37 ?S:     archive library.  Currently, this is only used by Linux, where
38 ?S:     nm --dynamic is *required* to get symbols from an ELF library which
39 ?S:     has been stripped, but nm --dynamic is *fatal* on an archive library.
40 ?S:     Maybe Linux should just always set usenm=false.
41 ?S:.
42 : see if nm is to be used to determine whether a symbol is defined or not
43 ?X: If there is enough enquiries, it might be worth to wait for the nm
44 ?X: extraction. Otherwise, the C compilations might be a better deal.
45 ?X:
46 ?X: Don't bother if we're using GNU libc -- skimo
47 case "$usenm" in
48 '')
49         dflt=''
50         case "$d_gnulibc" in
51         "$define")
52                 echo " "
53                 echo "nm probably won't work on the GNU C Library." >&4
54                 dflt=n
55                 ;;
56         esac
57         case "$dflt" in
58         '') 
59                 if $test "$osname" = aix -a "X$PASE" != "$Xdefine" -a ! -f /lib/syscalls.exp; then
60                         echo " "
61                         echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
62                         echo "'nm' won't be sufficient on this sytem." >&4
63                         dflt=n
64                 fi
65                 ;;
66         esac
67         case "$dflt" in
68         '') dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
69                 if $test $dflt -gt 20; then
70                         dflt=y
71                 else
72                         dflt=n
73                 fi
74                 ;;
75         esac
76         ;;
77 *)
78         case "$usenm" in
79         true|$define) dflt=y;;
80         *) dflt=n;;
81         esac
82         ;;
83 esac
84 $cat <<EOM
85
86 I can use $nm to extract the symbols from your C libraries. This
87 is a time consuming task which may generate huge output on the disk (up
88 to 3 megabytes) but that should make the symbols extraction faster. The
89 alternative is to skip the 'nm' extraction part and to compile a small
90 test program instead to determine whether each symbol is present. If
91 you have a fast C compiler and/or if your 'nm' output cannot be parsed,
92 this may be the best solution.
93
94 You probably shouldn't let me use 'nm' if you are using the GNU C Library.
95
96 EOM
97 rp="Shall I use $nm to extract C symbols from the libraries?"
98 . ./myread
99 case "$ans" in
100 [Nn]*) usenm=false;;
101 *) usenm=true;;
102 esac
103
104 ?X: Name extraction is to be run if 'nm' usage is wanted and if no -r flag
105 ?X: was provided to configure (in which case we simply re-use the previous
106 ?X: values).
107 runnm=$usenm
108 case "$reuseval" in
109 true) runnm=false;;
110 esac
111
112 : nm options which may be necessary
113 case "$nm_opt" in
114 '') if $test -f /mach_boot; then
115                 nm_opt=''       # Mach
116         elif $test -d /usr/ccs/lib; then
117                 nm_opt='-p'     # Solaris (and SunOS?)
118         elif $test -f /dgux; then
119                 nm_opt='-p'     # DG-UX
120         elif $test -f /lib64/rld; then
121                 nm_opt='-p'     # 64-bit Irix
122         else
123                 nm_opt=''
124         fi;;
125 esac
126
127 : nm options which may be necessary for shared libraries but illegal
128 : for archive libraries.  Thank you, Linux.
129 case "$nm_so_opt" in
130 '')     case "$myuname" in
131         *linux*)
132                 if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
133                         nm_so_opt='--dynamic'
134                 fi
135                 ;;
136         esac
137         ;;
138 esac
139