From dc4164cb4cddef207ac3c3023e92355bd03fa837 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Mon, 29 Jan 2024 16:35:17 +0100
Subject: [PATCH 1/2] Rename option --with-pic to --enable-pic.

Reported at <https://savannah.gnu.org/support/index.php?110674>.

* doc/libtool.texi (LT_INIT): Talk about --enable-pic instead of
--with-pic, and about --disable-pic instead of --without-pic.
(Test descriptions): Likewise.
* m4/ltoptions.m4 (_LT_WITH_PIC): Use AC_ARG_ENABLE instead of
AC_ARG_WITH. In the default case, use _AC_ENABLE_IF, in order to still
recognize the old options --with-pic and --without-pic.
* tests/demo.at: Add a test for --enable-pic, keeping the test for
--with-pic. Test '--disable-pic' instead of '--with-pic=no'.
* tests/with-pic.at: Test --enable-pic instead of --with-pic.
* NEWS: Mention the change.
---
 NEWS              |  7 ++++++
 doc/libtool.texi  | 23 +++++++++---------
 m4/ltoptions.m4   | 60 +++++++++++++++++++++++++++++++----------------
 tests/demo.at     | 12 +++++++++-
 tests/with-pic.at | 10 ++++----
 5 files changed, 75 insertions(+), 37 deletions(-)

diff --git a/NEWS b/NEWS
index 7750430a..555b2743 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,13 @@ NEWS - list of user-visible changes between releases of GNU Libtool
 
 * Noteworthy changes in release ?.? (????-??-??) [?]
 
+** Bug fixes:
+
+  - The configure options --with-pic and --without-pic have been renamed
+    to --enable-pic and --disable-pic, respectively.  The old names
+    --with-pic and --without-pic are still supported, though, for
+    backward compatibility.
+
 ** Changes in supported systems or compilers:
 
   - Removed support for bitrig (*-*-bitrig*).
diff --git a/doc/libtool.texi b/doc/libtool.texi
index aa965888..2bbfd102 100644
--- a/doc/libtool.texi
+++ b/doc/libtool.texi
@@ -2120,8 +2120,8 @@ LT_PREREQ([@value{VERSION}])
 @defmacx AC_PROG_LIBTOOL
 @defmacx AM_PROG_LIBTOOL
 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} flags.@footnote{@code{LT_INIT} requires
+@option{--enable-static}, @option{--disable-static}, @option{--enable-pic}, and
+@option{--disable-pic} @code{configure} flags.@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
@@ -2164,12 +2164,13 @@ 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,
+The @option{--enable-pic} and @option{--disable-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-pic=@var{pkgs}} is the same
-as configuring every package in @var{pkgs} with @option{--with-pic} and every
+static libraries.
+The @option{--enable-pic} option also accepts a comma-separated
+list of package names.  Specifying @option{--enable-pic=@var{pkgs}} is the same
+as configuring every package in @var{pkgs} with @option{--enable-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}.
@@ -2283,12 +2284,12 @@ specifying @option{--enable-static} to @command{configure}.
 @item pic-only
 Change the default behaviour for @command{libtool} to try to use only
 PIC objects.  The user may still override this default by specifying
-@option{--without-pic} to @command{configure}.
+@option{--disable-pic} to @command{configure}.
 
 @item no-pic
 Change the default behaviour of @command{libtool} to try to use only
 non-PIC objects.  The user may still override this default by
-specifying @option{--with-pic} to @command{configure}.
+specifying @option{--enable-pic} to @command{configure}.
 
 @end table
 
@@ -5313,8 +5314,8 @@ shared libraries (@option{--disable-static}).
 @file{demo-nofast.test} configures @file{demo/libtool} to
 disable the fast-install mode (@option{--enable-fast-install=no}).
 @file{demo-pic.test} configures @file{demo/libtool} to
-prefer building PIC code (@option{--with-pic}), @file{demo-nopic.test}
-to prefer non-PIC code (@option{--without-pic}).
+prefer building PIC code (@option{--enable-pic}), @file{demo-nopic.test}
+to prefer non-PIC code (@option{--disable-pic}).
 
 @item demo-deplibs.test
 @pindex demo-deplibs.test
diff --git a/m4/ltoptions.m4 b/m4/ltoptions.m4
index e24ae153..7e224ac8 100644
--- a/m4/ltoptions.m4
+++ b/m4/ltoptions.m4
@@ -8,7 +8,7 @@
 # unlimited permission to copy and/or distribute it, with or without
 # modifications, as long as this notice is preserved.
 
-# serial 8 ltoptions.m4
+# serial 9 ltoptions.m4
 
 # This is to help aclocal find these macros, as it can't see m4_define.
 AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
@@ -376,30 +376,50 @@ LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
 
 # _LT_WITH_PIC([MODE])
 # --------------------
-# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
+# implement the --enable-pic flag, and support the 'pic-only' and 'no-pic'
 # LT_INIT options.
 # 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@<:@=PKGS@:>@],
+[AC_ARG_ENABLE([pic],
+    [AS_HELP_STRING([--enable-pic@<:@=PKGS@:>@],
 	[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
     [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=m4_default([$1], [default])])
+     case $enableval in
+     yes|no) pic_mode=$enableval ;;
+     *)
+       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 $enableval; do
+	 IFS=$lt_save_ifs
+	 if test "X$lt_pkg" = "X$lt_p"; then
+	   pic_mode=yes
+	 fi
+       done
+       IFS=$lt_save_ifs
+       ;;
+     esac],
+    [dnl Continue to support --with-pic and --without-pic, for backward
+     dnl compatibility.
+     _AC_ENABLE_IF([with], [pic],
+	[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=m4_default([$1], [default])])]
+    )
 
 _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
 ])# _LT_WITH_PIC
