]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* ltconfig.in: Check if -lc is necessary for building shared
authorH.J. Lu <hjl@gnu.org>
Thu, 20 Jul 2000 02:28:44 +0000 (02:28 +0000)
committerAlexandre Oliva <aoliva@redhat.com>
Thu, 20 Jul 2000 02:28:44 +0000 (02:28 +0000)
libary. Set build_libtool_need_lc to indicate it.
* ltmain.in: Add -lc when building shared libary only if
necessary.

ChangeLog
ltconfig.in
ltmain.in

index ca588c8ac26b1a8350b2a4e9c305d62cc11c618d..538b9eb58ba06e31fe273b3de2f946cfeb2f73af 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2000-07-18  H.J. Lu  <hjl@gnu.org>
+
+       * ltconfig.in: Check if -lc is necessary for building shared
+       libary. Set build_libtool_need_lc to indicate it.
+       * ltmain.in: Add -lc when building shared libary only if
+       necessary.
+
 2000-07-10  Mo DeJong  <mdejong@redhat.com>
 
        * libtool.m4 (AC_PROG_NM): Fix macro so that it
index 4eee1aaf9f61e3f59130eff60142d3958a300798..4f51ab7ae398c3df116341aeb9781912ae6259ba 100755 (executable)
@@ -2019,6 +2019,51 @@ esac
 
 echo "$ac_t$enable_shared" 1>&6
 
+need_lc=yes
+if test "$enable_shared" = yes && test "$with_gcc" = yes; then
+  case "$archive_cmds" in
+  *'~'*)
+    # FIXME: we may have to deal with multi-command sequences.
+    ;;
+  '$CC '*)
+    # Test whether the compiler implicitly links with -lc since on some
+    # systems, -lgcc has to come before -lc. If gcc already passes -lc
+    # to ld, don't add -lc before -lgcc.
+    echo $ac_n "checking whether -lc is implicitly linked in... $ac_c" 1>&6
+    if eval "test \"`echo '$''{'ac_cv_archive_cmds_needs_lc'+set}'`\" = set"; then
+      echo $ac_n "(cached) $ac_c" 1>&6
+      need_lc=$ac_cv_archive_cmds_needs_lc
+    else
+      $rm conftest*
+      echo "static int dummy;" > conftest.c
+      if { (eval echo $progname:@LINENO@: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; }; then
+       # Append any warnings to the config.log.
+       cat conftest.err 1>&5
+       soname=conftest
+       lib=conftest
+       libobjs=conftest.o
+       deplibs=
+       linkopts=-v
+       compiler_flags=-v
+       linker_flags=-v
+       verstring=
+       output_objdir=.
+       libname=conftest
+       allow_undefined_flag=
+       if { (eval echo $progname:@LINENO@: \"$archive_cmds\") 1>&5; (eval $archive_cmds) 2>&1 | grep " -lc " 1>&5 ; }; then
+         need_lc=no
+       fi
+      else
+       cat conftest.err 1>&5
+      fi
+    fi
+    $rm conftest*
+    echo "$ac_t$need_lc" 1>&6
+    ;;
+  esac
+fi
+ac_cv_archive_cmds_needs_lc=$need_lc
+
 # Make sure either enable_shared or enable_static is yes.
 test "$enable_shared" = yes || enable_static=yes
 
@@ -2628,6 +2673,9 @@ SHELL=$LTSHELL
 # Whether or not to build shared libraries.
 build_libtool_libs=$enable_shared
 
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$need_lc
+
 # Whether or not to build static libraries.
 build_old_libs=$enable_static
 
index 17686090f577c6a6b87318878cf4b5d9e98fee7d..14fea5518f09f17394d0ef4d92b56e7b13f4b854 100644 (file)
--- a/ltmain.in
+++ b/ltmain.in
@@ -2384,8 +2384,10 @@ compiler."
            # these systems don't actually have a c library (as such)!
            ;;
          *)
-           # Add libc to deplibs on all other systems.
-           deplibs="$deplibs -lc"
+           # Add libc to deplibs on all other systems if necessary.
+           if test $build_libtool_need_lc = "yes"; then
+             deplibs="$deplibs -lc"
+           fi
            ;;
          esac
        fi