This commit was generated by cvs2svn to track changes on a CVS vendor
[platform/upstream/binutils.git] / bfd / aclocal.m4
1 dnl aclocal.m4 generated automatically by aclocal 1.4
2
3 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 dnl This program is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10 dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11 dnl PARTICULAR PURPOSE.
12
13 dnl See whether we need to use fopen-bin.h rather than fopen-same.h.
14 AC_DEFUN(BFD_BINARY_FOPEN,
15 [AC_REQUIRE([AC_CANONICAL_SYSTEM])
16 case "${host}" in
17 changequote(,)dnl
18 *-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
19 changequote([,])dnl
20   AC_DEFINE(USE_BINARY_FOPEN, 1, [Use b modifier when opening binary files?]) ;;
21 esac])dnl
22
23 dnl Get a default for CC_FOR_BUILD to put into Makefile.
24 AC_DEFUN(BFD_CC_FOR_BUILD,
25 [# Put a plausible default for CC_FOR_BUILD in Makefile.
26 if test -z "$CC_FOR_BUILD"; then
27   if test "x$cross_compiling" = "xno"; then
28     CC_FOR_BUILD='$(CC)'
29   else
30     CC_FOR_BUILD=gcc
31   fi
32 fi
33 AC_SUBST(CC_FOR_BUILD)
34 # Also set EXEEXT_FOR_BUILD.
35 if test "x$cross_compiling" = "xno"; then
36   EXEEXT_FOR_BUILD='$(EXEEXT)'
37 else
38   AC_CACHE_CHECK([for build system executable suffix], bfd_cv_build_exeext,
39     [rm -f conftest*
40      echo 'int main () { return 0; }' > conftest.c
41      bfd_cv_build_exeext=
42      ${CC_FOR_BUILD} -o conftest conftest.c 1>&5 2>&5
43      for file in conftest.*; do
44        case $file in
45        *.c | *.o | *.obj | *.ilk | *.pdb) ;;
46        *) bfd_cv_build_exeext=`echo $file | sed -e s/conftest//` ;;
47        esac
48      done
49      rm -f conftest*
50      test x"${bfd_cv_build_exeext}" = x && bfd_cv_build_exeext=no])
51   EXEEXT_FOR_BUILD=""
52   test x"${bfd_cv_build_exeext}" != xno && EXEEXT_FOR_BUILD=${bfd_cv_build_exeext}
53 fi
54 AC_SUBST(EXEEXT_FOR_BUILD)])dnl
55
56 dnl See whether we need a declaration for a function.
57 AC_DEFUN(BFD_NEED_DECLARATION,
58 [AC_MSG_CHECKING([whether $1 must be declared])
59 AC_CACHE_VAL(bfd_cv_decl_needed_$1,
60 [AC_TRY_COMPILE([
61 #include <stdio.h>
62 #ifdef HAVE_STRING_H
63 #include <string.h>
64 #else
65 #ifdef HAVE_STRINGS_H
66 #include <strings.h>
67 #endif
68 #endif
69 #ifdef HAVE_STDLIB_H
70 #include <stdlib.h>
71 #endif
72 #ifdef HAVE_UNISTD_H
73 #include <unistd.h>
74 #endif],
75 [char *(*pfn) = (char *(*)) $1],
76 bfd_cv_decl_needed_$1=no, bfd_cv_decl_needed_$1=yes)])
77 AC_MSG_RESULT($bfd_cv_decl_needed_$1)
78 if test $bfd_cv_decl_needed_$1 = yes; then
79   AC_DEFINE([NEED_DECLARATION_]translit($1, [a-z], [A-Z]), 1,
80             [Define if $1 is not declared in system header files.])
81 fi
82 ])dnl
83
84 dnl Check for existence of a type $1 in sys/procfs.h
85
86 AC_DEFUN(BFD_HAVE_SYS_PROCFS_TYPE,
87 [AC_MSG_CHECKING([for $1 in sys/procfs.h])
88  AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_$1,
89    [AC_TRY_COMPILE([#include <sys/procfs.h>],
90       [$1 avar],
91       bfd_cv_have_sys_procfs_type_$1=yes,
92       bfd_cv_have_sys_procfs_type_$1=no
93    )])
94  if test $bfd_cv_have_sys_procfs_type_$1 = yes; then
95    AC_DEFINE([HAVE_]translit($1, [a-z], [A-Z]), 1,
96              [Define if <sys/procfs.h> has $1.])
97  fi
98  AC_MSG_RESULT($bfd_cv_have_sys_procfs_type_$1)
99 ])
100
101
102 dnl Check for existence of member $2 in type $1 in sys/procfs.h
103
104 AC_DEFUN(BFD_HAVE_SYS_PROCFS_TYPE_MEMBER,
105 [AC_MSG_CHECKING([for $1.$2 in sys/procfs.h])
106  AC_CACHE_VAL(bfd_cv_have_sys_procfs_type_member_$1_$2,
107    [AC_TRY_COMPILE([#include <sys/procfs.h>],
108       [$1 avar; void* aref = (void*) &avar.$2],
109       bfd_cv_have_sys_procfs_type_member_$1_$2=yes,
110       bfd_cv_have_sys_procfs_type_member_$1_$2=no
111    )])
112  if test $bfd_cv_have_sys_procfs_type_member_$1_$2 = yes; then
113    AC_DEFINE([HAVE_]translit($1, [a-z], [A-Z])[_]translit($2, [a-z], [A-Z]), 1,
114              [Define if <sys/procfs.h> has $1.$2.])
115  fi
116  AC_MSG_RESULT($bfd_cv_have_sys_procfs_type_member_$1_$2)
117 ])
118
119
120
121 # Do all the work for Automake.  This macro actually does too much --
122 # some checks are only needed if your package does certain things.
123 # But this isn't really a big deal.
124
125 # serial 1
126
127 dnl Usage:
128 dnl AM_INIT_AUTOMAKE(package,version, [no-define])
129
130 AC_DEFUN(AM_INIT_AUTOMAKE,
131 [AC_REQUIRE([AC_PROG_INSTALL])
132 PACKAGE=[$1]
133 AC_SUBST(PACKAGE)
134 VERSION=[$2]
135 AC_SUBST(VERSION)
136 dnl test to see if srcdir already configured
137 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
138   AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
139 fi
140 ifelse([$3],,
141 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
142 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
143 AC_REQUIRE([AM_SANITY_CHECK])
144 AC_REQUIRE([AC_ARG_PROGRAM])
145 dnl FIXME This is truly gross.
146 missing_dir=`cd $ac_aux_dir && pwd`
147 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
148 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
149 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
150 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
151 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
152 AC_REQUIRE([AC_PROG_MAKE_SET])])
153
154 #
155 # Check to make sure that the build environment is sane.
156 #
157
158 AC_DEFUN(AM_SANITY_CHECK,
159 [AC_MSG_CHECKING([whether build environment is sane])
160 # Just in case
161 sleep 1
162 echo timestamp > conftestfile
163 # Do `set' in a subshell so we don't clobber the current shell's
164 # arguments.  Must try -L first in case configure is actually a
165 # symlink; some systems play weird games with the mod time of symlinks
166 # (eg FreeBSD returns the mod time of the symlink's containing
167 # directory).
168 if (
169    set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
170    if test "[$]*" = "X"; then
171       # -L didn't work.
172       set X `ls -t $srcdir/configure conftestfile`
173    fi
174    if test "[$]*" != "X $srcdir/configure conftestfile" \
175       && test "[$]*" != "X conftestfile $srcdir/configure"; then
176
177       # If neither matched, then we have a broken ls.  This can happen
178       # if, for instance, CONFIG_SHELL is bash and it inherits a
179       # broken ls alias from the environment.  This has actually
180       # happened.  Such a system could not be considered "sane".
181       AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
182 alias in your environment])
183    fi
184
185    test "[$]2" = conftestfile
186    )
187 then
188    # Ok.
189    :
190 else
191    AC_MSG_ERROR([newly created file is older than distributed files!
192 Check your system clock])
193 fi
194 rm -f conftest*
195 AC_MSG_RESULT(yes)])
196
197 dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
198 dnl The program must properly implement --version.
199 AC_DEFUN(AM_MISSING_PROG,
200 [AC_MSG_CHECKING(for working $2)
201 # Run test in a subshell; some versions of sh will print an error if
202 # an executable is not found, even if stderr is redirected.
203 # Redirect stdin to placate older versions of autoconf.  Sigh.
204 if ($2 --version) < /dev/null > /dev/null 2>&1; then
205    $1=$2
206    AC_MSG_RESULT(found)
207 else
208    $1="$3/missing $2"
209    AC_MSG_RESULT(missing)
210 fi
211 AC_SUBST($1)])
212
213
214 # serial 40 AC_PROG_LIBTOOL
215 AC_DEFUN(AC_PROG_LIBTOOL,
216 [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
217
218 # Save cache, so that ltconfig can load it
219 AC_CACHE_SAVE
220
221 # Actually configure libtool.  ac_aux_dir is where install-sh is found.
222 CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
223 LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
224 LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
225 DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
226 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
227 $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
228 || AC_MSG_ERROR([libtool configure failed])
229
230 # Reload cache, that may have been modified by ltconfig
231 AC_CACHE_LOAD
232
233 # This can be used to rebuild libtool when needed
234 LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
235
236 # Always use our own libtool.
237 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
238 AC_SUBST(LIBTOOL)dnl
239
240 # Redirect the config.log output again, so that the ltconfig log is not
241 # clobbered by the next message.
242 exec 5>>./config.log
243 ])
244
245 AC_DEFUN(AC_LIBTOOL_SETUP,
246 [AC_PREREQ(2.13)dnl
247 AC_REQUIRE([AC_ENABLE_SHARED])dnl
248 AC_REQUIRE([AC_ENABLE_STATIC])dnl
249 AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
250 AC_REQUIRE([AC_CANONICAL_HOST])dnl
251 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
252 AC_REQUIRE([AC_PROG_RANLIB])dnl
253 AC_REQUIRE([AC_PROG_CC])dnl
254 AC_REQUIRE([AC_PROG_LD])dnl
255 AC_REQUIRE([AC_PROG_NM])dnl
256 AC_REQUIRE([AC_PROG_LN_S])dnl
257 dnl
258
259 # Check for any special flags to pass to ltconfig.
260 libtool_flags="--cache-file=$cache_file"
261 test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
262 test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
263 test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
264 test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
265 test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
266 ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
267 [libtool_flags="$libtool_flags --enable-dlopen"])
268 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
269 [libtool_flags="$libtool_flags --enable-win32-dll"])
270 AC_ARG_ENABLE(libtool-lock,
271   [  --disable-libtool-lock  avoid locking (might break parallel builds)])
272 test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
273 test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
274
275 # Some flags need to be propagated to the compiler or linker for good
276 # libtool support.
277 case "$host" in
278 *-*-irix6*)
279   # Find out which ABI we are using.
280   echo '[#]line __oline__ "configure"' > conftest.$ac_ext
281   if AC_TRY_EVAL(ac_compile); then
282     case "`/usr/bin/file conftest.o`" in
283     *32-bit*)
284       LD="${LD-ld} -32"
285       ;;
286     *N32*)
287       LD="${LD-ld} -n32"
288       ;;
289     *64-bit*)
290       LD="${LD-ld} -64"
291       ;;
292     esac
293   fi
294   rm -rf conftest*
295   ;;
296
297 *-*-sco3.2v5*)
298   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
299   SAVE_CFLAGS="$CFLAGS"
300   CFLAGS="$CFLAGS -belf"
301   AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
302     [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
303   if test x"$lt_cv_cc_needs_belf" != x"yes"; then
304     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
305     CFLAGS="$SAVE_CFLAGS"
306   fi
307   ;;
308
309 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
310 [*-*-cygwin* | *-*-mingw*)
311   AC_CHECK_TOOL(DLLTOOL, dlltool, false)
312   AC_CHECK_TOOL(AS, as, false)
313   AC_CHECK_TOOL(OBJDUMP, objdump, false)
314   ;;
315 ])
316 esac
317 ])
318
319 # AC_LIBTOOL_DLOPEN - enable checks for dlopen support
320 AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
321
322 # AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
323 AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
324
325 # AC_ENABLE_SHARED - implement the --enable-shared flag
326 # Usage: AC_ENABLE_SHARED[(DEFAULT)]
327 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
328 #   `yes'.
329 AC_DEFUN(AC_ENABLE_SHARED, [dnl
330 define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
331 AC_ARG_ENABLE(shared,
332 changequote(<<, >>)dnl
333 <<  --enable-shared[=PKGS]  build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
334 changequote([, ])dnl
335 [p=${PACKAGE-default}
336 case "$enableval" in
337 yes) enable_shared=yes ;;
338 no) enable_shared=no ;;
339 *)
340   enable_shared=no
341   # Look at the argument we got.  We use all the common list separators.
342   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
343   for pkg in $enableval; do
344     if test "X$pkg" = "X$p"; then
345       enable_shared=yes
346     fi
347   done
348   IFS="$ac_save_ifs"
349   ;;
350 esac],
351 enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
352 ])
353
354 # AC_DISABLE_SHARED - set the default shared flag to --disable-shared
355 AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
356 AC_ENABLE_SHARED(no)])
357
358 # AC_ENABLE_STATIC - implement the --enable-static flag
359 # Usage: AC_ENABLE_STATIC[(DEFAULT)]
360 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
361 #   `yes'.
362 AC_DEFUN(AC_ENABLE_STATIC, [dnl
363 define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
364 AC_ARG_ENABLE(static,
365 changequote(<<, >>)dnl
366 <<  --enable-static[=PKGS]  build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
367 changequote([, ])dnl
368 [p=${PACKAGE-default}
369 case "$enableval" in
370 yes) enable_static=yes ;;
371 no) enable_static=no ;;
372 *)
373   enable_static=no
374   # Look at the argument we got.  We use all the common list separators.
375   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
376   for pkg in $enableval; do
377     if test "X$pkg" = "X$p"; then
378       enable_static=yes
379     fi
380   done
381   IFS="$ac_save_ifs"
382   ;;
383 esac],
384 enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
385 ])
386
387 # AC_DISABLE_STATIC - set the default static flag to --disable-static
388 AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
389 AC_ENABLE_STATIC(no)])
390
391
392 # AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
393 # Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
394 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
395 #   `yes'.
396 AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
397 define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
398 AC_ARG_ENABLE(fast-install,
399 changequote(<<, >>)dnl
400 <<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
401 changequote([, ])dnl
402 [p=${PACKAGE-default}
403 case "$enableval" in
404 yes) enable_fast_install=yes ;;
405 no) enable_fast_install=no ;;
406 *)
407   enable_fast_install=no
408   # Look at the argument we got.  We use all the common list separators.
409   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
410   for pkg in $enableval; do
411     if test "X$pkg" = "X$p"; then
412       enable_fast_install=yes
413     fi
414   done
415   IFS="$ac_save_ifs"
416   ;;
417 esac],
418 enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
419 ])
420
421 # AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
422 AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
423 AC_ENABLE_FAST_INSTALL(no)])
424
425 # AC_PROG_LD - find the path to the GNU or non-GNU linker
426 AC_DEFUN(AC_PROG_LD,
427 [AC_ARG_WITH(gnu-ld,
428 [  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
429 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
430 AC_REQUIRE([AC_PROG_CC])dnl
431 AC_REQUIRE([AC_CANONICAL_HOST])dnl
432 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
433 ac_prog=ld
434 if test "$ac_cv_prog_gcc" = yes; then
435   # Check if gcc -print-prog-name=ld gives a path.
436   AC_MSG_CHECKING([for ld used by GCC])
437   ac_prog=`($CC -print-prog-name=ld) 2>&5`
438   case "$ac_prog" in
439     # Accept absolute paths.
440 changequote(,)dnl
441     [\\/]* | [A-Za-z]:[\\/]*)
442       re_direlt='/[^/][^/]*/\.\./'
443 changequote([,])dnl
444       # Canonicalize the path of ld
445       ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
446       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
447         ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
448       done
449       test -z "$LD" && LD="$ac_prog"
450       ;;
451   "")
452     # If it fails, then pretend we aren't using GCC.
453     ac_prog=ld
454     ;;
455   *)
456     # If it is relative, then search for the first ld in PATH.
457     with_gnu_ld=unknown
458     ;;
459   esac
460 elif test "$with_gnu_ld" = yes; then
461   AC_MSG_CHECKING([for GNU ld])
462 else
463   AC_MSG_CHECKING([for non-GNU ld])
464 fi
465 AC_CACHE_VAL(ac_cv_path_LD,
466 [if test -z "$LD"; then
467   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
468   for ac_dir in $PATH; do
469     test -z "$ac_dir" && ac_dir=.
470     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
471       ac_cv_path_LD="$ac_dir/$ac_prog"
472       # Check to see if the program is GNU ld.  I'd rather use --version,
473       # but apparently some GNU ld's only accept -v.
474       # Break only if it was the GNU/non-GNU ld that we prefer.
475       if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
476         test "$with_gnu_ld" != no && break
477       else
478         test "$with_gnu_ld" != yes && break
479       fi
480     fi
481   done
482   IFS="$ac_save_ifs"
483 else
484   ac_cv_path_LD="$LD" # Let the user override the test with a path.
485 fi])
486 LD="$ac_cv_path_LD"
487 if test -n "$LD"; then
488   AC_MSG_RESULT($LD)
489 else
490   AC_MSG_RESULT(no)
491 fi
492 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
493 AC_PROG_LD_GNU
494 ])
495
496 AC_DEFUN(AC_PROG_LD_GNU,
497 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
498 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
499 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
500   ac_cv_prog_gnu_ld=yes
501 else
502   ac_cv_prog_gnu_ld=no
503 fi])
504 ])
505
506 # AC_PROG_NM - find the path to a BSD-compatible name lister
507 AC_DEFUN(AC_PROG_NM,
508 [AC_MSG_CHECKING([for BSD-compatible nm])
509 AC_CACHE_VAL(ac_cv_path_NM,
510 [if test -n "$NM"; then
511   # Let the user override the test.
512   ac_cv_path_NM="$NM"
513 else
514   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
515   for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
516     test -z "$ac_dir" && ac_dir=.
517     if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
518       # Check to see if the nm accepts a BSD-compat flag.
519       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
520       #   nm: unknown option "B" ignored
521       if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
522         ac_cv_path_NM="$ac_dir/nm -B"
523         break
524       elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
525         ac_cv_path_NM="$ac_dir/nm -p"
526         break
527       else
528         ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
529         continue # so that we can try to find one that supports BSD flags
530       fi
531     fi
532   done
533   IFS="$ac_save_ifs"
534   test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
535 fi])
536 NM="$ac_cv_path_NM"
537 AC_MSG_RESULT([$NM])
538 ])
539
540 # AC_CHECK_LIBM - check for math library
541 AC_DEFUN(AC_CHECK_LIBM,
542 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
543 LIBM=
544 case "$host" in
545 *-*-beos* | *-*-cygwin*)
546   # These system don't have libm
547   ;;
548 *-ncr-sysv4.3*)
549   AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
550   AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
551   ;;
552 *)
553   AC_CHECK_LIB(m, main, LIBM="-lm")
554   ;;
555 esac
556 ])
557
558 # AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
559 # the libltdl convenience library, adds --enable-ltdl-convenience to
560 # the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
561 # is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
562 # to be `${top_builddir}/libltdl'.  Make sure you start DIR with
563 # '${top_builddir}/' (note the single quotes!) if your package is not
564 # flat, and, if you're not using automake, define top_builddir as
565 # appropriate in the Makefiles.
566 AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
567   case "$enable_ltdl_convenience" in
568   no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
569   "") enable_ltdl_convenience=yes
570       ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
571   esac
572   LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
573   INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
574 ])
575
576 # AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
577 # the libltdl installable library, and adds --enable-ltdl-install to
578 # the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
579 # is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
580 # to be `${top_builddir}/libltdl'.  Make sure you start DIR with
581 # '${top_builddir}/' (note the single quotes!) if your package is not
582 # flat, and, if you're not using automake, define top_builddir as
583 # appropriate in the Makefiles.
584 # In the future, this macro may have to be called after AC_PROG_LIBTOOL.
585 AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
586   AC_CHECK_LIB(ltdl, main,
587   [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
588   [if test x"$enable_ltdl_install" = xno; then
589      AC_MSG_WARN([libltdl not installed, but installation disabled])
590    else
591      enable_ltdl_install=yes
592    fi
593   ])
594   if test x"$enable_ltdl_install" = x"yes"; then
595     ac_configure_args="$ac_configure_args --enable-ltdl-install"
596     LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la
597     INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
598   else
599     ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
600     LIBLTDL="-lltdl"
601     INCLTDL=
602   fi
603 ])
604
605 dnl old names
606 AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
607 AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
608 AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
609 AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
610 AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
611 AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
612 AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
613
614 dnl This is just to silence aclocal about the macro not being used
615 ifelse([AC_DISABLE_FAST_INSTALL])dnl
616
617 # Like AC_CONFIG_HEADER, but automatically create stamp file.
618
619 AC_DEFUN(AM_CONFIG_HEADER,
620 [AC_PREREQ([2.12])
621 AC_CONFIG_HEADER([$1])
622 dnl When config.status generates a header, we must update the stamp-h file.
623 dnl This file resides in the same directory as the config header
624 dnl that is generated.  We must strip everything past the first ":",
625 dnl and everything past the last "/".
626 AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
627 ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
628 <<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
629 <<am_indx=1
630 for am_file in <<$1>>; do
631   case " <<$>>CONFIG_HEADERS " in
632   *" <<$>>am_file "*<<)>>
633     echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
634     ;;
635   esac
636   am_indx=`expr "<<$>>am_indx" + 1`
637 done<<>>dnl>>)
638 changequote([,]))])
639
640 # Add --enable-maintainer-mode option to configure.
641 # From Jim Meyering
642
643 # serial 1
644
645 AC_DEFUN(AM_MAINTAINER_MODE,
646 [AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
647   dnl maintainer-mode is disabled by default
648   AC_ARG_ENABLE(maintainer-mode,
649 [  --enable-maintainer-mode enable make rules and dependencies not useful
650                           (and sometimes confusing) to the casual installer],
651       USE_MAINTAINER_MODE=$enableval,
652       USE_MAINTAINER_MODE=no)
653   AC_MSG_RESULT($USE_MAINTAINER_MODE)
654   AM_CONDITIONAL(MAINTAINER_MODE, test $USE_MAINTAINER_MODE = yes)
655   MAINT=$MAINTAINER_MODE_TRUE
656   AC_SUBST(MAINT)dnl
657 ]
658 )
659
660 # Define a conditional.
661
662 AC_DEFUN(AM_CONDITIONAL,
663 [AC_SUBST($1_TRUE)
664 AC_SUBST($1_FALSE)
665 if $2; then
666   $1_TRUE=
667   $1_FALSE='#'
668 else
669   $1_TRUE='#'
670   $1_FALSE=
671 fi])
672
673 # This file is derived from `gettext.m4'.  The difference is that the
674 # included macros assume Cygnus-style source and build trees.
675
676 # Macro to add for using GNU gettext.
677 # Ulrich Drepper <drepper@cygnus.com>, 1995.
678 #
679 # This file file be copied and used freely without restrictions.  It can
680 # be used in projects which are not available under the GNU Public License
681 # but which still want to provide support for the GNU gettext functionality.
682 # Please note that the actual code is *not* freely available.
683
684 # serial 3
685
686 AC_DEFUN(CY_WITH_NLS,
687   [AC_MSG_CHECKING([whether NLS is requested])
688     dnl Default is enabled NLS
689     AC_ARG_ENABLE(nls,
690       [  --disable-nls           do not use Native Language Support],
691       USE_NLS=$enableval, USE_NLS=yes)
692     AC_MSG_RESULT($USE_NLS)
693     AC_SUBST(USE_NLS)
694
695     USE_INCLUDED_LIBINTL=no
696
697     dnl If we use NLS figure out what method
698     if test "$USE_NLS" = "yes"; then
699       AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if NLS is requested])
700       AC_MSG_CHECKING([whether included gettext is requested])
701       AC_ARG_WITH(included-gettext,
702         [  --with-included-gettext use the GNU gettext library included here],
703         nls_cv_force_use_gnu_gettext=$withval,
704         nls_cv_force_use_gnu_gettext=no)
705       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
706
707       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
708       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
709         dnl User does not insist on using GNU NLS library.  Figure out what
710         dnl to use.  If gettext or catgets are available (in this order) we
711         dnl use this.  Else we have to fall back to GNU NLS library.
712         dnl catgets is only used if permitted by option --with-catgets.
713         nls_cv_header_intl=
714         nls_cv_header_libgt=
715         CATOBJEXT=NONE
716
717         AC_CHECK_HEADER(libintl.h,
718           [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
719             [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
720                gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
721
722            if test "$gt_cv_func_gettext_libc" != "yes"; then
723              AC_CHECK_LIB(intl, bindtextdomain,
724                [AC_CACHE_CHECK([for gettext in libintl],
725                  gt_cv_func_gettext_libintl,
726                  [AC_TRY_LINK([], [return (int) gettext ("")],
727                  gt_cv_func_gettext_libintl=yes,
728                  gt_cv_func_gettext_libintl=no)])])
729            fi
730
731            if test "$gt_cv_func_gettext_libc" = "yes" \
732               || test "$gt_cv_func_gettext_libintl" = "yes"; then
733               AC_DEFINE(HAVE_GETTEXT, 1,
734                         [Define as 1 if you have gettext and don't want to use GNU gettext.])
735               AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
736                 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
737               if test "$MSGFMT" != "no"; then
738                 AC_CHECK_FUNCS(dcgettext)
739                 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
740                 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
741                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
742                 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
743                                return _nl_msg_cat_cntr],
744                   [CATOBJEXT=.gmo
745                    DATADIRNAME=share],
746                   [CATOBJEXT=.mo
747                    DATADIRNAME=lib])
748                 INSTOBJEXT=.mo
749               fi
750             fi
751         ])
752
753         dnl In the standard gettext, we would now check for catgets.
754         dnl However, we never want to use catgets for our releases.
755
756         if test "$CATOBJEXT" = "NONE"; then
757           dnl Neither gettext nor catgets in included in the C library.
758           dnl Fall back on GNU gettext library.
759           nls_cv_use_gnu_gettext=yes
760         fi
761       fi
762
763       if test "$nls_cv_use_gnu_gettext" = "yes"; then
764         dnl Mark actions used to generate GNU NLS library.
765         INTLOBJS="\$(GETTOBJS)"
766         AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
767           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
768         AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
769         AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
770           [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
771         AC_SUBST(MSGFMT)
772         USE_INCLUDED_LIBINTL=yes
773         CATOBJEXT=.gmo
774         INSTOBJEXT=.mo
775         DATADIRNAME=share
776         INTLDEPS='$(top_builddir)/../intl/libintl.a'
777         INTLLIBS=$INTLDEPS
778         LIBS=`echo $LIBS | sed -e 's/-lintl//'`
779         nls_cv_header_intl=libintl.h
780         nls_cv_header_libgt=libgettext.h
781       fi
782
783       dnl Test whether we really found GNU xgettext.
784       if test "$XGETTEXT" != ":"; then
785         dnl If it is no GNU xgettext we define it as : so that the
786         dnl Makefiles still can work.
787         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
788           : ;
789         else
790           AC_MSG_RESULT(
791             [found xgettext programs is not GNU xgettext; ignore it])
792           XGETTEXT=":"
793         fi
794       fi
795
796       # We need to process the po/ directory.
797       POSUB=po
798     else
799       DATADIRNAME=share
800       nls_cv_header_intl=libintl.h
801       nls_cv_header_libgt=libgettext.h
802     fi
803
804     # If this is used in GNU gettext we have to set USE_NLS to `yes'
805     # because some of the sources are only built for this goal.
806     if test "$PACKAGE" = gettext; then
807       USE_NLS=yes
808       USE_INCLUDED_LIBINTL=yes
809     fi
810
811     dnl These rules are solely for the distribution goal.  While doing this
812     dnl we only have to keep exactly one list of the available catalogs
813     dnl in configure.in.
814     for lang in $ALL_LINGUAS; do
815       GMOFILES="$GMOFILES $lang.gmo"
816       POFILES="$POFILES $lang.po"
817     done
818
819     dnl Make all variables we use known to autoconf.
820     AC_SUBST(USE_INCLUDED_LIBINTL)
821     AC_SUBST(CATALOGS)
822     AC_SUBST(CATOBJEXT)
823     AC_SUBST(DATADIRNAME)
824     AC_SUBST(GMOFILES)
825     AC_SUBST(INSTOBJEXT)
826     AC_SUBST(INTLDEPS)
827     AC_SUBST(INTLLIBS)
828     AC_SUBST(INTLOBJS)
829     AC_SUBST(POFILES)
830     AC_SUBST(POSUB)
831   ])
832
833 AC_DEFUN(CY_GNU_GETTEXT,
834   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
835    AC_REQUIRE([AC_PROG_CC])dnl
836    AC_REQUIRE([AC_PROG_RANLIB])dnl
837    AC_REQUIRE([AC_ISC_POSIX])dnl
838    AC_REQUIRE([AC_HEADER_STDC])dnl
839    AC_REQUIRE([AC_C_CONST])dnl
840    AC_REQUIRE([AC_C_INLINE])dnl
841    AC_REQUIRE([AC_TYPE_OFF_T])dnl
842    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
843    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
844    AC_REQUIRE([AC_FUNC_MMAP])dnl
845
846    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
847 unistd.h values.h sys/param.h])
848    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
849 __argz_count __argz_stringify __argz_next])
850
851    if test "${ac_cv_func_stpcpy+set}" != "set"; then
852      AC_CHECK_FUNCS(stpcpy)
853    fi
854    if test "${ac_cv_func_stpcpy}" = "yes"; then
855      AC_DEFINE(HAVE_STPCPY, 1, [Define if you have the stpcpy function])
856    fi
857
858    AM_LC_MESSAGES
859    CY_WITH_NLS
860
861    if test "x$CATOBJEXT" != "x"; then
862      if test "x$ALL_LINGUAS" = "x"; then
863        LINGUAS=
864      else
865        AC_MSG_CHECKING(for catalogs to be installed)
866        NEW_LINGUAS=
867        for lang in ${LINGUAS=$ALL_LINGUAS}; do
868          case "$ALL_LINGUAS" in
869           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
870          esac
871        done
872        LINGUAS=$NEW_LINGUAS
873        AC_MSG_RESULT($LINGUAS)
874      fi
875
876      dnl Construct list of names of catalog files to be constructed.
877      if test -n "$LINGUAS"; then
878        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
879      fi
880    fi
881
882    dnl The reference to <locale.h> in the installed <libintl.h> file
883    dnl must be resolved because we cannot expect the users of this
884    dnl to define HAVE_LOCALE_H.
885    if test $ac_cv_header_locale_h = yes; then
886      INCLUDE_LOCALE_H="#include <locale.h>"
887    else
888      INCLUDE_LOCALE_H="\
889 /* The system does not provide the header <locale.h>.  Take care yourself.  */"
890    fi
891    AC_SUBST(INCLUDE_LOCALE_H)
892
893    dnl Determine which catalog format we have (if any is needed)
894    dnl For now we know about two different formats:
895    dnl   Linux libc-5 and the normal X/Open format
896    if test -f $srcdir/po2tbl.sed.in; then
897       if test "$CATOBJEXT" = ".cat"; then
898          AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
899
900          dnl Transform the SED scripts while copying because some dumb SEDs
901          dnl cannot handle comments.
902          sed -e '/^#/d' $srcdir/$msgformat-msg.sed > po2msg.sed
903       fi
904       dnl po2tbl.sed is always needed.
905       sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
906          $srcdir/po2tbl.sed.in > po2tbl.sed
907    fi
908
909    dnl In the intl/Makefile.in we have a special dependency which makes
910    dnl only sense for gettext.  We comment this out for non-gettext
911    dnl packages.
912    if test "$PACKAGE" = "gettext"; then
913      GT_NO="#NO#"
914      GT_YES=
915    else
916      GT_NO=
917      GT_YES="#YES#"
918    fi
919    AC_SUBST(GT_NO)
920    AC_SUBST(GT_YES)
921
922    MKINSTALLDIRS="\$(srcdir)/../../mkinstalldirs"
923    AC_SUBST(MKINSTALLDIRS)
924
925    dnl *** For now the libtool support in intl/Makefile is not for real.
926    l=
927    AC_SUBST(l)
928
929    dnl Generate list of files to be processed by xgettext which will
930    dnl be included in po/Makefile.  But only do this if the po directory
931    dnl exists in srcdir.
932    if test -d $srcdir/po; then
933       test -d po || mkdir po
934       if test "x$srcdir" != "x."; then
935          if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
936             posrcprefix="$srcdir/"
937          else
938             posrcprefix="../$srcdir/"
939          fi
940       else
941          posrcprefix="../"
942       fi
943       rm -f po/POTFILES
944       sed -e "/^#/d" -e "/^\$/d" -e "s,.*,      $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
945          < $srcdir/po/POTFILES.in > po/POTFILES
946    fi
947   ])
948
949 # Search path for a program which passes the given test.
950 # Ulrich Drepper <drepper@cygnus.com>, 1996.
951 #
952 # This file file be copied and used freely without restrictions.  It can
953 # be used in projects which are not available under the GNU Public License
954 # but which still want to provide support for the GNU gettext functionality.
955 # Please note that the actual code is *not* freely available.
956
957 # serial 1
958
959 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
960 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
961 AC_DEFUN(AM_PATH_PROG_WITH_TEST,
962 [# Extract the first word of "$2", so it can be a program name with args.
963 set dummy $2; ac_word=[$]2
964 AC_MSG_CHECKING([for $ac_word])
965 AC_CACHE_VAL(ac_cv_path_$1,
966 [case "[$]$1" in
967   /*)
968   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
969   ;;
970   *)
971   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
972   for ac_dir in ifelse([$5], , $PATH, [$5]); do
973     test -z "$ac_dir" && ac_dir=.
974     if test -f $ac_dir/$ac_word; then
975       if [$3]; then
976         ac_cv_path_$1="$ac_dir/$ac_word"
977         break
978       fi
979     fi
980   done
981   IFS="$ac_save_ifs"
982 dnl If no 4th arg is given, leave the cache variable unset,
983 dnl so AC_PATH_PROGS will keep looking.
984 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
985 ])dnl
986   ;;
987 esac])dnl
988 $1="$ac_cv_path_$1"
989 if test -n "[$]$1"; then
990   AC_MSG_RESULT([$]$1)
991 else
992   AC_MSG_RESULT(no)
993 fi
994 AC_SUBST($1)dnl
995 ])
996
997 # Check whether LC_MESSAGES is available in <locale.h>.
998 # Ulrich Drepper <drepper@cygnus.com>, 1995.
999 #
1000 # This file file be copied and used freely without restrictions.  It can
1001 # be used in projects which are not available under the GNU Public License
1002 # but which still want to provide support for the GNU gettext functionality.
1003 # Please note that the actual code is *not* freely available.
1004
1005 # serial 1
1006
1007 AC_DEFUN(AM_LC_MESSAGES,
1008   [if test $ac_cv_header_locale_h = yes; then
1009     AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES,
1010       [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES],
1011        am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)])
1012     if test $am_cv_val_LC_MESSAGES = yes; then
1013       AC_DEFINE(HAVE_LC_MESSAGES, 1,
1014                 [Define if your locale.h file contains LC_MESSAGES.])
1015     fi
1016   fi])
1017