]> Pileus Git - ~andy/gtk/blob - acinclude.m4
[ Merges from gtk-1-2 ]
[~andy/gtk] / acinclude.m4
1 ## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*-
2 ## Copyright (C) 1996-1999 Free Software Foundation, Inc.
3 ## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
4 ##
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 2 of the License, or
8 ## (at your option) any later version.
9 ##
10 ## This program is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program; if not, write to the Free Software
17 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 ##
19 ## As a special exception to the GNU General Public License, if you
20 ## distribute this file as part of a program that contains a
21 ## configuration script generated by Autoconf, you may include it under
22 ## the same distribution terms that you use for the rest of that program.
23
24 # serial 40 AC_PROG_LIBTOOL
25 AC_DEFUN(AC_PROG_LIBTOOL,
26 [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
27
28 # Save cache, so that ltconfig can load it
29 AC_CACHE_SAVE
30
31 # Actually configure libtool.  ac_aux_dir is where install-sh is found.
32 CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
33 LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
34 LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
35 DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
36 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
37 $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
38 || AC_MSG_ERROR([libtool configure failed])
39
40 # Reload cache, that may have been modified by ltconfig
41 AC_CACHE_LOAD
42
43 # This can be used to rebuild libtool when needed
44 LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
45
46 # Always use our own libtool.
47 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
48 AC_SUBST(LIBTOOL)dnl
49
50 # Redirect the config.log output again, so that the ltconfig log is not
51 # clobbered by the next message.
52 exec 5>>./config.log
53 ])
54
55 AC_DEFUN(AC_LIBTOOL_SETUP,
56 [AC_PREREQ(2.13)dnl
57 AC_REQUIRE([AC_ENABLE_SHARED])dnl
58 AC_REQUIRE([AC_ENABLE_STATIC])dnl
59 AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
60 AC_REQUIRE([AC_CANONICAL_HOST])dnl
61 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
62 AC_REQUIRE([AC_PROG_RANLIB])dnl
63 AC_REQUIRE([AC_PROG_CC])dnl
64 AC_REQUIRE([AC_PROG_LD])dnl
65 AC_REQUIRE([AC_PROG_NM])dnl
66 AC_REQUIRE([AC_PROG_LN_S])dnl
67 dnl
68
69 # Check for any special flags to pass to ltconfig.
70 libtool_flags="--cache-file=$cache_file"
71 test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
72 test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
73 test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
74 test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
75 test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
76 ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
77 [libtool_flags="$libtool_flags --enable-dlopen"])
78 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
79 [libtool_flags="$libtool_flags --enable-win32-dll"])
80 AC_ARG_ENABLE(libtool-lock,
81   [  --disable-libtool-lock  avoid locking (might break parallel builds)])
82 test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
83 test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
84
85 # Some flags need to be propagated to the compiler or linker for good
86 # libtool support.
87 case "$host" in
88 *-*-irix6*)
89   # Find out which ABI we are using.
90   echo '[#]line __oline__ "configure"' > conftest.$ac_ext
91   if AC_TRY_EVAL(ac_compile); then
92     case "`/usr/bin/file conftest.o`" in
93     *32-bit*)
94       LD="${LD-ld} -32"
95       ;;
96     *N32*)
97       LD="${LD-ld} -n32"
98       ;;
99     *64-bit*)
100       LD="${LD-ld} -64"
101       ;;
102     esac
103   fi
104   rm -rf conftest*
105   ;;
106
107 *-*-sco3.2v5*)
108   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
109   SAVE_CFLAGS="$CFLAGS"
110   CFLAGS="$CFLAGS -belf"
111   AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
112     [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
113   if test x"$lt_cv_cc_needs_belf" != x"yes"; then
114     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
115     CFLAGS="$SAVE_CFLAGS"
116   fi
117   ;;
118
119 ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
120 [*-*-cygwin* | *-*-mingw*)
121   AC_CHECK_TOOL(DLLTOOL, dlltool, false)
122   AC_CHECK_TOOL(AS, as, false)
123   AC_CHECK_TOOL(OBJDUMP, objdump, false)
124   ;;
125 ])
126 esac
127 ])
128
129 # AC_LIBTOOL_DLOPEN - enable checks for dlopen support
130 AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
131
132 # AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
133 AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
134
135 # AC_ENABLE_SHARED - implement the --enable-shared flag
136 # Usage: AC_ENABLE_SHARED[(DEFAULT)]
137 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
138 #   `yes'.
139 AC_DEFUN(AC_ENABLE_SHARED, [dnl
140 define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
141 AC_ARG_ENABLE(shared,
142 changequote(<<, >>)dnl
143 <<  --enable-shared[=PKGS]  build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
144 changequote([, ])dnl
145 [p=${PACKAGE-default}
146 case "$enableval" in
147 yes) enable_shared=yes ;;
148 no) enable_shared=no ;;
149 *)
150   enable_shared=no
151   # Look at the argument we got.  We use all the common list separators.
152   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
153   for pkg in $enableval; do
154     if test "X$pkg" = "X$p"; then
155       enable_shared=yes
156     fi
157   done
158   IFS="$ac_save_ifs"
159   ;;
160 esac],
161 enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
162 ])
163
164 # AC_DISABLE_SHARED - set the default shared flag to --disable-shared
165 AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
166 AC_ENABLE_SHARED(no)])
167
168 # AC_ENABLE_STATIC - implement the --enable-static flag
169 # Usage: AC_ENABLE_STATIC[(DEFAULT)]
170 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
171 #   `yes'.
172 AC_DEFUN(AC_ENABLE_STATIC, [dnl
173 define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
174 AC_ARG_ENABLE(static,
175 changequote(<<, >>)dnl
176 <<  --enable-static[=PKGS]  build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
177 changequote([, ])dnl
178 [p=${PACKAGE-default}
179 case "$enableval" in
180 yes) enable_static=yes ;;
181 no) enable_static=no ;;
182 *)
183   enable_static=no
184   # Look at the argument we got.  We use all the common list separators.
185   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
186   for pkg in $enableval; do
187     if test "X$pkg" = "X$p"; then
188       enable_static=yes
189     fi
190   done
191   IFS="$ac_save_ifs"
192   ;;
193 esac],
194 enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
195 ])
196
197 # AC_DISABLE_STATIC - set the default static flag to --disable-static
198 AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
199 AC_ENABLE_STATIC(no)])
200
201
202 # AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
203 # Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
204 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
205 #   `yes'.
206 AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
207 define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
208 AC_ARG_ENABLE(fast-install,
209 changequote(<<, >>)dnl
210 <<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
211 changequote([, ])dnl
212 [p=${PACKAGE-default}
213 case "$enableval" in
214 yes) enable_fast_install=yes ;;
215 no) enable_fast_install=no ;;
216 *)
217   enable_fast_install=no
218   # Look at the argument we got.  We use all the common list separators.
219   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
220   for pkg in $enableval; do
221     if test "X$pkg" = "X$p"; then
222       enable_fast_install=yes
223     fi
224   done
225   IFS="$ac_save_ifs"
226   ;;
227 esac],
228 enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
229 ])
230
231 # AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
232 AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
233 AC_ENABLE_FAST_INSTALL(no)])
234
235 # AC_PROG_LD - find the path to the GNU or non-GNU linker
236 AC_DEFUN(AC_PROG_LD,
237 [AC_ARG_WITH(gnu-ld,
238 [  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
239 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
240 AC_REQUIRE([AC_PROG_CC])dnl
241 AC_REQUIRE([AC_CANONICAL_HOST])dnl
242 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
243 ac_prog=ld
244 if test "$ac_cv_prog_gcc" = yes; then
245   # Check if gcc -print-prog-name=ld gives a path.
246   AC_MSG_CHECKING([for ld used by GCC])
247   ac_prog=`($CC -print-prog-name=ld) 2>&5`
248   case "$ac_prog" in
249     # Accept absolute paths.
250 changequote(,)dnl
251     [\\/]* | [A-Za-z]:[\\/]*)
252       re_direlt='/[^/][^/]*/\.\./'
253 changequote([,])dnl
254       # Canonicalize the path of ld
255       ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
256       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
257         ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
258       done
259       test -z "$LD" && LD="$ac_prog"
260       ;;
261   "")
262     # If it fails, then pretend we aren't using GCC.
263     ac_prog=ld
264     ;;
265   *)
266     # If it is relative, then search for the first ld in PATH.
267     with_gnu_ld=unknown
268     ;;
269   esac
270 elif test "$with_gnu_ld" = yes; then
271   AC_MSG_CHECKING([for GNU ld])
272 else
273   AC_MSG_CHECKING([for non-GNU ld])
274 fi
275 AC_CACHE_VAL(ac_cv_path_LD,
276 [if test -z "$LD"; then
277   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
278   for ac_dir in $PATH; do
279     test -z "$ac_dir" && ac_dir=.
280     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
281       ac_cv_path_LD="$ac_dir/$ac_prog"
282       # Check to see if the program is GNU ld.  I'd rather use --version,
283       # but apparently some GNU ld's only accept -v.
284       # Break only if it was the GNU/non-GNU ld that we prefer.
285       if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
286         test "$with_gnu_ld" != no && break
287       else
288         test "$with_gnu_ld" != yes && break
289       fi
290     fi
291   done
292   IFS="$ac_save_ifs"
293 else
294   ac_cv_path_LD="$LD" # Let the user override the test with a path.
295 fi])
296 LD="$ac_cv_path_LD"
297 if test -n "$LD"; then
298   AC_MSG_RESULT($LD)
299 else
300   AC_MSG_RESULT(no)
301 fi
302 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
303 AC_SUBST(LD)
304 AC_PROG_LD_GNU
305 ])
306
307 AC_DEFUN(AC_PROG_LD_GNU,
308 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
309 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
310 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
311   ac_cv_prog_gnu_ld=yes
312 else
313   ac_cv_prog_gnu_ld=no
314 fi])
315 ])
316
317 # AC_PROG_NM - find the path to a BSD-compatible name lister
318 AC_DEFUN(AC_PROG_NM,
319 [AC_MSG_CHECKING([for BSD-compatible nm])
320 AC_CACHE_VAL(ac_cv_path_NM,
321 [if test -n "$NM"; then
322   # Let the user override the test.
323   ac_cv_path_NM="$NM"
324 else
325   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
326   for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
327     test -z "$ac_dir" && ac_dir=.
328     if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
329       # Check to see if the nm accepts a BSD-compat flag.
330       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
331       #   nm: unknown option "B" ignored
332       if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
333         ac_cv_path_NM="$ac_dir/nm -B"
334         break
335       elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
336         ac_cv_path_NM="$ac_dir/nm -p"
337         break
338       else
339         ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
340         continue # so that we can try to find one that supports BSD flags
341       fi
342     fi
343   done
344   IFS="$ac_save_ifs"
345   test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
346 fi])
347 NM="$ac_cv_path_NM"
348 AC_MSG_RESULT([$NM])
349 AC_SUBST(NM)
350 ])
351
352 # AC_CHECK_LIBM - check for math library
353 AC_DEFUN(AC_CHECK_LIBM,
354 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
355 LIBM=
356 case "$host" in
357 *-*-beos* | *-*-cygwin*)
358   # These system don't have libm
359   ;;
360 *-ncr-sysv4.3*)
361   AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
362   AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
363   ;;
364 *)
365   AC_CHECK_LIB(m, main, LIBM="-lm")
366   ;;
367 esac
368 ])
369
370 # AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
371 # the libltdl convenience library, adds --enable-ltdl-convenience to
372 # the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
373 # is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
374 # to be `${top_builddir}/libltdl'.  Make sure you start DIR with
375 # '${top_builddir}/' (note the single quotes!) if your package is not
376 # flat, and, if you're not using automake, define top_builddir as
377 # appropriate in the Makefiles.
378 AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
379   case "$enable_ltdl_convenience" in
380   no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
381   "") enable_ltdl_convenience=yes
382       ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
383   esac
384   LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
385   INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
386 ])
387
388 # AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
389 # the libltdl installable library, and adds --enable-ltdl-install to
390 # the configure arguments.  Note that LIBLTDL is not AC_SUBSTed, nor
391 # is AC_CONFIG_SUBDIRS called.  If DIR is not provided, it is assumed
392 # to be `${top_builddir}/libltdl'.  Make sure you start DIR with
393 # '${top_builddir}/' (note the single quotes!) if your package is not
394 # flat, and, if you're not using automake, define top_builddir as
395 # appropriate in the Makefiles.
396 # In the future, this macro may have to be called after AC_PROG_LIBTOOL.
397 AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
398   AC_CHECK_LIB(ltdl, main,
399   [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
400   [if test x"$enable_ltdl_install" = xno; then
401      AC_MSG_WARN([libltdl not installed, but installation disabled])
402    else
403      enable_ltdl_install=yes
404    fi
405   ])
406   if test x"$enable_ltdl_install" = x"yes"; then
407     ac_configure_args="$ac_configure_args --enable-ltdl-install"
408     LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la
409     INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
410   else
411     ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
412     LIBLTDL="-lltdl"
413     INCLTDL=
414   fi
415 ])
416
417 dnl old names
418 AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
419 AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
420 AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
421 AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
422 AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
423 AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
424 AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
425
426 dnl This is just to silence aclocal about the macro not being used
427 ifelse([AC_DISABLE_FAST_INSTALL])dnl
428
429 # Macro to add for using GNU gettext.
430 # Ulrich Drepper <drepper@cygnus.com>, 1995.
431 #
432 # Modified to never use included libintl. 
433 # Owen Taylor <otaylor@redhat.com>, 12/15/1998
434 #
435 #
436 # This file can be copied and used freely without restrictions.  It can
437 # be used in projects which are not available under the GNU Public License
438 # but which still want to provide support for the GNU gettext functionality.
439 # Please note that the actual code is *not* freely available.
440
441 # serial 5
442
443 AC_DEFUN(AM_GTK_WITH_NLS,
444   [AC_MSG_CHECKING([whether NLS is requested])
445     dnl Default is enabled NLS
446     AC_ARG_ENABLE(nls,
447       [  --disable-nls           do not use Native Language Support],
448       USE_NLS=$enableval, USE_NLS=yes)
449     AC_MSG_RESULT($USE_NLS)
450     AC_SUBST(USE_NLS)
451
452     USE_INCLUDED_LIBINTL=no
453
454     dnl If we use NLS figure out what method
455     if test "$USE_NLS" = "yes"; then
456 #      AC_DEFINE(ENABLE_NLS)
457 #      AC_MSG_CHECKING([whether included gettext is requested])
458 #      AC_ARG_WITH(included-gettext,
459 #        [  --with-included-gettext use the GNU gettext library included here],
460 #        nls_cv_force_use_gnu_gettext=$withval,
461 #        nls_cv_force_use_gnu_gettext=no)
462 #      AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
463       nls_cv_force_use_gnu_gettext="no"
464
465       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
466       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
467         dnl User does not insist on using GNU NLS library.  Figure out what
468         dnl to use.  If gettext or catgets are available (in this order) we
469         dnl use this.  Else we have to fall back to GNU NLS library.
470         dnl catgets is only used if permitted by option --with-catgets.
471         nls_cv_header_intl=
472         nls_cv_header_libgt=
473         CATOBJEXT=NONE
474
475         AC_CHECK_HEADER(libintl.h,
476           [AC_CACHE_CHECK([for dgettext in libc], gt_cv_func_dgettext_libc,
477             [AC_TRY_LINK([#include <libintl.h>], [return (int) dgettext ("","")],
478                gt_cv_func_dgettext_libc=yes, gt_cv_func_dgettext_libc=no)])
479
480            if test "$gt_cv_func_dgettext_libc" != "yes"; then
481              AC_CHECK_LIB(intl, bindtextdomain,
482                [AC_CACHE_CHECK([for dgettext in libintl],
483                  gt_cv_func_dgettext_libintl,
484                  [AC_CHECK_LIB(intl, dgettext,
485                   gt_cv_func_dgettext_libintl=yes,
486                   gt_cv_func_dgettext_libintl=no)],
487                  gt_cv_func_dgettext_libintl=no)])
488            fi
489
490            if test "$gt_cv_func_dgettext_libc" = "yes" \
491               || test "$gt_cv_func_dgettext_libintl" = "yes"; then
492               AC_DEFINE(HAVE_GETTEXT)
493               AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
494                 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
495               if test "$MSGFMT" != "no"; then
496                 AC_CHECK_FUNCS(dcgettext)
497                 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
498                 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
499                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
500                 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
501                                return _nl_msg_cat_cntr],
502                   [CATOBJEXT=.gmo
503                    DATADIRNAME=share],
504                   [CATOBJEXT=.mo
505                    DATADIRNAME=lib])
506                 INSTOBJEXT=.mo
507               fi
508             fi
509
510             # Added by Martin Baulig 12/15/98 for libc5 systems
511             if test "$gt_cv_func_dgettext_libc" != "yes" \
512                && test "$gt_cv_func_dgettext_libintl" = "yes"; then
513                INTLLIBS=-lintl
514                LIBS=`echo $LIBS | sed -e 's/-lintl//'`
515             fi
516         ])
517
518         if test "$CATOBJEXT" = "NONE"; then
519           AC_MSG_CHECKING([whether catgets can be used])
520           AC_ARG_WITH(catgets,
521             [  --with-catgets          use catgets functions if available],
522             nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
523           AC_MSG_RESULT($nls_cv_use_catgets)
524
525           if test "$nls_cv_use_catgets" = "yes"; then
526             dnl No gettext in C library.  Try catgets next.
527             AC_CHECK_LIB(i, main)
528             AC_CHECK_FUNC(catgets,
529               [AC_DEFINE(HAVE_CATGETS)
530                INTLOBJS="\$(CATOBJS)"
531                AC_PATH_PROG(GENCAT, gencat, no)dnl
532 #              if test "$GENCAT" != "no"; then
533 #                AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
534 #                if test "$GMSGFMT" = "no"; then
535 #                  AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
536 #                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
537 #                fi
538 #                AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
539 #                  [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
540 #                USE_INCLUDED_LIBINTL=yes
541 #                CATOBJEXT=.cat
542 #                INSTOBJEXT=.cat
543 #                DATADIRNAME=lib
544 #                INTLDEPS='$(top_builddir)/intl/libintl.a'
545 #                INTLLIBS=$INTLDEPS
546 #                LIBS=`echo $LIBS | sed -e 's/-lintl//'`
547 #                nls_cv_header_intl=intl/libintl.h
548 #                nls_cv_header_libgt=intl/libgettext.h
549 #              fi
550             ])
551           fi
552         fi
553
554         if test "$CATOBJEXT" = "NONE"; then
555           dnl Neither gettext nor catgets in included in the C library.
556           dnl Fall back on GNU gettext library.
557           nls_cv_use_gnu_gettext=yes
558         fi
559       fi
560
561       if test "$nls_cv_use_gnu_gettext" != "yes"; then
562         AC_DEFINE(ENABLE_NLS)
563       else
564          # Unset this variable since we use the non-zero value as a flag.
565          CATOBJEXT=
566 #        dnl Mark actions used to generate GNU NLS library.
567 #        INTLOBJS="\$(GETTOBJS)"
568 #        AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
569 #         [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
570 #        AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
571 #        AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
572 #         [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
573 #        AC_SUBST(MSGFMT)
574 #       USE_INCLUDED_LIBINTL=yes
575 #        CATOBJEXT=.gmo
576 #        INSTOBJEXT=.mo
577 #        DATADIRNAME=share
578 #       INTLDEPS='$(top_builddir)/intl/libintl.a'
579 #       INTLLIBS=$INTLDEPS
580 #       LIBS=`echo $LIBS | sed -e 's/-lintl//'`
581 #        nls_cv_header_intl=intl/libintl.h
582 #        nls_cv_header_libgt=intl/libgettext.h
583       fi
584
585       dnl Test whether we really found GNU xgettext.
586       if test "$XGETTEXT" != ":"; then
587         dnl If it is no GNU xgettext we define it as : so that the
588         dnl Makefiles still can work.
589         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
590           : ;
591         else
592           AC_MSG_RESULT(
593             [found xgettext program is not GNU xgettext; ignore it])
594           XGETTEXT=":"
595         fi
596       fi
597
598       # We need to process the po/ directory.
599       POSUB=po
600     else
601       DATADIRNAME=share
602       nls_cv_header_intl=intl/libintl.h
603       nls_cv_header_libgt=intl/libgettext.h
604     fi
605     AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
606     AC_OUTPUT_COMMANDS(
607      [case "$CONFIG_FILES" in *po/Makefile.in*)
608         sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
609       esac])
610
611
612 #    # If this is used in GNU gettext we have to set USE_NLS to `yes'
613 #    # because some of the sources are only built for this goal.
614 #    if test "$PACKAGE" = gettext; then
615 #      USE_NLS=yes
616 #      USE_INCLUDED_LIBINTL=yes
617 #    fi
618
619     dnl These rules are solely for the distribution goal.  While doing this
620     dnl we only have to keep exactly one list of the available catalogs
621     dnl in configure.in.
622     for lang in $ALL_LINGUAS; do
623       GMOFILES="$GMOFILES $lang.gmo"
624       POFILES="$POFILES $lang.po"
625     done
626
627     dnl Make all variables we use known to autoconf.
628     AC_SUBST(USE_INCLUDED_LIBINTL)
629     AC_SUBST(CATALOGS)
630     AC_SUBST(CATOBJEXT)
631     AC_SUBST(DATADIRNAME)
632     AC_SUBST(GMOFILES)
633     AC_SUBST(INSTOBJEXT)
634     AC_SUBST(INTLDEPS)
635     AC_SUBST(INTLLIBS)
636     AC_SUBST(INTLOBJS)
637     AC_SUBST(POFILES)
638     AC_SUBST(POSUB)
639   ])
640
641 AC_DEFUN(AM_GTK_GNU_GETTEXT,
642   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
643    AC_REQUIRE([AC_PROG_CC])dnl
644    AC_REQUIRE([AC_PROG_RANLIB])dnl
645    AC_REQUIRE([AC_ISC_POSIX])dnl
646    AC_REQUIRE([AC_HEADER_STDC])dnl
647    AC_REQUIRE([AC_C_CONST])dnl
648    AC_REQUIRE([AC_C_INLINE])dnl
649    AC_REQUIRE([AC_TYPE_OFF_T])dnl
650    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
651    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
652    AC_REQUIRE([AC_FUNC_MMAP])dnl
653
654    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
655 unistd.h sys/param.h])
656    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
657 strdup __argz_count __argz_stringify __argz_next])
658
659    if test "${ac_cv_func_stpcpy+set}" != "set"; then
660      AC_CHECK_FUNCS(stpcpy)
661    fi
662    if test "${ac_cv_func_stpcpy}" = "yes"; then
663      AC_DEFINE(HAVE_STPCPY)
664    fi
665
666    AM_LC_MESSAGES
667    AM_GTK_WITH_NLS
668
669    if test "x$CATOBJEXT" != "x"; then
670      if test "x$ALL_LINGUAS" = "x"; then
671        LINGUAS=
672      else
673        AC_MSG_CHECKING(for catalogs to be installed)
674        NEW_LINGUAS=
675        for lang in ${LINGUAS=$ALL_LINGUAS}; do
676          case "$ALL_LINGUAS" in
677           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
678          esac
679        done
680        LINGUAS=$NEW_LINGUAS
681        AC_MSG_RESULT($LINGUAS)
682      fi
683
684      dnl Construct list of names of catalog files to be constructed.
685      if test -n "$LINGUAS"; then
686        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
687      fi
688    fi
689
690    dnl The reference to <locale.h> in the installed <libintl.h> file
691    dnl must be resolved because we cannot expect the users of this
692    dnl to define HAVE_LOCALE_H.
693    if test $ac_cv_header_locale_h = yes; then
694      INCLUDE_LOCALE_H="#include <locale.h>"
695    else
696      INCLUDE_LOCALE_H="\
697 /* The system does not provide the header <locale.h>.  Take care yourself.  */"
698    fi
699    AC_SUBST(INCLUDE_LOCALE_H)
700
701    dnl Determine which catalog format we have (if any is needed)
702    dnl For now we know about two different formats:
703    dnl   Linux libc-5 and the normal X/Open format
704    test -d intl || mkdir intl
705    if test "$CATOBJEXT" = ".cat"; then
706      AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
707
708      dnl Transform the SED scripts while copying because some dumb SEDs
709      dnl cannot handle comments.
710      sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
711    fi
712    dnl po2tbl.sed is always needed.
713    sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
714      $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
715
716    dnl In the intl/Makefile.in we have a special dependency which makes
717    dnl only sense for gettext.  We comment this out for non-gettext
718    dnl packages.
719    if test "$PACKAGE" = "gettext"; then
720      GT_NO="#NO#"
721      GT_YES=
722    else
723      GT_NO=
724      GT_YES="#YES#"
725    fi
726    AC_SUBST(GT_NO)
727    AC_SUBST(GT_YES)
728
729    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
730    dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
731    dnl Try to locate is.
732    MKINSTALLDIRS=
733    if test -n "$ac_aux_dir"; then
734      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
735    fi
736    if test -z "$MKINSTALLDIRS"; then
737      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
738    fi
739    AC_SUBST(MKINSTALLDIRS)
740
741    dnl *** For now the libtool support in intl/Makefile is not for real.
742    l=
743    AC_SUBST(l)
744
745    dnl Generate list of files to be processed by xgettext which will
746    dnl be included in po/Makefile.
747    test -d po || mkdir po
748    if test "x$srcdir" != "x."; then
749      if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
750        posrcprefix="$srcdir/"
751      else
752        posrcprefix="../$srcdir/"
753      fi
754    else
755      posrcprefix="../"
756    fi
757    rm -f po/POTFILES
758    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
759         < $srcdir/po/POTFILES.in > po/POTFILES
760   ])
761