Blame gettext-runtime/gnulib-m4/absolute-header.m4

Packit Bot 06c835
# absolute-header.m4 serial 16
Packit Bot 06c835
dnl Copyright (C) 2006-2015 Free Software Foundation, Inc.
Packit Bot 06c835
dnl This file is free software; the Free Software Foundation
Packit Bot 06c835
dnl gives unlimited permission to copy and/or distribute it,
Packit Bot 06c835
dnl with or without modifications, as long as this notice is preserved.
Packit Bot 06c835
Packit Bot 06c835
dnl From Derek Price.
Packit Bot 06c835
Packit Bot 06c835
# gl_ABSOLUTE_HEADER(HEADER1 HEADER2 ...)
Packit Bot 06c835
# ---------------------------------------
Packit Bot 06c835
# Find the absolute name of a header file, testing first if the header exists.
Packit Bot 06c835
# If the header were sys/inttypes.h, this macro would define
Packit Bot 06c835
# ABSOLUTE_SYS_INTTYPES_H to the '""' quoted absolute name of sys/inttypes.h
Packit Bot 06c835
# in config.h
Packit Bot 06c835
# (e.g. '#define ABSOLUTE_SYS_INTTYPES_H "///usr/include/sys/inttypes.h"').
Packit Bot 06c835
# The three "///" are to pacify Sun C 5.8, which otherwise would say
Packit Bot 06c835
# "warning: #include of /usr/include/... may be non-portable".
Packit Bot 06c835
# Use '""', not '<>', so that the /// cannot be confused with a C99 comment.
Packit Bot 06c835
# Note: This macro assumes that the header file is not empty after
Packit Bot 06c835
# preprocessing, i.e. it does not only define preprocessor macros but also
Packit Bot 06c835
# provides some type/enum definitions or function/variable declarations.
Packit Bot 06c835
AC_DEFUN([gl_ABSOLUTE_HEADER],
Packit Bot 06c835
[AC_REQUIRE([AC_CANONICAL_HOST])
Packit Bot 06c835
AC_LANG_PREPROC_REQUIRE()dnl
Packit Bot 06c835
dnl FIXME: gl_absolute_header and ac_header_exists must be used unquoted
Packit Bot 06c835
dnl until we can assume autoconf 2.64 or newer.
Packit Bot 06c835
m4_foreach_w([gl_HEADER_NAME], [$1],
Packit Bot 06c835
  [AS_VAR_PUSHDEF([gl_absolute_header],
Packit Bot 06c835
                  [gl_cv_absolute_]m4_defn([gl_HEADER_NAME]))dnl
Packit Bot 06c835
  AC_CACHE_CHECK([absolute name of <]m4_defn([gl_HEADER_NAME])[>],
Packit Bot 06c835
    m4_defn([gl_absolute_header]),
Packit Bot 06c835
    [AS_VAR_PUSHDEF([ac_header_exists],
Packit Bot 06c835
                    [ac_cv_header_]m4_defn([gl_HEADER_NAME]))dnl
Packit Bot 06c835
    AC_CHECK_HEADERS_ONCE(m4_defn([gl_HEADER_NAME]))dnl
Packit Bot 06c835
    if test AS_VAR_GET(ac_header_exists) = yes; then
Packit Bot 06c835
      gl_ABSOLUTE_HEADER_ONE(m4_defn([gl_HEADER_NAME]))
Packit Bot 06c835
    fi
Packit Bot 06c835
    AS_VAR_POPDEF([ac_header_exists])dnl
Packit Bot 06c835
    ])dnl
Packit Bot 06c835
  AC_DEFINE_UNQUOTED(AS_TR_CPP([ABSOLUTE_]m4_defn([gl_HEADER_NAME])),
Packit Bot 06c835
                     ["AS_VAR_GET(gl_absolute_header)"],
Packit Bot 06c835
                     [Define this to an absolute name of <]m4_defn([gl_HEADER_NAME])[>.])
Packit Bot 06c835
  AS_VAR_POPDEF([gl_absolute_header])dnl
Packit Bot 06c835
])dnl
Packit Bot 06c835
])# gl_ABSOLUTE_HEADER
Packit Bot 06c835
Packit Bot 06c835
# gl_ABSOLUTE_HEADER_ONE(HEADER)
Packit Bot 06c835
# ------------------------------
Packit Bot 06c835
# Like gl_ABSOLUTE_HEADER, except that:
Packit Bot 06c835
#   - it assumes that the header exists,
Packit Bot 06c835
#   - it uses the current CPPFLAGS,
Packit Bot 06c835
#   - it does not cache the result,
Packit Bot 06c835
#   - it is silent.
Packit Bot 06c835
AC_DEFUN([gl_ABSOLUTE_HEADER_ONE],
Packit Bot 06c835
[
Packit Bot 06c835
  AC_REQUIRE([AC_CANONICAL_HOST])
Packit Bot 06c835
  AC_LANG_CONFTEST([AC_LANG_SOURCE([[#include <]]m4_dquote([$1])[[>]])])
Packit Bot 06c835
  dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
Packit Bot 06c835
  dnl that contain only a #include of other header files and no
Packit Bot 06c835
  dnl non-comment tokens of their own. This leads to a failure to
Packit Bot 06c835
  dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
Packit Bot 06c835
  dnl and others. The workaround is to force preservation of comments
Packit Bot 06c835
  dnl through option -C. This ensures all necessary #line directives
Packit Bot 06c835
  dnl are present. GCC supports option -C as well.
Packit Bot 06c835
  case "$host_os" in
Packit Bot 06c835
    aix*) gl_absname_cpp="$ac_cpp -C" ;;
Packit Bot 06c835
    *)    gl_absname_cpp="$ac_cpp" ;;
Packit Bot 06c835
  esac
Packit Bot 06c835
changequote(,)
Packit Bot 06c835
  case "$host_os" in
Packit Bot 06c835
    mingw*)
Packit Bot 06c835
      dnl For the sake of native Windows compilers (excluding gcc),
Packit Bot 06c835
      dnl treat backslash as a directory separator, like /.
Packit Bot 06c835
      dnl Actually, these compilers use a double-backslash as
Packit Bot 06c835
      dnl directory separator, inside the
Packit Bot 06c835
      dnl   # line "filename"
Packit Bot 06c835
      dnl directives.
Packit Bot 06c835
      gl_dirsep_regex='[/\\]'
Packit Bot 06c835
      ;;
Packit Bot 06c835
    *)
Packit Bot 06c835
      gl_dirsep_regex='\/'
Packit Bot 06c835
      ;;
Packit Bot 06c835
  esac
Packit Bot 06c835
  dnl A sed expression that turns a string into a basic regular
Packit Bot 06c835
  dnl expression, for use within "/.../".
Packit Bot 06c835
  gl_make_literal_regex_sed='s,[]$^\\.*/[],\\&,g'
Packit Bot 06c835
  gl_header_literal_regex=`echo '$1' \
Packit Bot 06c835
                           | sed -e "$gl_make_literal_regex_sed"`
Packit Bot 06c835
  gl_absolute_header_sed="/${gl_dirsep_regex}${gl_header_literal_regex}/"'{
Packit Bot 06c835
      s/.*"\(.*'"${gl_dirsep_regex}${gl_header_literal_regex}"'\)".*/\1/
Packit Bot 06c835
      s|^/[^/]|//&|
Packit Bot 06c835
      p
Packit Bot 06c835
      q
Packit Bot 06c835
    }'
Packit Bot 06c835
changequote([,])
Packit Bot 06c835
  dnl eval is necessary to expand gl_absname_cpp.
Packit Bot 06c835
  dnl Ultrix and Pyramid sh refuse to redirect output of eval,
Packit Bot 06c835
  dnl so use subshell.
Packit Bot 06c835
  AS_VAR_SET([gl_cv_absolute_]AS_TR_SH([[$1]]),
Packit Bot 06c835
[`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
Packit Bot 06c835
  sed -n "$gl_absolute_header_sed"`])
Packit Bot 06c835
])