From 633556d650a5ea282f2515f3b6b13780eeef8792 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 8 May 2011 13:00:10 +0200 Subject: [PATCH] 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. --- ChangeLog | 8 ++++++++ m4/argp.m4 | 10 +++++----- m4/getopt.m4 | 21 ++++++++++++++++----- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index c742d4491c..5db6ffe3ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-05-08 Bruno Haible + + 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 getlogin_r: Move AC_LIBOBJ invocations to module description. diff --git a/m4/argp.m4 b/m4/argp.m4 index c274dd1095..4e3940a65c 100644 --- a/m4/argp.m4 +++ b/m4/argp.m4 @@ -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], []) diff --git a/m4/getopt.m4 b/m4/getopt.m4 index 035a530df2..4ad52fd54b 100644 --- a/m4/getopt.m4 +++ b/m4/getopt.m4 @@ -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. -- 2.30.2