bug-gnulib
[Top][All Lists]
Advanced

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

absolute-header: make the macro more usable


From: Bruno Haible
Subject: absolute-header: make the macro more usable
Date: Sun, 16 May 2010 23:43:43 +0200
User-agent: KMail/1.9.9

In a case where I want to use the absolute-header macro, it does not
work because it uses the CPPFLAGS from the beginning of the configure
run. But some macros augment CPPFLAGS.

In order to make the macro more usable, I'm extracting its core into
a separate macro.

Can someone explain why the argument of AS_TR_SH apparently needs to be
double-quoted? The autoconf doc does not mention this. (I experimentally
determine the number of needed quotations by adding too many [[[]]] here
and there, look at the generated configure file for input like
  gl_ABSOLUTE_HEADER_ONE([unistr.h])
  gl_ABSOLUTE_HEADER([foobar.h baz.h])
and remove the quotation levels one by one, until the generated code is fine.
This means, if I were to remove one more level of quotation, I would enable
some unwanted m4 evaluations, right?)


2010-05-16  Bruno Haible  <address@hidden>

        absolute-header: Make the macro usable in more situations.
        * m4/absolute-header.m4 (gl_ABSOLUTE_HEADER_ONE): New macro, extracted
        from gl_ABSOLUTE_HEADER.
        (gl_ABSOLUTE_HEADER): Use it. Fix comment.

--- m4/absolute-header.m4.orig  Sun May 16 23:31:59 2010
+++ m4/absolute-header.m4       Sun May 16 23:28:28 2010
@@ -1,4 +1,4 @@
-# absolute-header.m4 serial 11
+# absolute-header.m4 serial 12
 dnl Copyright (C) 2006-2010 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,7 +8,7 @@
 
 # gl_ABSOLUTE_HEADER(HEADER1 HEADER2 ...)
 # ---------------------------------------
-# Find the absolute name of a header file, assuming the header exists.
+# Find the absolute name of a header file, testing first if the header exists.
 # If the header were sys/inttypes.h, this macro would define
 # ABSOLUTE_SYS_INTTYPES_H to the `""' quoted absolute name of sys/inttypes.h
 # in config.h
@@ -31,29 +31,7 @@
                     [ac_cv_header_]m4_defn([gl_HEADER_NAME]))dnl
     AC_CHECK_HEADERS_ONCE(m4_defn([gl_HEADER_NAME]))dnl
     if test AS_VAR_GET(ac_header_exists) = yes; then
-      AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include 
<]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]])])
-      dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
-      dnl that contain only a #include of other header files and no
-      dnl non-comment tokens of their own. This leads to a failure to
-      dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
-      dnl and others. The workaround is to force preservation of comments
-      dnl through option -C. This ensures all necessary #line directives
-      dnl are present. GCC supports option -C as well.
-      case "$host_os" in
-        aix*) gl_absname_cpp="$ac_cpp -C" ;;
-        *)    gl_absname_cpp="$ac_cpp" ;;
-      esac
-      dnl eval is necessary to expand gl_absname_cpp.
-      dnl Ultrix and Pyramid sh refuse to redirect output of eval,
-      dnl so use subshell.
-      AS_VAR_SET(gl_absolute_header,
-[`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
-sed -n '\#/]m4_defn([gl_HEADER_NAME])[#{
-        s#.*"\(.*/]m4_defn([gl_HEADER_NAME])[\)".*#\1#
-        s#^/[^/]#//&#
-        p
-        q
-}'`])
+      gl_ABSOLUTE_HEADER_ONE(m4_defn([gl_HEADER_NAME]))
     fi
     AS_VAR_POPDEF([ac_header_exists])dnl
     ])dnl
@@ -63,3 +41,37 @@
   AS_VAR_POPDEF([gl_absolute_header])dnl
 ])dnl
 ])# gl_ABSOLUTE_HEADER
+
+# gl_ABSOLUTE_HEADER_ONE(HEADER)
+# ------------------------------
+# Like gl_ABSOLUTE_HEADER, except that:
+#   - it assumes that the header exists,
+#   - it uses the current CPPFLAGS,
+#   - it does not cache the result,
+#   - it is silent.
+AC_DEFUN([gl_ABSOLUTE_HEADER_ONE],
+[
+  AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote([$1])[[>]])])
+  dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
+  dnl that contain only a #include of other header files and no
+  dnl non-comment tokens of their own. This leads to a failure to
+  dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
+  dnl and others. The workaround is to force preservation of comments
+  dnl through option -C. This ensures all necessary #line directives
+  dnl are present. GCC supports option -C as well.
+  case "$host_os" in
+    aix*) gl_absname_cpp="$ac_cpp -C" ;;
+    *)    gl_absname_cpp="$ac_cpp" ;;
+  esac
+  dnl eval is necessary to expand gl_absname_cpp.
+  dnl Ultrix and Pyramid sh refuse to redirect output of eval,
+  dnl so use subshell.
+  AS_VAR_SET([gl_cv_absolute_]AS_TR_SH([[$1]]),
+[`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
+sed -n '\#/$1#{
+        s#.*"\(.*/$1\)".*#\1#
+        s#^/[^/]#//&#
+        p
+        q
+}'`])
+])



reply via email to

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