getopt, argp: Respect rules for use of AC_LIBOBJ.
authorBruno Haible <bruno@clisp.org>
Sun, 8 May 2011 11:00:10 +0000 (13:00 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 15 Jun 2011 22:06:06 +0000 (00:06 +0200)
* m4/argp.m4 (gl_ARGP): Don't invoke gl_REPLACE_GETOPT.
(gl_REPLACE_GETOPT_ALWAYS): New macro.
* m4/getopt.m4 (gl_FUNC_GETOPT_POSIX): Test whether
gl_REPLACE_GETOPT_ALWAYS is defined. Set REPLACE_GETOPT.

ChangeLog
m4/argp.m4
m4/getopt.m4

index c742d44..5db6ffe 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2011-05-08  Bruno Haible  <bruno@clisp.org>
 
+       getopt, argp: Respect rules for use of AC_LIBOBJ.
+       * m4/argp.m4 (gl_ARGP): Don't invoke gl_REPLACE_GETOPT.
+       (gl_REPLACE_GETOPT_ALWAYS): New macro.
+       * m4/getopt.m4 (gl_FUNC_GETOPT_POSIX): Test whether
+       gl_REPLACE_GETOPT_ALWAYS is defined. Set REPLACE_GETOPT.
+
+2011-05-08  Bruno Haible  <bruno@clisp.org>
+
        getlogin_r: Move AC_LIBOBJ invocations to module description.
        * m4/getlogin_r.m4 (gl_FUNC_GETLOGIN_R): Move AC_LIBOBJ and
        gl_PREREQ_GETLOGIN_R invocations from here...
index c274dd1..4e3940a 100644 (file)
@@ -1,4 +1,4 @@
-# argp.m4 serial 11
+# argp.m4 serial 12
 dnl Copyright (C) 2003-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,10 +9,6 @@ AC_DEFUN([gl_ARGP],
   AC_REQUIRE([AC_C_INLINE])
   AC_REQUIRE([AC_C_RESTRICT])
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-  dnl argp-parse.c depends on GNU getopt internals, therefore use GNU getopt
-  dnl always.
-  gl_REPLACE_GETOPT
-  dnl Note: gl_REPLACE_GETOPT does AC_LIBOBJ([getopt]), AC_LIBOBJ([getopt1]).
 
   AC_CHECK_DECL([program_invocation_name],
                 [AC_DEFINE([HAVE_DECL_PROGRAM_INVOCATION_NAME], [1],
@@ -63,3 +59,7 @@ AC_DEFUN([gl_ARGP],
   AC_CHECK_FUNCS_ONCE([flockfile funlockfile])
   AC_CHECK_HEADERS_ONCE([features.h linewrap.h])
 ])
+
+dnl argp-parse.c depends on GNU getopt internals, therefore use GNU getopt
+dnl always.
+AC_DEFUN([gl_REPLACE_GETOPT_ALWAYS], [])
index 035a530..4ad52fd 100644 (file)
@@ -1,4 +1,4 @@
-# getopt.m4 serial 34
+# getopt.m4 serial 35
 dnl Copyright (C) 2002-2006, 2008-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -9,10 +9,22 @@ AC_DEFUN([gl_FUNC_GETOPT_POSIX],
 [
   m4_divert_text([DEFAULTS], [gl_getopt_required=POSIX])
   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
-  gl_GETOPT_IFELSE([
+  dnl Other modules can request the gnulib implementation of the getopt
+  dnl functions unconditionally, by defining gl_REPLACE_GETOPT_ALWAYS.
+  dnl argp.m4 does this.
+  m4_ifdef([gl_REPLACE_GETOPT_ALWAYS], [
+    gl_GETOPT_IFELSE([], [])
+    REPLACE_GETOPT=1
+  ], [
+    REPLACE_GETOPT=0
+    gl_GETOPT_IFELSE([
+      REPLACE_GETOPT=1
+    ],
+    [])
+  ])
+  if test $REPLACE_GETOPT = 1; then
     gl_REPLACE_GETOPT
-  ],
-  [])
+  fi
 ])
 
 # Request a POSIX compliant getopt function with GNU extensions (such as
@@ -26,7 +38,6 @@ AC_DEFUN([gl_FUNC_GETOPT_GNU],
 ])
 
 # Request the gnulib implementation of the getopt functions unconditionally.
-# argp.m4 uses this.
 AC_DEFUN([gl_REPLACE_GETOPT],
 [
   dnl Arrange for getopt.h to be created.