bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] argp: fix program_invocation_name detection


From: Mike Frysinger
Subject: [PATCH] argp: fix program_invocation_name detection
Date: Thu, 18 Nov 2010 17:15:18 -0500

The current program_invocation_name symbol detection fails if the argp.h
header is missing.  So check for the header first before detecting if the
symbol exists.

Signed-off-by: Mike Frysinger <address@hidden>
---
 m4/argp.m4 |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/m4/argp.m4 b/m4/argp.m4
index d3ca5ba..efa562c 100644
--- a/m4/argp.m4
+++ b/m4/argp.m4
@@ -31,8 +31,14 @@ AC_DEFUN([gl_ARGP],
   # are defined elsewhere. It is improbable that only one of them will
   # be defined and other not, I prefer to stay on the safe side and to
   # test each one separately.
+  AC_CHECK_HEADERS_ONCE([argp.h])
   AC_MSG_CHECKING([whether program_invocation_name is defined])
-  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <argp.h>]],
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#include <errno.h>
+#ifdef HAVE_ARGP_H
+# include <argp.h>
+#endif
+]],
                                   [[program_invocation_name = "test";]])],
                  [AC_DEFINE([HAVE_PROGRAM_INVOCATION_NAME], [1],
                             [Define if program_invocation_name is defined])
@@ -40,7 +46,12 @@ AC_DEFUN([gl_ARGP],
                  [AC_MSG_RESULT([no])])
 
   AC_MSG_CHECKING([whether program_invocation_short_name is defined])
-  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <argp.h>]],
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#include <errno.h>
+#ifdef HAVE_ARGP_H
+# include <argp.h>
+#endif
+]],
                                   [[program_invocation_short_name = 
"test";]])],
                  [AC_DEFINE([HAVE_PROGRAM_INVOCATION_SHORT_NAME], [1],
                             [Define if program_invocation_short_name is 
defined])
-- 
1.7.3.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]