~bzr-explorers/gnuhello/test

« back to all changes in this revision

Viewing changes to gnulib/m4/include_next.m4

  • Committer: karl
  • Date: 2008-11-05 19:46:20 UTC
  • Revision ID: vcs-imports@canonical.com-20081105194620-im27k670llw7s8ms
gnulib update

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# include_next.m4 serial 6
 
1
# include_next.m4 serial 9
2
2
dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
3
3
dnl This file is free software; the Free Software Foundation
4
4
dnl gives unlimited permission to copy and/or distribute it,
6
6
 
7
7
dnl From Paul Eggert and Derek Price.
8
8
 
 
9
dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER.
 
10
dnl
 
11
dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
 
12
dnl 'include' otherwise.
 
13
dnl
 
14
dnl PRAGMA_SYSTEM_HEADER can be used in files that contain #include_next,
 
15
dnl so as to avoid GCC warnings when the gcc option -pedantic is used.
 
16
dnl '#pragma GCC system_header' has the same effect as if the file was found
 
17
dnl through the include search path specified with '-isystem' options (as
 
18
dnl opposed to the search path specified with '-I' options). Namely, gcc
 
19
dnl does not warn about some things, and on some systems (Solaris and Interix)
 
20
dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side
 
21
dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead
 
22
dnl of plain '__STDC__'.
 
23
 
9
24
AC_DEFUN([gl_INCLUDE_NEXT],
10
25
[
11
26
  AC_LANG_PREPROC_REQUIRE()
13
28
    [gl_cv_have_include_next],
14
29
    [rm -rf conftestd1 conftestd2
15
30
     mkdir conftestd1 conftestd2
 
31
     dnl The include of <stdio.h> is because IBM C 9.0 on AIX 6.1 supports
 
32
     dnl include_next when used as first preprocessor directive in a file,
 
33
     dnl but not when preceded by another include directive.
16
34
     cat <<EOF > conftestd1/conftest.h
17
35
#define DEFINED_IN_CONFTESTD1
 
36
#include <stdio.h>
18
37
#include_next <conftest.h>
19
38
#ifdef DEFINED_IN_CONFTESTD2
20
39
int foo;
36
55
     CPPFLAGS="$save_CPPFLAGS"
37
56
     rm -rf conftestd1 conftestd2
38
57
    ])
 
58
  PRAGMA_SYSTEM_HEADER=
39
59
  if test $gl_cv_have_include_next = yes; then
40
 
 
41
 
    dnl FIXME: Remove HAVE_INCLUDE_NEXT and update everything that uses it
42
 
    dnl to use @INCLUDE_NEXT@ instead.
43
 
    AC_DEFINE([HAVE_INCLUDE_NEXT], 1,
44
 
              [Define if your compiler supports the #include_next directive.])
45
 
 
46
60
    INCLUDE_NEXT=include_next
 
61
    if test -n "$GCC"; then
 
62
      PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
 
63
    fi
47
64
  else
48
65
    INCLUDE_NEXT=include
49
66
  fi
50
67
  AC_SUBST([INCLUDE_NEXT])
 
68
  AC_SUBST([PRAGMA_SYSTEM_HEADER])
51
69
])
52
70
 
53
71
# gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
69
87
AC_DEFUN([gl_CHECK_NEXT_HEADERS],
70
88
[
71
89
  AC_REQUIRE([gl_INCLUDE_NEXT])
 
90
  AC_REQUIRE([AC_CANONICAL_HOST])
72
91
  AC_CHECK_HEADERS_ONCE([$1])
73
92
 
74
93
  m4_foreach_w([gl_HEADER_NAME], [$1],
87
106
              [AC_LANG_SOURCE(
88
107
                 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
89
108
               )])
90
 
            dnl eval is necessary to expand ac_cpp.
 
109
            dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
 
110
            dnl that contain only a #include of other header files and no
 
111
            dnl non-comment tokens of their own. This leads to a failure to
 
112
            dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
 
113
            dnl and others. The workaround is to force preservation of comments
 
114
            dnl through option -C. This ensures all necessary #line directives
 
115
            dnl are present. GCC supports option -C as well.
 
116
            case "$host_os" in
 
117
              aix*) gl_absname_cpp="$ac_cpp -C" ;;
 
118
              *)    gl_absname_cpp="$ac_cpp" ;;
 
119
            esac
 
120
            dnl eval is necessary to expand gl_absname_cpp.
91
121
            dnl Ultrix and Pyramid sh refuse to redirect output of eval,
92
122
            dnl so use subshell.
93
123
            AS_VAR_SET([gl_next_header],
94
 
              ['"'`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
 
124
              ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
95
125
               sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
96
126
                 s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
97
127
                 s#^/[^/]#//&#