On Sat, Oct 23, 2010 at 2:32 AM, Ralf Wildenhues <ralf.wildenh...@gmx.de> wrote:
>
> This patch looks ok but it uses $pkg and $p which are not in Libtool's
> name space, and it lacks updates to NEWS, libtool.texi, and the test
> suite.  Oh yes, the --enable-shared code has similar problems, but a
> patch shouldn't be held hostage for drive-by bugs.  ;-)

Here's an updated patch which includes a new test, documentation, and
fixed variable names.  Please take another look.

Thanks,
Ollie


2010-11-07  Ollie Wild  <a...@google.com>

        Modify --with-pic to support per-package configurations.
        * libltdl/m4/libtool.m4:  Modify --with-pic to accept a list of
        package names.  Modelled off --enable-shared.
        * tests/with-pic.at: New test.
        * Makefile.am (TESTSUITE_AT): Add tests/with-pic.at.
        * doc/libtool.texi (LT_INIT): Enhance documentation of
        --with-pic configure flag.
        * NEWS (New features): Mention that --with-pic now accepts a
        comma-separated list of package names.
2010-11-07  Ollie Wild  <a...@google.com>

        Modify --with-pic to support per-package configurations.
        * libltdl/m4/libtool.m4:  Modify --with-pic to accept a list of
        package names.  Modelled off --enable-shared.
        * tests/with-pic.at: New test.
        * Makefile.am (TESTSUITE_AT): Add tests/with-pic.at.
        * doc/libtool.texi (LT_INIT): Enhance documentation of
        --with-pic configure flag.
        * NEWS (New features): Mention that --with-pic now accepts a
        comma-separated list of package names.

diff --git a/Makefile.am b/Makefile.am
index db2c0a9..53c8e8b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -511,7 +511,8 @@ TESTSUITE_AT        = tests/testsuite.at \
                  tests/darwin.at \
                  tests/dumpbin-symbols.at \
                  tests/deplibs-mingw.at \
-                 tests/sysroot.at
+                 tests/sysroot.at \
+                 tests/with-pic.at
 
 EXTRA_DIST     += $(srcdir)/$(TESTSUITE) $(TESTSUITE_AT) 
$(srcdir)/tests/package.m4
 
diff --git a/NEWS b/NEWS
index d8d692e..6930274 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,12 @@ NEWS - list of user-visible changes between releases of GNU 
Libtool
 
 New in 2.4.2 2010-12-??: git version 2.4.1a, Libtool team:
 