diff --git a/tests/demo.at b/tests/demo.at
index feb71dcd..8aa1cf9b 100644
--- a/tests/demo.at
+++ b/tests/demo.at
@@ -498,6 +498,16 @@ AT_SETUP([force PIC objects])
 
 _LT_DEMO_SETUP
 
+LT_AT_CHECK_CONFIG([--enable-pic])
+_LT_CHECK_EXECUTE
+
+AT_CLEANUP
+
+
+AT_SETUP([force PIC objects (old option name)])
+
+_LT_DEMO_SETUP
+
 LT_AT_CHECK_CONFIG([--with-pic])
 _LT_CHECK_EXECUTE
 
@@ -536,7 +546,7 @@ fi
 ])
 
 _LT_DEMO_SETUP
-LT_AT_CHECK_CONFIG([--with-pic=no])
+LT_AT_CHECK_CONFIG([--disable-pic])
 _LT_CHECK_EXECUTE
 
 AT_CLEANUP
diff --git a/tests/with-pic.at b/tests/with-pic.at
index e63d8421..0beb9c42 100644
--- a/tests/with-pic.at
+++ b/tests/with-pic.at
@@ -21,7 +21,7 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 ####
 
-AT_SETUP([test --with-pic])
+AT_SETUP([test --enable-pic])
 
 # Set up a tests/demo.at style project.
 _LT_DEMO_SETUP
@@ -41,22 +41,22 @@ AT_CHECK([test . != "$at_srcdir" || exit 77])
 
 : ${MAKE=make}
 
-LT_AT_CONFIGURE([--disable-shared --with-pic=no])
+LT_AT_CONFIGURE([--disable-shared --enable-pic=no])
 AT_CHECK([$MAKE], [], [stdout], [ignore])
 AT_CHECK([$FGREP -v "$pic_flag" stdout], [], [ignore], [ignore])
 $MAKE clean
 
-LT_AT_CONFIGURE([--disable-shared --with-pic=yes])
+LT_AT_CONFIGURE([--disable-shared --enable-pic=yes])
 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"])
+LT_AT_CONFIGURE([--disable-shared --enable-pic="demo,foo,bar"])
 AT_CHECK([$MAKE], [], [stdout], [ignore])
 AT_CHECK([$FGREP "$pic_flag" stdout], [], [ignore], [ignore])
 $MAKE clean
 
-LT_AT_CONFIGURE([--disable-shared --with-pic="foo,bar"])
+LT_AT_CONFIGURE([--disable-shared --enable-pic="foo,bar"])
 AT_CHECK([$MAKE], [], [stdout], [ignore])
 AT_CHECK([$FGREP -v "$pic_flag" stdout], [], [ignore], [ignore])
 $MAKE clean
-- 
2.34.1

