changeset 11809:0e2c54ee1521

Clarify logic; Separate gl_replace_getopt and GETOPT_H.
author Bruno Haible <bruno@clisp.org>
date Wed, 12 Aug 2009 17:18:53 +0200
parents 208b63596fa6
children d2c9dd185002
files ChangeLog m4/getopt.m4
diffstat 2 files changed, 18 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-08-12  Bruno Haible  <bruno@clisp.org>
+
+	Clarify logic.
+	* m4/getopt.m4 (gl_GETOPT_CHECK_HEADERS, gl_GETOPT_IFELSE): Use
+	gl_replace_getopt instead of GETOPT_H.
+
 2009-08-12  Bruno Haible  <bruno@clisp.org>
 
 	* m4/getopt.m4: Add comments.
--- a/m4/getopt.m4
+++ b/m4/getopt.m4
@@ -1,4 +1,4 @@
-# getopt.m4 serial 15
+# getopt.m4 serial 16
 dnl Copyright (C) 2002-2006, 2008-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -28,23 +28,25 @@
 
 AC_DEFUN([gl_GETOPT_CHECK_HEADERS],
 [
-  if test -z "$GETOPT_H"; then
-    AC_CHECK_HEADERS([getopt.h], [], [GETOPT_H=getopt.h])
+  gl_replace_getopt=
+  if test -z "$gl_replace_getopt"; then
+    AC_CHECK_HEADERS([getopt.h], [], [gl_replace_getopt=yes])
   fi
 
-  if test -z "$GETOPT_H"; then
-    AC_CHECK_FUNCS([getopt_long_only], [], [GETOPT_H=getopt.h])
+  if test -z "$gl_replace_getopt"; then
+    AC_CHECK_FUNCS([getopt_long_only], [], [gl_replace_getopt=yes])
   fi
 
   dnl BSD getopt_long uses an incompatible method to reset option processing,
   dnl and (as of 2004-10-15) mishandles optional option-arguments.
-  if test -z "$GETOPT_H"; then
-    AC_CHECK_DECL([optreset], [GETOPT_H=getopt.h], [], [#include <getopt.h>])
+  if test -z "$gl_replace_getopt"; then
+    AC_CHECK_DECL([optreset], [gl_replace_getopt=yes], [],
+      [#include <getopt.h>])
   fi
 
   dnl Solaris 10 getopt doesn't handle `+' as a leading character in an
   dnl option string (as of 2005-05-05).
-  if test -z "$GETOPT_H"; then
+  if test -z "$gl_replace_getopt"; then
     AC_CACHE_CHECK([for working GNU getopt function], [gl_cv_func_gnu_getopt],
       [AC_RUN_IFELSE(
 	[AC_LANG_PROGRAM([[#include <getopt.h>]],
@@ -64,7 +66,7 @@
 	   [gl_cv_func_gnu_getopt=no], [gl_cv_func_gnu_getopt=yes],
 	   [#include <getopt.h>])])])
     if test "$gl_cv_func_gnu_getopt" = "no"; then
-      GETOPT_H=getopt.h
+      gl_replace_getopt=yes
     fi
   fi
 ])
@@ -73,7 +75,7 @@
 AC_DEFUN([gl_GETOPT_IFELSE],
 [
   AC_REQUIRE([gl_GETOPT_CHECK_HEADERS])
-  AS_IF([test -n "$GETOPT_H"], [$1], [$2])
+  AS_IF([test -n "$gl_replace_getopt"], [$1], [$2])
 ])
 
 # This is gnulib's entry-point.