123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
- dnl This file is free software; the Free Software Foundation
- dnl gives unlimited permission to copy and/or distribute it,
- dnl with or without modifications, as long as this notice is preserved.
- dnl From Paul Eggert and Derek Price.
- dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER.
- dnl
- dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
- dnl 'include' otherwise.
- dnl
- dnl INCLUDE_NEXT_AS_FIRST_DIRECTIVE expands to 'include_next' if the compiler
- dnl supports it in the special case that it is the first include directive in
- dnl the given file, or to 'include' otherwise.
- dnl
- dnl PRAGMA_SYSTEM_HEADER can be used in files that contain
- dnl so as to avoid GCC warnings when the gcc option -pedantic is used.
- dnl '#pragma GCC system_header' has the same effect as if the file was found
- dnl through the include search path specified with '-isystem' options (as
- dnl opposed to the search path specified with '-I' options). Namely, gcc
- dnl does not warn about some things, and on some systems (Solaris and Interix)
- dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side
- dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead
- dnl of plain '__STDC__'.
- dnl
- dnl PRAGMA_COLUMNS can be used in files that override system header files, so
- dnl as to avoid compilation errors on HP NonStop systems when the gnulib file
- dnl is included by a system header file that does a "#pragma COLUMNS 80" (which
- dnl has the effect of truncating the lines of that file and all files that it
- dnl includes to 80 columns) and the gnulib file has lines longer than 80
- dnl columns.
- AC_DEFUN([gl_INCLUDE_NEXT],
- [
- AC_LANG_PREPROC_REQUIRE()
- AC_CACHE_CHECK([whether the preprocessor supports include_next],
- [gl_cv_have_include_next],
- [rm -rf conftestd1a conftestd1b conftestd2
- mkdir conftestd1a conftestd1b conftestd2
- dnl IBM C 9.0, 10.1 (original versions, prior to the 2009-01 updates) on
- dnl AIX 6.1 support include_next when used as first preprocessor directive
- dnl in a file, but not when preceded by another include directive. Check
- dnl for this bug by including <stdio.h>.
- dnl Additionally, with this same compiler, include_next is a no-op when
- dnl used in a header file that was included by specifying its absolute
- dnl file name. Despite these two bugs, include_next is used in the
- dnl compiler's <math.h>. By virtue of the second bug, we need to use
- dnl include_next as well in this case.
- cat <<EOF > conftestd1a/conftest.h
- #define DEFINED_IN_CONFTESTD1
- #include_next <conftest.h>
- #ifdef DEFINED_IN_CONFTESTD2
- int foo;
- #else
- #error "include_next doesn't work"
- #endif
- EOF
- cat <<EOF > conftestd1b/conftest.h
- #define DEFINED_IN_CONFTESTD1
- #include <stdio.h>
- #include_next <conftest.h>
- #ifdef DEFINED_IN_CONFTESTD2
- int foo;
- #else
- #error "include_next doesn't work"
- #endif
- EOF
- cat <<EOF > conftestd2/conftest.h
- #ifndef DEFINED_IN_CONFTESTD1
- #error "include_next test doesn't work"
- #endif
- #define DEFINED_IN_CONFTESTD2
- EOF
- gl_save_CPPFLAGS="$CPPFLAGS"
- CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2"
- dnl We intentionally avoid using AC_LANG_SOURCE here.
- AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
- [gl_cv_have_include_next=yes],
- [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2"
- AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
- [gl_cv_have_include_next=buggy],
- [gl_cv_have_include_next=no])
- ])
- CPPFLAGS="$gl_save_CPPFLAGS"
- rm -rf conftestd1a conftestd1b conftestd2
- ])
- PRAGMA_SYSTEM_HEADER=
- if test $gl_cv_have_include_next = yes; then
- INCLUDE_NEXT=include_next
- INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
- if test -n "$GCC"; then
- PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
- fi
- else
- if test $gl_cv_have_include_next = buggy; then
- INCLUDE_NEXT=include
- INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
- else
- INCLUDE_NEXT=include
- INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include
- fi
- fi
- AC_SUBST([INCLUDE_NEXT])
- AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
- AC_SUBST([PRAGMA_SYSTEM_HEADER])
- AC_CACHE_CHECK([whether system header files limit the line length],
- [gl_cv_pragma_columns],
- [dnl HP NonStop systems, which define __TANDEM, have this misfeature.
- AC_EGREP_CPP([choke me],
- [
- #ifdef __TANDEM
- choke me
- #endif
- ],
- [gl_cv_pragma_columns=yes],
- [gl_cv_pragma_columns=no])
- ])
- if test $gl_cv_pragma_columns = yes; then
- PRAGMA_COLUMNS="
- else
- PRAGMA_COLUMNS=
- fi
- AC_SUBST([PRAGMA_COLUMNS])
- ])
- AC_DEFUN([gl_CHECK_NEXT_HEADERS],
- [
- gl_NEXT_HEADERS_INTERNAL([$1], [check])
- ])
- AC_DEFUN([gl_NEXT_HEADERS],
- [
- gl_NEXT_HEADERS_INTERNAL([$1], [assume])
- ])
- AC_DEFUN([gl_NEXT_HEADERS_INTERNAL],
- [
- AC_REQUIRE([gl_INCLUDE_NEXT])
- AC_REQUIRE([AC_CANONICAL_HOST])
- m4_if([$2], [check],
- [AC_CHECK_HEADERS_ONCE([$1])
- ])
- m4_foreach_w([gl_HEADER_NAME], [$1],
- [AS_VAR_PUSHDEF([gl_next_header],
- [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
- if test $gl_cv_have_include_next = yes; then
- AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
- else
- AC_CACHE_CHECK(
- [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
- m4_defn([gl_next_header]),
- [m4_if([$2], [check],
- [AS_VAR_PUSHDEF([gl_header_exists],
- [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
- if test AS_VAR_GET(gl_header_exists) = yes; then
- AS_VAR_POPDEF([gl_header_exists])
- ])
- AC_LANG_CONFTEST(
- [AC_LANG_SOURCE(
- [[
- )])
- dnl AIX "xlc -E" and "cc -E" omit
- dnl files that contain only a
- dnl no non-comment tokens of their own. This leads to a failure
- dnl to detect the absolute name of <dirent.h>, <signal.h>,
- dnl <poll.h> and others. The workaround is to force preservation
- dnl of comments through option -C. This ensures all necessary
- dnl
- 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_next_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
- }'`'"'])
- m4_if([$2], [check],
- [else
- AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
- fi
- ])
- ])
- fi
- AC_SUBST(
- AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
- [AS_VAR_GET([gl_next_header])])
- if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
-
- gl_next_as_first_directive='<'gl_HEADER_NAME'>'
- else
-
- gl_next_as_first_directive=AS_VAR_GET([gl_next_header])
- fi
- AC_SUBST(
- AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])),
- [$gl_next_as_first_directive])
- AS_VAR_POPDEF([gl_next_header])])
- ])
- m4_define_default([AC_LANG_DEFINES_PROVIDED])
|