annotate m4/include_next.m4 @ 10836:08a197428e92

Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
author Bruno Haible <bruno@clisp.org>
date Thu, 20 Nov 2008 23:33:58 +0100
parents bca6f1ff10b0
children 485c7346774b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10836
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
1 # include_next.m4 serial 10
9782
1c4f650f9b07 Document a pitfall.
Bruno Haible <bruno@clisp.org>
parents: 9123
diff changeset
2 dnl Copyright (C) 2006-2008 Free Software Foundation, Inc.
6735
1f6871379885 * modules/inttypes: New file.
Derek R. Price <derek@ximbiot.com>
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
1f6871379885 * modules/inttypes: New file.
Derek R. Price <derek@ximbiot.com>
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
1f6871379885 * modules/inttypes: New file.
Derek R. Price <derek@ximbiot.com>
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
1f6871379885 * modules/inttypes: New file.
Derek R. Price <derek@ximbiot.com>
parents:
diff changeset
6
8995
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
7 dnl From Paul Eggert and Derek Price.
6735
1f6871379885 * modules/inttypes: New file.
Derek R. Price <derek@ximbiot.com>
parents:
diff changeset
8
10375
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
9 dnl Sets INCLUDE_NEXT and PRAGMA_SYSTEM_HEADER.
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
10 dnl
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
11 dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
12 dnl 'include' otherwise.
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
13 dnl
10836
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
14 dnl INCLUDE_NEXT_AS_FIRST_DIRECTIVE expands to 'include_next' if the compiler
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
15 dnl supports it in the special case that it is the first include directive in
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
16 dnl the given file, or to 'include' otherwise.
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
17 dnl
10375
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
18 dnl PRAGMA_SYSTEM_HEADER can be used in files that contain #include_next,
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
19 dnl so as to avoid GCC warnings when the gcc option -pedantic is used.
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
20 dnl '#pragma GCC system_header' has the same effect as if the file was found
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
21 dnl through the include search path specified with '-isystem' options (as
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
22 dnl opposed to the search path specified with '-I' options). Namely, gcc
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
23 dnl does not warn about some things, and on some systems (Solaris and Interix)
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
24 dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
25 dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
26 dnl of plain '__STDC__'.
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
27
6735
1f6871379885 * modules/inttypes: New file.
Derek R. Price <derek@ximbiot.com>
parents:
diff changeset
28 AC_DEFUN([gl_INCLUDE_NEXT],
8995
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
29 [
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
30 AC_LANG_PREPROC_REQUIRE()
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
31 AC_CACHE_CHECK([whether the preprocessor supports include_next],
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
32 [gl_cv_have_include_next],
10836
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
33 [rm -rf conftestd1a conftestd1b conftestd2
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
34 mkdir conftestd1a conftestd1b conftestd2
10399
d409a1cc4085 Add check whether #include_next also works after #include directives.
Albert Chin <bug-gnulib@mlists.thewrittenword.com>
parents: 10375
diff changeset
35 dnl The include of <stdio.h> is because IBM C 9.0 on AIX 6.1 supports
d409a1cc4085 Add check whether #include_next also works after #include directives.
Albert Chin <bug-gnulib@mlists.thewrittenword.com>
parents: 10375
diff changeset
36 dnl include_next when used as first preprocessor directive in a file,
10836
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
37 dnl but not when preceded by another include directive. Additionally,
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
38 dnl with this same compiler, include_next is a no-op when used in a
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
39 dnl header file that was included by specifying its absolute file name.
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
40 dnl Despite these two bugs, include_next is used in the compiler's
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
41 dnl <math.h>. By virtue of the second bug, we need to use include_next
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
42 dnl as well in this case.
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
43 cat <<EOF > conftestd1a/conftest.h
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
44 #define DEFINED_IN_CONFTESTD1
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
45 #include_next <conftest.h>
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
46 #ifdef DEFINED_IN_CONFTESTD2
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
47 int foo;
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
48 #else
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
49 #error "include_next doesn't work"
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
50 #endif
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
51 EOF
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
52 cat <<EOF > conftestd1b/conftest.h
9123
72496d26ba38 Fix the include_next test so that it rejects AIX 4.3 xlc.
Bruno Haible <bruno@clisp.org>
parents: 9004
diff changeset
53 #define DEFINED_IN_CONFTESTD1
10399
d409a1cc4085 Add check whether #include_next also works after #include directives.
Albert Chin <bug-gnulib@mlists.thewrittenword.com>
parents: 10375
diff changeset
54 #include <stdio.h>
9123
72496d26ba38 Fix the include_next test so that it rejects AIX 4.3 xlc.
Bruno Haible <bruno@clisp.org>
parents: 9004
diff changeset
55 #include_next <conftest.h>
72496d26ba38 Fix the include_next test so that it rejects AIX 4.3 xlc.
Bruno Haible <bruno@clisp.org>
parents: 9004
diff changeset
56 #ifdef DEFINED_IN_CONFTESTD2
72496d26ba38 Fix the include_next test so that it rejects AIX 4.3 xlc.
Bruno Haible <bruno@clisp.org>
parents: 9004
diff changeset
57 int foo;
72496d26ba38 Fix the include_next test so that it rejects AIX 4.3 xlc.
Bruno Haible <bruno@clisp.org>
parents: 9004
diff changeset
58 #else
72496d26ba38 Fix the include_next test so that it rejects AIX 4.3 xlc.
Bruno Haible <bruno@clisp.org>
parents: 9004
diff changeset
59 #error "include_next doesn't work"
72496d26ba38 Fix the include_next test so that it rejects AIX 4.3 xlc.
Bruno Haible <bruno@clisp.org>
parents: 9004
diff changeset
60 #endif
72496d26ba38 Fix the include_next test so that it rejects AIX 4.3 xlc.
Bruno Haible <bruno@clisp.org>
parents: 9004
diff changeset
61 EOF
72496d26ba38 Fix the include_next test so that it rejects AIX 4.3 xlc.
Bruno Haible <bruno@clisp.org>
parents: 9004
diff changeset
62 cat <<EOF > conftestd2/conftest.h
72496d26ba38 Fix the include_next test so that it rejects AIX 4.3 xlc.
Bruno Haible <bruno@clisp.org>
parents: 9004
diff changeset
63 #ifndef DEFINED_IN_CONFTESTD1
72496d26ba38 Fix the include_next test so that it rejects AIX 4.3 xlc.
Bruno Haible <bruno@clisp.org>
parents: 9004
diff changeset
64 #error "include_next test doesn't work"
72496d26ba38 Fix the include_next test so that it rejects AIX 4.3 xlc.
Bruno Haible <bruno@clisp.org>
parents: 9004
diff changeset
65 #endif
72496d26ba38 Fix the include_next test so that it rejects AIX 4.3 xlc.
Bruno Haible <bruno@clisp.org>
parents: 9004
diff changeset
66 #define DEFINED_IN_CONFTESTD2
72496d26ba38 Fix the include_next test so that it rejects AIX 4.3 xlc.
Bruno Haible <bruno@clisp.org>
parents: 9004
diff changeset
67 EOF
10836
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
68 gl_save_CPPFLAGS="$CPPFLAGS"
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
69 CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2"
9123
72496d26ba38 Fix the include_next test so that it rejects AIX 4.3 xlc.
Bruno Haible <bruno@clisp.org>
parents: 9004
diff changeset
70 AC_COMPILE_IFELSE([#include <conftest.h>],
8995
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
71 [gl_cv_have_include_next=yes],
10836
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
72 [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2"
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
73 AC_COMPILE_IFELSE([#include <conftest.h>],
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
74 [gl_cv_have_include_next=buggy],
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
75 [gl_cv_have_include_next=no])
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
76 ])
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
77 CPPFLAGS="$gl_save_CPPFLAGS"
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
78 rm -rf conftestd1a conftestd1b conftestd2
9123
72496d26ba38 Fix the include_next test so that it rejects AIX 4.3 xlc.
Bruno Haible <bruno@clisp.org>
parents: 9004
diff changeset
79 ])
10375
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
80 PRAGMA_SYSTEM_HEADER=
8995
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
81 if test $gl_cv_have_include_next = yes; then
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
82 INCLUDE_NEXT=include_next
10836
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
83 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
10375
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
84 if test -n "$GCC"; then
10655
8668b19a7032 Avoid gcc warnings because of #pragma GCC system_header on older gcc.
Bruno Haible <bruno@clisp.org>
parents: 10654
diff changeset
85 PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
10375
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
86 fi
8995
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
87 else
10836
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
88 if test $gl_cv_have_include_next = buggy; then
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
89 INCLUDE_NEXT=include
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
90 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
91 else
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
92 INCLUDE_NEXT=include
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
93 INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
94 fi
8995
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
95 fi
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
96 AC_SUBST([INCLUDE_NEXT])
10836
08a197428e92 Attempt to work around another AIX 5.3, 6.1 compiler bug with include_next.
Bruno Haible <bruno@clisp.org>
parents: 10758
diff changeset
97 AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
10375
f96e845fc36d Avoid some "gcc -pedantic" warnings.
Bruno Haible <bruno@clisp.org>
parents: 10374
diff changeset
98 AC_SUBST([PRAGMA_SYSTEM_HEADER])
6735
1f6871379885 * modules/inttypes: New file.
Derek R. Price <derek@ximbiot.com>
parents:
diff changeset
99 ])
8995
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
100
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
101 # gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
102 # ------------------------------------------
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
103 # For each arg foo.h, if #include_next works, define NEXT_FOO_H to be
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
104 # '<foo.h>'; otherwise define it to be
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
105 # '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
106 # That way, a header file with the following line:
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
107 # #@INCLUDE_NEXT@ @NEXT_FOO_H@
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
108 # behaves (after sed substitution) as if it contained
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
109 # #include_next <foo.h>
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
110 # even if the compiler does not support include_next.
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
111 # The three "///" are to pacify Sun C 5.8, which otherwise would say
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
112 # "warning: #include of /usr/include/... may be non-portable".
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
113 # Use `""', not `<>', so that the /// cannot be confused with a C99 comment.
9782
1c4f650f9b07 Document a pitfall.
Bruno Haible <bruno@clisp.org>
parents: 9123
diff changeset
114 # Note: This macro assumes that the header file is not empty after
1c4f650f9b07 Document a pitfall.
Bruno Haible <bruno@clisp.org>
parents: 9123
diff changeset
115 # preprocessing, i.e. it does not only define preprocessor macros but also
1c4f650f9b07 Document a pitfall.
Bruno Haible <bruno@clisp.org>
parents: 9123
diff changeset
116 # provides some type/enum definitions or function/variable declarations.
8995
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
117 AC_DEFUN([gl_CHECK_NEXT_HEADERS],
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
118 [
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
119 AC_REQUIRE([gl_INCLUDE_NEXT])
10758
bca6f1ff10b0 Make determination of absolute name of header file work with AIX xlc.
Bruno Haible <bruno@clisp.org>
parents: 10655
diff changeset
120 AC_REQUIRE([AC_CANONICAL_HOST])
8995
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
121 AC_CHECK_HEADERS_ONCE([$1])
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
122
9878
f3f53950d4f1 Avoid some autoconf warnings.
Eric Blake <ebb9@byu.net>
parents: 9782
diff changeset
123 m4_foreach_w([gl_HEADER_NAME], [$1],
8995
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
124 [AS_VAR_PUSHDEF([gl_next_header],
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
125 [gl_cv_next_]m4_quote(m4_defn([gl_HEADER_NAME])))
9004
2d5c09e70f28 * m4/include_next.m4 (gl_CHECK_NEXT_HEADERS): Check some typos
Paul Eggert <eggert@cs.ucla.edu>
parents: 8995
diff changeset
126 if test $gl_cv_have_include_next = yes; then
2d5c09e70f28 * m4/include_next.m4 (gl_CHECK_NEXT_HEADERS): Check some typos
Paul Eggert <eggert@cs.ucla.edu>
parents: 8995
diff changeset
127 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
2d5c09e70f28 * m4/include_next.m4 (gl_CHECK_NEXT_HEADERS): Check some typos
Paul Eggert <eggert@cs.ucla.edu>
parents: 8995
diff changeset
128 else
8995
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
129 AC_CACHE_CHECK(
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
130 [absolute name of <]m4_quote(m4_defn([gl_HEADER_NAME]))[>],
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
131 m4_quote(m4_defn([gl_next_header])),
9004
2d5c09e70f28 * m4/include_next.m4 (gl_CHECK_NEXT_HEADERS): Check some typos
Paul Eggert <eggert@cs.ucla.edu>
parents: 8995
diff changeset
132 [AS_VAR_PUSHDEF([gl_header_exists],
2d5c09e70f28 * m4/include_next.m4 (gl_CHECK_NEXT_HEADERS): Check some typos
Paul Eggert <eggert@cs.ucla.edu>
parents: 8995
diff changeset
133 [ac_cv_header_]m4_quote(m4_defn([gl_HEADER_NAME])))
2d5c09e70f28 * m4/include_next.m4 (gl_CHECK_NEXT_HEADERS): Check some typos
Paul Eggert <eggert@cs.ucla.edu>
parents: 8995
diff changeset
134 if test AS_VAR_GET(gl_header_exists) = yes; then
8995
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
135 AC_LANG_CONFTEST(
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
136 [AC_LANG_SOURCE(
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
137 [[#include <]]m4_dquote(m4_defn([gl_HEADER_NAME]))[[>]]
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
138 )])
10758
bca6f1ff10b0 Make determination of absolute name of header file work with AIX xlc.
Bruno Haible <bruno@clisp.org>
parents: 10655
diff changeset
139 dnl AIX "xlc -E" and "cc -E" omit #line directives for header files
bca6f1ff10b0 Make determination of absolute name of header file work with AIX xlc.
Bruno Haible <bruno@clisp.org>
parents: 10655
diff changeset
140 dnl that contain only a #include of other header files and no
bca6f1ff10b0 Make determination of absolute name of header file work with AIX xlc.
Bruno Haible <bruno@clisp.org>
parents: 10655
diff changeset
141 dnl non-comment tokens of their own. This leads to a failure to
bca6f1ff10b0 Make determination of absolute name of header file work with AIX xlc.
Bruno Haible <bruno@clisp.org>
parents: 10655
diff changeset
142 dnl detect the absolute name of <dirent.h>, <signal.h>, <poll.h>
bca6f1ff10b0 Make determination of absolute name of header file work with AIX xlc.
Bruno Haible <bruno@clisp.org>
parents: 10655
diff changeset
143 dnl and others. The workaround is to force preservation of comments
bca6f1ff10b0 Make determination of absolute name of header file work with AIX xlc.
Bruno Haible <bruno@clisp.org>
parents: 10655
diff changeset
144 dnl through option -C. This ensures all necessary #line directives
bca6f1ff10b0 Make determination of absolute name of header file work with AIX xlc.
Bruno Haible <bruno@clisp.org>
parents: 10655
diff changeset
145 dnl are present. GCC supports option -C as well.
bca6f1ff10b0 Make determination of absolute name of header file work with AIX xlc.
Bruno Haible <bruno@clisp.org>
parents: 10655
diff changeset
146 case "$host_os" in
bca6f1ff10b0 Make determination of absolute name of header file work with AIX xlc.
Bruno Haible <bruno@clisp.org>
parents: 10655
diff changeset
147 aix*) gl_absname_cpp="$ac_cpp -C" ;;
bca6f1ff10b0 Make determination of absolute name of header file work with AIX xlc.
Bruno Haible <bruno@clisp.org>
parents: 10655
diff changeset
148 *) gl_absname_cpp="$ac_cpp" ;;
bca6f1ff10b0 Make determination of absolute name of header file work with AIX xlc.
Bruno Haible <bruno@clisp.org>
parents: 10655
diff changeset
149 esac
bca6f1ff10b0 Make determination of absolute name of header file work with AIX xlc.
Bruno Haible <bruno@clisp.org>
parents: 10655
diff changeset
150 dnl eval is necessary to expand gl_absname_cpp.
8995
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
151 dnl Ultrix and Pyramid sh refuse to redirect output of eval,
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
152 dnl so use subshell.
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
153 AS_VAR_SET([gl_next_header],
10758
bca6f1ff10b0 Make determination of absolute name of header file work with AIX xlc.
Bruno Haible <bruno@clisp.org>
parents: 10655
diff changeset
154 ['"'`(eval "$gl_absname_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD |
8995
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
155 sed -n '\#/]m4_quote(m4_defn([gl_HEADER_NAME]))[#{
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
156 s#.*"\(.*/]m4_quote(m4_defn([gl_HEADER_NAME]))[\)".*#\1#
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
157 s#^/[^/]#//&#
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
158 p
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
159 q
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
160 }'`'"'])
9004
2d5c09e70f28 * m4/include_next.m4 (gl_CHECK_NEXT_HEADERS): Check some typos
Paul Eggert <eggert@cs.ucla.edu>
parents: 8995
diff changeset
161 else
2d5c09e70f28 * m4/include_next.m4 (gl_CHECK_NEXT_HEADERS): Check some typos
Paul Eggert <eggert@cs.ucla.edu>
parents: 8995
diff changeset
162 AS_VAR_SET([gl_next_header], ['<'gl_HEADER_NAME'>'])
2d5c09e70f28 * m4/include_next.m4 (gl_CHECK_NEXT_HEADERS): Check some typos
Paul Eggert <eggert@cs.ucla.edu>
parents: 8995
diff changeset
163 fi
2d5c09e70f28 * m4/include_next.m4 (gl_CHECK_NEXT_HEADERS): Check some typos
Paul Eggert <eggert@cs.ucla.edu>
parents: 8995
diff changeset
164 AS_VAR_POPDEF([gl_header_exists])])
8995
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
165 fi
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
166 AC_SUBST(
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
167 AS_TR_CPP([NEXT_]m4_quote(m4_defn([gl_HEADER_NAME]))),
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
168 [AS_VAR_GET([gl_next_header])])
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
169 AS_VAR_POPDEF([gl_next_header])])
1025663f7658 * m4/include_next.m4 (gl_INCLUDE_NEXT): Define and AC_SUBST
Paul Eggert <eggert@cs.ucla.edu>
parents: 6735
diff changeset
170 ])