absolute-header.m4 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # absolute-header.m4 serial 7
  2. dnl Copyright (C) 2006, 2007 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. dnl From Derek Price.
  7. # gl_ABSOLUTE_HEADER(HEADER1 HEADER2 ...)
  8. # ---------------------------------------
  9. # Find the absolute name of a header file, assuming the header exists.
  10. # If the header were sys/inttypes.h, this macro would define
  11. # ABSOLUTE_SYS_INTTYPES_H to the `""' quoted absolute name of sys/inttypes.h
  12. # in config.h
  13. # (e.g. `#define ABSOLUTE_SYS_INTTYPES_H "///usr/include/sys/inttypes.h"').
  14. # The three "///" are to pacify Sun C 5.8, which otherwise would say
  15. # "warning: #include of /usr/include/... may be non-portable".
  16. # Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
  17. AC_DEFUN([gl_ABSOLUTE_HEADER],
  18. [AC_LANG_PREPROC_REQUIRE()dnl
  19. AC_FOREACH([gl_HEADER_NAME], [$1],
  20. [AS_VAR_PUSHDEF([gl_absolute_header],
  21. [gl_cv_absolute_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl
  22. AC_CACHE_CHECK([absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
  23. m4_quote(m4_defn([gl_absolute_header])),
  24. [AS_VAR_PUSHDEF([ac_header_exists],
  25. [ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))dnl
  26. AC_CHECK_HEADERS_ONCE(m4_quote(m4_defn([gl_HEADER_NAME])))dnl
  27. if test AS_VAR_GET(ac_header_exists) = yes; then
  28. AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]])])
  29. dnl eval is necessary to expand ac_cpp.
  30. dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell.
  31. AS_VAR_SET(gl_absolute_header,
  32. [`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
  33. sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
  34. s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
  35. s#^/[^/]#//&#
  36. p
  37. q
  38. }'`])
  39. fi
  40. AS_VAR_POPDEF([ac_header_exists])dnl
  41. ])dnl
  42. AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_quote(m4_defn([gl_HEADER_NAME]))),
  43. ["AS_VAR_GET(gl_absolute_header)"],
  44. [Define this to an absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>.])
  45. AS_VAR_POPDEF([gl_absolute_header])dnl
  46. ])dnl
  47. ])# gl_ABSOLUTE_HEADER