summaryrefslogtreecommitdiff
path: root/mcon/U/libs.U
diff options
context:
space:
mode:
Diffstat (limited to 'mcon/U/libs.U')
-rw-r--r--mcon/U/libs.U213
1 files changed, 149 insertions, 64 deletions
diff --git a/mcon/U/libs.U b/mcon/U/libs.U
index 0a4932b..0a8feaa 100644
--- a/mcon/U/libs.U
+++ b/mcon/U/libs.U
@@ -1,12 +1,12 @@
-?RCS: $Id: libs.U,v 3.0.1.6 1997/02/28 16:09:11 ram Exp $
+?RCS: $Id$
?RCS:
-?RCS: Copyright (c) 1991-1993, Raphael Manfredi
+?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
?RCS:
?RCS: You may redistribute only under the terms of the Artistic Licence,
?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 Licence; a copy of which may be found at the root
-?RCS: of the source tree for dist 3.0.
+?RCS: of the source tree for dist 4.0.
?RCS:
?RCS: $Log: libs.U,v $
?RCS: Revision 3.0.1.6 1997/02/28 16:09:11 ram
@@ -32,15 +32,60 @@
?RCS: Revision 3.0 1993/08/18 12:09:03 ram
?RCS: Baseline for dist 3.0 netwide release.
?RCS:
-?MAKE:libs: test cat Myread Oldconfig Loc libpth package xlibpth so _a
+?MAKE:libs libsfound libsfiles libsdirs libspath libscheck: \
+ test cat Myread Oldconfig Loc libpth package xlibpth so _a \
+ +usesocks sed +cc +ccflags +ldflags rm
?MAKE: -pick add $@ %<
?S:libs:
?S: This variable holds the additional libraries we want to use.
-?S: It is up to the Makefile to deal with it.
+?S: It is up to the Makefile to deal with it. The list can be empty.
+?S:.
+?S:libsfound:
+?S: This variable holds the full pathnames of the libraries
+?S: we found and accepted.
+?S:.
+?S:libsfiles:
+?S: This variable holds the filenames aka basenames of the libraries
+?S: we found and accepted.
+?S:.
+?S:libsdirs:
+?S: This variable holds the directory names aka dirnames of the libraries
+?S: we found and accepted, duplicates are removed.
+?S:.
+?S:libspath:
+?S: This variable holds the directory names probed for libraries.
+?S:.
+?S:libscheck:
+?S: This variable is intended to be set by hint files, if needed.
+?S: It should contain shell code that will be eval'ed with $xxx holding
+?S: some library file. It may change $xxx if needed.
+?S: For instance, on an Irix platform, you may make sure the right
+?S: library file is used depending on the cc command line, so that the
+?S: correct library is used depending on the selected ABI (for 32 and
+?S: 64-bit compilations).
+?S:
+?S: Here is an example of code that could be found in a hint file on Irix
+?S: when the selected compiler was for 32-bit -- that code is put in the
+?S: cc.cbu call-back unit to be invoked AFTER the C compiler and its
+?S: flags have been chosen:
+?S:
+?S: libscheck='case "$xxx" in
+?S: *.a) /bin/ar p $xxx `/bin/ar t $xxx | sed q` >$$.o;
+?S: case "`/usr/bin/file $$.o`" in
+?S: *N32*) rm -f $$.o ;;
+?S: *) rm -f $$.o; xxx=/no/n32$xxx ;;
+?S: esac ;;
+?S: *) case "`/usr/bin/file $xxx`" in
+?S: *N32*) ;;
+?S: *) xxx=/no/n32$xxx ;;
+?S: esac ;;
+?S: esac'
?S:.
-?T:xxx thislib libswanted
?D:libs=''
-?X:
+?LINT:extern libswanted
+?LINT:change libswanted
+?INIT:: default library list
+?INIT:libswanted=''
?X: This order is chosen so that libraries -lndir, -ldir, -lucb, -lbsd,
?X: -lBSD, -lPW, and -lx only get used if there are unresolved
?X: routines at link time. Usually, these are backwards compatability
@@ -58,12 +103,14 @@
?X: Set proper libswanted in your private Myinit.U if needed.
?X:
?X:: default ordered library list
-?X:libswanted='net socket inet nsl nm sdbm gdbm ndbm dbm malloc dl'
+?X:libswanted='net socket inet bind nsl nm sdbm gdbm ndbm dbm malloc dl'
?X:libswanted="$libswanted dld sun m c_s c posix cposix ndir dir ucb"
?X:libswanted="$libswanted bsd BSD PW x"
?X:
-?INIT:: default library list
-?INIT:libswanted=''
+?INIT:: should be set by hint files if needed
+?INIT:libscheck=''
+?T:xxx yyy thislib thisdir libstyle linkmsg
+?F:lt.c lt
: Looking for optional libraries
echo " "
echo "Checking for optional libraries..." >&4
@@ -74,53 +121,96 @@ esac
case "$libswanted" in
'') libswanted='c_s';;
esac
+?X: libsocks has nasty naming scheme.
+?X: This does not work if somebody wants SOCKS 4.
+case "$usesocks" in
+"$define") libswanted="$libswanted socks5 socks5_sh" ;;
+esac
+?X: Used later for link checks
+echo "extern char printf(); int main() { printf(); return 0; }" > lt.c
+libsfound=''
+libsfiles=''
+libsdirs=''
+libspath=''
+for thisdir in $libpth $xlibpth; do
+ test -d $thisdir && libspath="$libspath $thisdir"
+done
for thislib in $libswanted; do
-
+ for thisdir in $libspath; do
+ xxx=''
+ if $test ! -f "$xxx" ; then
+ xxx=`ls $thisdir/lib$thislib.$so.[0-9]* 2>/dev/null | $sed -n '1p'`
+ $test -f "$xxx" && eval $libscheck
+ $test -f "$xxx" && libstyle=shared
+ fi
+ if test ! -f "$xxx"; then
+ xxx=$thisdir/lib$thislib.$so
+ $test -f "$xxx" && eval $libscheck
+ $test -f "$xxx" && libstyle=shared
+ fi
+ if test ! -f "$xxx"; then
+ xxx=$thisdir/lib$thislib$_a
+ $test -f "$xxx" && eval $libscheck
+ $test -f "$xxx" && libstyle=static
+ fi
+ if test ! -f "$xxx"; then
+ xxx=$thisdir/$thislib$_a
+ $test -f "$xxx" && eval $libscheck
+ $test -f "$xxx" && libstyle=static
+ fi
+ if test ! -f "$xxx"; then
+ xxx=$thisdir/lib${thislib}_s$_a
+ $test -f "$xxx" && eval $libscheck
+ $test -f "$xxx" && libstyle=static
+ $test -f "$xxx" && thislib=${thislib}_s
+ fi
+ if test ! -f "$xxx"; then
+ xxx=$thisdir/Slib$thislib$_a
+ $test -f "$xxx" && eval $libscheck
+ $test -f "$xxx" && libstyle=static
+ fi
+ if $test -f "$xxx"; then
?X:
-?X: Comparaisons via case statement use the string " $dflt " to ensure that
-?X: each library is separated by a space. That way, by looking to something
-?X: like *"-l$thislib "*, we ensure we find -lm and not -lmalloc (which was
-?X: the case with the old looking pattern *-l$thislib*.
+?X: It is not sufficient to find a .so on the disk. We must make sure
+?X: that we can indeed supply the -lfoo line on the cc line to link against
+?X: that library. On Linux for instance, a versionned .so will not be
+?X: implicitly linked against, whereas it will work fine on Solaris 2.6.
+?X: --RAM, 10/10/2003
?X:
- if xxx=`./loc lib$thislib.$so.[0-9]'*' X $libpth`; $test -f "$xxx"; then
- echo "Found -l$thislib (shared)."
- case " $dflt " in
- *"-l$thislib "*);;
- *) dflt="$dflt -l$thislib";;
- esac
- elif xxx=`./loc lib$thislib.$so X $libpth` ; $test -f "$xxx"; then
- echo "Found -l$thislib (shared)."
- case " $dflt " in
- *"-l$thislib "*);;
- *) dflt="$dflt -l$thislib";;
- esac
- elif xxx=`./loc lib$thislib$_a X $libpth`; $test -f "$xxx"; then
- echo "Found -l$thislib."
- case " $dflt " in
- *"-l$thislib "*);;
- *) dflt="$dflt -l$thislib";;
- esac
-?X: Don't forget about OS/2 where -lmalloc is spelled out malloc.a
- elif xxx=`./loc $thislib$_a X $libpth`; $test -f "$xxx"; then
- echo "Found -l$thislib."
- case " $dflt " in
- *"-l$thislib "*);;
- *) dflt="$dflt -l$thislib";;
- esac
- elif xxx=`./loc lib${thislib}_s$_a X $libpth`; $test -f "$xxx"; then
- echo "Found -l${thislib}_s."
- case " $dflt " in
- *"-l$thislib "*);;
- *) dflt="$dflt -l${thislib}_s";;
- esac
- elif xxx=`./loc Slib$thislib$_a X $xlibpth`; $test -f "$xxx"; then
- echo "Found -l$thislib."
- case " $dflt " in
- *"-l$thislib "*);;
- *) dflt="$dflt -l$thislib";;
- esac
- else
- echo "No -l$thislib."
+ if $cc -o lt $ccflags $ldflags lt.c -l$thislib >/dev/null 2>&1;
+ then
+ linkmsg=""
+ else
+ linkmsg=" but I can't link against it"
+ fi
+ case "$libstyle" in
+ shared) echo "Found -l$thislib (shared)$linkmsg." ;;
+ static) echo "Found -l$thislib$linkmsg." ;;
+ *) echo "Found -l$thislib ($libstyle)$linkmsg." ;;
+ esac
+ case " $dflt " in
+ *"-l$thislib "*) ;;
+ *)
+ case "$linkmsg" in
+ '')
+ dflt="$dflt -l$thislib"
+ libsfound="$libsfound $xxx"
+ yyy=`basename $xxx`
+ libsfiles="$libsfiles $yyy"
+ yyy=`echo $xxx|$sed -e "s%/$yyy\\$%%"`
+ case " $libsdirs " in
+ *" $yyy "*) ;;
+ *) libsdirs="$libsdirs $yyy" ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ break
+ fi
+ done
+ if $test ! -f "$xxx"; then
+ echo "No -l$thislib."
fi
done
set X $dflt
@@ -133,22 +223,17 @@ esac
case "$dflt" in
' '|'') dflt='none';;
esac
+$rm -f lt.c lt
$cat <<EOM
-
-Some versions of Unix support shared libraries, which make executables smaller
-but make load time slightly longer.
-On some systems, mostly System V Release 3's, the shared library is included
-by putting the option "-lc_s" as the last thing on the cc command line when
-linking. Other systems use shared libraries by default. There may be other
-libraries needed to compile $package on your machine as well. If your system
-needs the "-lc_s" option, include it here. Include any other special libraries
-here as well. Say "none" for none.
+In order to compile $package on your machine, a number of libraries
+are usually needed. Include any other special libraries here as well.
+Say "none" for none. The default list is almost always right.
EOM
echo " "
-rp="Any additional libraries?"
+rp="Which libraries to use?"
. ./myread
case "$ans" in
none) libs=' ';;