OSDN Git Service

top:
[pf3gnuchains/gcc-fork.git] / gcc / aclocal.m4
1 sinclude(../config/acx.m4)
2 sinclude(../config/accross.m4)
3 sinclude(../config/gettext.m4)
4 sinclude(../config/progtest.m4)
5
6 dnl See if stdbool.h properly defines bool and true/false.
7 AC_DEFUN(gcc_AC_HEADER_STDBOOL,
8 [AC_CACHE_CHECK([for working stdbool.h],
9   ac_cv_header_stdbool_h,
10 [AC_TRY_COMPILE([#include <stdbool.h>],
11 [bool foo = false;],
12 ac_cv_header_stdbool_h=yes, ac_cv_header_stdbool_h=no)])
13 if test $ac_cv_header_stdbool_h = yes; then
14   AC_DEFINE(HAVE_STDBOOL_H, 1,
15   [Define if you have a working <stdbool.h> header file.])
16 fi
17 ])
18
19 dnl See whether we can include both string.h and strings.h.
20 AC_DEFUN(gcc_AC_HEADER_STRING,
21 [AC_CACHE_CHECK([whether string.h and strings.h may both be included],
22   gcc_cv_header_string,
23 [AC_TRY_COMPILE([#include <string.h>
24 #include <strings.h>], , gcc_cv_header_string=yes, gcc_cv_header_string=no)])
25 if test $gcc_cv_header_string = yes; then
26   AC_DEFINE(STRING_WITH_STRINGS, 1, [Define if you can safely include both <string.h> and <strings.h>.])
27 fi
28 ])
29
30 dnl See whether we need a declaration for a function.
31 dnl The result is highly dependent on the INCLUDES passed in, so make sure
32 dnl to use a different cache variable name in this macro if it is invoked
33 dnl in a different context somewhere else.
34 dnl gcc_AC_CHECK_DECL(SYMBOL,
35 dnl     [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, INCLUDES]]])
36 AC_DEFUN(gcc_AC_CHECK_DECL,
37 [AC_MSG_CHECKING([whether $1 is declared])
38 AC_CACHE_VAL(gcc_cv_have_decl_$1,
39 [AC_TRY_COMPILE([$4],
40 [#ifndef $1
41 char *(*pfn) = (char *(*)) $1 ;
42 #endif], eval "gcc_cv_have_decl_$1=yes", eval "gcc_cv_have_decl_$1=no")])
43 if eval "test \"`echo '$gcc_cv_have_decl_'$1`\" = yes"; then
44   AC_MSG_RESULT(yes) ; ifelse([$2], , :, [$2])
45 else
46   AC_MSG_RESULT(no) ; ifelse([$3], , :, [$3])
47 fi
48 ])dnl
49
50 dnl Check multiple functions to see whether each needs a declaration.
51 dnl Arrange to define HAVE_DECL_<FUNCTION> to 0 or 1 as appropriate.
52 dnl gcc_AC_CHECK_DECLS(SYMBOLS,
53 dnl     [ACTION-IF-NEEDED [, ACTION-IF-NOT-NEEDED [, INCLUDES]]])
54 AC_DEFUN(gcc_AC_CHECK_DECLS,
55 [for ac_func in $1
56 do
57 changequote(, )dnl
58   ac_tr_decl=HAVE_DECL_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
59 changequote([, ])dnl
60 gcc_AC_CHECK_DECL($ac_func,
61   [AC_DEFINE_UNQUOTED($ac_tr_decl, 1) $2],
62   [AC_DEFINE_UNQUOTED($ac_tr_decl, 0) $3],
63 dnl It is possible that the include files passed in here are local headers
64 dnl which supply a backup declaration for the relevant prototype based on
65 dnl the definition of (or lack of) the HAVE_DECL_ macro.  If so, this test
66 dnl will always return success.  E.g. see libiberty.h's handling of
67 dnl `basename'.  To avoid this, we define the relevant HAVE_DECL_ macro to
68 dnl 1 so that any local headers used do not provide their own prototype
69 dnl during this test.
70 #undef $ac_tr_decl
71 #define $ac_tr_decl 1
72   $4
73 )
74 done
75 dnl Automatically generate config.h entries via autoheader.
76 if test x = y ; then
77   patsubst(translit([$1], [a-z], [A-Z]), [\w+],
78     [AC_DEFINE([HAVE_DECL_\&], 1,
79       [Define to 1 if we found this declaration otherwise define to 0.])])dnl
80 fi
81 ])
82
83 dnl See if the printf functions in libc support %p in format strings.
84 AC_DEFUN(gcc_AC_FUNC_PRINTF_PTR,
85 [AC_CACHE_CHECK(whether the printf functions support %p,
86   gcc_cv_func_printf_ptr,
87 [AC_TRY_RUN([#include <stdio.h>
88
89 int main()
90 {
91   char buf[64];
92   char *p = buf, *q = NULL;
93   sprintf(buf, "%p", p);
94   sscanf(buf, "%p", &q);
95   return (p != q);
96 }], gcc_cv_func_printf_ptr=yes, gcc_cv_func_printf_ptr=no,
97         gcc_cv_func_printf_ptr=no)
98 rm -f core core.* *.core])
99 if test $gcc_cv_func_printf_ptr = yes ; then
100   AC_DEFINE(HAVE_PRINTF_PTR, 1, [Define if printf supports "%p".])
101 fi
102 ])
103
104 dnl See if symbolic links work and if not, try to substitute either hard links or simple copy.
105 AC_DEFUN(gcc_AC_PROG_LN_S,
106 [AC_MSG_CHECKING(whether ln -s works)
107 AC_CACHE_VAL(gcc_cv_prog_LN_S,
108 [rm -f conftestdata_t
109 echo >conftestdata_f
110 if ln -s conftestdata_f conftestdata_t 2>/dev/null
111 then
112   gcc_cv_prog_LN_S="ln -s"
113 else
114   if ln conftestdata_f conftestdata_t 2>/dev/null
115   then
116     gcc_cv_prog_LN_S=ln
117   else
118     gcc_cv_prog_LN_S=cp
119   fi
120 fi
121 rm -f conftestdata_f conftestdata_t
122 ])dnl
123 LN_S="$gcc_cv_prog_LN_S"
124 if test "$gcc_cv_prog_LN_S" = "ln -s"; then
125   AC_MSG_RESULT(yes)
126 else
127   if test "$gcc_cv_prog_LN_S" = "ln"; then
128     AC_MSG_RESULT([no, using ln])
129   else
130     AC_MSG_RESULT([no, and neither does ln, so using cp])
131   fi
132 fi
133 AC_SUBST(LN_S)dnl
134 ])
135
136 dnl See if hard links work and if not, try to substitute either symbolic links or simple copy.
137 AC_DEFUN(gcc_AC_PROG_LN,
138 [AC_MSG_CHECKING(whether ln works)
139 AC_CACHE_VAL(gcc_cv_prog_LN,
140 [rm -f conftestdata_t
141 echo >conftestdata_f
142 if ln conftestdata_f conftestdata_t 2>/dev/null
143 then
144   gcc_cv_prog_LN="ln"
145 else
146   if ln -s conftestdata_f conftestdata_t 2>/dev/null
147   then
148     gcc_cv_prog_LN="ln -s"
149   else
150     gcc_cv_prog_LN=cp
151   fi
152 fi
153 rm -f conftestdata_f conftestdata_t
154 ])dnl
155 LN="$gcc_cv_prog_LN"
156 if test "$gcc_cv_prog_LN" = "ln"; then
157   AC_MSG_RESULT(yes)
158 else
159   if test "$gcc_cv_prog_LN" = "ln -s"; then
160     AC_MSG_RESULT([no, using ln -s])
161   else
162     AC_MSG_RESULT([no, and neither does ln -s, so using cp])
163   fi
164 fi
165 AC_SUBST(LN)dnl
166 ])
167
168 dnl Check whether _Bool is built-in.
169 AC_DEFUN(gcc_AC_C__BOOL,
170 [AC_CACHE_CHECK(for built-in _Bool, gcc_cv_c__bool,
171 [AC_TRY_COMPILE(,
172 [_Bool foo;],
173 gcc_cv_c__bool=yes, gcc_cv_c__bool=no)
174 ])
175 if test $gcc_cv_c__bool = yes; then
176   AC_DEFINE(HAVE__BOOL, 1, [Define if the \`_Bool' type is built-in.])
177 fi
178 ])
179
180 dnl Define MKDIR_TAKES_ONE_ARG if mkdir accepts only one argument instead
181 dnl of the usual 2.
182 AC_DEFUN(gcc_AC_FUNC_MKDIR_TAKES_ONE_ARG,
183 [AC_CACHE_CHECK([if mkdir takes one argument], gcc_cv_mkdir_takes_one_arg,
184 [AC_TRY_COMPILE([
185 #include <sys/types.h>
186 #ifdef HAVE_SYS_STAT_H
187 # include <sys/stat.h>
188 #endif
189 #ifdef HAVE_UNISTD_H
190 # include <unistd.h>
191 #endif
192 #ifdef HAVE_DIRECT_H
193 # include <direct.h>
194 #endif], [mkdir ("foo", 0);], 
195         gcc_cv_mkdir_takes_one_arg=no, gcc_cv_mkdir_takes_one_arg=yes)])
196 if test $gcc_cv_mkdir_takes_one_arg = yes ; then
197   AC_DEFINE(MKDIR_TAKES_ONE_ARG, 1, [Define if host mkdir takes a single argument.])
198 fi
199 ])
200
201 AC_DEFUN(gcc_AC_PROG_INSTALL,
202 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
203 # Find a good install program.  We prefer a C program (faster),
204 # so one script is as good as another.  But avoid the broken or
205 # incompatible versions:
206 # SysV /etc/install, /usr/sbin/install
207 # SunOS /usr/etc/install
208 # IRIX /sbin/install
209 # AIX /bin/install
210 # AFS /usr/afsws/bin/install, which mishandles nonexistent args
211 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
212 # ./install, which can be erroneously created by make from ./install.sh.
213 AC_MSG_CHECKING(for a BSD compatible install)
214 if test -z "$INSTALL"; then
215 AC_CACHE_VAL(ac_cv_path_install,
216 [  IFS="${IFS=  }"; ac_save_IFS="$IFS"; IFS="${IFS}:"
217   for ac_dir in $PATH; do
218     # Account for people who put trailing slashes in PATH elements.
219     case "$ac_dir/" in
220     /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
221     *)
222       # OSF1 and SCO ODT 3.0 have their own names for install.
223       for ac_prog in ginstall scoinst install; do
224         if test -f $ac_dir/$ac_prog; then
225           if test $ac_prog = install &&
226             grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
227             # AIX install.  It has an incompatible calling convention.
228             # OSF/1 installbsd also uses dspmsg, but is usable.
229             :
230           else
231             ac_cv_path_install="$ac_dir/$ac_prog -c"
232             break 2
233           fi
234         fi
235       done
236       ;;
237     esac
238   done
239   IFS="$ac_save_IFS"
240 ])dnl
241   if test "${ac_cv_path_install+set}" = set; then
242     INSTALL="$ac_cv_path_install"
243   else
244     # As a last resort, use the slow shell script.  We don't cache a
245     # path for INSTALL within a source directory, because that will
246     # break other packages using the cache if that directory is
247     # removed, or if the path is relative.
248     INSTALL="$ac_install_sh"
249   fi
250 fi
251 dnl We do special magic for INSTALL instead of AC_SUBST, to get
252 dnl relative paths right.
253 AC_MSG_RESULT($INSTALL)
254 AC_SUBST(INSTALL)dnl
255
256 # Use test -z because SunOS4 sh mishandles braces in ${var-val}.
257 # It thinks the first close brace ends the variable substitution.
258 test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
259 AC_SUBST(INSTALL_PROGRAM)dnl
260
261 test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
262 AC_SUBST(INSTALL_DATA)dnl
263 ])
264
265 dnl Test for GNAT.
266 dnl We require the gnatbind program, and a compiler driver that
267 dnl understands Ada.  The user may set the driver name explicitly
268 dnl with ADAC; also, the user's CC setting is tried.  Failing that,
269 dnl we try gcc and cc, then a sampling of names known to be used for
270 dnl the Ada driver on various systems.
271 dnl
272 dnl Sets the shell variable have_gnat to yes or no as appropriate, and
273 dnl substitutes GNATBIND and ADAC.
274 AC_DEFUN([gcc_AC_PROG_GNAT],
275 [AC_REQUIRE([AC_CHECK_TOOL_PREFIX])
276 AC_CHECK_TOOL(GNATBIND, gnatbind, no)
277 AC_CACHE_CHECK([for compiler driver that understands Ada],
278                  gcc_cv_prog_adac,
279 [cat >conftest.adb <<EOF
280 procedure conftest is begin null; end conftest;
281 EOF
282 gcc_cv_prog_adac=no
283 # Have to do ac_tool_prefix and user overrides by hand.
284 for cand in ${ADAC+"$ADAC"} ${CC+"$CC"} \
285             ${ac_tool_prefix}gcc        gcc             \
286             ${ac_tool_prefix}cc         cc              \
287             ${ac_tool_prefix}gnatgcc    gnatgcc         \
288             ${ac_tool_prefix}gnatcc     gnatcc          \
289             ${ac_tool_prefix}adagcc     adagcc          \
290             ${ac_tool_prefix}adacc      adacc           ; do
291   # There is a bug in all released versions of GCC which causes the
292   # driver to exit successfully when the appropriate language module
293   # has not been installed.  This is fixed in 2.95.4, 3.0.2, and 3.1.
294   # Therefore we must check for the error message as well as an
295   # unsuccessful exit.
296   errors=`($cand -c conftest.adb) 2>&1 || echo failure`
297   if test x"$errors" = x; then
298     gcc_cv_prog_adac=$cand
299     break
300   fi
301 done
302 rm -f conftest.*])
303 ADAC=$gcc_cv_prog_adac
304 AC_SUBST(ADAC)
305
306 if test x$GNATBIND != xno && test x$ADAC != xno; then
307   have_gnat=yes
308 else
309   have_gnat=no
310 fi
311 ])
312
313 dnl GCC_PATH_PROG(VARIABLE, PROG-TO-CHECK-FOR [, VALUE-IF-NOT-FOUND [, PATH]])
314 dnl like AC_PATH_PROG but use other cache variables
315 AC_DEFUN(GCC_PATH_PROG,
316 [# Extract the first word of "$2", so it can be a program name with args.
317 set dummy $2; ac_word=[$]2
318 AC_MSG_CHECKING([for $ac_word])
319 AC_CACHE_VAL(gcc_cv_path_$1,
320 [case "[$]$1" in
321   /*)
322   gcc_cv_path_$1="[$]$1" # Let the user override the test with a path.
323   ;;
324   ?:/*)                  
325   gcc_cv_path_$1="[$]$1" # Let the user override the test with a dos path.
326   ;;
327   *)
328   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
329 dnl $ac_dummy forces splitting on constant user-supplied paths.
330 dnl POSIX.2 word splitting is done only on the output of word expansions,
331 dnl not every word.  This closes a longstanding sh security hole.
332   ac_dummy="ifelse([$4], , $PATH, [$4])"
333   for ac_dir in $ac_dummy; do 
334     test -z "$ac_dir" && ac_dir=.
335     if test -f $ac_dir/$ac_word; then
336       gcc_cv_path_$1="$ac_dir/$ac_word"
337       break
338     fi
339   done
340   IFS="$ac_save_ifs"
341 dnl If no 3rd arg is given, leave the cache variable unset,
342 dnl so GCC_PATH_PROGS will keep looking.
343 ifelse([$3], , , [  test -z "[$]gcc_cv_path_$1" && gcc_cv_path_$1="$3"
344 ])dnl
345   ;;
346 esac])dnl
347 $1="$gcc_cv_path_$1"
348 if test -n "[$]$1"; then
349   AC_MSG_RESULT([$]$1)
350 else
351   AC_MSG_RESULT(no)
352 fi
353 AC_SUBST($1)dnl
354 ])
355
356 # mmap(2) blacklisting.  Some platforms provide the mmap library routine
357 # but don't support all of the features we need from it.
358 AC_DEFUN([gcc_AC_FUNC_MMAP_BLACKLIST],
359 [if test $ac_cv_header_sys_mman_h != yes \
360  || test $ac_cv_func_mmap != yes; then
361    gcc_cv_func_mmap_file=no
362    gcc_cv_func_mmap_dev_zero=no
363    gcc_cv_func_mmap_anon=no
364 else
365    AC_CACHE_CHECK([whether read-only mmap of a plain file works], 
366   gcc_cv_func_mmap_file,
367   [# Add a system to this blacklist if 
368    # mmap(0, stat_size, PROT_READ, MAP_PRIVATE, fd, 0) doesn't return a
369    # memory area containing the same data that you'd get if you applied
370    # read() to the same fd.  The only system known to have a problem here
371    # is VMS, where text files have record structure.
372    case "$host_os" in
373      vms*) 
374         gcc_cv_func_mmap_file=no ;;
375      *)
376         gcc_cv_func_mmap_file=yes;;
377    esac])
378    AC_CACHE_CHECK([whether mmap from /dev/zero works],
379   gcc_cv_func_mmap_dev_zero,
380   [# Add a system to this blacklist if it has mmap() but /dev/zero
381    # does not exist, or if mmapping /dev/zero does not give anonymous
382    # zeroed pages with both the following properties:
383    # 1. If you map N consecutive pages in with one call, and then
384    #    unmap any subset of those pages, the pages that were not
385    #    explicitly unmapped remain accessible.
386    # 2. If you map two adjacent blocks of memory and then unmap them
387    #    both at once, they must both go away.
388    # Systems known to be in this category are Windows (all variants),
389    # VMS, and Darwin.
390    case "$host_os" in
391      vms* | cygwin* | pe | mingw* | darwin*)
392         gcc_cv_func_mmap_dev_zero=no ;;
393      *)
394         gcc_cv_func_mmap_dev_zero=yes;;
395    esac])
396
397    # Unlike /dev/zero, the MAP_ANON(YMOUS) defines can be probed for.
398    AC_CACHE_CHECK([for MAP_ANON(YMOUS)], gcc_cv_decl_map_anon,
399     [AC_TRY_COMPILE(
400 [#include <sys/types.h>
401 #include <sys/mman.h>
402 #include <unistd.h>
403
404 #ifndef MAP_ANONYMOUS
405 #define MAP_ANONYMOUS MAP_ANON
406 #endif
407 ],
408 [int n = MAP_ANONYMOUS;],
409     gcc_cv_decl_map_anon=yes,
410     gcc_cv_decl_map_anon=no)])
411
412    if test $gcc_cv_decl_map_anon = no; then
413      gcc_cv_func_mmap_anon=no
414    else
415      AC_CACHE_CHECK([whether mmap with MAP_ANON(YMOUS) works],
416      gcc_cv_func_mmap_anon,
417   [# Add a system to this blacklist if it has mmap() and MAP_ANON or
418    # MAP_ANONYMOUS, but using mmap(..., MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
419    # doesn't give anonymous zeroed pages with the same properties listed
420    # above for use of /dev/zero.
421    # Systems known to be in this category are Windows, VMS, and SCO Unix.
422    case "$host_os" in
423      vms* | cygwin* | pe | mingw* | sco* | udk* )
424         gcc_cv_func_mmap_anon=no ;;
425      *)
426         gcc_cv_func_mmap_anon=yes;;
427    esac])
428    fi
429 fi
430
431 if test $gcc_cv_func_mmap_file = yes; then
432   AC_DEFINE(HAVE_MMAP_FILE, 1,
433             [Define if read-only mmap of a plain file works.])
434 fi
435 if test $gcc_cv_func_mmap_dev_zero = yes; then
436   AC_DEFINE(HAVE_MMAP_DEV_ZERO, 1,
437             [Define if mmap of /dev/zero works.])
438 fi
439 if test $gcc_cv_func_mmap_anon = yes; then
440   AC_DEFINE(HAVE_MMAP_ANON, 1,
441             [Define if mmap with MAP_ANON(YMOUS) works.])
442 fi
443 ])
444
445 dnl Locate a program and check that its version is acceptable.
446 dnl AC_PROG_CHECK_VER(var, name, version-switch,
447 dnl                  version-extract-regexp, version-glob)
448 AC_DEFUN(gcc_AC_CHECK_PROG_VER,
449 [AC_CHECK_PROG([$1], [$2], [$2])
450 if test -n "[$]$1"; then
451   # Found it, now check the version.
452   AC_CACHE_CHECK(for modern $2, gcc_cv_prog_$2_modern,
453 [changequote(<<,>>)dnl
454   ac_prog_version=`<<$>>$1 $3 2>&1 |
455                    sed -n 's/^.*patsubst(<<$4>>,/,\/).*$/\1/p'`
456 changequote([,])dnl
457   echo "configure:__oline__: version of $2 is $ac_prog_version" >&AC_FD_CC
458 changequote(<<,>>)dnl
459   case $ac_prog_version in
460     '')     gcc_cv_prog_$2_modern=no;;
461     <<$5>>)
462             gcc_cv_prog_$2_modern=yes;;
463     *)      gcc_cv_prog_$2_modern=no;;
464   esac
465 changequote([,])dnl
466 ])
467 else
468   gcc_cv_prog_$2_modern=no
469 fi
470 ])
471
472 dnl Determine if enumerated bitfields are unsigned.   ISO C says they can 
473 dnl be either signed or unsigned.
474 dnl
475 AC_DEFUN(gcc_AC_C_ENUM_BF_UNSIGNED,
476 [AC_CACHE_CHECK(for unsigned enumerated bitfields, gcc_cv_enum_bf_unsigned,
477 [AC_TRY_RUN(#include <stdlib.h>
478 enum t { BLAH = 128 } ;
479 struct s_t { enum t member : 8; } s ;
480 int main(void)
481 {            
482         s.member = BLAH;
483         if (s.member < 0) exit(1);
484         exit(0);
485
486 }, gcc_cv_enum_bf_unsigned=yes, gcc_cv_enum_bf_unsigned=no, gcc_cv_enum_bf_unsigned=yes)])
487 if test $gcc_cv_enum_bf_unsigned = yes; then
488   AC_DEFINE(ENUM_BITFIELDS_ARE_UNSIGNED, 1,
489     [Define if enumerated bitfields are treated as unsigned values.])
490 fi])
491
492 dnl Probe number of bits in a byte.
493 dnl Note C89 requires CHAR_BIT >= 8.
494 dnl
495 AC_DEFUN(gcc_AC_C_CHAR_BIT,
496 [AC_CACHE_CHECK(for CHAR_BIT, gcc_cv_decl_char_bit,
497 [AC_EGREP_CPP(found,
498 [#ifdef HAVE_LIMITS_H
499 #include <limits.h>
500 #endif
501 #ifdef CHAR_BIT
502 found
503 #endif], gcc_cv_decl_char_bit=yes, gcc_cv_decl_char_bit=no)
504 ])
505 if test $gcc_cv_decl_char_bit = no; then
506   AC_CACHE_CHECK(number of bits in a byte, gcc_cv_c_nbby,
507 [i=8
508  gcc_cv_c_nbby=
509  while test $i -lt 65; do
510    AC_TRY_COMPILE(,
511      [switch(0) {
512   case (unsigned char)((unsigned long)1 << $i) == ((unsigned long)1 << $i):
513   case (unsigned char)((unsigned long)1<<($i-1)) == ((unsigned long)1<<($i-1)):
514   ; }], 
515      [gcc_cv_c_nbby=$i; break])
516    i=`expr $i + 1`
517  done
518  test -z "$gcc_cv_c_nbby" && gcc_cv_c_nbby=failed
519 ])
520 if test $gcc_cv_c_nbby = failed; then
521   AC_MSG_ERROR(cannot determine number of bits in a byte)
522 else
523   AC_DEFINE_UNQUOTED(CHAR_BIT, $gcc_cv_c_nbby,
524   [Define as the number of bits in a byte, if \`limits.h' doesn't.])
525 fi
526 fi])
527
528 dnl Checking for long long.
529 dnl By Caolan McNamara <caolan@skynet.ie>
530 dnl Added check for __int64, Zack Weinberg <zackw@stanford.edu>
531 dnl
532 AC_DEFUN([gcc_AC_C_LONG_LONG],
533 [AC_CACHE_CHECK(for long long int, ac_cv_c_long_long,
534   [AC_TRY_COMPILE(,[long long int i;],
535          ac_cv_c_long_long=yes,
536          ac_cv_c_long_long=no)])
537   if test $ac_cv_c_long_long = yes; then
538     AC_DEFINE(HAVE_LONG_LONG, 1,
539       [Define if your compiler supports the \`long long' type.])
540   fi
541 AC_CACHE_CHECK(for __int64, ac_cv_c___int64,
542   [AC_TRY_COMPILE(,[__int64 i;],
543         ac_cv_c___int64=yes,
544         ac_cv_c___int64=no)])
545   if test $ac_cv_c___int64 = yes; then
546     AC_DEFINE(HAVE___INT64, 1,
547       [Define if your compiler supports the \`__int64' type.])
548   fi
549 ])
550
551 #serial AM2
552
553 dnl From Bruno Haible.
554
555 AC_DEFUN([AM_ICONV],
556 [
557   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
558   dnl those with the standalone portable GNU libiconv installed).
559
560   am_cv_lib_iconv_ldpath=
561   AC_ARG_WITH([libiconv-prefix],
562 [  --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib], [
563     for dir in `echo "$withval" | tr : ' '`; do
564       if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
565       if test -d $dir/lib; then am_cv_lib_iconv_ldpath="-L$dir/lib"; fi
566     done
567    ])
568
569   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
570     am_cv_func_iconv="no, consider installing GNU libiconv"
571     am_cv_lib_iconv=no
572     AC_TRY_LINK([#include <stdlib.h>
573 #include <iconv.h>],
574       [iconv_t cd = iconv_open("","");
575        iconv(cd,NULL,NULL,NULL,NULL);
576        iconv_close(cd);],
577       am_cv_func_iconv=yes)
578     if test "$am_cv_func_iconv" != yes; then
579       am_save_LIBS="$LIBS"
580       LIBS="$LIBS $am_cv_libiconv_ldpath -liconv"
581       AC_TRY_LINK([#include <stdlib.h>
582 #include <iconv.h>],
583         [iconv_t cd = iconv_open("","");
584          iconv(cd,NULL,NULL,NULL,NULL);
585          iconv_close(cd);],
586         am_cv_lib_iconv=yes
587         am_cv_func_iconv=yes)
588       LIBS="$am_save_LIBS"
589     fi
590   ])
591   if test "$am_cv_func_iconv" = yes; then
592     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
593     AC_MSG_CHECKING([for iconv declaration])
594     AC_CACHE_VAL(am_cv_proto_iconv, [
595       AC_TRY_COMPILE([
596 #include <stdlib.h>
597 #include <iconv.h>
598 extern
599 #ifdef __cplusplus
600 "C"
601 #endif
602 #if defined(__STDC__) || defined(__cplusplus)
603 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
604 #else
605 size_t iconv();
606 #endif
607 ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
608       am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
609     am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
610     AC_MSG_RESULT([$]{ac_t:-
611          }[$]am_cv_proto_iconv)
612     AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
613       [Define as const if the declaration of iconv() needs const.])
614   fi
615   LIBICONV=
616   if test "$am_cv_lib_iconv" = yes; then
617     LIBICONV="$am_cv_lib_iconv_ldpath -liconv"
618   fi
619   AC_SUBST(LIBICONV)
620 ])
621
622 AC_DEFUN(gcc_AC_INITFINI_ARRAY,
623 [AC_ARG_ENABLE(initfini-array,
624         [  --enable-initfini-array      use .init_array/.fini_array sections],
625         [], [
626 AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
627                  gcc_cv_initfini_array, [dnl
628   AC_TRY_RUN([
629 static int x = -1;
630 int main (void) { return x; }
631 int foo (void) { x = 0; }
632 int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;],
633              [gcc_cv_initfini_array=yes], [gcc_cv_initfini_array=no],
634              [gcc_cv_initfini_array=no])])
635   enable_initfini_array=$gcc_cv_initfini_array
636 ])
637 if test $enable_initfini_array = yes; then
638   AC_DEFINE(HAVE_INITFINI_ARRAY, 1,
639     [Define .init_array/.fini_array sections are available and working.])
640 fi])
641
642 dnl # _gcc_COMPUTE_GAS_VERSION
643 dnl # Used by gcc_GAS_VERSION_GTE_IFELSE
644 dnl #
645 dnl # WARNING:
646 dnl # gcc_cv_as_gas_srcdir must be defined before this.
647 dnl # This gross requirement will go away eventually.
648 AC_DEFUN([_gcc_COMPUTE_GAS_VERSION],
649 [gcc_cv_as_bfd_srcdir=`echo $srcdir | sed -e 's,/gcc$,,'`/bfd
650 for f in $gcc_cv_as_bfd_srcdir/configure \
651          $gcc_cv_as_gas_srcdir/configure \
652          $gcc_cv_as_gas_srcdir/configure.in \
653          $gcc_cv_as_gas_srcdir/Makefile.in ; do
654   gcc_cv_gas_version=`grep '^VERSION=[[0-9]]*\.[[0-9]]*' $f`
655   if test x$gcc_cv_gas_version != x; then
656     break
657   fi
658 done
659 gcc_cv_gas_major_version=`expr "$gcc_cv_gas_version" : "VERSION=\([[0-9]]*\)"`
660 gcc_cv_gas_minor_version=`expr "$gcc_cv_gas_version" : "VERSION=[[0-9]]*\.\([[0-9]]*\)"`
661 gcc_cv_gas_patch_version=`expr "$gcc_cv_gas_version" : "VERSION=[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)"`
662 ]) []dnl # _gcc_COMPUTE_GAS_VERSION
663
664 dnl # gcc_GAS_VERSION_GTE_IFELSE(major, minor, patchlevel,
665 dnl #                     [command_if_true = :], [command_if_false = :])
666 dnl # Check to see if the version of GAS is greater than or
667 dnl # equal to the specified version.
668 dnl #
669 dnl # The first ifelse() shortens the shell code if the patchlevel
670 dnl # is unimportant (the usual case).  The others handle missing
671 dnl # commands.  Note that the tests are structured so that the most
672 dnl # common version number cases are tested first.
673 AC_DEFUN([gcc_GAS_VERSION_GTE_IFELSE],
674 [AC_REQUIRE([_gcc_COMPUTE_GAS_VERSION]) []dnl
675 ifelse([$3],[0],
676 [if test $gcc_cv_gas_major_version -eq $1 \
677 && test $gcc_cv_gas_minor_version -ge $2 \
678 || test $gcc_cv_gas_major_version -gt $1 ; then
679 ],
680 [if test $gcc_cv_gas_major_version -eq $1 \
681 && (test $gcc_cv_gas_minor_version -gt $2 \
682     || (test $gcc_cv_gas_minor_version -eq $2 \
683         && test $gcc_cv_gas_patch_version -ge $3 )) \
684 || test $gcc_cv_gas_major_version -gt $1 ; then
685 ])
686 ifelse([$4],[],[:],[$4])
687 ifelse([$5],[],[],[else $5])
688 fi
689 ]) []dnl # gcc_GAS_VERSION_GTE_IFELSE
690
691 # lcmessage.m4 serial 3 (gettext-0.11.3)
692 dnl Copyright (C) 1995-2002 Free Software Foundation, Inc.
693 dnl This file is free software, distributed under the terms of the GNU
694 dnl General Public License.  As a special exception to the GNU General
695 dnl Public License, this file may be distributed as part of a program
696 dnl that contains a configuration script generated by Autoconf, under
697 dnl the same distribution terms as the rest of that program.
698 dnl
699 dnl This file can can be used in projects which are not available under
700 dnl the GNU General Public License or the GNU Library General Public
701 dnl License but which still want to provide support for the GNU gettext
702 dnl functionality.
703 dnl Please note that the actual code of the GNU gettext library is covered
704 dnl by the GNU Library General Public License, and the rest of the GNU
705 dnl gettext package package is covered by the GNU General Public License.
706 dnl They are *not* in the public domain.
707
708 dnl Authors:
709 dnl   Ulrich Drepper <drepper@cygnus.com>, 1995.
710
711 # Check whether LC_MESSAGES is available in <locale.h>.
712
713 AC_DEFUN([AM_LC_MESSAGES],
714 [
715   AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
716     [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
717        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
718   if test $am_cv_val_LC_MESSAGES = yes; then
719     AC_DEFINE(HAVE_LC_MESSAGES, 1,
720       [Define if your <locale.h> file defines LC_MESSAGES.])
721   fi
722 ])