?RCS: $Id$
?RCS:
?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
?RCS:
?RCS: You may redistribute only under the terms of the Artistic License,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic License; a copy of which may be found at the root
?RCS: of the source tree for dist 4.0.
?RCS:
?RCS: $Log: usenm.U,v $
?RCS: Revision 3.0.1.1  1997/02/28  16:26:40  ram
?RCS: patch61: don't use nm with the GNU C library
?RCS: patch61: added support for Linux shared libs
?RCS:
?RCS: Revision 3.0  1993/08/18  12:09:57  ram
?RCS: Baseline for dist 3.0 netwide release.
?RCS:
?MAKE:usenm runnm nm_opt nm_so_opt: cat test Myread Oldconfig grep \
	d_gnulibc nm egrep rsrc osname Guess
?MAKE:	-pick add $@ %<
?S:usenm:
?S:	This variable contains 'true' or 'false' depending whether the
?S:	nm extraction is wanted or not.
?S:.
?S:runnm:
?S:	This variable contains 'true' or 'false' depending whether the
?S:	nm extraction should be performed or not, according to the value
?S:	of usenm and the flags on the Configure command line.
?S:.
?S:nm_opt:
?S:	This variable holds the options that may be necessary for nm.
?S:.
?S:nm_so_opt:
?S:	This variable holds the options that may be necessary for nm
?S:	to work on a shared library but that can not be used on an
?S:	archive library.  Currently, this is only used by Linux, where
?S:	nm --dynamic is *required* to get symbols from an ELF library which
?S:	has been stripped, but nm --dynamic is *fatal* on an archive library.
?S:	Maybe Linux should just always set usenm=false.
?S:.
: see if nm is to be used to determine whether a symbol is defined or not
?X: If there is enough inquiries, it might be worth to wait for the nm
?X: extraction. Otherwise, the C compilations might be a better deal.
?X:
?X: Don't bother if we're using GNU libc -- skimo
case "$usenm" in
'')
	dflt=''
	case "$d_gnulibc" in
	"$define")
		echo " "
		echo "$nm probably won't work on the GNU C Library." >&4
		dflt=n
		;;
	esac
	case "$dflt" in
	'')
		if $test "$osname" = aix -a ! -f /lib/syscalls.exp; then
			echo " "
			echo "Whoops!  This is an AIX system without /lib/syscalls.exp!" >&4
			echo "'nm' won't be sufficient on this system." >&4
			dflt=n
		fi
		;;
	esac
	case "$dflt" in
	'')
		if ./gnu; then
			echo " "
			echo "Hmm...  A GNU system without a GNU C Library?  Weird..." >&4
			dflt=n
		else
			dflt=`$egrep 'inlibc|csym' $rsrc/Configure | wc -l 2>/dev/null`
			if $test $dflt -gt 20; then
				dflt=y
			else
				dflt=n
			fi
		fi
		;;
	esac
	;;
*)
	case "$usenm" in
	true|$define) dflt=y;;
	*) dflt=n;;
	esac
	;;
esac
$cat <<EOM

I can use $nm to extract the symbols from your C libraries. This
is a time consuming task which may generate huge output on the disk (up
to 3 megabytes) but that should make the symbols extraction faster. The
alternative is to skip the 'nm' extraction part and to compile a small
test program instead to determine whether each symbol is present. If
you have a fast C compiler and/or if your 'nm' output cannot be parsed,
this may be the best solution.

EOM
rp='Shall I use nm to extract C symbols from the libraries?'
. ./myread
case "$ans" in
[Nn]*) usenm=false;;
*) usenm=true;;
esac

?X: Name extraction is to be run if 'nm' usage is wanted and if no -r flag
?X: was provided to configure (in which case we simply re-use the previous
?X: values).
runnm=$usenm
case "$reuseval" in
true) runnm=false;;
esac

: nm options which may be necessary
case "$nm_opt" in
'') if $test -f /mach_boot; then
		nm_opt=''		# Mach
	elif $test -d /usr/ccs/lib; then
		nm_opt='-p'		# Solaris (and SunOS?)
	elif $test -f /dgux; then
		nm_opt='-p'		# DG-UX
	elif $test -f /lib64/rld; then
		nm_opt='-p'		# 64-bit Irix
	else
		nm_opt=''
	fi;;
esac

?X: nm options which may be necessary for shared libraries but illegal
?X: for archive libraries.  Thank you, Linux.
case "$nm_so_opt" in
'')	case "$osname" in
	*linux*)
		if $nm --help | $grep 'dynamic' > /dev/null 2>&1; then
			nm_so_opt='--dynamic'
		fi
		;;
	esac
	;;
esac