+* New features:
+
+  - The --with-pic configure option now supports a list of comma-separated
+    package names.  This can be used to build some static libraries with PIC
+    objects while building others with non-PIC objects.
+
 * Bug fixes:
 
   - The generic approximation of the command line length limit (when getconf is
diff --git a/doc/libtool.texi b/doc/libtool.texi
index 2f48a09..5c2570d 100644
--- a/doc/libtool.texi
+++ b/doc/libtool.texi
@@ -2042,9 +2042,10 @@ LT_PREREQ([...@value{version}])
 @defmac LT_INIT (@var{options})
 @defmacx AC_PROG_LIBTOOL
 @defmacx AM_PROG_LIBTOOL
-Add support for the @option{--enable-shared} and @option{--disable-shared}
-...@code{configure} fla...@footnote{@code{LT_INIT} requires that
-you define the @file{Makefile} variable @code{top_builddir} in your
+Add support for the @option{--enable-shared}, @option{--disable-shared},
+...@option{--enable-static}, @option{--disable-static}, @option{--with-pic}, 
and
+...@option{--without-pic} @code{configure} fla...@footnote{@code{LT_INIT} 
requires
+that you define the @file{Makefile} variable @code{top_builddir} in your
 @file{Makefile.in}.  Automake does this automatically, but Autoconf
 users should set it to the relative path to the top of your build
 directory (@file{../..}, for example).}  @code{AC_PROG_LIBTOOL} and
@@ -2086,6 +2087,16 @@ behaves similarly, but it uses @option{--enable-static} 
and
 The package name @samp{default} matches any packages that have not set
 their name in the @code{PACKAGE} environment variable.
 
+The @option{--with-pic} and @option{--without-pic} configure flags can be used
+to specify whether or not @command{libtool} uses PIC objects.  By default,
+...@command{libtool} uses PIC objects for shared libraries and non-PIC objects 
for
+static libraries.  The @option{--with-pic} option also accepts a 
comma-separated
+list of package names.  Specifying @option{--with-p...@var{pkgs}} is the same
+as configuring every package in @var{pkgs} with @option{--with-pic} and every
+other package with the default configuration.  The package name @samp{default}
+is treated the same as for @option{--enable-shared} and
+...@option{--enable-static}.
+
 This macro also sets the shell variable @code{LIBTOOL_DEPS}, that you
 can use to automatically update the libtool script if it becomes
 out-of-date.  In order to do that, add to your @file{configure.ac}:
diff --git a/libltdl/m4/ltoptions.m4 b/libltdl/m4/ltoptions.m4
index 17cfd51..5d9acd8 100644
--- a/libltdl/m4/ltoptions.m4
+++ b/libltdl/m4/ltoptions.m4
@@ -326,9 +326,24 @@ dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
 # MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
 m4_define([_LT_WITH_PIC],
 [AC_ARG_WITH([pic],
-    [AS_HELP_STRING([--with-pic],
+    [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
        [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
-    [pic_mode="$withval"],
+    [lt_p=${PACKAGE-default}
+    case $withval in
+    yes|no) pic_mode=$withval ;;
+    *)
+      pic_mode=default
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for lt_pkg in $withval; do
+       IFS="$lt_save_ifs"
+       if test "X$lt_pkg" = "X$lt_p"; then
+         pic_mode=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
     [pic_mode=default])
 
 test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
diff --git a/tests/with-pic.at b/tests/with-pic.at
new file mode 100644
index 0000000..a80535b
--- /dev/null
+++ b/tests/with-pic.at
@@ -0,0 +1,55 @@
+# with-pic.at -- test the --with-pic flag -*- 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([test --with-pic])
+eval `$LIBTOOL --config | $EGREP '^(pic_flag|FGREP)='`
+
+AT_CHECK([test "z$pic_flag" != "z" || exit 77])
+AT_CHECK([test "$at_srcdir" != . || exit 77])
+AT_CHECK([$LIBTOOL --features | $FGREP 'enable static libraries' || exit 77],
+        [], [ignore], [ignore])
+
+CONFIGURE=$abs_top_srcdir/tests/demo/configure
+: ${MAKE=make}
+
+LT_AT_CONFIGURE([--disable-shared --with-pic=no], [$CONFIGURE])
+AT_CHECK([$MAKE], [], [stdout], [ignore])
+AT_CHECK([$FGREP -v "$pic_flag" stdout], [], [ignore], [ignore])
+$MAKE clean
+
+LT_AT_CONFIGURE([--disable-shared --with-pic=yes], [$CONFIGURE])
+AT_CHECK([$MAKE], [], [stdout], [ignore])
+AT_CHECK([$FGREP "$pic_flag" stdout], [], [ignore], [ignore])
+$MAKE clean
+
+LT_AT_CONFIGURE([--disable-shared --with-pic="demo,foo,bar"], [$CONFIGURE])
+AT_CHECK([$MAKE], [], [stdout], [ignore])
+AT_CHECK([$FGREP "$pic_flag" stdout], [], [ignore], [ignore])
+$MAKE clean
+
+LT_AT_CONFIGURE([--disable-shared --with-pic="foo,bar"], [$CONFIGURE])
+AT_CHECK([$MAKE], [], [stdout], [ignore])
+AT_CHECK([$FGREP -v "$pic_flag" stdout], [], [ignore], [ignore])
+$MAKE clean
+
+AT_CLEANUP

Reply via email to