]>
Commit | Line | Data |
---|---|---|
9fdf713f | 1 | Fdnl See whether we can include both string.h and strings.h. |
99e757d5 | 2 | AC_DEFUN(gcc_AC_HEADER_STRING, |
ccc7d11a KG |
3 | [AC_CACHE_CHECK([whether string.h and strings.h may both be included], |
4 | gcc_cv_header_string, | |
5 | [AC_TRY_COMPILE([#include <string.h> | |
6 | #include <strings.h>], , gcc_cv_header_string=yes, gcc_cv_header_string=no)]) | |
7 | if test $gcc_cv_header_string = yes; then | |
91029a29 | 8 | AC_DEFINE(STRING_WITH_STRINGS, 1, [Define if you can safely include both <string.h> and <strings.h>.]) |
ccc7d11a KG |
9 | fi |
10 | ]) | |
11 | ||
2f51182a | 12 | dnl See whether we need a declaration for a function. |
86cf1cbd KG |
13 | dnl The result is highly dependent on the INCLUDES passed in, so make sure |
14 | dnl to use a different cache variable name in this macro if it is invoked | |
15 | dnl in a different context somewhere else. | |
f31e826b KG |
16 | dnl gcc_AC_CHECK_DECL(SYMBOL, |
17 | dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]]) | |
18 | AC_DEFUN(gcc_AC_CHECK_DECL, | |
19 | [AC_MSG_CHECKING([whether $1 is declared]) | |
20 | AC_CACHE_VAL(gcc_cv_have_decl_$1, | |
21 | [AC_TRY_COMPILE([$4], | |
86cf1cbd KG |
22 | [#ifndef $1 |
23 | char *(*pfn) = (char *(*)) $1 ; | |
f31e826b KG |
24 | #endif], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")]) |
25 | if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then | |
26 | AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2]) | |
a81fb89e | 27 | else |
f31e826b | 28 | AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3]) |
2f51182a DE |
29 | fi |
30 | ])dnl | |
ac64120e | 31 | |
a81fb89e | 32 | dnl Check multiple functions to see whether each needs a declaration. |
f31e826b KG |
33 | dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate. |
34 | dnl gcc_AC_CHECK_DECLS(SYMBOLS, | |
35 | dnl [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]]) | |
36 | AC_DEFUN(gcc_AC_CHECK_DECLS, | |
a81fb89e KG |
37 | [for ac_func in $1 |
38 | do | |
f31e826b KG |
39 | changequote(, )dnl |
40 | ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` | |
86cf1cbd | 41 | changequote([, ])dnl |
f31e826b KG |
42 | gcc_AC_CHECK_DECL($ac_func, |
43 | [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2], | |
44 | [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3], | |
7afe8c41 KG |
45 | dnl It is possible that the include files passed in here are local headers |
46 | dnl which supply a backup declaration for the relevant prototype based on | |
47 | dnl the definition of (or lack of) the HAVE_DECL_ macro. If so, this test | |
48 | dnl will always return success. E.g. see libiberty.h's handling of | |
49 | dnl `basename'. To avoid this, we define the relevant HAVE_DECL_ macro to | |
50 | dnl 1 so that any local headers used do not provide their own prototype | |
51 | dnl during this test. | |
52 | #undef $ac_tr_decl | |
53 | #define $ac_tr_decl 1 | |
f31e826b KG |
54 | $4 |
55 | ) | |
a81fb89e | 56 | done |
86cf1cbd KG |
57 | dnl Automatically generate config.h entries via autoheader. |
58 | if test x = y ; then | |
59 | patsubst(translit([$1], [a-z], [A-Z]), [\w+], | |
f31e826b KG |
60 | AC_DEFINE([HAVE_DECL_\&], 1, |
61 | [Define to 1 if we found this declaration otherwise define to 0.]))dnl | |
86cf1cbd | 62 | fi |
a81fb89e KG |
63 | ]) |
64 | ||
76b4b31e KG |
65 | dnl Check if we have vprintf and possibly _doprnt. |
66 | dnl Note autoconf checks for vprintf even though we care about vfprintf. | |
99e757d5 | 67 | AC_DEFUN(gcc_AC_FUNC_VFPRINTF_DOPRNT, |
76b4b31e KG |
68 | [AC_FUNC_VPRINTF |
69 | vfprintf= | |
70 | doprint= | |
71 | if test $ac_cv_func_vprintf != yes ; then | |
72 | vfprintf=vfprintf.o | |
73 | if test $ac_cv_func__doprnt != yes ; then | |
74 | doprint=doprint.o | |
75 | fi | |
76 | fi | |
77 | AC_SUBST(vfprintf) | |
78 | AC_SUBST(doprint) | |
79 | ]) | |
80 | ||
b3e1e64f MS |
81 | dnl Check if we have strstr. |
82 | AC_DEFUN([gcc_AC_FUNC_STRSTR], | |
83 | [AC_CHECK_FUNCS([strstr], [strstr=], [strstr=strstr.o]) | |
84 | AC_SUBST([strstr])]) | |
85 | ||
f1b54f9b | 86 | dnl See if the printf functions in libc support %p in format strings. |
99e757d5 | 87 | AC_DEFUN(gcc_AC_FUNC_PRINTF_PTR, |
f1b54f9b KG |
88 | [AC_CACHE_CHECK(whether the printf functions support %p, |
89 | gcc_cv_func_printf_ptr, | |
90 | [AC_TRY_RUN([#include <stdio.h> | |
91 | ||
86cf1cbd | 92 | int main() |
f1b54f9b KG |
93 | { |
94 | char buf[64]; | |
95 | char *p = buf, *q = NULL; | |
96 | sprintf(buf, "%p", p); | |
97 | sscanf(buf, "%p", &q); | |
86cf1cbd | 98 | return (p != q); |
f1b54f9b KG |
99 | }], gcc_cv_func_printf_ptr=yes, gcc_cv_func_printf_ptr=no, |
100 | gcc_cv_func_printf_ptr=no) | |
101 | rm -f core core.* *.core]) | |
102 | if test $gcc_cv_func_printf_ptr = yes ; then | |
91029a29 | 103 | AC_DEFINE(HAVE_PRINTF_PTR, 1, [Define if printf supports "%p".]) |
f1b54f9b KG |
104 | fi |
105 | ]) | |
106 | ||
ac64120e | 107 | dnl See if symbolic links work and if not, try to substitute either hard links or simple copy. |
99e757d5 | 108 | AC_DEFUN(gcc_AC_PROG_LN_S, |
ac64120e JW |
109 | [AC_MSG_CHECKING(whether ln -s works) |
110 | AC_CACHE_VAL(gcc_cv_prog_LN_S, | |
e566af04 MH |
111 | [rm -f conftestdata_t |
112 | echo >conftestdata_f | |
113 | if ln -s conftestdata_f conftestdata_t 2>/dev/null | |
ac64120e JW |
114 | then |
115 | gcc_cv_prog_LN_S="ln -s" | |
116 | else | |
e566af04 | 117 | if ln conftestdata_f conftestdata_t 2>/dev/null |
ac64120e JW |
118 | then |
119 | gcc_cv_prog_LN_S=ln | |
120 | else | |
121 | gcc_cv_prog_LN_S=cp | |
122 | fi | |
123 | fi | |
e566af04 | 124 | rm -f conftestdata_f conftestdata_t |
ac64120e JW |
125 | ])dnl |
126 | LN_S="$gcc_cv_prog_LN_S" | |
127 | if test "$gcc_cv_prog_LN_S" = "ln -s"; then | |
128 | AC_MSG_RESULT(yes) | |
129 | else | |
130 | if test "$gcc_cv_prog_LN_S" = "ln"; then | |
131 | AC_MSG_RESULT([no, using ln]) | |
132 | else | |
133 | AC_MSG_RESULT([no, and neither does ln, so using cp]) | |
134 | fi | |
135 | fi | |
136 | AC_SUBST(LN_S)dnl | |
137 | ]) | |
138 | ||
139 | dnl See if hard links work and if not, try to substitute either symbolic links or simple copy. | |
99e757d5 | 140 | AC_DEFUN(gcc_AC_PROG_LN, |
ac64120e JW |
141 | [AC_MSG_CHECKING(whether ln works) |
142 | AC_CACHE_VAL(gcc_cv_prog_LN, | |
e566af04 MH |
143 | [rm -f conftestdata_t |
144 | echo >conftestdata_f | |
145 | if ln conftestdata_f conftestdata_t 2>/dev/null | |
ac64120e JW |
146 | then |
147 | gcc_cv_prog_LN="ln" | |
148 | else | |
e566af04 | 149 | if ln -s conftestdata_f conftestdata_t 2>/dev/null |
ac64120e JW |
150 | then |
151 | gcc_cv_prog_LN="ln -s" | |
152 | else | |
153 | gcc_cv_prog_LN=cp | |
154 | fi | |
155 | fi | |
e566af04 | 156 | rm -f conftestdata_f conftestdata_t |
ac64120e JW |
157 | ])dnl |
158 | LN="$gcc_cv_prog_LN" | |
159 | if test "$gcc_cv_prog_LN" = "ln"; then | |
160 | AC_MSG_RESULT(yes) | |
161 | else | |
162 | if test "$gcc_cv_prog_LN" = "ln -s"; then | |
163 | AC_MSG_RESULT([no, using ln -s]) | |
164 | else | |
165 | AC_MSG_RESULT([no, and neither does ln -s, so using cp]) | |
166 | fi | |
167 | fi | |
168 | AC_SUBST(LN)dnl | |
169 | ]) | |
76143254 | 170 | |
e9b4fabf | 171 | dnl See whether the stage1 host compiler accepts the volatile keyword. |
99e757d5 | 172 | AC_DEFUN(gcc_AC_C_VOLATILE, |
e9b4fabf JL |
173 | [AC_CACHE_CHECK([for volatile], gcc_cv_c_volatile, |
174 | [AC_TRY_COMPILE(, [volatile int foo;], | |
175 | gcc_cv_c_volatile=yes, gcc_cv_c_volatile=no)]) | |
176 | if test $gcc_cv_c_volatile = yes ; then | |
91029a29 | 177 | AC_DEFINE(HAVE_VOLATILE, 1, [Define if your compiler understands volatile.]) |
e9b4fabf JL |
178 | fi |
179 | ]) | |
180 | ||
04cabffc KG |
181 | dnl Check whether long double is supported. This differs from the |
182 | dnl built-in autoconf test in that it works for cross compiles. | |
99e757d5 | 183 | AC_DEFUN(gcc_AC_C_LONG_DOUBLE, |
04cabffc KG |
184 | [AC_CACHE_CHECK(for long double, gcc_cv_c_long_double, |
185 | [if test "$GCC" = yes; then | |
186 | gcc_cv_c_long_double=yes | |
187 | else | |
188 | AC_TRY_COMPILE(, | |
189 | [/* The Stardent Vistra knows sizeof(long double), but does not support it. */ | |
190 | long double foo = 0.0; | |
191 | /* On Ultrix 4.3 cc, long double is 4 and double is 8. */ | |
192 | switch (0) case 0: case (sizeof(long double) >= sizeof(double)):;], | |
193 | gcc_cv_c_long_double=yes, gcc_cv_c_long_double=no) | |
194 | fi]) | |
195 | if test $gcc_cv_c_long_double = yes; then | |
196 | AC_DEFINE(HAVE_LONG_DOUBLE) | |
197 | fi | |
198 | ]) | |
199 | ||
75923b2f MK |
200 | dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead |
201 | dnl of the usual 2. | |
99e757d5 | 202 | AC_DEFUN(gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG, |
75923b2f MK |
203 | [AC_CACHE_CHECK([if mkdir takes one argument], gcc_cv_mkdir_takes_one_arg, |
204 | [AC_TRY_COMPILE([ | |
205 | #include <sys/types.h> | |
206 | #ifdef HAVE_SYS_STAT_H | |
207 | # include <sys/stat.h> | |
208 | #endif | |
209 | #ifdef HAVE_UNISTD_H | |
210 | # include <unistd.h> | |
211 | #endif | |
212 | #ifdef HAVE_DIRECT_H | |
213 | # include <direct.h> | |
214 | #endif], [mkdir ("foo", 0);], | |
215 | gcc_cv_mkdir_takes_one_arg=no, gcc_cv_mkdir_takes_one_arg=yes)]) | |
216 | if test $gcc_cv_mkdir_takes_one_arg = yes ; then | |
91029a29 | 217 | AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a single argument.]) |
75923b2f MK |
218 | fi |
219 | ]) | |
220 | ||
99e757d5 | 221 | AC_DEFUN(gcc_AC_PROG_INSTALL, |
76143254 JL |
222 | [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl |
223 | # Find a good install program. We prefer a C program (faster), | |
224 | # so one script is as good as another. But avoid the broken or | |
225 | # incompatible versions: | |
226 | # SysV /etc/install, /usr/sbin/install | |
227 | # SunOS /usr/etc/install | |
228 | # IRIX /sbin/install | |
229 | # AIX /bin/install | |
230 | # AFS /usr/afsws/bin/install, which mishandles nonexistent args | |
231 | # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" | |
232 | # ./install, which can be erroneously created by make from ./install.sh. | |
233 | AC_MSG_CHECKING(for a BSD compatible install) | |
234 | if test -z "$INSTALL"; then | |
235 | AC_CACHE_VAL(ac_cv_path_install, | |
236 | [ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS="${IFS}:" | |
237 | for ac_dir in $PATH; do | |
238 | # Account for people who put trailing slashes in PATH elements. | |
239 | case "$ac_dir/" in | |
240 | /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; | |
241 | *) | |
242 | # OSF1 and SCO ODT 3.0 have their own names for install. | |
243 | for ac_prog in ginstall scoinst install; do | |
244 | if test -f $ac_dir/$ac_prog; then | |
245 | if test $ac_prog = install && | |
246 | grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then | |
247 | # AIX install. It has an incompatible calling convention. | |
248 | # OSF/1 installbsd also uses dspmsg, but is usable. | |
249 | : | |
250 | else | |
251 | ac_cv_path_install="$ac_dir/$ac_prog -c" | |
252 | break 2 | |
253 | fi | |
254 | fi | |
255 | done | |
256 | ;; | |
257 | esac | |
258 | done | |
259 | IFS="$ac_save_IFS" | |
260 | ])dnl | |
261 | if test "${ac_cv_path_install+set}" = set; then | |
262 | INSTALL="$ac_cv_path_install" | |
263 | else | |
264 | # As a last resort, use the slow shell script. We don't cache a | |
265 | # path for INSTALL within a source directory, because that will | |
266 | # break other packages using the cache if that directory is | |
267 | # removed, or if the path is relative. | |
268 | INSTALL="$ac_install_sh" | |
269 | fi | |
270 | fi | |
271 | dnl We do special magic for INSTALL instead of AC_SUBST, to get | |
272 | dnl relative paths right. | |
273 | AC_MSG_RESULT($INSTALL) | |
5643c767 | 274 | AC_SUBST(INSTALL)dnl |
76143254 JL |
275 | |
276 | # Use test -z because SunOS4 sh mishandles braces in ${var-val}. | |
277 | # It thinks the first close brace ends the variable substitution. | |
278 | test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' | |
279 | AC_SUBST(INSTALL_PROGRAM)dnl | |
280 | ||
281 | test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' | |
282 | AC_SUBST(INSTALL_DATA)dnl | |
283 | ]) | |
ab87f8c8 JL |
284 | |
285 | #serial 1 | |
286 | dnl This test replaces the one in autoconf. | |
287 | dnl Currently this macro should have the same name as the autoconf macro | |
288 | dnl because gettext's gettext.m4 (distributed in the automake package) | |
289 | dnl still uses it. Otherwise, the use in gettext.m4 makes autoheader | |
290 | dnl give these diagnostics: | |
291 | dnl configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX | |
292 | dnl configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX | |
293 | ||
294 | undefine([AC_ISC_POSIX]) | |
295 | AC_DEFUN(AC_ISC_POSIX, | |
296 | [ | |
297 | dnl This test replaces the obsolescent AC_ISC_POSIX kludge. | |
298 | AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"]) | |
299 | ] | |
300 | ) | |
301 | ||
00036f5c PT |
302 | |
303 | dnl GCC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND [, PATH]]) | |
304 | dnl like AC_PATH_PROG but use other cache variables | |
305 | AC_DEFUN(GCC_PATH_PROG, | |
306 | [# Extract the first word of "$2", so it can be a program name with args. | |
307 | set dummy $2; ac_word=[$]2 | |
308 | AC_MSG_CHECKING([for $ac_word]) | |
309 | AC_CACHE_VAL(gcc_cv_path_$1, | |
310 | [case "[$]$1" in | |
311 | /*) | |
312 | gcc_cv_path_$1="[$]$1" # Let the user override the test with a path. | |
313 | ;; | |
314 | ?:/*) | |
315 | gcc_cv_path_$1="[$]$1" # Let the user override the test with a dos path. | |
316 | ;; | |
317 | *) | |
318 | IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" | |
319 | dnl $ac_dummy forces splitting on constant user-supplied paths. | |
320 | dnl POSIX.2 word splitting is done only on the output of word expansions, | |
321 | dnl not every word. This closes a longstanding sh security hole. | |
322 | ac_dummy="ifelse([$4], , $PATH, [$4])" | |
323 | for ac_dir in $ac_dummy; do | |
324 | test -z "$ac_dir" && ac_dir=. | |
325 | if test -f $ac_dir/$ac_word; then | |
326 | gcc_cv_path_$1="$ac_dir/$ac_word" | |
327 | break | |
328 | fi | |
329 | done | |
330 | IFS="$ac_save_ifs" | |
331 | dnl If no 3rd arg is given, leave the cache variable unset, | |
332 | dnl so GCC_PATH_PROGS will keep looking. | |
333 | ifelse([$3], , , [ test -z "[$]gcc_cv_path_$1" && gcc_cv_path_$1="$3" | |
334 | ])dnl | |
335 | ;; | |
336 | esac])dnl | |
337 | $1="$gcc_cv_path_$1" | |
338 | if test -n "[$]$1"; then | |
339 | AC_MSG_RESULT([$]$1) | |
340 | else | |
341 | AC_MSG_RESULT(no) | |
342 | fi | |
343 | AC_SUBST($1)dnl | |
344 | ]) | |
345 | ||
346 | ||
347 | ||
ab87f8c8 JL |
348 | # Macro to add for using GNU gettext. |
349 | # Ulrich Drepper <drepper@cygnus.com>, 1995. | |
350 | # | |
351 | # This file can be copied and used freely without restrictions. It can | |
352 | # be used in projects which are not available under the GNU Public License | |
353 | # but which still want to provide support for the GNU gettext functionality. | |
354 | # Please note that the actual code is *not* freely available. | |
355 | ||
356 | # serial 5 | |
357 | ||
358 | AC_DEFUN(AM_WITH_NLS, | |
359 | [AC_MSG_CHECKING([whether NLS is requested]) | |
360 | dnl Default is enabled NLS | |
361 | AC_ARG_ENABLE(nls, | |
362 | [ --disable-nls do not use Native Language Support], | |
363 | USE_NLS=$enableval, USE_NLS=yes) | |
364 | AC_MSG_RESULT($USE_NLS) | |
365 | AC_SUBST(USE_NLS) | |
366 | ||
367 | USE_INCLUDED_LIBINTL=no | |
368 | ||
369 | dnl If we use NLS figure out what method | |
370 | if test "$USE_NLS" = "yes"; then | |
371 | AC_DEFINE(ENABLE_NLS) | |
372 | AC_MSG_CHECKING([whether included gettext is requested]) | |
373 | AC_ARG_WITH(included-gettext, | |
374 | [ --with-included-gettext use the GNU gettext library included here], | |
375 | nls_cv_force_use_gnu_gettext=$withval, | |
bfa29b63 | 376 | nls_cv_force_use_gnu_gettext=no) |
ab87f8c8 JL |
377 | AC_MSG_RESULT($nls_cv_force_use_gnu_gettext) |
378 | ||
379 | nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" | |
380 | if test "$nls_cv_force_use_gnu_gettext" != "yes"; then | |
381 | dnl User does not insist on using GNU NLS library. Figure out what | |
382 | dnl to use. If gettext or catgets are available (in this order) we | |
383 | dnl use this. Else we have to fall back to GNU NLS library. | |
384 | dnl catgets is only used if permitted by option --with-catgets. | |
385 | nls_cv_header_intl= | |
386 | nls_cv_header_libgt= | |
387 | CATOBJEXT=NONE | |
388 | ||
389 | AC_CHECK_HEADER(libintl.h, | |
390 | [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc, | |
391 | [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")], | |
392 | gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)]) | |
393 | ||
394 | if test "$gt_cv_func_gettext_libc" != "yes"; then | |
395 | AC_CHECK_LIB(intl, bindtextdomain, | |
396 | [AC_CACHE_CHECK([for gettext in libintl], | |
397 | gt_cv_func_gettext_libintl, | |
398 | [AC_CHECK_LIB(intl, gettext, | |
399 | gt_cv_func_gettext_libintl=yes, | |
400 | gt_cv_func_gettext_libintl=no)], | |
401 | gt_cv_func_gettext_libintl=no)]) | |
402 | fi | |
403 | ||
380a627a PT |
404 | if test "$gt_cv_func_gettext_libintl" = "yes"; then |
405 | LIBS="-lintl $LIBS" | |
406 | fi | |
407 | ||
ab87f8c8 JL |
408 | if test "$gt_cv_func_gettext_libc" = "yes" \ |
409 | || test "$gt_cv_func_gettext_libintl" = "yes"; then | |
410 | AC_DEFINE(HAVE_GETTEXT) | |
00036f5c | 411 | GCC_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, |
ab87f8c8 JL |
412 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl |
413 | if test "$MSGFMT" != "no"; then | |
414 | AC_CHECK_FUNCS(dcgettext) | |
00036f5c PT |
415 | GCC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) |
416 | GCC_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, | |
ab87f8c8 JL |
417 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) |
418 | AC_TRY_LINK(, [extern int _nl_msg_cat_cntr; | |
419 | return _nl_msg_cat_cntr], | |
420 | [CATOBJEXT=.gmo | |
421 | DATADIRNAME=share], | |
422 | [CATOBJEXT=.mo | |
423 | DATADIRNAME=lib]) | |
424 | INSTOBJEXT=.mo | |
9fdf713f PT |
425 | else |
426 | create_catalogs="no" | |
ab87f8c8 JL |
427 | fi |
428 | fi | |
429 | ]) | |
430 | ||
431 | if test "$CATOBJEXT" = "NONE"; then | |
432 | AC_MSG_CHECKING([whether catgets can be used]) | |
433 | AC_ARG_WITH(catgets, | |
434 | [ --with-catgets use catgets functions if available], | |
435 | nls_cv_use_catgets=$withval, nls_cv_use_catgets=no) | |
436 | AC_MSG_RESULT($nls_cv_use_catgets) | |
437 | ||
438 | if test "$nls_cv_use_catgets" = "yes"; then | |
439 | dnl No gettext in C library. Try catgets next. | |
440 | AC_CHECK_LIB(i, main) | |
441 | AC_CHECK_FUNC(catgets, | |
442 | [AC_DEFINE(HAVE_CATGETS) | |
443 | INTLOBJS="\$(CATOBJS)" | |
00036f5c | 444 | GCC_PATH_PROG(GENCAT, gencat, no)dnl |
ab87f8c8 | 445 | if test "$GENCAT" != "no"; then |
00036f5c | 446 | GCC_PATH_PROG(GMSGFMT, gmsgfmt, no) |
ab87f8c8 | 447 | if test "$GMSGFMT" = "no"; then |
00036f5c | 448 | GCC_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt, |
cab10d56 PT |
449 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt) |
450 | if test "$GMSGFMT" = "msgfmt"; then | |
17297c41 PT |
451 | create_catalogs="no" |
452 | fi | |
ab87f8c8 | 453 | fi |
00036f5c | 454 | GCC_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, |
ab87f8c8 JL |
455 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) |
456 | USE_INCLUDED_LIBINTL=yes | |
457 | CATOBJEXT=.cat | |
458 | INSTOBJEXT=.cat | |
459 | DATADIRNAME=lib | |
460 | INTLDEPS='$(top_builddir)/intl/libintl.a' | |
461 | INTLLIBS=$INTLDEPS | |
462 | LIBS=`echo $LIBS | sed -e 's/-lintl//'` | |
463 | nls_cv_header_intl=intl/libintl.h | |
464 | nls_cv_header_libgt=intl/libgettext.h | |
465 | fi]) | |
466 | fi | |
467 | fi | |
468 | ||
469 | if test "$CATOBJEXT" = "NONE"; then | |
470 | dnl Neither gettext nor catgets in included in the C library. | |
471 | dnl Fall back on GNU gettext library. | |
472 | nls_cv_use_gnu_gettext=yes | |
473 | fi | |
474 | fi | |
475 | ||
476 | if test "$nls_cv_use_gnu_gettext" = "yes"; then | |
477 | dnl Mark actions used to generate GNU NLS library. | |
478 | INTLOBJS="\$(GETTOBJS)" | |
00036f5c | 479 | GCC_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, |
cab10d56 | 480 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt) |
00036f5c | 481 | GCC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) |
17297c41 PT |
482 | dnl If we didn't find either msgfmt or gmsgfmt, don't try to |
483 | dnl create a catalog. | |
cab10d56 | 484 | if test "$MSGFMT" = "msgfmt" && test "$GMSGFMT" = "msgfmt"; then |
17297c41 | 485 | create_catalogs="no" |
17297c41 | 486 | fi |
00036f5c | 487 | GCC_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, |
ab87f8c8 JL |
488 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) |
489 | AC_SUBST(MSGFMT) | |
490 | USE_INCLUDED_LIBINTL=yes | |
491 | CATOBJEXT=.gmo | |
492 | INSTOBJEXT=.mo | |
493 | DATADIRNAME=share | |
494 | INTLDEPS='$(top_builddir)/intl/libintl.a' | |
495 | INTLLIBS=$INTLDEPS | |
496 | LIBS=`echo $LIBS | sed -e 's/-lintl//'` | |
497 | nls_cv_header_intl=intl/libintl.h | |
498 | nls_cv_header_libgt=intl/libgettext.h | |
499 | fi | |
500 | ||
501 | dnl Test whether we really found GNU xgettext. | |
502 | if test "$XGETTEXT" != ":"; then | |
503 | dnl If it is no GNU xgettext we define it as : so that the | |
504 | dnl Makefiles still can work. | |
505 | if $XGETTEXT --omit-header /dev/null 2> /dev/null; then | |
506 | : ; | |
507 | else | |
508 | AC_MSG_RESULT( | |
509 | [found xgettext program is not GNU xgettext; ignore it]) | |
510 | XGETTEXT=":" | |
511 | fi | |
512 | fi | |
513 | ||
17297c41 PT |
514 | |
515 | ||
ab87f8c8 JL |
516 | # We need to process the po/ directory. |
517 | POSUB=po | |
518 | else | |
519 | DATADIRNAME=share | |
520 | nls_cv_header_intl=intl/libintl.h | |
521 | nls_cv_header_libgt=intl/libgettext.h | |
522 | fi | |
523 | AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl) | |
524 | AC_OUTPUT_COMMANDS( | |
525 | [case "$CONFIG_FILES" in *po/Makefile.in*) | |
526 | sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile | |
527 | esac]) | |
528 | ||
529 | ||
530 | # If this is used in GNU gettext we have to set USE_NLS to `yes' | |
531 | # because some of the sources are only built for this goal. | |
532 | if test "$PACKAGE" = gettext; then | |
533 | USE_NLS=yes | |
534 | USE_INCLUDED_LIBINTL=yes | |
535 | fi | |
536 | ||
537 | dnl These rules are solely for the distribution goal. While doing this | |
538 | dnl we only have to keep exactly one list of the available catalogs | |
539 | dnl in configure.in. | |
540 | for lang in $ALL_LINGUAS; do | |
541 | GMOFILES="$GMOFILES $lang.gmo" | |
542 | POFILES="$POFILES $lang.po" | |
543 | done | |
544 | ||
545 | dnl Make all variables we use known to autoconf. | |
546 | AC_SUBST(USE_INCLUDED_LIBINTL) | |
547 | AC_SUBST(CATALOGS) | |
548 | AC_SUBST(CATOBJEXT) | |
549 | AC_SUBST(DATADIRNAME) | |
550 | AC_SUBST(GMOFILES) | |
551 | AC_SUBST(INSTOBJEXT) | |
552 | AC_SUBST(INTLDEPS) | |
553 | AC_SUBST(INTLLIBS) | |
554 | AC_SUBST(INTLOBJS) | |
555 | AC_SUBST(POFILES) | |
556 | AC_SUBST(POSUB) | |
557 | ]) | |
558 | ||
559 | AC_DEFUN(AM_GNU_GETTEXT, | |
560 | [AC_REQUIRE([AC_PROG_MAKE_SET])dnl | |
561 | AC_REQUIRE([AC_PROG_CC])dnl | |
562 | AC_REQUIRE([AC_PROG_RANLIB])dnl | |
563 | AC_REQUIRE([AC_ISC_POSIX])dnl | |
564 | AC_REQUIRE([AC_HEADER_STDC])dnl | |
565 | AC_REQUIRE([AC_C_CONST])dnl | |
566 | AC_REQUIRE([AC_C_INLINE])dnl | |
567 | AC_REQUIRE([AC_TYPE_OFF_T])dnl | |
568 | AC_REQUIRE([AC_TYPE_SIZE_T])dnl | |
ab87f8c8 JL |
569 | |
570 | AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \ | |
571 | unistd.h sys/param.h]) | |
572 | AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \ | |
573 | strdup __argz_count __argz_stringify __argz_next]) | |
574 | ||
575 | if test "${ac_cv_func_stpcpy+set}" != "set"; then | |
576 | AC_CHECK_FUNCS(stpcpy) | |
577 | fi | |
578 | if test "${ac_cv_func_stpcpy}" = "yes"; then | |
579 | AC_DEFINE(HAVE_STPCPY) | |
580 | fi | |
581 | ||
582 | AM_LC_MESSAGES | |
583 | AM_WITH_NLS | |
584 | ||
4d0230e1 | 585 | if test "x$create_catalogs" = "xno"; then |
9fdf713f PT |
586 | AC_MSG_WARN([No program for building catalogs found -> building disabled]) |
587 | fi | |
588 | ||
17297c41 | 589 | if test "x$CATOBJEXT" != "x" && test "x$create_catalogs" != "xno" ; then |
ab87f8c8 JL |
590 | if test "x$ALL_LINGUAS" = "x"; then |
591 | LINGUAS= | |
592 | else | |
593 | AC_MSG_CHECKING(for catalogs to be installed) | |
47f01856 PT |
594 | if test "x$LINGUAS" = "x"; then |
595 | LINGUAS=$ALL_LINGUAS | |
596 | else | |
597 | NEW_LINGUAS= | |
598 | for lang in $ALL_LINGUAS; do | |
599 | case " $LINGUAS " in | |
600 | *" $lang "*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;; | |
601 | esac | |
602 | done | |
603 | LINGUAS=$NEW_LINGUAS | |
604 | fi | |
ab87f8c8 JL |
605 | AC_MSG_RESULT($LINGUAS) |
606 | fi | |
607 | ||
608 | dnl Construct list of names of catalog files to be constructed. | |
609 | if test -n "$LINGUAS"; then | |
610 | for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done | |
611 | fi | |
612 | fi | |
613 | ||
614 | dnl The reference to <locale.h> in the installed <libintl.h> file | |
615 | dnl must be resolved because we cannot expect the users of this | |
616 | dnl to define HAVE_LOCALE_H. | |
617 | if test $ac_cv_header_locale_h = yes; then | |
618 | INCLUDE_LOCALE_H="#include <locale.h>" | |
619 | else | |
620 | INCLUDE_LOCALE_H="\ | |
621 | /* The system does not provide the header <locale.h>. Take care yourself. */" | |
622 | fi | |
623 | AC_SUBST(INCLUDE_LOCALE_H) | |
624 | ||
625 | dnl Determine which catalog format we have (if any is needed) | |
626 | dnl For now we know about two different formats: | |
627 | dnl Linux libc-5 and the normal X/Open format | |
628 | test -d intl || mkdir intl | |
629 | if test "$CATOBJEXT" = ".cat"; then | |
630 | AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen) | |
631 | ||
632 | dnl Transform the SED scripts while copying because some dumb SEDs | |
633 | dnl cannot handle comments. | |
634 | sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed | |
635 | fi | |
636 | dnl po2tbl.sed is always needed. | |
637 | sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \ | |
638 | $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed | |
639 | ||
640 | dnl In the intl/Makefile.in we have a special dependency which makes | |
641 | dnl only sense for gettext. We comment this out for non-gettext | |
642 | dnl packages. | |
643 | if test "$PACKAGE" = "gettext"; then | |
644 | GT_NO="#NO#" | |
645 | GT_YES= | |
646 | else | |
647 | GT_NO= | |
648 | GT_YES="#YES#" | |
649 | fi | |
650 | AC_SUBST(GT_NO) | |
651 | AC_SUBST(GT_YES) | |
652 | ||
653 | dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly | |
654 | dnl find the mkinstalldirs script in another subdir but ($top_srcdir). | |
655 | dnl Try to locate is. | |
656 | MKINSTALLDIRS= | |
657 | if test -n "$ac_aux_dir"; then | |
658 | MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" | |
659 | fi | |
660 | if test -z "$MKINSTALLDIRS"; then | |
661 | MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs" | |
662 | fi | |
663 | AC_SUBST(MKINSTALLDIRS) | |
664 | ||
665 | dnl *** For now the libtool support in intl/Makefile is not for real. | |
666 | l= | |
667 | AC_SUBST(l) | |
668 | ||
669 | dnl Generate list of files to be processed by xgettext which will | |
670 | dnl be included in po/Makefile. | |
671 | test -d po || mkdir po | |
672 | if test "x$srcdir" != "x."; then | |
673 | if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then | |
674 | posrcprefix="$srcdir/" | |
675 | else | |
676 | posrcprefix="../$srcdir/" | |
677 | fi | |
678 | else | |
679 | posrcprefix="../" | |
680 | fi | |
681 | rm -f po/POTFILES | |
682 | sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \ | |
683 | < $srcdir/po/POTFILES.in > po/POTFILES | |
684 | ]) | |
685 | ||
686 | # Check whether LC_MESSAGES is available in <locale.h>. | |
687 | # Ulrich Drepper <drepper@cygnus.com>, 1995. | |
688 | # | |
689 | # This file can be copied and used freely without restrictions. It can | |
690 | # be used in projects which are not available under the GNU Public License | |
691 | # but which still want to provide support for the GNU gettext functionality. | |
692 | # Please note that the actual code is *not* freely available. | |
693 | ||
694 | # serial 1 | |
695 | ||
696 | AC_DEFUN(AM_LC_MESSAGES, | |
697 | [if test $ac_cv_header_locale_h = yes; then | |
698 | AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES, | |
699 | [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES], | |
700 | am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)]) | |
701 | if test $am_cv_val_LC_MESSAGES = yes; then | |
702 | AC_DEFINE(HAVE_LC_MESSAGES) | |
703 | fi | |
704 | fi]) | |
705 | ||
706 | # Search path for a program which passes the given test. | |
707 | # Ulrich Drepper <drepper@cygnus.com>, 1996. | |
708 | # | |
709 | # This file can be copied and used freely without restrictions. It can | |
710 | # be used in projects which are not available under the GNU Public License | |
711 | # but which still want to provide support for the GNU gettext functionality. | |
712 | # Please note that the actual code is *not* freely available. | |
713 | ||
714 | # serial 1 | |
715 | ||
00036f5c | 716 | dnl GCC_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, |
ab87f8c8 | 717 | dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) |
00036f5c | 718 | AC_DEFUN(GCC_PATH_PROG_WITH_TEST, |
ab87f8c8 JL |
719 | [# Extract the first word of "$2", so it can be a program name with args. |
720 | set dummy $2; ac_word=[$]2 | |
721 | AC_MSG_CHECKING([for $ac_word]) | |
00036f5c | 722 | AC_CACHE_VAL(gcc_cv_path_$1, |
ab87f8c8 JL |
723 | [case "[$]$1" in |
724 | /*) | |
00036f5c | 725 | gcc_cv_path_$1="[$]$1" # Let the user override the test with a path. |
ab87f8c8 JL |
726 | ;; |
727 | *) | |
728 | IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" | |
729 | for ac_dir in ifelse([$5], , $PATH, [$5]); do | |
730 | test -z "$ac_dir" && ac_dir=. | |
731 | if test -f $ac_dir/$ac_word; then | |
732 | if [$3]; then | |
00036f5c | 733 | gcc_cv_path_$1="$ac_dir/$ac_word" |
ab87f8c8 JL |
734 | break |
735 | fi | |
736 | fi | |
737 | done | |
738 | IFS="$ac_save_ifs" | |
739 | dnl If no 4th arg is given, leave the cache variable unset, | |
00036f5c PT |
740 | dnl so GCC_PATH_PROGS will keep looking. |
741 | ifelse([$4], , , [ test -z "[$]gcc_cv_path_$1" && gcc_cv_path_$1="$4" | |
ab87f8c8 JL |
742 | ])dnl |
743 | ;; | |
744 | esac])dnl | |
00036f5c | 745 | $1="$gcc_cv_path_$1" |
ab87f8c8 JL |
746 | if test -n "[$]$1"; then |
747 | AC_MSG_RESULT([$]$1) | |
748 | else | |
749 | AC_MSG_RESULT(no) | |
750 | fi | |
751 | AC_SUBST($1)dnl | |
752 | ]) | |
4acab94b | 753 | |
4c1331d6 DA |
754 | # Check whether mmap can map an arbitrary page from /dev/zero or with |
755 | # MAP_ANONYMOUS, without MAP_FIXED. | |
4acab94b | 756 | AC_DEFUN([AC_FUNC_MMAP_ANYWHERE], |
825b6926 ZW |
757 | [AC_CHECK_FUNCS(getpagesize) |
758 | # The test program for the next two tests is the same except for one | |
759 | # set of ifdefs. | |
760 | changequote({{{,}}})dnl | |
761 | {{{cat >ct-mmap.inc <<'EOF' | |
4acab94b | 762 | #include <sys/types.h> |
4acab94b | 763 | #include <sys/mman.h> |
825b6926 ZW |
764 | #include <fcntl.h> |
765 | #include <signal.h> | |
766 | #include <setjmp.h> | |
767 | #include <stdio.h> | |
4acab94b | 768 | |
4c1331d6 DA |
769 | #if !defined (MAP_ANONYMOUS) && defined (MAP_ANON) |
770 | # define MAP_ANONYMOUS MAP_ANON | |
771 | #endif | |
772 | ||
4acab94b AO |
773 | /* This mess was copied from the GNU getpagesize.h. */ |
774 | #ifndef HAVE_GETPAGESIZE | |
775 | # ifdef HAVE_UNISTD_H | |
776 | # include <unistd.h> | |
777 | # endif | |
778 | ||
779 | /* Assume that all systems that can run configure have sys/param.h. */ | |
780 | # ifndef HAVE_SYS_PARAM_H | |
781 | # define HAVE_SYS_PARAM_H 1 | |
782 | # endif | |
783 | ||
784 | # ifdef _SC_PAGESIZE | |
785 | # define getpagesize() sysconf(_SC_PAGESIZE) | |
786 | # else /* no _SC_PAGESIZE */ | |
787 | # ifdef HAVE_SYS_PARAM_H | |
788 | # include <sys/param.h> | |
789 | # ifdef EXEC_PAGESIZE | |
790 | # define getpagesize() EXEC_PAGESIZE | |
791 | # else /* no EXEC_PAGESIZE */ | |
792 | # ifdef NBPG | |
793 | # define getpagesize() NBPG * CLSIZE | |
794 | # ifndef CLSIZE | |
795 | # define CLSIZE 1 | |
796 | # endif /* no CLSIZE */ | |
797 | # else /* no NBPG */ | |
798 | # ifdef NBPC | |
799 | # define getpagesize() NBPC | |
800 | # else /* no NBPC */ | |
801 | # ifdef PAGESIZE | |
802 | # define getpagesize() PAGESIZE | |
803 | # endif /* PAGESIZE */ | |
804 | # endif /* no NBPC */ | |
805 | # endif /* no NBPG */ | |
806 | # endif /* no EXEC_PAGESIZE */ | |
807 | # else /* no HAVE_SYS_PARAM_H */ | |
808 | # define getpagesize() 8192 /* punt totally */ | |
809 | # endif /* no HAVE_SYS_PARAM_H */ | |
810 | # endif /* no _SC_PAGESIZE */ | |
811 | ||
812 | #endif /* no HAVE_GETPAGESIZE */ | |
813 | ||
825b6926 ZW |
814 | #ifndef MAP_FAILED |
815 | # define MAP_FAILED -1 | |
4c1331d6 | 816 | #endif |
4acab94b | 817 | |
825b6926 ZW |
818 | #undef perror_exit |
819 | #define perror_exit(str, val) \ | |
820 | do { perror(str); exit(val); } while (0) | |
821 | ||
822 | /* Some versions of cygwin mmap require that munmap is called with the | |
823 | same parameters as mmap. GCC expects that this is not the case. | |
824 | Test for various forms of this problem. Warning - icky signal games. */ | |
825 | ||
826 | static sigset_t unblock_sigsegv; | |
827 | static jmp_buf r; | |
828 | static size_t pg; | |
829 | static int devzero; | |
830 | ||
831 | static char * | |
832 | anonmap (size) | |
833 | size_t size; | |
834 | { | |
835 | #ifdef USE_MAP_ANON | |
836 | return (char *) mmap (0, size, PROT_READ|PROT_WRITE, | |
837 | MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); | |
4c1331d6 | 838 | #else |
825b6926 ZW |
839 | return (char *) mmap (0, size, PROT_READ|PROT_WRITE, |
840 | MAP_PRIVATE, devzero, 0); | |
4c1331d6 | 841 | #endif |
825b6926 ZW |
842 | } |
843 | ||
844 | static void | |
845 | sigsegv (unused) | |
846 | int unused; | |
847 | { | |
848 | sigprocmask (SIG_UNBLOCK, &unblock_sigsegv, 0); | |
849 | longjmp (r, 1); | |
850 | } | |
851 | ||
852 | /* Basic functionality test. */ | |
853 | void | |
854 | test_0 () | |
855 | { | |
856 | char *x = anonmap (pg); | |
857 | if (x == (char *) MAP_FAILED) | |
858 | perror_exit("test 0 mmap", 2); | |
4acab94b AO |
859 | |
860 | *(int *)x += 1; | |
861 | ||
862 | if (munmap(x, pg) < 0) | |
825b6926 ZW |
863 | perror_exit("test 0 munmap", 3); |
864 | } | |
865 | ||
866 | /* 1. If we map a 2-page region and unmap its second page, the first page | |
867 | must remain. */ | |
868 | static void | |
869 | test_1 () | |
870 | { | |
871 | char *x = anonmap (pg * 2); | |
872 | if (x == (char *)MAP_FAILED) | |
873 | perror_exit ("test 1 mmap", 4); | |
874 | ||
875 | signal (SIGSEGV, sigsegv); | |
876 | if (setjmp (r)) | |
877 | perror_exit ("test 1 fault", 5); | |
878 | ||
879 | x[0] = 1; | |
880 | x[pg] = 1; | |
881 | ||
882 | if (munmap (x + pg, pg) < 0) | |
883 | perror_exit ("test 1 munmap 1", 6); | |
884 | x[0] = 2; | |
885 | ||
886 | if (setjmp (r) == 0) | |
887 | { | |
888 | x[pg] = 1; | |
889 | perror_exit ("test 1 no fault", 7); | |
890 | } | |
891 | if (munmap (x, pg) < 0) | |
892 | perror_exit ("test 1 munmap 2", 8); | |
893 | } | |
894 | ||
895 | /* 2. If we map a 2-page region and unmap its first page, the second | |
896 | page must remain. */ | |
897 | static void | |
898 | test_2 () | |
899 | { | |
900 | char *x = anonmap (pg * 2); | |
901 | if (x == (char *)MAP_FAILED) | |
902 | perror_exit ("test 2 mmap", 9); | |
903 | ||
904 | signal (SIGSEGV, sigsegv); | |
905 | if (setjmp (r)) | |
906 | perror_exit ("test 2 fault", 10); | |
907 | ||
908 | x[0] = 1; | |
909 | x[pg] = 1; | |
910 | ||
911 | if (munmap (x, pg) < 0) | |
912 | perror_exit ("test 2 munmap 1", 11); | |
913 | ||
914 | x[pg] = 2; | |
915 | ||
916 | if (setjmp (r) == 0) | |
917 | { | |
918 | x[0] = 1; | |
919 | perror_exit ("test 2 no fault", 12); | |
920 | } | |
921 | ||
922 | if (munmap (x+pg, pg) < 0) | |
923 | perror_exit ("test 2 munmap 2", 13); | |
924 | } | |
925 | ||
926 | /* 3. If we map two adjacent 1-page regions and unmap them both with | |
927 | one munmap, both must go away. | |
928 | ||
929 | Getting two adjacent 1-page regions with two mmap calls is slightly | |
930 | tricky. All OS's tested skip over already-allocated blocks; therefore | |
931 | we have been careful to unmap all allocated regions in previous tests. | |
932 | HP/UX allocates pages backward in memory. No OS has yet been observed | |
933 | to be so perverse as to leave unmapped space between consecutive calls | |
934 | to mmap. */ | |
935 | ||
936 | static void | |
937 | test_3 () | |
938 | { | |
939 | char *x, *y, *z; | |
940 | ||
941 | x = anonmap (pg); | |
942 | if (x == (char *)MAP_FAILED) | |
943 | perror_exit ("test 3 mmap 1", 14); | |
944 | y = anonmap (pg); | |
945 | if (y == (char *)MAP_FAILED) | |
946 | perror_exit ("test 3 mmap 2", 15); | |
947 | ||
948 | if (y != x + pg) | |
949 | { | |
950 | if (y == x - pg) | |
951 | z = y, y = x, x = z; | |
952 | else | |
953 | { | |
954 | fprintf (stderr, "test 3 nonconsecutive pages - %lx, %lx\n", | |
955 | (unsigned long)x, (unsigned long)y); | |
956 | exit (16); | |
957 | } | |
958 | } | |
959 | ||
960 | signal (SIGSEGV, sigsegv); | |
961 | if (setjmp (r)) | |
962 | perror_exit ("test 3 fault", 17); | |
963 | ||
964 | x[0] = 1; | |
965 | y[0] = 1; | |
966 | ||
967 | if (munmap (x, pg*2) < 0) | |
968 | perror_exit ("test 3 munmap", 18); | |
969 | ||
970 | if (setjmp (r) == 0) | |
971 | { | |
972 | x[0] = 1; | |
973 | perror_exit ("test 3 no fault 1", 19); | |
974 | } | |
975 | ||
976 | signal (SIGSEGV, sigsegv); | |
977 | if (setjmp (r) == 0) | |
978 | { | |
979 | y[0] = 1; | |
980 | perror_exit ("test 3 no fault 2", 20); | |
981 | } | |
982 | } | |
983 | ||
984 | int | |
985 | main () | |
986 | { | |
987 | sigemptyset (&unblock_sigsegv); | |
988 | sigaddset (&unblock_sigsegv, SIGSEGV); | |
989 | pg = getpagesize (); | |
990 | #ifndef USE_MAP_ANON | |
991 | devzero = open ("/dev/zero", O_RDWR); | |
992 | if (devzero < 0) | |
993 | perror_exit ("open /dev/zero", 1); | |
994 | #endif | |
995 | ||
996 | test_0(); | |
997 | test_1(); | |
998 | test_2(); | |
999 | test_3(); | |
4acab94b AO |
1000 | |
1001 | exit(0); | |
825b6926 ZW |
1002 | } |
1003 | EOF}}} | |
1004 | changequote([,])dnl | |
1005 | ||
1006 | AC_CACHE_CHECK(for working mmap from /dev/zero, | |
1007 | ac_cv_func_mmap_dev_zero, | |
1008 | [AC_TRY_RUN( | |
1009 | [#include "ct-mmap.inc"], | |
1010 | ac_cv_func_mmap_dev_zero=yes, | |
1011 | [if test $? -lt 4 | |
1012 | then ac_cv_func_mmap_dev_zero=no | |
1013 | else ac_cv_func_mmap_dev_zero=buggy | |
1014 | fi], | |
1015 | # If this is not cygwin, and /dev/zero is a character device, it's probably | |
1016 | # safe to assume it works. | |
1017 | [case "$host_os" in | |
1018 | cygwin* | win32 | pe | mingw* ) ac_cv_func_mmap_dev_zero=buggy ;; | |
1019 | * ) if test -c /dev/zero | |
1020 | then ac_cv_func_mmap_dev_zero=yes | |
1021 | else ac_cv_func_mmap_dev_zero=no | |
1022 | fi ;; | |
1023 | esac]) | |
1024 | ]) | |
1025 | if test $ac_cv_func_mmap_dev_zero = yes; then | |
1026 | AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1, | |
1027 | [Define if mmap can get us zeroed pages from /dev/zero.]) | |
1028 | fi | |
1029 | ||
1030 | AC_CACHE_CHECK([for working mmap with MAP_ANON(YMOUS)], | |
1031 | ac_cv_func_mmap_anon, | |
1032 | [AC_TRY_RUN( | |
1033 | [#define USE_MAP_ANON | |
1034 | #include "ct-mmap.inc"], | |
1035 | ac_cv_func_mmap_anon=yes, | |
1036 | [if test $? -lt 4 | |
1037 | then ac_cv_func_mmap_anon=no | |
1038 | else ac_cv_func_mmap_anon=buggy | |
1039 | fi], | |
1040 | # Unlike /dev/zero, it is not safe to assume MAP_ANON(YMOUS) works | |
1041 | # just because it's there. Some SCO Un*xen define it but don't implement it. | |
1042 | ac_cv_func_mmap_anon=no) | |
1043 | ]) | |
1044 | if test $ac_cv_func_mmap_anon = yes; then | |
1045 | AC_DEFINE(HAVE_MMAP_ANON, 1, | |
1046 | [Define if mmap can get us zeroed pages using MAP_ANON(YMOUS).]) | |
4acab94b | 1047 | fi |
825b6926 | 1048 | rm -f ct-mmap.inc |
4acab94b | 1049 | ]) |
56f02b88 ZW |
1050 | |
1051 | # Check whether mmap can map a plain file, without MAP_FIXED. | |
1052 | AC_DEFUN([AC_FUNC_MMAP_FILE], | |
825b6926 | 1053 | [AC_CACHE_CHECK(for working mmap of a file, ac_cv_func_mmap_file, |
56f02b88 ZW |
1054 | [# Create a file one thousand bytes long. |
1055 | for i in 1 2 3 4 5 6 7 8 9 0 | |
1056 | do for j in 1 2 3 4 5 6 7 8 9 0 | |
1057 | do echo $i $j xxxxx | |
1058 | done | |
1059 | done > conftestdata$$ | |
1060 | ||
1061 | AC_TRY_RUN([ | |
1062 | /* Test by Zack Weinberg. Modified from MMAP_ANYWHERE test by | |
1063 | Richard Henderson and Alexandre Oliva. | |
1064 | Check whether read-only mmap of a plain file works. */ | |
1065 | #include <sys/types.h> | |
1066 | #include <sys/stat.h> | |
1067 | #include <fcntl.h> | |
1068 | #include <sys/mman.h> | |
1069 | ||
1070 | int main() | |
1071 | { | |
1072 | char *x; | |
1073 | int fd; | |
1074 | struct stat st; | |
1075 | ||
1076 | fd = open("conftestdata$$", O_RDONLY); | |
1077 | if (fd < 0) | |
1078 | exit(1); | |
1079 | ||
1080 | if (fstat (fd, &st)) | |
1081 | exit(2); | |
1082 | ||
1083 | x = (char*)mmap(0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); | |
1084 | if (x == (char *) -1) | |
1085 | exit(3); | |
1086 | ||
1087 | if (x[0] != '1' || x[1] != ' ' || x[2] != '1' || x[3] != ' ') | |
1088 | exit(4); | |
1089 | ||
1090 | if (munmap(x, st.st_size) < 0) | |
1091 | exit(5); | |
1092 | ||
1093 | exit(0); | |
1094 | }], ac_cv_func_mmap_file=yes, ac_cv_func_mmap_file=no, | |
1095 | ac_cv_func_mmap_file=no)]) | |
1096 | if test $ac_cv_func_mmap_file = yes; then | |
1097 | AC_DEFINE(HAVE_MMAP_FILE, 1, | |
1098 | [Define if read-only mmap of a plain file works.]) | |
1099 | fi | |
1100 | ]) | |
09fa0705 ZW |
1101 | |
1102 | dnl Locate a program and check that its version is acceptable. | |
1103 | dnl AC_PROG_CHECK_VER(var, name, version-switch, | |
1104 | dnl version-extract-regexp, version-glob) | |
1105 | AC_DEFUN(gcc_AC_CHECK_PROG_VER, | |
1106 | [AC_CHECK_PROG([$1], [$2], [$2]) | |
1107 | if test -n "[$]$1"; then | |
1108 | # Found it, now check the version. | |
1109 | AC_CACHE_CHECK(for modern $2, gcc_cv_prog_$2_modern, | |
1110 | [changequote(<<,>>)dnl | |
1111 | ac_prog_version=`<<$>>$1 $3 2>&1 | | |
1112 | sed -n 's/^.*patsubst(<<$4>>,/,\/).*$/\1/p'` | |
1113 | echo "configure:__oline__: version of $2 is $ac_prog_version" >&AC_FD_CC | |
1114 | case $ac_prog_version in | |
1115 | '') gcc_cv_prog_$2_modern=no;; | |
1116 | <<$5>>) | |
1117 | gcc_cv_prog_$2_modern=yes;; | |
1118 | *) gcc_cv_prog_$2_modern=no;; | |
1119 | esac | |
1120 | changequote([,])dnl | |
1121 | ]) | |
1122 | else | |
1123 | gcc_cv_prog_$2_modern=no | |
1124 | fi | |
1125 | ]) | |
75e93faa ZW |
1126 | |
1127 | dnl Determine if enumerated bitfields are unsigned. ISO C says they can | |
1128 | dnl be either signed or unsigned. | |
1129 | dnl | |
1130 | AC_DEFUN(gcc_AC_C_ENUM_BF_UNSIGNED, | |
1131 | [AC_CACHE_CHECK(for unsigned enumerated bitfields, gcc_cv_enum_bf_unsigned, | |
1132 | [AC_TRY_RUN(#include <stdlib.h> | |
1133 | enum t { BLAH = 128 } ; | |
1134 | struct s_t { enum t member : 8; } s ; | |
1135 | int main(void) | |
1136 | { | |
1137 | s.member = BLAH; | |
1138 | if (s.member < 0) exit(1); | |
1139 | exit(0); | |
1140 | ||
1141 | }, gcc_cv_enum_bf_unsigned=yes, gcc_cv_enum_bf_unsigned=no, gcc_cv_enum_bf_unsigned=yes)]) | |
1142 | if test $gcc_cv_enum_bf_unsigned = yes; then | |
1143 | AC_DEFINE(ENUM_BITFIELDS_ARE_UNSIGNED, 1, | |
1144 | [Define if enumerated bitfields are treated as unsigned values.]) | |
1145 | fi]) | |
1146 | ||
1147 | dnl Host type sizes probe. | |
1148 | dnl By Kaveh R. Ghazi. One typo fixed since. | |
1149 | dnl | |
1150 | AC_DEFUN([gcc_AC_COMPILE_CHECK_SIZEOF], | |
1151 | [changequote(<<, >>)dnl | |
1152 | dnl The name to #define. | |
1153 | define(<<AC_TYPE_NAME>>, translit(sizeof_$1, [a-z *], [A-Z_P]))dnl | |
1154 | dnl The cache variable name. | |
1155 | define(<<AC_CV_NAME>>, translit(ac_cv_sizeof_$1, [ *], [_p]))dnl | |
1156 | changequote([, ])dnl | |
1157 | AC_MSG_CHECKING(size of $1) | |
1158 | AC_CACHE_VAL(AC_CV_NAME, | |
1159 | [for ac_size in 4 8 1 2 16 $3 ; do # List sizes in rough order of prevalence. | |
1160 | AC_TRY_COMPILE([#include "confdefs.h" | |
1161 | #include <sys/types.h> | |
1162 | $2 | |
1163 | ], [switch (0) case 0: case (sizeof ($1) == $ac_size):;], AC_CV_NAME=$ac_size) | |
1164 | if test x$AC_CV_NAME != x ; then break; fi | |
1165 | done | |
1166 | ]) | |
1167 | if test x$AC_CV_NAME = x ; then | |
1168 | AC_MSG_ERROR([cannot determine a size for $1]) | |
1169 | fi | |
1170 | AC_MSG_RESULT($AC_CV_NAME) | |
1171 | AC_DEFINE_UNQUOTED(AC_TYPE_NAME, $AC_CV_NAME, [The number of bytes in type $1]) | |
1172 | undefine([AC_TYPE_NAME])dnl | |
1173 | undefine([AC_CV_NAME])dnl | |
1174 | ]) | |
1175 | ||
1176 | dnl Probe number of bits in a byte. | |
1177 | dnl Note C89 requires CHAR_BIT >= 8. | |
1178 | dnl | |
1179 | AC_DEFUN(gcc_AC_C_CHAR_BIT, | |
1180 | [AC_CACHE_CHECK(for CHAR_BIT, gcc_cv_decl_char_bit, | |
1181 | [AC_EGREP_CPP(found, | |
1182 | [#ifdef HAVE_LIMITS_H | |
1183 | #include <limits.h> | |
1184 | #endif | |
1185 | #ifdef CHAR_BIT | |
1186 | found | |
1187 | #endif], gcc_cv_decl_char_bit=yes, gcc_cv_decl_char_bit=no) | |
1188 | ]) | |
1189 | if test $gcc_cv_decl_char_bit = no; then | |
1190 | AC_CACHE_CHECK(number of bits in a byte, gcc_cv_c_nbby, | |
1191 | [i=8 | |
1192 | gcc_cv_c_nbby= | |
1193 | while test $i -lt 65; do | |
1194 | AC_TRY_COMPILE(, | |
1195 | [switch(0) { case 0: case (char)(1 << $i) && (char)(1 << $i) != 1: ; }], | |
1196 | gcc_cv_c_nbby=$i | |
1197 | break) | |
1198 | i=`expr $i + 1` | |
1199 | done | |
1200 | test -z "$gcc_cv_c_nbby" && gcc_cv_c_nbby=failed | |
1201 | ]) | |
1202 | if test $gcc_cv_c_nbby = failed; then | |
1203 | AC_MSG_ERROR(cannot determine number of bits in a byte) | |
1204 | else | |
1205 | AC_DEFINE_UNQUOTED(CHAR_BIT, $gcc_cv_c_nbby, | |
1206 | [Define as the number of bits in a byte, if \`limits.h' doesn't.]) | |
1207 | fi | |
1208 | fi]) | |
1209 | ||
1210 | dnl Checking for long long. | |
1211 | dnl By Caolan McNamara <caolan@skynet.ie> | |
1212 | dnl Added check for __int64, Zack Weinberg <zackw@stanford.edu> | |
1213 | dnl | |
1214 | AC_DEFUN([gcc_AC_C_LONG_LONG], | |
1215 | [AC_CACHE_CHECK(for long long int, ac_cv_c_long_long, | |
1216 | [AC_TRY_COMPILE(,[long long int i;], | |
1217 | ac_cv_c_long_long=yes, | |
1218 | ac_cv_c_long_long=no)]) | |
1219 | if test $ac_cv_c_long_long = yes; then | |
1220 | AC_DEFINE(HAVE_LONG_LONG, 1, | |
1221 | [Define if your compiler supports the \`long long' type.]) | |
1222 | fi | |
1223 | AC_CACHE_CHECK(for __int64, ac_cv_c___int64, | |
1224 | [AC_TRY_COMPILE(,[__int64 i;], | |
1225 | ac_cv_c___int64=yes, | |
1226 | ac_cv_c___int64=no)]) | |
1227 | if test $ac_cv_c___int64 = yes; then | |
1228 | AC_DEFINE(HAVE___INT64, 1, | |
1229 | [Define if your compiler supports the \`__int64' type.]) | |
1230 | fi | |
1231 | ]) |