Annotation of embedaddon/libiconv/srcm4/include_next.m4, revision 1.1.1.3
1.1.1.3 ! misho 1: # include_next.m4 serial 24
! 2: dnl Copyright (C) 2006-2019 Free Software Foundation, Inc.
1.1 misho 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:
7: dnl From Paul Eggert and Derek Price.
8:
1.1.1.3 ! misho 9: dnl Sets INCLUDE_NEXT, INCLUDE_NEXT_AS_FIRST_DIRECTIVE, PRAGMA_SYSTEM_HEADER,
! 10: dnl and PRAGMA_COLUMNS.
1.1 misho 11: dnl
12: dnl INCLUDE_NEXT expands to 'include_next' if the compiler supports it, or to
13: dnl 'include' otherwise.
14: dnl
15: dnl INCLUDE_NEXT_AS_FIRST_DIRECTIVE expands to 'include_next' if the compiler
16: dnl supports it in the special case that it is the first include directive in
17: dnl the given file, or to 'include' otherwise.
18: dnl
19: dnl PRAGMA_SYSTEM_HEADER can be used in files that contain #include_next,
20: dnl so as to avoid GCC warnings when the gcc option -pedantic is used.
21: dnl '#pragma GCC system_header' has the same effect as if the file was found
22: dnl through the include search path specified with '-isystem' options (as
23: dnl opposed to the search path specified with '-I' options). Namely, gcc
24: dnl does not warn about some things, and on some systems (Solaris and Interix)
25: dnl __STDC__ evaluates to 0 instead of to 1. The latter is an undesired side
26: dnl effect; we are therefore careful to use 'defined __STDC__' or '1' instead
27: dnl of plain '__STDC__'.
1.1.1.2 misho 28: dnl
29: dnl PRAGMA_COLUMNS can be used in files that override system header files, so
30: dnl as to avoid compilation errors on HP NonStop systems when the gnulib file
31: dnl is included by a system header file that does a "#pragma COLUMNS 80" (which
32: dnl has the effect of truncating the lines of that file and all files that it
33: dnl includes to 80 columns) and the gnulib file has lines longer than 80
34: dnl columns.
1.1 misho 35:
36: AC_DEFUN([gl_INCLUDE_NEXT],
37: [
38: AC_LANG_PREPROC_REQUIRE()
39: AC_CACHE_CHECK([whether the preprocessor supports include_next],
40: [gl_cv_have_include_next],
41: [rm -rf conftestd1a conftestd1b conftestd2
42: mkdir conftestd1a conftestd1b conftestd2
43: dnl IBM C 9.0, 10.1 (original versions, prior to the 2009-01 updates) on
44: dnl AIX 6.1 support include_next when used as first preprocessor directive
45: dnl in a file, but not when preceded by another include directive. Check
46: dnl for this bug by including <stdio.h>.
47: dnl Additionally, with this same compiler, include_next is a no-op when
48: dnl used in a header file that was included by specifying its absolute
49: dnl file name. Despite these two bugs, include_next is used in the
50: dnl compiler's <math.h>. By virtue of the second bug, we need to use
51: dnl include_next as well in this case.
52: cat <<EOF > conftestd1a/conftest.h
53: #define DEFINED_IN_CONFTESTD1
54: #include_next <conftest.h>
55: #ifdef DEFINED_IN_CONFTESTD2
56: int foo;
57: #else
58: #error "include_next doesn't work"
59: #endif
60: EOF
61: cat <<EOF > conftestd1b/conftest.h
62: #define DEFINED_IN_CONFTESTD1
63: #include <stdio.h>
64: #include_next <conftest.h>
65: #ifdef DEFINED_IN_CONFTESTD2
66: int foo;
67: #else
68: #error "include_next doesn't work"
69: #endif
70: EOF
71: cat <<EOF > conftestd2/conftest.h
72: #ifndef DEFINED_IN_CONFTESTD1
73: #error "include_next test doesn't work"
74: #endif
75: #define DEFINED_IN_CONFTESTD2
76: EOF
77: gl_save_CPPFLAGS="$CPPFLAGS"
78: CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1b -Iconftestd2"
1.1.1.2 misho 79: dnl We intentionally avoid using AC_LANG_SOURCE here.
80: AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
1.1 misho 81: [gl_cv_have_include_next=yes],
82: [CPPFLAGS="$gl_save_CPPFLAGS -Iconftestd1a -Iconftestd2"
1.1.1.2 misho 83: AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[#include <conftest.h>]],
1.1 misho 84: [gl_cv_have_include_next=buggy],
85: [gl_cv_have_include_next=no])
86: ])
87: CPPFLAGS="$gl_save_CPPFLAGS"
88: rm -rf conftestd1a conftestd1b conftestd2
89: ])
90: PRAGMA_SYSTEM_HEADER=
91: if test $gl_cv_have_include_next = yes; then
92: INCLUDE_NEXT=include_next
93: INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
94: if test -n "$GCC"; then
95: PRAGMA_SYSTEM_HEADER='#pragma GCC system_header'
96: fi
97: else
98: if test $gl_cv_have_include_next = buggy; then
99: INCLUDE_NEXT=include
100: INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include_next
101: else
102: INCLUDE_NEXT=include
103: INCLUDE_NEXT_AS_FIRST_DIRECTIVE=include
104: fi
105: fi
106: AC_SUBST([INCLUDE_NEXT])
107: AC_SUBST([INCLUDE_NEXT_AS_FIRST_DIRECTIVE])
108: AC_SUBST([PRAGMA_SYSTEM_HEADER])
1.1.1.2 misho 109: AC_CACHE_CHECK([whether system header files limit the line length],
110: [gl_cv_pragma_columns],
111: [dnl HP NonStop systems, which define __TANDEM, have this misfeature.
112: AC_EGREP_CPP([choke me],
113: [
114: #ifdef __TANDEM
115: choke me
116: #endif
117: ],
118: [gl_cv_pragma_columns=yes],
119: [gl_cv_pragma_columns=no])
120: ])
121: if test $gl_cv_pragma_columns = yes; then
122: PRAGMA_COLUMNS="#pragma COLUMNS 10000"
123: else
124: PRAGMA_COLUMNS=
125: fi
126: AC_SUBST([PRAGMA_COLUMNS])
1.1 misho 127: ])
128:
129: # gl_CHECK_NEXT_HEADERS(HEADER1 HEADER2 ...)
130: # ------------------------------------------
131: # For each arg foo.h, if #include_next works, define NEXT_FOO_H to be
132: # '<foo.h>'; otherwise define it to be
133: # '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
134: # Also, if #include_next works as first preprocessing directive in a file,
135: # define NEXT_AS_FIRST_DIRECTIVE_FOO_H to be '<foo.h>'; otherwise define it to
136: # be
137: # '"///usr/include/foo.h"', or whatever other absolute file name is suitable.
138: # That way, a header file with the following line:
1.1.1.2 misho 139: # #@INCLUDE_NEXT@ @NEXT_FOO_H@
1.1 misho 140: # or
1.1.1.2 misho 141: # #@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_FOO_H@
1.1 misho 142: # behaves (after sed substitution) as if it contained
1.1.1.2 misho 143: # #include_next <foo.h>
1.1 misho 144: # even if the compiler does not support include_next.
145: # The three "///" are to pacify Sun C 5.8, which otherwise would say
146: # "warning: #include of /usr/include/... may be non-portable".
1.1.1.3 ! misho 147: # Use '""', not '<>', so that the /// cannot be confused with a C99 comment.
1.1 misho 148: # Note: This macro assumes that the header file is not empty after
149: # preprocessing, i.e. it does not only define preprocessor macros but also
150: # provides some type/enum definitions or function/variable declarations.
1.1.1.2 misho 151: #
152: # This macro also checks whether each header exists, by invoking
153: # AC_CHECK_HEADERS_ONCE or AC_CHECK_HEADERS on each argument.
1.1 misho 154: AC_DEFUN([gl_CHECK_NEXT_HEADERS],
155: [
1.1.1.2 misho 156: gl_NEXT_HEADERS_INTERNAL([$1], [check])
157: ])
158:
159: # gl_NEXT_HEADERS(HEADER1 HEADER2 ...)
160: # ------------------------------------
161: # Like gl_CHECK_NEXT_HEADERS, except do not check whether the headers exist.
162: # This is suitable for headers like <stddef.h> that are standardized by C89
163: # and therefore can be assumed to exist.
164: AC_DEFUN([gl_NEXT_HEADERS],
165: [
166: gl_NEXT_HEADERS_INTERNAL([$1], [assume])
167: ])
168:
169: # The guts of gl_CHECK_NEXT_HEADERS and gl_NEXT_HEADERS.
170: AC_DEFUN([gl_NEXT_HEADERS_INTERNAL],
171: [
1.1 misho 172: AC_REQUIRE([gl_INCLUDE_NEXT])
173: AC_REQUIRE([AC_CANONICAL_HOST])
174:
1.1.1.2 misho 175: m4_if([$2], [check],
176: [AC_CHECK_HEADERS_ONCE([$1])
177: ])
178:
179: dnl FIXME: gl_next_header and gl_header_exists must be used unquoted
180: dnl until we can assume autoconf 2.64 or newer.
1.1 misho 181: m4_foreach_w([gl_HEADER_NAME], [$1],
182: [AS_VAR_PUSHDEF([gl_next_header],
1.1.1.2 misho 183: [gl_cv_next_]m4_defn([gl_HEADER_NAME]))
1.1 misho 184: if test $gl_cv_have_include_next = yes; then
1.1.1.2 misho 185: AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>'])
1.1 misho 186: else
187: AC_CACHE_CHECK(
1.1.1.2 misho 188: [absolute name of <]m4_defn([gl_HEADER_NAME])[>],
189: m4_defn([gl_next_header]),
190: [m4_if([$2], [check],
191: [AS_VAR_PUSHDEF([gl_header_exists],
192: [ac_cv_header_]m4_defn([gl_HEADER_NAME]))
193: if test AS_VAR_GET(gl_header_exists) = yes; then
194: AS_VAR_POPDEF([gl_header_exists])
195: ])
1.1.1.3 ! misho 196: gl_ABSOLUTE_HEADER_ONE(gl_HEADER_NAME)
! 197: AS_VAR_COPY([gl_header], [gl_cv_absolute_]AS_TR_SH(gl_HEADER_NAME))
! 198: AS_VAR_SET(gl_next_header, ['"'$gl_header'"'])
1.1.1.2 misho 199: m4_if([$2], [check],
200: [else
201: AS_VAR_SET(gl_next_header, ['<'gl_HEADER_NAME'>'])
202: fi
203: ])
204: ])
1.1 misho 205: fi
206: AC_SUBST(
207: AS_TR_CPP([NEXT_]m4_defn([gl_HEADER_NAME])),
1.1.1.2 misho 208: [AS_VAR_GET(gl_next_header)])
1.1 misho 209: if test $gl_cv_have_include_next = yes || test $gl_cv_have_include_next = buggy; then
210: # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include_next'
211: gl_next_as_first_directive='<'gl_HEADER_NAME'>'
212: else
213: # INCLUDE_NEXT_AS_FIRST_DIRECTIVE='include'
1.1.1.2 misho 214: gl_next_as_first_directive=AS_VAR_GET(gl_next_header)
1.1 misho 215: fi
216: AC_SUBST(
217: AS_TR_CPP([NEXT_AS_FIRST_DIRECTIVE_]m4_defn([gl_HEADER_NAME])),
218: [$gl_next_as_first_directive])
219: AS_VAR_POPDEF([gl_next_header])])
220: ])
1.1.1.2 misho 221:
222: # Autoconf 2.68 added warnings for our use of AC_COMPILE_IFELSE;
223: # this fallback is safe for all earlier autoconf versions.
224: m4_define_default([AC_LANG_DEFINES_PROVIDED])
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>