]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* ltcf-c.sh, ltcf-cxx.sh: Check if -lc is necessary for building
authorAlexandre Oliva <oliva@lsd.ic.unicamp.br>
Thu, 20 Jul 2000 02:29:16 +0000 (02:29 +0000)
committerAlexandre Oliva <aoliva@redhat.com>
Thu, 20 Jul 2000 02:29:16 +0000 (02:29 +0000)
shared library.
* ltcf-gcj.sh: Assume -lc is implicitly linked in.
* ltconfig.in: Set build_libtool_need_lc to indicate it.
* ltmain.in: Add -lc when building shared libary only if
necessary.

ChangeLog
ltcf-c.sh
ltcf-cxx.sh
ltcf-gcj.sh
ltconfig.in
ltmain.in

index 3aad8a60de1c014a391eef2a53bc3133a5fb51e5..e890110e3d29dcb2460c5c8aeb2c0bf7e2b7105f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2000-07-19  H.J. Lu  <hjl@gnu.org>,  Alexandre Oliva  <oliva@lsd.ic.unicamp.br>
+
+       * ltcf-c.sh, ltcf-cxx.sh: Check if -lc is necessary for building
+       shared library.
+       * ltcf-gcj.sh: Assume -lc is implicitly linked in.
+       * ltconfig.in: 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 3277e9415e87ae800908500b9df67a5dc644ac85..756b15120233e233f3affe7ed7d2f9f2f0dc4fe2 100644 (file)
--- a/ltcf-c.sh
+++ b/ltcf-c.sh
@@ -643,4 +643,47 @@ else
   ac_cv_prog_cc_pic="$ac_cv_prog_cc_pic -DPIC"
 fi
 
-
+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.$ac_ext
+      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
index ac33579819689e80be38f2ee8617b23dfba22c32..c8e5b1fa8ee168a5e4a69dc9b0320edceb7fff5c 100644 (file)
@@ -873,3 +873,49 @@ else
 fi
 
 $rm -f confest.$objext
+
+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_cxx_archive_cmds_needs_lc'+set}'`\" = set"; then
+      echo $ac_n "(cached) $ac_c" 1>&6
+      need_lc=$ac_cv_cxx_archive_cmds_needs_lc
+    else
+      $rm conftest*
+      echo "static int dummy;" > conftest.$ac_ext
+      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_cxx_archive_cmds_needs_lc=$need_lc
index 44b1fb234cf49f9b641da1edc8ae4ed78d8209a6..3340a6f43149e805f76ba31fa9afc408470e2932 100644 (file)
@@ -568,3 +568,6 @@ fi
       ac_cv_prog_cc_pic='-fPIC'
       ;;
     esac
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+need_lc=no
index a4126e407404e9d31a315b34d26a167decdce274..f3e53fefdd6af460730fc4906dcd4c1931d9adb4 100755 (executable)
@@ -2061,6 +2061,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 6ee9098801e4b0b5a329cacde12d1f619c31a6f9..e9543d17a27502364c41993203511b07f2a76a4e 100644 (file)
--- a/ltmain.in
+++ b/ltmain.in
@@ -2557,8 +2557,10 @@ EOF
            # 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