]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
Use config.cache variable for PIC flag, to allow override.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 19 Jun 2010 04:47:42 +0000 (06:47 +0200)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 19 Jun 2010 04:47:42 +0000 (06:47 +0200)
* libltdl/m4/libtool.m4 (_LT_COMPILER_PIC) <lt_prog_compiler_pic>:
Save result, and allow override, through cache variable
lt_cv_prog_compiler_pic{,_CXX,_F77,_FC}.  The cache variable
needs to contain an eventual -DPIC.
* doc/libtool.texi (): Document it.
* tests/pic_flag.at (override pic_flag at configure time):
New file, new test.
* Makefile.am (TESTSUITE_AT): Update.
* NEWS, THANKS: Update.
Suggestion by Joakim Tjernlund and Paolo Bonzini.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
Makefile.am
THANKS
libltdl/m4/libtool.m4
tests/pic_flag.at [new file with mode: 0644]

index a5676efc43e8c4c2f33cd8eab49a0edd2d9844e1..feffb964b54af34671664aa94c1d5047a0c2ec2d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2010-06-19  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+       Use config.cache variable for PIC flag, to allow override.
+       * libltdl/m4/libtool.m4 (_LT_COMPILER_PIC) <lt_prog_compiler_pic>:
+       Save result, and allow override, through cache variable
+       lt_cv_prog_compiler_pic{,_CXX,_F77,_FC}.  The cache variable
+       needs to contain an eventual -DPIC.
+       * doc/libtool.texi (): Document it.
+       * tests/pic_flag.at (override pic_flag at configure time):
+       New file, new test.
+       * Makefile.am (TESTSUITE_AT): Update.
+       * NEWS, THANKS: Update.
+       Suggestion by Joakim Tjernlund and Paolo Bonzini.
+
 2010-06-16  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        Optimize func_ltwrapper_scriptname to assume a cwrapper.
index d0688eec20df3e7f86c806e0dd3c464e320b4ce6..58224286ac3310df54ad3a842a3f88c47b92ae42 100644 (file)
@@ -509,6 +509,7 @@ TESTSUITE_AT        = tests/testsuite.at \
                  tests/configure-iface.at \
                  tests/stresstest.at \
                  tests/cmdline_wrap.at \
+                 tests/pic_flag.at \
                  tests/darwin.at \
                  tests/deplibs-mingw.at
 
diff --git a/THANKS b/THANKS
index 8a866a407c308148083e9fbfc4515e42ea1e04e7..46fd88a4708207c03eb722dd273c79a729b9575b 100644 (file)
--- a/THANKS
+++ b/THANKS
   Jeff Squyres                 jsquyres@lam-mpi.org
   Jeremy C. Reed               reed@reedmedia.net
   Jim Meyering                 jim@meyering.net
+  Joakim Tjernlund             joakim.tjernlund@transmode.se
   Joel N. Weber II             devnull@gnu.org
   Joerg Sonnenberger           joerg@netbsd.org
   John Bowler                  jbowler@acm.org
index a91bd615794a9d33296bafbdf59360e16ff2857a..b93dd0cf957d9a85a349267c02528646decbf11a 100644 (file)
@@ -3587,7 +3587,6 @@ _LT_TAGVAR(lt_prog_compiler_wl, $1)=
 _LT_TAGVAR(lt_prog_compiler_pic, $1)=
 _LT_TAGVAR(lt_prog_compiler_static, $1)=
 
-AC_MSG_CHECKING([for $compiler option to produce PIC])
 m4_if([$1], [CXX], [
   # C++ specific cases for pic, static, wl, etc.
   if test "$GXX" = yes; then
@@ -4185,9 +4184,11 @@ case $host_os in
     _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
     ;;
 esac
-AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
-_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
-       [How to pass a linker flag through the compiler])
+
+AC_CACHE_CHECK([for $compiler option to produce PIC],
+  [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)],
+  [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
+_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)
 
 #
 # Check to make sure the PIC flag actually works.
@@ -4206,6 +4207,8 @@ fi
 _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
        [Additional compiler flags for building library objects])
 
+_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
+       [How to pass a linker flag through the compiler])
 #
 # Check to make sure the static flag actually works.
 #
diff --git a/tests/pic_flag.at b/tests/pic_flag.at
new file mode 100644 (file)
index 0000000..a729d16
--- /dev/null
@@ -0,0 +1,51 @@
+# pic_flag.at -- override the pic_flag at configure time   -*- Autotest -*-
+
+#   Copyright (C) 2010 Free Software Foundation, Inc.
+#
+#   This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from  http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+####
+
+AT_SETUP([override pic_flag at configure time])
+
+# Just try to configure the Libtool package with -fpic if we can compile
+# with it, for C and C++.
+
+AT_DATA([foo.c],
+[[int data = 42;
+int func(void) { return data; }
+]])
+
+cp foo.c foo.cpp
+C_pic_flag='-fpic -DPIC'
+AT_CHECK([$CC $CPPFLAGS $CFLAGS $C_pic_flag -c foo.c || exit 77],
+        [], [ignore], [ignore])
+
+CXX_pic_flag='-fpic -DPIC'
+if $CXX $CPPFLAGS $CXXFLAGS $CXX_pic_flag -c foo.cpp; then :; else
+  CXX_pic_flag=
+fi
+
+AT_CHECK(["$abs_top_srcdir"/configure lt_cv_prog_compiler_pic="$C_pic_flag" ]dnl
+        [lt_cv_prog_compiler_pic_CXX="$CXX_pic_flag"], [], [ignore], [ignore])
+: ${MAKE=make}
+AT_CHECK([$MAKE], [], [stdout], [ignore])
+AT_CHECK([if ./libtool --features | grep 'enable shared libraries'; then ]dnl
+        [  grep -e -fpic stdout; else exit 77; fi], [], [ignore], [ignore])
+
+AT_CLEANUP