]> Pileus Git - ~andy/gtk/blob - acinclude.m4
Doah. libtool isn't the only thing in here.
[~andy/gtk] / acinclude.m4
1 ## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*-
2 ## Copyright (C) 1996-1998 Free Software Foundation, Inc.
3 ## 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 29 AM_PROG_LIBTOOL
25 AC_DEFUN(AM_PROG_LIBTOOL,
26 [AC_REQUIRE([AM_ENABLE_SHARED])dnl
27 AC_REQUIRE([AM_ENABLE_STATIC])dnl
28 AC_REQUIRE([AC_CANONICAL_HOST])dnl
29 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
30 AC_REQUIRE([AC_PROG_RANLIB])dnl
31 AC_REQUIRE([AC_PROG_CC])dnl
32 AC_REQUIRE([AM_PROG_LD])dnl
33 AC_REQUIRE([AM_PROG_NM])dnl
34 AC_REQUIRE([AM_SYS_NM_PARSE])dnl
35 AC_REQUIRE([AM_SYS_SYMBOL_UNDERSCORE])dnl
36 AC_REQUIRE([AC_PROG_LN_S])dnl
37 dnl
38 # Always use our own libtool.
39 LIBTOOL='$(SHELL) $(top_builddir)/libtool'
40 AC_SUBST(LIBTOOL)dnl
41
42 # Check for any special flags to pass to ltconfig.
43 libtool_flags=
44 test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
45 test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
46 test "$silent" = yes && libtool_flags="$libtool_flags --silent"
47 test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
48 test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
49
50 # Some flags need to be propagated to the compiler or linker for good
51 # libtool support.
52 case "$host" in
53 *-*-irix6*)
54   # Find out which ABI we are using.
55   echo '[#]line __oline__ "configure"' > conftest.$ac_ext
56   if AC_TRY_EVAL(ac_compile); then
57     case "`/usr/bin/file conftest.o`" in
58     *32-bit*)
59       LD="${LD-ld} -32"
60       ;;
61     *N32*)
62       LD="${LD-ld} -n32"
63       ;;
64     *64-bit*)
65       LD="${LD-ld} -64"
66       ;;
67     esac
68   fi
69   rm -rf conftest*
70   ;;
71
72 *-*-sco3.2v5*)
73   # On SCO OpenServer 5, we need -belf to get full-featured binaries.
74   SAVE_CFLAGS="$CFLAGS"
75   CFLAGS="$CFLAGS -belf"
76   AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
77     [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
78   if test x"$lt_cv_cc_needs_belf" != x"yes"; then
79     # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
80     CFLAGS="$SAVE_CFLAGS"
81   fi
82   ;;
83
84 *-*-cygwin32*)
85   AM_SYS_LIBTOOL_CYGWIN32
86   ;;
87
88 esac
89
90 # enable the --disable-libtool-lock switch
91
92 AC_ARG_ENABLE(libtool-lock,
93 [  --disable-libtool-lock  force libtool not to do file locking],
94 need_locks=$enableval,
95 need_locks=yes)
96
97 if test x"$need_locks" = xno; then
98   libtool_flags="$libtool_flags --disable-lock"
99 fi
100
101
102 # Actually configure libtool.  ac_aux_dir is where install-sh is found.
103 CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
104 LD="$LD" NM="$NM" RANLIB="$RANLIB" LN_S="$LN_S" \
105 DLLTOOL="$DLLTOOL" AS="$AS" \
106 ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
107 $libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \
108 || AC_MSG_ERROR([libtool configure failed])
109
110 # Redirect the config.log output again, so that the ltconfig log is not
111 # clobbered by the next message.
112 exec 5>>./config.log
113 ])
114
115 # AM_ENABLE_SHARED - implement the --enable-shared flag
116 # Usage: AM_ENABLE_SHARED[(DEFAULT)]
117 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
118 #   `yes'.
119 AC_DEFUN(AM_ENABLE_SHARED,
120 [define([AM_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
121 AC_ARG_ENABLE(shared,
122 changequote(<<, >>)dnl
123 <<  --enable-shared[=PKGS]  build shared libraries [default=>>AM_ENABLE_SHARED_DEFAULT],
124 changequote([, ])dnl
125 [p=${PACKAGE-default}
126 case "$enableval" in
127 yes) enable_shared=yes ;;
128 no) enable_shared=no ;;
129 *)
130   enable_shared=no
131   # Look at the argument we got.  We use all the common list separators.
132   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
133   for pkg in $enableval; do
134     if test "X$pkg" = "X$p"; then
135       enable_shared=yes
136     fi
137   done
138   IFS="$ac_save_ifs"
139   ;;
140 esac],
141 enable_shared=AM_ENABLE_SHARED_DEFAULT)dnl
142 ])
143
144 # AM_DISABLE_SHARED - set the default shared flag to --disable-shared
145 AC_DEFUN(AM_DISABLE_SHARED,
146 [AM_ENABLE_SHARED(no)])
147
148 # AM_DISABLE_STATIC - set the default static flag to --disable-static
149 AC_DEFUN(AM_DISABLE_STATIC,
150 [AM_ENABLE_STATIC(no)])
151
152 # AM_ENABLE_STATIC - implement the --enable-static flag
153 # Usage: AM_ENABLE_STATIC[(DEFAULT)]
154 #   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
155 #   `yes'.
156 AC_DEFUN(AM_ENABLE_STATIC,
157 [define([AM_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
158 AC_ARG_ENABLE(static,
159 changequote(<<, >>)dnl
160 <<  --enable-static[=PKGS]  build static libraries [default=>>AM_ENABLE_STATIC_DEFAULT],
161 changequote([, ])dnl
162 [p=${PACKAGE-default}
163 case "$enableval" in
164 yes) enable_static=yes ;;
165 no) enable_static=no ;;
166 *)
167   enable_static=no
168   # Look at the argument we got.  We use all the common list separators.
169   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
170   for pkg in $enableval; do
171     if test "X$pkg" = "X$p"; then
172       enable_static=yes
173     fi
174   done
175   IFS="$ac_save_ifs"
176   ;;
177 esac],
178 enable_static=AM_ENABLE_STATIC_DEFAULT)dnl
179 ])
180
181
182 # AM_PROG_LD - find the path to the GNU or non-GNU linker
183 AC_DEFUN(AM_PROG_LD,
184 [AC_ARG_WITH(gnu-ld,
185 [  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
186 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
187 AC_REQUIRE([AC_PROG_CC])dnl
188 AC_REQUIRE([AC_CANONICAL_HOST])dnl
189 AC_REQUIRE([AC_CANONICAL_BUILD])dnl
190 ac_prog=ld
191 if test "$ac_cv_prog_gcc" = yes; then
192   # Check if gcc -print-prog-name=ld gives a path.
193   AC_MSG_CHECKING([for ld used by GCC])
194   ac_prog=`($CC -print-prog-name=ld) 2>&5`
195   case "$ac_prog" in
196     # Accept absolute paths.
197 changequote(,)dnl
198     /* | [A-Za-z]:/*)
199       # Canonicalize the path of ld
200       re_direlt='/[^/][^/]*/\.\./'
201       sub_uncdrive='s%^\([A-Za-z]\):/%//\1/%'
202 changequote([,])dnl
203       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
204         ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
205       done
206       case "$host_os" in
207       cygwin*)
208         # Convert to a UNC path for cygwin
209         test -z "$LD" && LD=`echo X$ac_prog | $Xsed -e "$sub_uncdrive"`
210         ;;
211       *)
212         test -z "$LD" && LD="$ac_prog"
213         ;;
214       esac
215       ;;
216     ##
217     ## FIXME:  The code fails later on if we try to use an $LD with
218     ##         '\\' path separators.
219     ##
220 changequote(,)dnl
221     [A-Za-z]:[\\]*)
222       # Canonicalize the path of ld
223       re_direlt='\\[^\\][^\\]*\\\.\.\(\\\)'
224       sub_uncdrive='s%^\([A-Za-z]\):\\%//\1/%'
225 changequote([,])dnl
226       sub_uncdir='s%\\%/%g'
227       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
228         ac_prog=`echo $ac_prog| sed "s%$re_direlt%\1%"`
229       done
230       case "$host_os" in
231       cygwin*)
232         # Convert to a UNC path for cygwin
233         test -z "$LD" && LD=`echo X$ac_prog | sed -e 's%^X%%' -e "$sub_uncdrive" -e "$sub_uncdir"`
234         ;;
235       *)
236         test -z "$LD" && LD="$ac_prog"
237         ;;
238       esac
239       ;;
240   "")
241     # If it fails, then pretend we aren't using GCC.
242     ac_prog=ld
243     ;;
244   *)
245     # If it is relative, then search for the first ld in PATH.
246     with_gnu_ld=unknown
247     ;;
248   esac
249 elif test "$with_gnu_ld" = yes; then
250   AC_MSG_CHECKING([for GNU ld])
251 else
252   AC_MSG_CHECKING([for non-GNU ld])
253 fi
254 AC_CACHE_VAL(ac_cv_path_LD,
255 [if test -z "$LD"; then
256   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
257   for ac_dir in $PATH; do
258     test -z "$ac_dir" && ac_dir=.
259     if test -f "$ac_dir/$ac_prog"; then
260       ac_cv_path_LD="$ac_dir/$ac_prog"
261       # Check to see if the program is GNU ld.  I'd rather use --version,
262       # but apparently some GNU ld's only accept -v.
263       # Break only if it was the GNU/non-GNU ld that we prefer.
264       if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
265         test "$with_gnu_ld" != no && break
266       else
267         test "$with_gnu_ld" != yes && break
268       fi
269     fi
270   done
271   IFS="$ac_save_ifs"
272 else
273   ac_cv_path_LD="$LD" # Let the user override the test with a path.
274 fi])
275 LD="$ac_cv_path_LD"
276 if test -n "$LD"; then
277   AC_MSG_RESULT($LD)
278 else
279   AC_MSG_RESULT(no)
280 fi
281 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
282 AC_SUBST(LD)
283 AM_PROG_LD_GNU
284 ])
285
286 AC_DEFUN(AM_PROG_LD_GNU,
287 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
288 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
289 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
290   ac_cv_prog_gnu_ld=yes
291 else
292   ac_cv_prog_gnu_ld=no
293 fi])
294 ])
295
296 # AM_PROG_NM - find the path to a BSD-compatible name lister
297 AC_DEFUN(AM_PROG_NM,
298 [AC_MSG_CHECKING([for BSD-compatible nm])
299 AC_CACHE_VAL(ac_cv_path_NM,
300 [if test -n "$NM"; then
301   # Let the user override the test.
302   ac_cv_path_NM="$NM"
303 else
304   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
305   for ac_dir in /usr/ucb /usr/ccs/bin $PATH /bin; do
306     test -z "$ac_dir" && ac_dir=.
307     if test -f $ac_dir/nm; then
308       # Check to see if the nm accepts a BSD-compat flag.
309       # Adding the `sed 1q' prevents false positives on HP-UX, which says:
310       #   nm: unknown option "B" ignored
311       if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
312         ac_cv_path_NM="$ac_dir/nm -B"
313       elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
314         ac_cv_path_NM="$ac_dir/nm -p"
315       else
316         ac_cv_path_NM="$ac_dir/nm"
317       fi
318       break
319     fi
320   done
321   IFS="$ac_save_ifs"
322   test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
323 fi])
324 NM="$ac_cv_path_NM"
325 AC_MSG_RESULT([$NM])
326 AC_SUBST(NM)
327 ])
328
329 # AM_SYS_NM_PARSE - Check for command ro grab the raw symbol name followed
330 # by C symbol name from nm.
331 AC_DEFUN(AM_SYS_NM_PARSE,
332 [AC_REQUIRE([AC_CANONICAL_HOST])dnl
333 AC_REQUIRE([AM_PROG_NM])dnl
334 # Check for command to grab the raw symbol name followed by C symbol from nm.
335 AC_MSG_CHECKING([command to parse $NM output])
336 AC_CACHE_VAL(ac_cv_sys_global_symbol_pipe,
337 [# These are sane defaults that work on at least a few old systems.
338 # {They come from Ultrix.  What could be older than Ultrix?!! ;)}
339
340 changequote(,)dnl
341 # Character class describing NM global symbol codes.
342 ac_symcode='[BCDEGRSTU]'
343
344 # Regexp to match symbols that can be accessed directly from C.
345 ac_sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
346
347 # Transform the above into a raw symbol and a C symbol.
348 ac_symxfrm='\1 \1'
349
350 # Define system-specific variables.
351 case "$host_os" in
352 aix*)
353   ac_symcode='[BCDTU]'
354   ;;
355 sunos* | cygwin32* | mingw32*)
356   ac_sympat='_\([_A-Za-z][_A-Za-z0-9]*\)'
357   ac_symxfrm='_\1 \1'
358   ;;
359 irix*)
360   # Cannot use undefined symbols on IRIX because inlined functions mess us up.
361   ac_symcode='[BCDEGRST]'
362   ;;
363 solaris*)
364   ac_symcode='[BDTU]'
365   ;;
366 esac
367
368 # If we're using GNU nm, then use its standard symbol codes.
369 if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then
370   ac_symcode='[ABCDGISTUW]'
371 fi
372
373 case "$host_os" in
374 cygwin32* | mingw32*)
375   # We do not want undefined symbols on cygwin32.  The user must
376   # arrange to define them via -l arguments.
377   ac_symcode='[ABCDGISTW]'
378   ;;
379 esac
380 changequote([,])dnl
381
382 # Write the raw and C identifiers.
383 ac_cv_sys_global_symbol_pipe="sed -n -e 's/^.* $ac_symcode $ac_sympat$/$ac_symxfrm/p'"
384
385 # Check to see that the pipe works correctly.
386 ac_pipe_works=no
387 cat > conftest.$ac_ext <<EOF
388 #ifdef __cplusplus
389 extern "C" {
390 #endif
391 char nm_test_var;
392 void nm_test_func(){}
393 #ifdef __cplusplus
394 }
395 #endif
396 int main(){nm_test_var='a';nm_test_func;return 0;}
397 EOF
398 if AC_TRY_EVAL(ac_compile); then
399   # Now try to grab the symbols.
400   ac_nlist=conftest.nm
401   if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
402
403     # Try sorting and uniquifying the output.
404     if sort "$ac_nlist" | uniq > "$ac_nlist"T; then
405       mv -f "$ac_nlist"T "$ac_nlist"
406       ac_wcout=`wc "$ac_nlist" 2>/dev/null`
407 changequote(,)dnl
408       ac_count=`echo "X$ac_wcout" | sed -e 's,^X,,' -e 's/^[    ]*\([0-9][0-9]*\).*$/\1/'`
409 changequote([,])dnl
410       (test "$ac_count" -ge 0) 2>/dev/null || ac_count=-1
411     else
412       rm -f "$ac_nlist"T
413       ac_count=-1
414     fi
415
416     # Make sure that we snagged all the symbols we need.
417     if egrep ' nm_test_var$' "$ac_nlist" >/dev/null; then
418       if egrep ' nm_test_func$' "$ac_nlist" >/dev/null; then
419         cat <<EOF > conftest.c
420 #ifdef __cplusplus
421 extern "C" {
422 #endif
423
424 EOF
425         # Now generate the symbol file.
426         sed 's/^.* \(.*\)$/extern char \1;/' < "$ac_nlist" >> conftest.c
427
428         cat <<EOF >> conftest.c
429 #if defined (__STDC__) && __STDC__
430 # define __ptr_t void *
431 #else
432 # define __ptr_t char *
433 #endif
434
435 /* The number of symbols in dld_preloaded_symbols, -1 if unsorted. */
436 int dld_preloaded_symbol_count = $ac_count;
437
438 /* The mapping between symbol names and symbols. */
439 struct {
440   char *name;
441   __ptr_t address;
442 }
443 changequote(,)dnl
444 dld_preloaded_symbols[] =
445 changequote([,])dnl
446 {
447 EOF
448         sed 's/^\(.*\) \(.*\)$/  {"\1", (__ptr_t) \&\2},/' < "$ac_nlist" >> conftest.c
449         cat <<\EOF >> conftest.c
450   {0, (__ptr_t) 0}
451 };
452
453 #ifdef __cplusplus
454 }
455 #endif
456 EOF
457         # Now try linking the two files.
458         mv conftest.$ac_objext conftestm.$ac_objext
459         ac_save_LIBS="$LIBS"
460         ac_save_CFLAGS="$CFLAGS"
461         LIBS="conftestm.$ac_objext"
462         CFLAGS="$CFLAGS$no_builtin_flag"
463         if AC_TRY_EVAL(ac_link) && test -s conftest; then
464           ac_pipe_works=yes
465         else
466           echo "configure: failed program was:" >&AC_FD_CC
467           cat conftest.c >&AC_FD_CC
468         fi
469         LIBS="$ac_save_LIBS"
470         CFLAGS="$ac_save_CFLAGS"
471       else
472         echo "cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
473       fi
474     else
475       echo "cannot find nm_test_var in $ac_nlist" >&AC_FD_CC
476     fi
477   else
478     echo "cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
479   fi
480 else
481   echo "$progname: failed program was:" >&AC_FD_CC
482   cat conftest.c >&AC_FD_CC
483 fi
484 rm -rf conftest*
485
486 # Do not use the global_symbol_pipe unless it works.
487 test "$ac_pipe_works" = yes || ac_cv_sys_global_symbol_pipe=
488 ])
489
490 ac_result=yes
491 if test -z "$ac_cv_sys_global_symbol_pipe"; then
492    ac_result=no
493 fi
494 AC_MSG_RESULT($ac_result)
495 ])
496
497 # AM_SYS_LIBTOOL_CYGWIN32 - find tools needed on cygwin32
498 AC_DEFUN(AM_SYS_LIBTOOL_CYGWIN32,
499 [AC_CHECK_TOOL(DLLTOOL, dlltool, false)
500 AC_CHECK_TOOL(AS, as, false)
501 ])
502
503 # AM_SYS_SYMBOL_UNDERSCORE - does the compiler prefix global symbols
504 #                            with an underscore?
505 AC_DEFUN(AM_SYS_SYMBOL_UNDERSCORE,
506 [AC_REQUIRE([AM_PROG_NM])dnl
507 AC_REQUIRE([AM_SYS_NM_PARSE])dnl
508 AC_MSG_CHECKING([for _ prefix in compiled symbols])
509 AC_CACHE_VAL(ac_cv_sys_symbol_underscore,
510 [ac_cv_sys_symbol_underscore=no
511 cat > conftest.$ac_ext <<EOF
512 void nm_test_func(){}
513 int main(){nm_test_func;return 0;}
514 EOF
515 if AC_TRY_EVAL(ac_compile); then
516   # Now try to grab the symbols.
517   ac_nlist=conftest.nm
518   if AC_TRY_EVAL(NM conftest.$ac_objext \| $ac_cv_sys_global_symbol_pipe \> $ac_nlist) && test -s "$ac_nlist"; then
519     # See whether the symbols have a leading underscore.
520     if egrep '^_nm_test_func' "$ac_nlist" >/dev/null; then
521       ac_cv_sys_symbol_underscore=yes
522     else
523       if egrep '^nm_test_func ' "$ac_nlist" >/dev/null; then
524         :
525       else
526         echo "configure: cannot find nm_test_func in $ac_nlist" >&AC_FD_CC
527       fi
528     fi
529   else
530     echo "configure: cannot run $ac_cv_sys_global_symbol_pipe" >&AC_FD_CC
531   fi
532 else
533   echo "configure: failed program was:" >&AC_FD_CC
534   cat conftest.c >&AC_FD_CC
535 fi
536 rm -rf conftest*
537 ])
538 AC_MSG_RESULT($ac_cv_sys_symbol_underscore)
539 if test x$ac_cv_sys_symbol_underscore = xyes; then
540   AC_DEFINE(WITH_SYMBOL_UNDERSCORE,1,
541   [define if compiled symbols have a leading underscore])
542 fi
543 ])
544
545 # Macro to add for using GNU gettext.
546 # Ulrich Drepper <drepper@cygnus.com>, 1995.
547 #
548 # Modified to never use included libintl. 
549 # Owen Taylor <otaylor@redhat.com>, 12/15/1998
550 #
551 #
552 # This file can be copied and used freely without restrictions.  It can
553 # be used in projects which are not available under the GNU Public License
554 # but which still want to provide support for the GNU gettext functionality.
555 # Please note that the actual code is *not* freely available.
556
557 # serial 5
558
559 AC_DEFUN(AM_GTK_WITH_NLS,
560   [AC_MSG_CHECKING([whether NLS is requested])
561     dnl Default is enabled NLS
562     AC_ARG_ENABLE(nls,
563       [  --disable-nls           do not use Native Language Support],
564       USE_NLS=$enableval, USE_NLS=yes)
565     AC_MSG_RESULT($USE_NLS)
566     AC_SUBST(USE_NLS)
567
568     USE_INCLUDED_LIBINTL=no
569
570     dnl If we use NLS figure out what method
571     if test "$USE_NLS" = "yes"; then
572       AC_DEFINE(ENABLE_NLS)
573 #      AC_MSG_CHECKING([whether included gettext is requested])
574 #      AC_ARG_WITH(included-gettext,
575 #        [  --with-included-gettext use the GNU gettext library included here],
576 #        nls_cv_force_use_gnu_gettext=$withval,
577 #        nls_cv_force_use_gnu_gettext=no)
578 #      AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
579       nls_cv_force_use_gnu_gettext="no"
580
581       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
582       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
583         dnl User does not insist on using GNU NLS library.  Figure out what
584         dnl to use.  If gettext or catgets are available (in this order) we
585         dnl use this.  Else we have to fall back to GNU NLS library.
586         dnl catgets is only used if permitted by option --with-catgets.
587         nls_cv_header_intl=
588         nls_cv_header_libgt=
589         CATOBJEXT=NONE
590
591         AC_CHECK_HEADER(libintl.h,
592           [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
593             [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
594                gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
595
596            if test "$gt_cv_func_gettext_libc" != "yes"; then
597              AC_CHECK_LIB(intl, bindtextdomain,
598                [AC_CACHE_CHECK([for gettext in libintl],
599                  gt_cv_func_gettext_libintl,
600                  [AC_CHECK_LIB(intl, gettext,
601                   gt_cv_func_gettext_libintl=yes,
602                   gt_cv_func_gettext_libintl=no)],
603                  gt_cv_func_gettext_libintl=no)])
604            fi
605
606            if test "$gt_cv_func_gettext_libc" = "yes" \
607               || test "$gt_cv_func_gettext_libintl" = "yes"; then
608               AC_DEFINE(HAVE_GETTEXT)
609               AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
610                 [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
611               if test "$MSGFMT" != "no"; then
612                 AC_CHECK_FUNCS(dcgettext)
613                 AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
614                 AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
615                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
616                 AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
617                                return _nl_msg_cat_cntr],
618                   [CATOBJEXT=.gmo
619                    DATADIRNAME=share],
620                   [CATOBJEXT=.mo
621                    DATADIRNAME=lib])
622                 INSTOBJEXT=.mo
623               fi
624             fi
625
626             # Added by Martin Baulig 12/15/98 for libc5 systems
627             if test "$gt_cv_func_gettext_libc" != "yes" \
628                && test "$gt_cv_func_gettext_libintl" = "yes"; then
629                INTLLIBS=-lintl
630                LIBS=`echo $LIBS | sed -e 's/-lintl//'`
631             fi
632         ])
633
634         if test "$CATOBJEXT" = "NONE"; then
635           AC_MSG_CHECKING([whether catgets can be used])
636           AC_ARG_WITH(catgets,
637             [  --with-catgets          use catgets functions if available],
638             nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
639           AC_MSG_RESULT($nls_cv_use_catgets)
640
641           if test "$nls_cv_use_catgets" = "yes"; then
642             dnl No gettext in C library.  Try catgets next.
643             AC_CHECK_LIB(i, main)
644             AC_CHECK_FUNC(catgets,
645               [AC_DEFINE(HAVE_CATGETS)
646                INTLOBJS="\$(CATOBJS)"
647                AC_PATH_PROG(GENCAT, gencat, no)dnl
648 #              if test "$GENCAT" != "no"; then
649 #                AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
650 #                if test "$GMSGFMT" = "no"; then
651 #                  AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
652 #                   [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
653 #                fi
654 #                AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
655 #                  [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
656 #                USE_INCLUDED_LIBINTL=yes
657 #                CATOBJEXT=.cat
658 #                INSTOBJEXT=.cat
659 #                DATADIRNAME=lib
660 #                INTLDEPS='$(top_builddir)/intl/libintl.a'
661 #                INTLLIBS=$INTLDEPS
662 #                LIBS=`echo $LIBS | sed -e 's/-lintl//'`
663 #                nls_cv_header_intl=intl/libintl.h
664 #                nls_cv_header_libgt=intl/libgettext.h
665 #              fi
666             ])
667           fi
668         fi
669
670         if test "$CATOBJEXT" = "NONE"; then
671           dnl Neither gettext nor catgets in included in the C library.
672           dnl Fall back on GNU gettext library.
673           nls_cv_use_gnu_gettext=yes
674         fi
675       fi
676
677       if test "$nls_cv_use_gnu_gettext" != "yes"; then
678         AC_DEFINE(ENABLE_NLS)
679 #      else
680 #        dnl Mark actions used to generate GNU NLS library.
681 #        INTLOBJS="\$(GETTOBJS)"
682 #        AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
683 #         [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
684 #        AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
685 #        AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
686 #         [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
687 #        AC_SUBST(MSGFMT)
688 #       USE_INCLUDED_LIBINTL=yes
689 #        CATOBJEXT=.gmo
690 #        INSTOBJEXT=.mo
691 #        DATADIRNAME=share
692 #       INTLDEPS='$(top_builddir)/intl/libintl.a'
693 #       INTLLIBS=$INTLDEPS
694 #       LIBS=`echo $LIBS | sed -e 's/-lintl//'`
695 #        nls_cv_header_intl=intl/libintl.h
696 #        nls_cv_header_libgt=intl/libgettext.h
697       fi
698
699       dnl Test whether we really found GNU xgettext.
700       if test "$XGETTEXT" != ":"; then
701         dnl If it is no GNU xgettext we define it as : so that the
702         dnl Makefiles still can work.
703         if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
704           : ;
705         else
706           AC_MSG_RESULT(
707             [found xgettext program is not GNU xgettext; ignore it])
708           XGETTEXT=":"
709         fi
710       fi
711
712       # We need to process the po/ directory.
713       POSUB=po
714     else
715       DATADIRNAME=share
716       nls_cv_header_intl=intl/libintl.h
717       nls_cv_header_libgt=intl/libgettext.h
718     fi
719     AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
720     AC_OUTPUT_COMMANDS(
721      [case "$CONFIG_FILES" in *po/Makefile.in*)
722         sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
723       esac])
724
725
726 #    # If this is used in GNU gettext we have to set USE_NLS to `yes'
727 #    # because some of the sources are only built for this goal.
728 #    if test "$PACKAGE" = gettext; then
729 #      USE_NLS=yes
730 #      USE_INCLUDED_LIBINTL=yes
731 #    fi
732
733     dnl These rules are solely for the distribution goal.  While doing this
734     dnl we only have to keep exactly one list of the available catalogs
735     dnl in configure.in.
736     for lang in $ALL_LINGUAS; do
737       GMOFILES="$GMOFILES $lang.gmo"
738       POFILES="$POFILES $lang.po"
739     done
740
741     dnl Make all variables we use known to autoconf.
742     AC_SUBST(USE_INCLUDED_LIBINTL)
743     AC_SUBST(CATALOGS)
744     AC_SUBST(CATOBJEXT)
745     AC_SUBST(DATADIRNAME)
746     AC_SUBST(GMOFILES)
747     AC_SUBST(INSTOBJEXT)
748     AC_SUBST(INTLDEPS)
749     AC_SUBST(INTLLIBS)
750     AC_SUBST(INTLOBJS)
751     AC_SUBST(POFILES)
752     AC_SUBST(POSUB)
753   ])
754
755 AC_DEFUN(AM_GTK_GNU_GETTEXT,
756   [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
757    AC_REQUIRE([AC_PROG_CC])dnl
758    AC_REQUIRE([AC_PROG_RANLIB])dnl
759    AC_REQUIRE([AC_ISC_POSIX])dnl
760    AC_REQUIRE([AC_HEADER_STDC])dnl
761    AC_REQUIRE([AC_C_CONST])dnl
762    AC_REQUIRE([AC_C_INLINE])dnl
763    AC_REQUIRE([AC_TYPE_OFF_T])dnl
764    AC_REQUIRE([AC_TYPE_SIZE_T])dnl
765    AC_REQUIRE([AC_FUNC_ALLOCA])dnl
766    AC_REQUIRE([AC_FUNC_MMAP])dnl
767
768    AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
769 unistd.h sys/param.h])
770    AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
771 strdup __argz_count __argz_stringify __argz_next])
772
773    if test "${ac_cv_func_stpcpy+set}" != "set"; then
774      AC_CHECK_FUNCS(stpcpy)
775    fi
776    if test "${ac_cv_func_stpcpy}" = "yes"; then
777      AC_DEFINE(HAVE_STPCPY)
778    fi
779
780    AM_LC_MESSAGES
781    AM_GTK_WITH_NLS
782
783    if test "x$CATOBJEXT" != "x"; then
784      if test "x$ALL_LINGUAS" = "x"; then
785        LINGUAS=
786      else
787        AC_MSG_CHECKING(for catalogs to be installed)
788        NEW_LINGUAS=
789        for lang in ${LINGUAS=$ALL_LINGUAS}; do
790          case "$ALL_LINGUAS" in
791           *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
792          esac
793        done
794        LINGUAS=$NEW_LINGUAS
795        AC_MSG_RESULT($LINGUAS)
796      fi
797
798      dnl Construct list of names of catalog files to be constructed.
799      if test -n "$LINGUAS"; then
800        for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
801      fi
802    fi
803
804    dnl The reference to <locale.h> in the installed <libintl.h> file
805    dnl must be resolved because we cannot expect the users of this
806    dnl to define HAVE_LOCALE_H.
807    if test $ac_cv_header_locale_h = yes; then
808      INCLUDE_LOCALE_H="#include <locale.h>"
809    else
810      INCLUDE_LOCALE_H="\
811 /* The system does not provide the header <locale.h>.  Take care yourself.  */"
812    fi
813    AC_SUBST(INCLUDE_LOCALE_H)
814
815    dnl Determine which catalog format we have (if any is needed)
816    dnl For now we know about two different formats:
817    dnl   Linux libc-5 and the normal X/Open format
818    test -d intl || mkdir intl
819    if test "$CATOBJEXT" = ".cat"; then
820      AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
821
822      dnl Transform the SED scripts while copying because some dumb SEDs
823      dnl cannot handle comments.
824      sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
825    fi
826    dnl po2tbl.sed is always needed.
827    sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
828      $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
829
830    dnl In the intl/Makefile.in we have a special dependency which makes
831    dnl only sense for gettext.  We comment this out for non-gettext
832    dnl packages.
833    if test "$PACKAGE" = "gettext"; then
834      GT_NO="#NO#"
835      GT_YES=
836    else
837      GT_NO=
838      GT_YES="#YES#"
839    fi
840    AC_SUBST(GT_NO)
841    AC_SUBST(GT_YES)
842
843    dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
844    dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
845    dnl Try to locate is.
846    MKINSTALLDIRS=
847    if test -n "$ac_aux_dir"; then
848      MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
849    fi
850    if test -z "$MKINSTALLDIRS"; then
851      MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
852    fi
853    AC_SUBST(MKINSTALLDIRS)
854
855    dnl *** For now the libtool support in intl/Makefile is not for real.
856    l=
857    AC_SUBST(l)
858
859    dnl Generate list of files to be processed by xgettext which will
860    dnl be included in po/Makefile.
861    test -d po || mkdir po
862    if test "x$srcdir" != "x."; then
863      if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
864        posrcprefix="$srcdir/"
865      else
866        posrcprefix="../$srcdir/"
867      fi
868    else
869      posrcprefix="../"
870    fi
871    rm -f po/POTFILES
872    sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
873         < $srcdir/po/POTFILES.in > po/POTFILES
874   ])
875