* FvwmScript/FvwmScript.1.in (following): Clarify description of
[fvwm.git] / acinclude.m4
blobd066a6f46a2cc376bffc20076838caccfac56a25
1 dnl Convenience macros
4 dnl new version of FUNC_SELECT
5 dnl - submitted to autoconf maintainer; expected to appear in next version
7 AC_DEFUN(AC_FUNC_SELECT,
8 [AC_CHECK_FUNCS(select)
9 if test "$ac_cv_func_select" = yes; then
10   AC_CHECK_HEADERS(unistd.h sys/types.h sys/time.h sys/select.h sys/socket.h)
11   AC_MSG_CHECKING([argument types of select()])
12   AC_CACHE_VAL(ac_cv_type_fd_set_size_t,dnl
13     [AC_CACHE_VAL(ac_cv_type_fd_set,dnl
14       [for ac_cv_type_fd_set in 'fd_set' 'int' 'void'; do
15         for ac_cv_type_fd_set_size_t in 'int' 'size_t' 'unsigned long' 'unsigned'; do
16           for ac_type_timeval in 'struct timeval' 'const struct timeval'; do
17             AC_TRY_COMPILE(dnl
18 [#ifdef HAVE_SYS_TIME_H
19 #include <sys/time.h>
20 #endif
21 #ifdef HAVE_SYS_TYPES_H
22 #include <sys/types.h>
23 #endif
24 #ifdef HAVE_UNISTD_H
25 #include <unistd.h>
26 #endif
27 #ifdef HAVE_SYS_SELECT_H
28 #include <sys/select.h>
29 #endif
30 #ifdef HAVE_SYS_SOCKET_H
31 #include <sys/socket.h>
32 #endif],
33 [extern select ($ac_cv_type_fd_set_size_t,
34  $ac_cv_type_fd_set *,  $ac_cv_type_fd_set *, $ac_cv_type_fd_set *,
35  $ac_type_timeval *);],
36 [ac_found=yes ; break 3],ac_found=no)
37           done
38         done
39       done
40     ])dnl AC_CACHE_VAL
41   ])dnl AC_CACHE_VAL
42   if test "$ac_found" = no; then
43     AC_MSG_ERROR([can't determine argument types])
44   fi
46   AC_MSG_RESULT([select($ac_cv_type_fd_set_size_t,$ac_cv_type_fd_set *,...)])
47   AC_DEFINE_UNQUOTED(fd_set_size_t, $ac_cv_type_fd_set_size_t)
48   ac_cast=
49   if test "$ac_cv_type_fd_set" != fd_set; then
50     # Arguments 2-4 are not fd_set.  Some weirdo systems use fd_set type for
51     # FD_SET macros, but insist that you cast the argument to select.  I don't
52     # understand why that might be, but it means we cannot define fd_set.
53     AC_EGREP_CPP(dnl
54 changequote(<<,>>)dnl
55 <<(^|[^a-zA-Z_0-9])fd_set[^a-zA-Z_0-9]>>dnl
56 changequote([,]),dnl
57 [#ifdef HAVE_SYS_TIME_H
58 #include <sys/time.h>
59 #endif
60 #ifdef HAVE_SYS_TYPES_H
61 #include <sys/types.h>
62 #endif
63 #ifdef HAVE_UNISTD_H
64 #include <unistd.h>
65 #endif
66 #ifdef HAVE_SYS_SELECT_H
67 #include <sys/select.h>
68 #endif
69 #ifdef HAVE_SYS_SOCKET_H
70 #include <sys/socket.h>
71 #endif],dnl
72     # We found fd_set type in a header, need special cast
73     ac_cast="($ac_cv_type_fd_set *)",dnl
74     # No fd_set type; it is safe to define it
75     AC_DEFINE_UNQUOTED(fd_set,$ac_cv_type_fd_set))
76   fi
77   AC_DEFINE_UNQUOTED(SELECT_FD_SET_CAST,$ac_cast)
83 dnl Checking for typedefs, with extra headers
86 dnl pds_CHECK_TYPE(TYPE, DEFAULT, [HEADERS])
87 AC_DEFUN(pds_CHECK_TYPE,
88 [AC_REQUIRE([AC_HEADER_STDC])dnl
89 AC_MSG_CHECKING(for $1)
90 AC_CACHE_VAL(ac_cv_type_$1,
91 [AC_EGREP_CPP(dnl
92 changequote(<<,>>)dnl
93 <<(^|[^a-zA-Z_0-9])$1[^a-zA-Z_0-9]>>dnl
94 changequote([,]), [#include <sys/types.h>
95 #if STDC_HEADERS
96 #include <stdlib.h>
97 #include <stddef.h>
98 #endif
99 $3], ac_cv_type_$1=yes, ac_cv_type_$1=no)])dnl
100 AC_MSG_RESULT($ac_cv_type_$1)
101 if test $ac_cv_type_$1 = no; then
102   AC_DEFINE($1, $2)
107 dnl Configure-time switch with default
109 dnl Each switch defines an --enable-FOO and --disable-FOO option in
110 dnl the resulting configure script.
112 dnl Usage:
113 dnl smr_SWITCH(name, description, default, pos-def, neg-def)
115 dnl where:
117 dnl name        name of switch; generates --enable-name & --disable-name
118 dnl             options
119 dnl description help string is set to this prefixed by "enable" or
120 dnl             "disable", whichever is the non-default value
121 dnl default     either "on" or "off"; specifies default if neither
122 dnl             --enable-name nor --disable-name is specified
123 dnl pos-def     a symbol to AC_DEFINE if switch is on (optional)
124 dnl neg-def     a symbol to AC_DEFINE if switch is off (optional)
126 AC_DEFUN(smr_SWITCH, [
127     AC_MSG_CHECKING(whether to enable $2)
128     AC_ARG_ENABLE(
129         $1,
130         ifelse($3, on,
131             [  --disable-[$1]m4_substr([             ], m4_len([$1])) disable [$2]],
132             [  --enable-[$1] m4_substr([             ], m4_len([$1])) enable [$2]]),
133         [ if test "$enableval" = yes; then
134             AC_MSG_RESULT(yes)
135             ifelse($4, , , [AC_DEFINE($4)])
136         else
137             AC_MSG_RESULT(no)
138             ifelse($5, , , [AC_DEFINE($5)])
139         fi ],
140         ifelse($3, on,
141            [ AC_MSG_RESULT(yes)
142             ifelse($4, , , [AC_DEFINE($4)]) ],
143            [ AC_MSG_RESULT(no)
144             ifelse($5, , , [AC_DEFINE($5)])]))])
147 dnl Allow argument for optional libraries; wraps AC_ARG_WITH, to
148 dnl provide a "--with-foo-library" option in the configure script, where foo
149 dnl is presumed to be a library name.  The argument given by the user
150 dnl (i.e. "bar" in ./configure --with-foo-library=bar) may be one of three
151 dnl things:
152 dnl     * boolean (no, yes or blank): whether to use library or not
153 dnl     * file: assumed to be the name of the library
154 dnl     * directory: assumed to *contain* the library
156 dnl The argument is sanity-checked.  If all is well, two variables are
157 dnl set: "with_foo" (value is yes, no, or maybe), and "foo_LIBS" (value
158 dnl is either blank, a file, -lfoo, or '-L/some/dir -lfoo').  The idea
159 dnl is: the first tells you whether the library is to be used or not
160 dnl (or the user didn't specify one way or the other) and the second
161 dnl to put on the command line for linking with the library.
163 dnl Usage:
164 dnl smr_ARG_WITHLIB(name, libname, description)
166 dnl name                name for --with argument ("foo" for libfoo)
167 dnl libname             (optional) actual name of library,
168 dnl                     if different from name
169 dnl description         (optional) used to construct help string
171 AC_DEFUN(smr_ARG_WITHLIB, [
173 ifelse($2, , smr_lib=[$1], smr_lib=[$2])
175 AC_ARG_WITH([$1]-library,
176 ifelse($3, ,
177 [  --with-$1-library[=PATH]  use $1 library],
178 [  --with-$1-library[=PATH]  use $1 library ($3)]),
180     if test "$withval" = yes; then
181         with_[$1]=yes
182         [$1]_LIBS="-l${smr_lib}"
183     elif test "$withval" = no; then
184         with_[$1]=no
185         [$1]_LIBS=
186     else
187         with_[$1]=yes
188         if test -f "$withval"; then
189             [$1]_LIBS=$withval
190         elif test -d "$withval"; then
191             [$1]_LIBS="-L$withval -l${smr_lib}"
192         else
193             AC_MSG_ERROR([--with-$1-library argument must be yes/no, file or directory])
194         fi
195     fi
196 ], [
197     with_[$1]=maybe
198     [$1]_LIBS="-l${smr_lib}"
199 ])])
202 dnl Check if the include files for a library are accessible, and
203 dnl define the variable "name_CFLAGS" with the proper "-I" flag for
204 dnl the compiler.  The user has a chance to specify the includes
205 dnl location, using "--with-foo-includes".
207 dnl This should be used *after* smr_ARG_WITHLIB *and* AC_CHECK_LIB are
208 dnl successful.
210 dnl Usage:
211 dnl smr_ARG_WITHINCLUDES(name, header, extra-flags)
213 dnl name                library name, MUST same as used with smr_ARG_WITHLIB
214 dnl header              a header file required for using the lib
215 dnl extra-flags         (optional) flags required when compiling the
216 dnl                     header, typically more includes; for ex. X_CFLAGS
218 AC_DEFUN(smr_ARG_WITHINCLUDES, [
220 AC_ARG_WITH([$1]-includes,
221 [  --with-$1-includes=DIR  set directory for $1 headers],
223     if test -d "$withval"; then
224         [$1]_CFLAGS="-I${withval}"
225     else
226         AC_MSG_ERROR([argument must be a directory])
227     fi])
229     dnl We need to put the given include directory into CPPFLAGS temporarily, but
230     dnl then restore CPPFLAGS to its old value.
231     dnl
232     smr_save_CPPFLAGS="$CPPFLAGS"
233     CPPFLAGS="$CPPFLAGS ${[$1]_CFLAGS}"
234     ifelse($3, , , CPPFLAGS="$CPPFLAGS [$3]")
236     AC_CHECK_HEADERS($2)
238     CPPFLAGS=$smr_save_CPPFLAGS
242 dnl Probe for an optional library.  This macro creates both
243 dnl --with-foo-library and --with-foo-includes options for the configure
244 dnl script.  If --with-foo-library is *not* specified, the default is to
245 dnl probe for the library, and use it if found.
247 dnl Usage:
248 dnl smr_CHECK_LIB(name, libname, desc, func, header, x-libs, x-flags)
250 dnl name        name for --with options
251 dnl libname     (optional) real name of library, if different from
252 dnl             above
253 dnl desc        (optional) short descr. of library, for help string
254 dnl func        function of library, to probe for
255 dnl header      (optional) header required for using library
256 dnl x-libs      (optional) extra libraries, if needed to link with lib
257 dnl x-flags     (optional) extra flags, if needed to include header files
259 AC_DEFUN(smr_CHECK_LIB,
261 ifelse($2, , smr_lib=[$1], smr_lib=[$2])
262 ifelse($5, , , smr_header=[$5])
263 smr_ARG_WITHLIB($1,$2,$3)
264 if test "$with_$1" != no; then
265     AC_CHECK_LIB(ifelse($2, , $1, $2), $4,
266         smr_havelib=yes,
267         smr_havelib=no; problem_$1=": Can't find working lib$smr_lib",
268         ifelse($6, , ${$1_LIBS}, [${$1_LIBS} $6]))
269     if test "$smr_havelib" = yes -a "$smr_header" != ""; then
270         smr_ARG_WITHINCLUDES($1, $smr_header, $7)
271         smr_safe=`echo "$smr_header" | sed 'y%./+-%__p_%'`
272         if eval "test \"`echo '$ac_cv_header_'$smr_safe`\" != yes"; then
273             smr_havelib=no
274             problem_$1=": Can't find working $smr_header"
275         fi
276     fi
277     if test "$smr_havelib" = yes; then
278         with_$1=yes
279         problem_$1=
280     else
281         $1_LIBS=
282         $1_CFLAGS=
283         with_$1=no
284     fi
285 else
286     problem_$1=": Explicitly disabled"
287 fi])
290 dnl Defines a boolean variable good for acconfig.h depending on a condition.
292 dnl Usage:
293 dnl mg_DEFINE_IF_NOT(c-code, cpp-if-cond, var-name, extra-flags)
295 dnl c-code       the first code part inside main()
296 dnl cpp-if-cond  boolean preprocessor condition
297 dnl var-name     this variable will be defined if the given condition is false
298 dnl extra-flags  (optional) extra flags for compiling, typically more -I glags
300 dnl Example:
301 dnl mg_DEFINE_IF_NOT([#include <features.h>], [defined __USE_BSD], [NON_BSD])
303 AC_DEFUN(mg_DEFINE_IF_NOT, [
304 mg_save_CPPFLAGS="$CPPFLAGS"
305 ifelse($4, , , CPPFLAGS="$CPPFLAGS [$4]")
307 AC_TRY_RUN([
308 #include <stdio.h>
309 int main(int c, char **v) {
311 #if $2
312   return 0;
313 #else
314   return 1;
315 #endif
317 ], [:], [AC_DEFINE($3)])
319 CPPFLAGS="$mg_save_CPPFLAGS"
323 dnl --------------------------------------------------------------------------
324 dnl contents of gtk.m4
326 # Configure paths for GTK+
327 # Owen Taylor     97-11-3
329 dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
330 dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
332 AC_DEFUN(AM_PATH_GTK,
333 [dnl
334 dnl Get the cflags and libraries from the gtk-config script
336 AC_ARG_WITH(gtk-prefix,[  --with-gtk-prefix=PFX   prefix for GTK files (optional)],
337             gtk_config_prefix="$withval", gtk_config_prefix="")
338 AC_ARG_WITH(gtk-exec-prefix,[  --with-gtk-exec-prefix=PFX  exec prefix for GTK files (optional)],
339             gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
340 AC_ARG_ENABLE(gtktest, [  --disable-gtktest       do not try to compile and run a test GTK program],
341                     , enable_gtktest=yes)
343   if test x$gtk_config_exec_prefix != x ; then
344      gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
345      if test x${GTK_CONFIG+set} != xset ; then
346         GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
347      fi
348   fi
349   if test x$gtk_config_prefix != x ; then
350      gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
351      if test x${GTK_CONFIG+set} != xset ; then
352         GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
353      fi
354   fi
356   AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
357   min_gtk_version=ifelse([$1], ,0.99.7,$1)
358   AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
359   no_gtk=""
360   if test "$GTK_CONFIG" = "no" ; then
361     no_gtk=yes
362   else
363     GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
364     GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
365     gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
366            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
367     gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
368            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
369     gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
370            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
371     if test "x$enable_gtktest" = "xyes" ; then
372       ac_save_CFLAGS="$CFLAGS"
373       ac_save_LIBS="$LIBS"
374       CFLAGS="$CFLAGS $GTK_CFLAGS"
375       LIBS="$LIBS $GTK_LIBS"
377 dnl Now check if the installed GTK is sufficiently new. (Also sanity
378 dnl checks the results of gtk-config to some extent
380       rm -f conf.gtktest
381       AC_TRY_RUN([
382 #include <gtk/gtk.h>
383 #include <stdio.h>
384 #include <stdlib.h>
387 main ()
389   int major, minor, micro;
390   char *tmp_version;
392   system ("touch conf.gtktest");
394   /* HP/UX 9 (%@#!) writes to sscanf strings */
395   tmp_version = g_strdup("$min_gtk_version");
396   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
397      printf("%s, bad version string\n", "$min_gtk_version");
398      exit(1);
399    }
401   if ((gtk_major_version != $gtk_config_major_version) ||
402       (gtk_minor_version != $gtk_config_minor_version) ||
403       (gtk_micro_version != $gtk_config_micro_version))
404     {
405       printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
406              $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
407              gtk_major_version, gtk_minor_version, gtk_micro_version);
408       printf ("*** was found! If gtk-config was correct, then it is best\n");
409       printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
410       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
411       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
412       printf("*** required on your system.\n");
413       printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
414       printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
415       printf("*** before re-running configure\n");
416     }
417 #if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
418   else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
419            (gtk_minor_version != GTK_MINOR_VERSION) ||
420            (gtk_micro_version != GTK_MICRO_VERSION))
421     {
422       printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
423              GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
424       printf("*** library (version %d.%d.%d)\n",
425              gtk_major_version, gtk_minor_version, gtk_micro_version);
426     }
427 #endif /* defined (GTK_MAJOR_VERSION) ... */
428   else
429     {
430       if ((gtk_major_version > major) ||
431         ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
432         ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
433       {
434         return 0;
435        }
436      else
437       {
438         printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
439                gtk_major_version, gtk_minor_version, gtk_micro_version);
440         printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
441                major, minor, micro);
442         printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
443         printf("***\n");
444         printf("*** If you have already installed a sufficiently new version, this error\n");
445         printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
446         printf("*** being found. The easiest way to fix this is to remove the old version\n");
447         printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
448         printf("*** correct copy of gtk-config. (In this case, you will have to\n");
449         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
450         printf("*** so that the correct libraries are found at run-time))\n");
451       }
452     }
453   return 1;
455 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
456        CFLAGS="$ac_save_CFLAGS"
457        LIBS="$ac_save_LIBS"
458      fi
459   fi
460   if test "x$no_gtk" = x ; then
461      AC_MSG_RESULT(yes)
462      ifelse([$2], , :, [$2])
463   else
464      AC_MSG_RESULT(no)
465      if test "$GTK_CONFIG" = "no" ; then
466        echo "*** The gtk-config script installed by GTK could not be found"
467        echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
468        echo "*** your path, or set the GTK_CONFIG environment variable to the"
469        echo "*** full path to gtk-config."
470      else
471        if test -f conf.gtktest ; then
472         :
473        else
474           echo "*** Could not run GTK test program, checking why..."
475           CFLAGS="$CFLAGS $GTK_CFLAGS"
476           LIBS="$LIBS $GTK_LIBS"
477           AC_TRY_LINK([
478 #include <gtk/gtk.h>
479 #include <stdio.h>
480 ],      [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
481         [ echo "*** The test program compiled, but did not run. This usually means"
482           echo "*** that the run-time linker is not finding GTK or finding the wrong"
483           echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
484           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
485           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
486           echo "*** is required on your system"
487           echo "***"
488           echo "*** If you have an old version installed, it is best to remove it, although"
489           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
490           echo "***"
491           echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
492           echo "*** came with the system with the command"
493           echo "***"
494           echo "***    rpm --erase --nodeps gtk gtk-devel" ],
495         [ echo "*** The test program failed to compile or link. See the file config.log for the"
496           echo "*** exact error that occured. This usually means GTK was incorrectly installed"
497           echo "*** or that you have moved GTK since it was installed. In the latter case, you"
498           echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
499           CFLAGS="$ac_save_CFLAGS"
500           LIBS="$ac_save_LIBS"
501        fi
502      fi
503      GTK_CFLAGS=""
504      GTK_LIBS=""
505      ifelse([$3], , :, [$3])
506   fi
507   AC_SUBST(GTK_CFLAGS)
508   AC_SUBST(GTK_LIBS)
509   rm -f conf.gtktest
513 dnl --------------------------------------------------------------------------
514 dnl contents of imlib.m4
515 dnl modified by migo - write diagnostics to >&5 (i.e. config.log) not stdout
517 # Configure paths for IMLIB
518 # Frank Belew     98-8-31
519 # stolen from Manish Singh
520 # Shamelessly stolen from Owen Taylor
522 dnl AM_PATH_IMLIB([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
523 dnl Test for IMLIB, and define IMLIB_CFLAGS and IMLIB_LIBS
525 AC_DEFUN(AM_PATH_IMLIB,
526 [dnl
527 dnl Get the cflags and libraries from the imlib-config script
529 AC_ARG_WITH(imlib-prefix,[  --with-imlib-prefix=PFX prefix for IMLIB files (optional)],
530             imlib_prefix="$withval", imlib_prefix="")
531 AC_ARG_WITH(imlib-exec-prefix,[  --with-imlib-exec-prefix=PFX  exec prefix for IMLIB files (optional)],
532             imlib_exec_prefix="$withval", imlib_exec_prefix="")
533 AC_ARG_ENABLE(imlibtest, [  --disable-imlibtest     do not try to compile and run a test IMLIB program],
534             , enable_imlibtest=yes)
536   if test x$imlib_exec_prefix != x ; then
537      imlib_args="$imlib_args --exec-prefix=$imlib_exec_prefix"
538      if test x${IMLIBCONF+set} != xset ; then
539         IMLIBCONF=$imlib_exec_prefix/bin/imlib-config
540      fi
541   fi
542   if test x$imlib_prefix != x ; then
543      imlib_args="$imlib_args --prefix=$imlib_prefix"
544      if test x${IMLIBCONF+set} != xset ; then
545         IMLIBCONF=$imlib_prefix/bin/imlib-config
546      fi
547   fi
549   AC_PATH_PROG(IMLIBCONF, imlib-config, no)
550   min_imlib_version=ifelse([$1], ,1.8.1,$1)
551   AC_MSG_CHECKING(for IMLIB - version >= $min_imlib_version)
552   no_imlib=""
553   if test "$IMLIBCONF" = "no" ; then
554     no_imlib=yes
555   else
556     IMLIB_CFLAGS=`$IMLIBCONF $imlibconf_args --cflags`
557     IMLIB_LIBS=`$IMLIBCONF $imlibconf_args --libs`
559     imlib_major_version=`$IMLIBCONF $imlib_args --version | \
560            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
561     imlib_minor_version=`$IMLIBCONF $imlib_args --version | \
562            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
563     if test "x$enable_imlibtest" = "xyes" ; then
564       ac_save_CFLAGS="$CFLAGS"
565       ac_save_LIBS="$LIBS"
566       CFLAGS="$CFLAGS $IMLIB_CFLAGS"
567       LIBS="$LIBS $IMLIB_LIBS"
569 dnl Now check if the installed IMLIB is sufficiently new. (Also sanity
570 dnl checks the results of imlib-config to some extent
572       rm -f conf.imlibtest
573       AC_TRY_RUN([
574 #include <stdio.h>
575 #include <stdlib.h>
576 #include <Imlib.h>
578 ImlibImage testimage;
580 int main ()
582   int major, minor;
583   char *tmp_version;
585   system ("touch conf.imlibtest");
587   /* HP/UX 9 (%@#!) writes to sscanf strings */
588   tmp_version = strdup("$min_imlib_version");
589   if (sscanf(tmp_version, "%d.%d", &major, &minor) != 2) {
590      printf("%s, bad version string\n", "$min_imlib_version");
591      exit(1);
592    }
594     if (($imlib_major_version > major) ||
595         (($imlib_major_version == major) && ($imlib_minor_version > minor)))
596     {
597       return 0;
598     }
599   else
600     {
601       printf("\n*** 'imlib-config --version' returned %d.%d, but the minimum version\n", $imlib_major_version, $imlib_minor_version);
602       printf("*** of IMLIB required is %d.%d. If imlib-config is correct, then it is\n", major, minor);
603       printf("*** best to upgrade to the required version.\n");
604       printf("*** If imlib-config was wrong, set the environment variable IMLIBCONF\n");
605       printf("*** to point to the correct copy of imlib-config, and remove the file\n");
606       printf("*** config.cache before re-running configure\n");
607       return 1;
608     }
611 ],, no_imlib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
612        CFLAGS="$ac_save_CFLAGS"
613        LIBS="$ac_save_LIBS"
614      fi
615   fi
616   if test "x$no_imlib" = x ; then
617      AC_MSG_RESULT(yes)
618      ifelse([$2], , :, [$2])
619   else
620      AC_MSG_RESULT(no)
621      if test "$IMLIBCONF" = "no" ; then
622        echo "*** The imlib-config script installed by IMLIB could not be found"
623        echo "*** If IMLIB was installed in PREFIX, make sure PREFIX/bin is in"
624        echo "*** your path, or set the IMLIBCONF environment variable to the"
625        echo "*** full path to imlib-config."
626      else
627        if test -f conf.imlibtest ; then
628         :
629        else
630           echo "*** Could not run IMLIB test program, checking why..."
631           CFLAGS="$CFLAGS $IMLIB_CFLAGS"
632           LIBS="$LIBS $IMLIB_LIBS"
633           AC_TRY_LINK([
634 #include <stdio.h>
635 #include <Imlib.h>
636 ],      [ return 0; ],
637         [ echo "*** The test program compiled, but did not run. This usually means"
638           echo "*** that the run-time linker is not finding IMLIB or finding the wrong"
639           echo "*** version of IMLIB. If it is not finding IMLIB, you'll need to set your"
640           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
641           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
642           echo "*** is required on your system"
643           echo "***"
644           echo "*** If you have an old version installed, it is best to remove it, although"
645           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
646         [ echo "*** The test program failed to compile or link. See the file config.log for the"
647           echo "*** exact error that occured. This usually means IMLIB was incorrectly installed"
648           echo "*** or that you have moved IMLIB since it was installed. In the latter case, you"
649           echo "*** may want to edit the imlib-config script: $IMLIBCONF" ])
650           CFLAGS="$ac_save_CFLAGS"
651           LIBS="$ac_save_LIBS"
652        fi
653      fi
654      IMLIB_CFLAGS=""
655      IMLIB_LIBS=""
656      ifelse([$3], , :, [$3])
657   fi
658   AC_SUBST(IMLIB_CFLAGS)
659   AC_SUBST(IMLIB_LIBS)
660   rm -f conf.imlibtest
663 # Check for gdk-imlib
664 AC_DEFUN(AM_PATH_GDK_IMLIB,
665 [dnl
666 dnl Get the cflags and libraries from the imlib-config script
668 AC_ARG_WITH(imlib-prefix,[  --with-imlib-prefix=PFX prefix for IMLIB files (optional)],
669             imlib_prefix="$withval", imlib_prefix="")
670 AC_ARG_WITH(imlib-exec-prefix,[  --with-imlib-exec-prefix=PFX  exec prefix for IMLIB files (optional)],
671             imlib_exec_prefix="$withval", imlib_exec_prefix="")
672 AC_ARG_ENABLE(imlibtest, [  --disable-imlibtest     do not try to compile and run a test IMLIB program],
673             , enable_imlibtest=yes)
675   if test x$imlib_exec_prefix != x ; then
676      imlib_args="$imlib_args --exec-prefix=$imlib_exec_prefix"
677      if test x${IMLIBCONF+set} != xset ; then
678         IMLIBCONF=$imlib_exec_prefix/bin/imlib-config
679      fi
680   fi
681   if test x$imlib_prefix != x ; then
682      imlib_args="$imlib_args --prefix=$imlib_prefix"
683      if test x${IMLIBCONF+set} != xset ; then
684         IMLIBCONF=$imlib_prefix/bin/imlib-config
685      fi
686   fi
688   AC_PATH_PROG(IMLIBCONF, imlib-config, no)
689   min_imlib_version=ifelse([$1], ,1.8.1,$1)
690   AC_MSG_CHECKING(for GDK IMLIB - version >= $min_imlib_version)
691   no_imlib=""
692   if test "$IMLIBCONF" = "no" ; then
693     no_imlib=yes
694   else
695     GDK_IMLIB_CFLAGS=`$IMLIBCONF $imlibconf_args --cflags-gdk`
696     GDK_IMLIB_LIBS=`$IMLIBCONF $imlibconf_args --libs-gdk`
698     imlib_major_version=`$IMLIBCONF $imlib_args --version | \
699            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
700     imlib_minor_version=`$IMLIBCONF $imlib_args --version | \
701            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
702     if test "x$enable_imlibtest" = "xyes" ; then
703       ac_save_CFLAGS="$CFLAGS"
704       ac_save_LIBS="$LIBS"
705       CFLAGS="$CFLAGS $GDK_IMLIB_CFLAGS"
706       LIBS="$LIBS $GDK_IMLIB_LIBS"
708 dnl Now check if the installed IMLIB is sufficiently new. (Also sanity
709 dnl checks the results of imlib-config to some extent
711       rm -f conf.imlibtest
712       AC_TRY_RUN([
713 #include <stdio.h>
714 #include <stdlib.h>
715 #include <Imlib.h>
716 #include <gdk_imlib.h>
718 /* migo: originally it was GdkImLibColor with incorrect spelling */
719 GdkImlibImage testimage;
721 int main ()
723   int major, minor;
724   char *tmp_version;
726   system ("touch conf.gdkimlibtest");
728   /* HP/UX 9 (%@#!) writes to sscanf strings */
729   tmp_version = g_strdup("$min_imlib_version");
730   if (sscanf(tmp_version, "%d.%d", &major, &minor) != 2) {
731      printf("%s, bad version string\n", "$min_imlib_version");
732      exit(1);
733    }
735     if (($imlib_major_version > major) ||
736         (($imlib_major_version == major) && ($imlib_minor_version > minor)))
737     {
738       return 0;
739     }
740   else
741     {
742       printf("\n*** 'imlib-config --version' returned %d.%d, but the minimum version\n", $imlib_major_version, $imlib_minor_version);
743       printf("*** of IMLIB required is %d.%d. If imlib-config is correct, then it is\n", major, minor);
744       printf("*** best to upgrade to the required version.\n");
745       printf("*** If imlib-config was wrong, set the environment variable IMLIBCONF\n");
746       printf("*** to point to the correct copy of imlib-config, and remove the file\n");
747       printf("*** config.cache before re-running configure\n");
748       return 1;
749     }
752 ],, no_imlib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
753        CFLAGS="$ac_save_CFLAGS"
754        LIBS="$ac_save_LIBS"
755      fi
756   fi
757   if test "x$no_imlib" = x ; then
758      AC_MSG_RESULT(yes)
759      ifelse([$2], , :, [$2])
760   else
761      AC_MSG_RESULT(no)
762      if test "$IMLIBCONF" = "no" ; then
763                        (echo "*** The imlib-config script installed by IMLIB could not be found" >&5) 2>/dev/null || \
764        echo "*** The imlib-config script installed by IMLIB could not be found"
765                        (echo "*** If IMLIB was installed in PREFIX, make sure PREFIX/bin is in" >&5) 2>/dev/null || \
766        echo "*** If IMLIB was installed in PREFIX, make sure PREFIX/bin is in"
767                        (echo "*** your path, or set the IMLIBCONF environment variable to the" >&5) 2>/dev/null || \
768        echo "*** your path, or set the IMLIBCONF environment variable to the"
769                        (echo "*** full path to imlib-config." >&5) 2>/dev/null || \
770        echo "*** full path to imlib-config."
771      else
772        if test -f conf.gdkimlibtest ; then
773         :
774        else
775                           (echo "*** Could not run IMLIB test program, checking why..." >&5) 2>/dev/null || \
776           echo "*** Could not run IMLIB test program, checking why..."
777           CFLAGS="$CFLAGS $GDK_IMLIB_CFLAGS"
778           LIBS="$LIBS $GDK_IMLIB_LIBS"
779           AC_TRY_LINK([
780 #include <stdio.h>
781 #include <Imlib.h>
782 #include <gdk_imlib.h>
783 ],      [ return 0; ],
784         [                 (echo "*** The test program compiled, but did not run. This usually means" >&5) 2>/dev/null || \
785           echo "*** The test program compiled, but did not run. This usually means"
786                           (echo "*** that the run-time linker is not finding IMLIB or finding the wrong" >&5) 2>/dev/null || \
787           echo "*** that the run-time linker is not finding IMLIB or finding the wrong"
788                           (echo "*** version of IMLIB. If it is not finding IMLIB, you'll need to set your" >&5) 2>/dev/null || \
789           echo "*** version of IMLIB. If it is not finding IMLIB, you'll need to set your"
790                           (echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" >&5) 2>/dev/null || \
791           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
792                           (echo "*** to the installed location  Also, make sure you have run ldconfig if that" >&5) 2>/dev/null || \
793           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
794                           (echo "*** is required on your system" >&5) 2>/dev/null || \
795           echo "*** is required on your system"
796                           (echo "***" >&5) 2>/dev/null || \
797           echo "***"
798                           (echo "*** If you have an old version installed, it is best to remove it, although" >&5) 2>/dev/null || \
799           echo "*** If you have an old version installed, it is best to remove it, although"
800                           (echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" >&5) 2>/dev/null || \
801           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
802         [                 (echo "*** The test program failed to compile or link. See the file config.log for the" >&5) 2>/dev/null || \
803           echo "*** The test program failed to compile or link. See the file config.log for the"
804                           (echo "*** exact error that occured. This usually means IMLIB was incorrectly installed" >&5) 2>/dev/null || \
805           echo "*** exact error that occured. This usually means IMLIB was incorrectly installed"
806                           (echo "*** or that you have moved IMLIB since it was installed. In the latter case, you" >&5) 2>/dev/null || \
807           echo "*** or that you have moved IMLIB since it was installed. In the latter case, you"
808                           (echo "*** may want to edit the imlib-config script: $IMLIBCONF" >&5) 2>/dev/null || \
809           echo "*** may want to edit the imlib-config script: $IMLIBCONF"])
810           CFLAGS="$ac_save_CFLAGS"
811           LIBS="$ac_save_LIBS"
812        fi
813      fi
814      GDK_IMLIB_CFLAGS=""
815      GDK_IMLIB_LIBS=""
816      ifelse([$3], , :, [$3])
817   fi
818   AC_SUBST(GDK_IMLIB_CFLAGS)
819   AC_SUBST(GDK_IMLIB_LIBS)
820   rm -f conf.gdkimlibtest
824 dnl --------------------------------------------------------------------------
825 dnl from gnome.m4, modified by migo
828 dnl GNOME_INIT_HOOK (script-if-gnome-enabled, [failflag])
830 dnl if failflag is "fail" then GNOME_INIT_HOOK will abort if gnomeConf.sh
831 dnl is not found.
834 AC_DEFUN([GNOME_INIT_HOOK],[
835         AC_SUBST(GNOME_LIBS)
836         AC_SUBST(GNOMEUI_LIBS)
837         AC_SUBST(GNOME_LIBDIR)
838         AC_SUBST(GNOME_INCLUDEDIR)
840         AC_ARG_WITH(gnome-includes,
841         [  --with-gnome-includes   location of GNOME headers],[
842         CFLAGS="$CFLAGS -I$withval"
843         ])
845         gnome_prefix=$ac_default_prefix/lib
847         AC_ARG_WITH(gnome-libs,
848         [  --with-gnome-libs       location of GNOME libs],[
849         LDFLAGS="$LDFLAGS -L$withval"
850         gnome_prefix=$withval
851         ])
853         AC_ARG_WITH(gnome,
854         [  --with-gnome            no, yes or prefix for GNOME files (for FvwmGtk only)],
855                 if test x$withval = xyes; then
856                         with_gnomelibs=yes
857                         dnl Note that an empty true branch is not
858                         dnl valid sh syntax.
859                         ifelse([$1], [], :, [$1])
860                 else
861                         if test "x$withval" = xno; then
862                                 with_gnomelibs=no
863                                 problem_gnomelibs=": Explicitly disabled"
864                         else
865                                 with_gnomelibs=yes
866                                 LDFLAGS="$LDFLAGS -L$withval/lib"
867                                 CFLAGS="$CFLAGS -I$withval/include"
868                                 gnome_prefix=$withval/lib
869                         fi
870                 fi,
871                 with_gnomelibs=yes)
873         if test "x$with_gnomelibs" = xyes; then
874             problem_gnomelibs=": Can't find working gnome-config"
876             AC_PATH_PROG(GNOME_CONFIG,gnome-config,no)
877             if test "$GNOME_CONFIG" = "no"; then
878               no_gnome_config="yes"
879             else
880               AC_MSG_CHECKING(whether $GNOME_CONFIG works)
881               if $GNOME_CONFIG --libs-only-l gnome >/dev/null 2>&1; then
882                 AC_MSG_RESULT(yes)
883                 GNOME_LIBS="`$GNOME_CONFIG --libs-only-l gnome`"
884                 GNOMEUI_LIBS="`$GNOME_CONFIG --libs-only-l gnomeui`"
885                 GNOME_LIBDIR="`$GNOME_CONFIG --libs-only-L gnorba gnomeui`"
886                 GNOME_INCLUDEDIR="`$GNOME_CONFIG --cflags gnorba gnomeui`"
887                 $1
888               else
889                 AC_MSG_RESULT(no)
890                 no_gnome_config="yes"
891               fi
892             fi
894             # migo: disable this destructive logic
895 #           if test x$exec_prefix = xNONE; then
896 #               if test x$prefix = xNONE; then
897 #                   gnome_prefix=$ac_default_prefix/lib
898 #               else
899 #                   gnome_prefix=$prefix/lib
900 #               fi
901 #           else
902 #               gnome_prefix=`eval echo \`echo $libdir\``
903 #           fi
905             if test "$no_gnome_config" = "yes"; then
906               AC_MSG_CHECKING(for gnomeConf.sh file in $gnome_prefix)
907               if test -f $gnome_prefix/gnomeConf.sh; then
908                 AC_MSG_RESULT(found)
909                 echo "loading gnome configuration from" \
910                      "$gnome_prefix/gnomeConf.sh"
911                 . $gnome_prefix/gnomeConf.sh
912                 $1
913               else
914                 AC_MSG_RESULT(not found)
915                 if test x$2 = xfail; then
916                   AC_MSG_ERROR([Could not find the gnomeConf.sh file that is generated by gnome-libs install])
917                 fi
918                 with_gnomelibs=no
919               fi
920             fi
921         fi
923         # test whether gnome can be compiled
924         if test "x$with_gnomelibs" = xyes; then
925                 problem_gnomelibs=": Can't compile trivial gnome app"
927                 AC_MSG_CHECKING(whether trivial gnome compilation works)
928                 my_CPPFLAGS="$CPPFLAGS"
929                 my_LIBS="$LIBS"
930                 CPPFLAGS="$CPPFLAGS $GNOME_INCLUDEDIR $GTK_CFLAGS"
931                 LIBS="$LIBS $GNOME_LIBDIR $GNOMEUI_LIBS"
932                 AC_TRY_RUN([
933                         #include <gnome.h>
934                         int main(int c, char **v) {
935                                 /* we can't really run this outside of X */
936                                 if (!c) gnome_init("test-app", "0.0", c, v);
937                                 return 0;
938                         }],
939                         [with_gnomelibs=yes],
940                         [with_gnomelibs=no]
941                 )
942                 AC_MSG_RESULT($with_gnomelibs)
943                 CPPFLAGS="$my_CPPFLAGS"
944                 LIBS="$my_LIBS"
945         else
946                 # just for safety
947                 with_gnomelibs=no
948         fi
950         if test "x$with_gnomelibs" = xyes; then
951                 problem_gnomelibs=""
952         else
953                 GNOME_LIBS=
954                 GNOMEUI_LIBS=
955                 GNOME_LIBDIR=
956                 GNOME_INCLUDEDIR=
957         fi
961 # check if iconv second argument use const char.
963 AC_DEFUN([ICONV_SECOND_ARG],[
964         AC_MSG_CHECKING(check if second arg of iconv is const)
965         AC_TRY_COMPILE([
966 #include <stdlib.h>
967 #include <iconv.h>
968 extern
969 #if defined(__STDC__)
970 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
971 #else
972 size_t iconv();
973 #endif
974 ], [], use_const=no, use_const=yes)
975         AC_MSG_RESULT($use_const)
976         if test "x$use_const" = "xyes"; then
977                 AC_DEFINE(ICONV_ARG_CONST, const)
978         else
979                 AC_DEFINE(ICONV_ARG_CONST, )
980         fi
984 # check for  locale_charset if libiconv is used
986 AC_DEFUN([CHECK_LIBCHARSET],[
987         AC_MSG_CHECKING(check for libcharset)
988         ac_save_CFLAGS="$CFLAGS"
989         ac_save_LIBS="$LIBS"
990         CFLAGS="$CFLAGS $iconv_CFLAGS"
991         LIBS="$LIBS $iconv_LIBS"
992         AC_TRY_LINK([
993 #include <libcharset.h>],
994 [const char *c;
995 c = locale_charset ();
996 ], r=yes, r=no)
997         AC_MSG_RESULT($r)
998         if test "x$r" = "xyes"; then
999                 AC_DEFINE(HAVE_LIBCHARSET)
1000         fi
1001         CFLAGS="$ac_save_CFLAGS"
1002         LIBS="$ac_save_LIBS"
1005 #-----------------------------------------------------------------------------
1006 # pkg-config
1010 AC_DEFUN(AM_CHECK_PKG_CONFIG,
1011 [dnl
1012 dnl Get the cflags and libraries from the freetype-config script
1014 AC_ARG_WITH(pkgconfig-prefix,
1015 [  --with-pkgconfig-prefix=PFX  prefix where pkg-config is installed],
1016             pkgconfig_config_prefix="$withval", pkgconfig_config_prefix="")
1017 AC_ARG_WITH(pkgconfig-exec-prefix,
1018 [  --with-pkgconfig-exec-prefix=PFX  exec prefix where pkg-config is installed],
1019             pkgconfig_config_exec_prefix="$withval",pkgconfig_config_exec_prefix="")
1021 if test x$pkgconfig_config_exec_prefix != x ; then
1022   pkgconfig_config_args="$pkgconfig_config_args --exec-prefix=$pkgconfig_config_exec_prefix"
1023   if test x${PKG_CONFIG+set} != xset ; then
1024     PKG_CONFIG=$pkgconfig_config_exec_prefix/bin/pkg-config
1025   fi
1027 if test x$pkgconfig_config_prefix != x ; then
1028   pkgconfig_config_args="$pkgconfig_config_args --prefix=$pkgconfig_config_prefix"
1029   if test x${PKG_CONFIG+set} != xset ; then
1030     PKG_CONFIG=$pkgconfig_config_prefix/bin/pkg-config
1031   fi
1033 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
1036 #-----------------------------------------------------------------------------
1037 # Configure paths for FreeType2
1038 # Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor
1040 dnl AM_CHECK_FT2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
1041 dnl Test for FreeType2, and define FT2_CFLAGS and FT2_LIBS
1043 AC_DEFUN(AM_CHECK_FT2,
1044 [dnl
1045 dnl Get the cflags and libraries from the freetype-config script
1047 AC_ARG_WITH(freetype-prefix,
1048 [  --with-freetype-prefix=PFX  prefix where FreeType is installed (for Xft)],
1049             ft_config_prefix="$withval", ft_config_prefix="")
1050 AC_ARG_WITH(freetype-exec-prefix,
1051 [  --with-freetype-exec-prefix=PFX  exec prefix where FreeType is installed],
1052             ft_config_exec_prefix="$withval", ft_config_exec_prefix="")
1053 AC_ARG_ENABLE(freetypetest,
1054 [  --disable-freetypetest  do not try to compile and run a test FreeType program],
1055             [], enable_fttest=yes)
1057 if test x$ft_config_exec_prefix != x ; then
1058   ft_config_args="$ft_config_args --exec-prefix=$ft_config_exec_prefix"
1059   if test x${FT2_CONFIG+set} != xset ; then
1060     FT2_CONFIG=$ft_config_exec_prefix/bin/freetype-config
1061   fi
1063 if test x$ft_config_prefix != x ; then
1064   ft_config_args="$ft_config_args --prefix=$ft_config_prefix"
1065   if test x${FT2_CONFIG+set} != xset ; then
1066     FT2_CONFIG=$ft_config_prefix/bin/freetype-config
1067   fi
1069 AC_PATH_PROG(FT2_CONFIG, freetype-config, no)
1071 min_ft_version=ifelse([$1], ,6.1.0,$1)
1072 AC_MSG_CHECKING(for FreeType - version >= $min_ft_version)
1073 no_ft=""
1074 if test "$FT2_CONFIG" = "no" ; then
1075   no_ft=yes
1076 else
1077   FT2_CFLAGS=`$FT2_CONFIG $ft_config_args --cflags`
1078   FT2_LIBS=`$FT2_CONFIG $ft_config_args --libs`
1079   ft_config_major_version=`$FT2_CONFIG $ft_config_args --version | \
1080          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1081   ft_config_minor_version=`$FT2_CONFIG $ft_config_args --version | \
1082          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1083   ft_config_micro_version=`$FT2_CONFIG $ft_config_args --version | \
1084          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1085   ft_min_major_version=`echo $min_ft_version | \
1086          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1087   ft_min_minor_version=`echo $min_ft_version | \
1088          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1089   ft_min_micro_version=`echo $min_ft_version | \
1090          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1091   if test "x$enable_fttest" = "xyes" ; then
1092     ft_config_is_lt=no
1093     if test $ft_config_major_version -lt $ft_min_major_version ; then
1094       ft_config_is_lt=yes
1095     else
1096       if test $ft_config_major_version -eq $ft_min_major_version ; then
1097         if test $ft_config_minor_version -lt $ft_min_minor_version ; then
1098           ft_config_is_lt=yes
1099         else
1100           if test $ft_config_minor_version -eq $ft_min_minor_version ; then
1101             if test $ft_config_micro_version -lt $ft_min_micro_version ; then
1102               ft_config_is_lt=yes
1103             fi
1104           fi
1105         fi
1106       fi
1107     fi
1108     if test "x$ft_config_is_lt" = "xyes" ; then
1109       ifelse([$3], , :, [$3])
1110     else
1111       ac_save_CFLAGS="$CFLAGS"
1112       ac_save_LIBS="$LIBS"
1113       CFLAGS="$CFLAGS $FT2_CFLAGS"
1114       LIBS="$FT2_LIBS $LIBS"
1116 dnl Sanity checks for the results of freetype-config to some extent
1118       AC_TRY_RUN([
1119 #include <ft2build.h>
1120 #include FT_FREETYPE_H
1121 #include <stdio.h>
1122 #include <stdlib.h>
1125 main()
1127   FT_Library library;
1128   FT_Error error;
1130   error = FT_Init_FreeType(&library);
1132   if (error)
1133     return 1;
1134   else
1135   {
1136     FT_Done_FreeType(library);
1137     return 0;
1138   }
1140 ],, no_ft=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
1141       CFLAGS="$ac_save_CFLAGS"
1142       LIBS="$ac_save_LIBS"
1143     fi             # test $ft_config_version -lt $ft_min_version
1144   fi               # test "x$enable_fttest" = "xyes"
1145 fi                 # test "$FT2_CONFIG" = "no"
1146 if test "x$no_ft" = x ; then
1147    AC_MSG_RESULT(yes)
1148    ifelse([$2], , :, [$2])
1149 else
1150    AC_MSG_RESULT(no)
1151    if test "$FT2_CONFIG" = "no" ; then
1152      echo "*** The freetype-config script installed by FreeType 2 could not be found."
1153      echo "*** If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in"
1154      echo "*** your path, or set the FT2_CONFIG environment variable to the"
1155      echo "*** full path to freetype-config."
1156    else
1157      echo "*** The FreeType test program failed to run.  If your system uses"
1158      echo "*** shared libraries and they are installed outside the normal"
1159      echo "*** system library path, make sure the variable LD_LIBRARY_PATH"
1160      echo "*** (or whatever is appropiate for your system) is correctly set."
1161    fi
1162    FT2_CFLAGS=""
1163    FT2_LIBS=""
1164    ifelse([$3], , :, [$3])
1166 AC_SUBST(FT2_CFLAGS)
1167 AC_SUBST(FT2_LIBS)
1170 #-----------------------------------------------------------------------------
1171 # Configure paths for fontconfig
1172 # Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor
1173 # modified by olicha for fontconfig
1175 dnl AM_CHECK_FC([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
1176 dnl Test for fontconfig, and define FC_CFLAGS and FC_LIBS
1178 AC_DEFUN(AM_CHECK_FC,
1179 [dnl
1180 dnl Get the cflags and libraries from the fontconfig-config script
1182 AC_ARG_WITH(fontconfig-prefix,
1183 [  --with-fontconfig-prefix=PFX  prefix where fontconfig is installed (for Xft2)],
1184             fc_config_prefix="$withval", fc_config_prefix="")
1185 AC_ARG_WITH(fontconfig-exec-prefix,
1186 [  --with-fontconfig-exec-prefix=PFX  exec prefix where fontconfig is installed],
1187             fc_config_exec_prefix="$withval", fc_config_exec_prefix="")
1188 AC_ARG_ENABLE(fontconfigtest,
1189 [  --disable-fontconfigtest  do not try to compile and run a test fontconfig program],
1190             [], enable_fctest=yes)
1192 if test x$fc_config_exec_prefix != x ; then
1193   fc_config_args="$fc_config_args --exec-prefix=$fc_config_exec_prefix"
1194   if test x${FC_CONFIG+set} != xset ; then
1195     FC_CONFIG=$fc_config_exec_prefix/bin/fontconfig-config
1196   fi
1198 if test x$fc_config_prefix != x ; then
1199   fc_config_args="$fc_config_args --prefix=$fc_config_prefix"
1200   if test x${FC_CONFIG+set} != xset ; then
1201     FC_CONFIG=$fc_config_prefix/bin/fontconfig-config
1202   fi
1204 AC_PATH_PROG(FC_CONFIG, fontconfig-config, no)
1206 min_fc_version=ifelse([$1], ,1.0.1,$1)
1207 AC_MSG_CHECKING(for Fontconfig - version >= $min_fc_version)
1208 no_fc=""
1209 pkg_config_fontconfig_exists=""
1211 if test "$FC_CONFIG" = "no" ; then
1212   if test "x$PKG_CONFIG" != "xno" ; then
1213     if $PKG_CONFIG --exists 'fontconfig' ; then
1214       if $PKG_CONFIG --exists 'fontconfig >= $1' ; then
1215         FC_CFLAGS=`$PKG_CONFIG --cflags fontconfig`
1216         FC_LIBS=`$PKG_CONFIG --libs fontconfig`
1217       else
1218         no_fc=yes
1219         fc_config_is_lt=yes
1220       fi
1221     else
1222       pkg_config_fontconfig_exists="maybe"
1223       no_fc=yes
1224     fi
1225   else
1226     no_fc=yes
1227   fi
1228 else
1229   FC_CFLAGS=`$FC_CONFIG $fc_config_args --cflags`
1230   FC_LIBS=`$FC_CONFIG $fc_config_args --libs`
1231   fc_config_major_version=`$FC_CONFIG $fc_config_args --version | \
1232          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1233   fc_config_minor_version=`$FC_CONFIG $fc_config_args --version | \
1234          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1235   fc_config_micro_version=`$FC_CONFIG $fc_config_args --version | \
1236          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1237   fc_min_major_version=`echo $min_fc_version | \
1238          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1239   fc_min_minor_version=`echo $min_fc_version | \
1240          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1241   fc_min_micro_version=`echo $min_fc_version | \
1242          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1243   fc_config_is_lt=no
1244   if test $fc_config_major_version -lt $fc_min_major_version ; then
1245     fc_config_is_lt=yes
1246   else
1247     if test $fc_config_major_version -eq $fc_min_major_version ; then
1248       if test $fc_config_minor_version -lt $fc_min_minor_version ; then
1249         fc_config_is_lt=yes
1250       else
1251         if test $fc_config_minor_version -eq $fc_min_minor_version ; then
1252           if test $fc_config_micro_version -lt $fc_min_micro_version ; then
1253             fc_config_is_lt=yes
1254           fi
1255         fi
1256       fi
1257     fi
1258   fi
1259   if test "x$fc_config_is_lt" = "xyes" ; then
1260     no_fc=yes
1261   fi
1264 if test "x$no_fc" = x ; then
1265   if test "x$enable_fctest" = "xyes" ; then
1266     ac_save_CFLAGS="$CFLAGS"
1267     ac_save_LIBS="$LIBS"
1268     CFLAGS="$CFLAGS $FC_CFLAGS $FT2_CFLAGS"
1269     LIBS="$FC_LIBS $LIBS $FT2_LIBS"
1271 dnl Sanity checks for the results of fontconfig-config/pkg-config to some extent
1273       AC_TRY_RUN([
1274 #include <fontconfig/fontconfig.h>
1275 #include <stdio.h>
1276 #include <stdlib.h>
1279 main()
1281   FcBool result;
1283   result = FcInit();
1285   if (result)
1286   {
1287     return 0;
1288   }
1289   else
1290   {
1291     return 1;
1292   }
1294 ],, no_fc=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
1295     CFLAGS="$ac_save_CFLAGS"
1296     LIBS="$ac_save_LIBS"
1297   fi
1300 if test "x$no_fc" = x; then
1301   AC_MSG_RESULT(yes)
1302   ifelse([$2], , :, [$2])
1303 else
1304   AC_MSG_RESULT(no)
1305   if test "x$fc_config_is_lt" = "xyes"; then
1306     echo "*** Your Fontconfig package version is < $1"
1307   elif test "x$pkg_config_fontconfig_exists" = "xmaybe"; then
1308     echo "*** fontconfig was not found in the pkg-config search path."
1309     echo "*** either fontconfig is not installed or perhaps you should"
1310     echo "*** add the directory containing fontconfig.pc to the "
1311     echo "*** PKG_CONFIG_PATH environment variable."
1312   elif test "$FC_CONFIG" != "no"; then
1313     echo "*** The Fontconfig test program failed to run.  If your system uses"
1314     echo "*** shared libraries and they are installed outside the normal"
1315     echo "*** system library path, make sure the variable LD_LIBRARY_PATH"
1316     echo "*** (or whatever is appropiate for your system) is correctly set."
1317   fi
1318   FC_CFLAGS=""
1319   FC_LIBS=""
1320   ifelse([$3], , :, [$3])
1322 AC_SUBST(FC_CFLAGS)
1323 AC_SUBST(FC_LIBS)
1326 #-----------------------------------------------------------------------------
1327 # Configure paths for xft 2
1328 # Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor
1329 # modified by olicha for xft
1331 dnl AM_CHECK_XFT([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
1332 dnl Test for xft, and define XFT_CFLAGS and XFT_LIBS
1334 AC_DEFUN(AM_CHECK_XFT,
1335 [dnl
1336 dnl Get the cflags and libraries from the xft-config script
1338 AC_ARG_WITH(xft-prefix,
1339 [  --with-xft-prefix=PFX    prefix where Xft2 is installed (optional)],
1340             xft_config_prefix="$withval", xft_config_prefix="")
1341 AC_ARG_WITH(xft-exec-prefix,
1342 [  --with-xft-exec-prefix=PFX  exec prefix where Xft2 is installed],
1343             xft_config_exec_prefix="$withval", xft_config_exec_prefix="")
1344 AC_ARG_ENABLE(xfttest,
1345 [  --disable-xfttest       do not try to compile and run a test Xft program],
1346             [], enable_xfttest=yes)
1348 if test x$xft_config_exec_prefix != x ; then
1349   xft_config_args="$xft_config_args --exec-prefix=$xft_config_exec_prefix"
1350   if test x${XFT_CONFIG+set} != xset ; then
1351     XFT_CONFIG=$xft_config_exec_prefix/bin/xft-config
1352   fi
1354 if test x$xft_config_prefix != x ; then
1355   xft_config_args="$xft_config_args --prefix=$xft_config_prefix"
1356   if test x${XFT_CONFIG+set} != xset ; then
1357     XFT_CONFIG=$xft_config_prefix/bin/xft-config
1358   fi
1360 AC_PATH_PROG(XFT_CONFIG, xft-config, no)
1362 min_xft_version=ifelse([$1], ,2.0.0,$1)
1363 AC_MSG_CHECKING(for Xft - version >= $min_xft_version)
1364 no_xft=""
1365 pkg_config_xft_exists=""
1367 if test "$XFT_CONFIG" = "no" ; then
1368   if test "x$PKG_CONFIG" != "xno" ; then
1369     if $PKG_CONFIG --exists 'xft' ; then
1370       if $PKG_CONFIG --exists 'xft >= $1' ; then
1371         XFT_CFLAGS=`$PKG_CONFIG --cflags xft`
1372         XFT_LIBS=`$PKG_CONFIG --libs xft`
1373       else
1374         no_xft=yes
1375         xft_config_is_lt=yes
1376       fi
1377     else
1378       pkg_config_xft_exists="maybe"
1379       no_xft=yes
1380     fi
1381   else
1382     no_xft=yes
1383   fi
1384 else
1385   XFT_CFLAGS=`$XFT_CONFIG $xft_config_args --cflags`
1386   XFT_LIBS=`$XFT_CONFIG $xft_config_args --libs`
1387   xft_config_major_version=`$XFT_CONFIG $xft_config_args --version | \
1388          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1389   xft_config_minor_version=`$XFT_CONFIG $xft_config_args --version | \
1390          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1391   xft_config_micro_version=`$XFT_CONFIG $xft_config_args --version | \
1392          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1393   xft_min_major_version=`echo $min_xft_version | \
1394          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1395   xft_min_minor_version=`echo $min_xft_version | \
1396          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1397   xft_min_micro_version=`echo $min_xft_version | \
1398          sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1399   xft_config_is_lt=no
1400   if test $xft_config_major_version -lt $xft_min_major_version ; then
1401     xft_config_is_lt=yes
1402   else
1403     if test $xft_config_major_version -eq $xft_min_major_version ; then
1404       if test $xft_config_minor_version -lt $xft_min_minor_version ; then
1405         xft_config_is_lt=yes
1406       else
1407         if test $xft_config_minor_version -eq $xft_min_minor_version ; then
1408           if test $xft_config_micro_version -lt $xft_min_micro_version ; then
1409             xft_config_is_lt=yes
1410           fi
1411         fi
1412       fi
1413     fi
1414   fi
1415   if test "x$xft_config_is_lt" = "xyes" ; then
1416     ifelse([$3], , :, [$3])
1417   fi
1420 if test "x$no_xft" = x ; then
1421   if test "x$enable_xfttest" = "xyes" ; then
1422     ac_save_CFLAGS="$CFLAGS"
1423     ac_save_LIBS="$LIBS"
1424     CFLAGS="$XFT_CFLAGS $CFLAGS"
1425     LIBS="$XFT_LIBS $LIBS"
1427 dnl Sanity checks for the results of xft-config/pkg-config to some extent
1429       AC_TRY_RUN([
1430 #include <X11/Xft/Xft.h>
1431 #include <stdio.h>
1432 #include <stdlib.h>
1435 main()
1437   FcBool result = 1;
1439   result = XftInit(NULL);
1441   if (result)
1442   {
1443     return 0;
1444   }
1445   else
1446   {
1447     return 1;
1448   }
1450 ],, no_xft=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
1451     CFLAGS="$ac_save_CFLAGS"
1452     LIBS="$ac_save_LIBS"
1453   fi
1456 if test "x$no_xft" = x; then
1457   AC_MSG_RESULT(yes)
1458   ifelse([$2], , :, [$2])
1459 else
1460   AC_MSG_RESULT(no)
1461   if test "x$xft_config_is_lt" = "xyes"; then
1462     echo "*** Your xft2 package version is < $1"
1463   elif test "x$pkg_config_fontconfig_exists" = "xmaybe" ; then
1464     echo "*** xft2 was not found in the pkg-config search path."
1465     echo "*** either xft is not installed or perhaps you should"
1466     echo "*** add the directory containing xft.pc to the "
1467     echo "*** PKG_CONFIG_PATH environment variable."
1468   elif test "$XFT_CONFIG" = "no"; then
1469     echo "*** The xft-config script installed by Xft 2 could not be found."
1470     echo "*** If Xft 2 was installed in PREFIX, make sure PREFIX/bin is in"
1471     echo "*** your path, or set the XFT_CONFIG environment variable to the"
1472     echo "*** full path to xft-config."
1473   else
1474     echo "*** The Xft test program failed to run.  If your system uses"
1475     echo "*** shared libraries and they are installed outside the normal"
1476     echo "*** system library path, make sure the variable LD_LIBRARY_PATH"
1477     echo "*** (or whatever is appropiate for your system) is correctly set."
1478   fi
1479   XFT_CFLAGS=""
1480   XFT_LIBS=""
1481   ifelse([$3], , :, [$3])
1483 AC_SUBST(XFT_CFLAGS)
1484 AC_SUBST(XFT_LIBS)
1487 #-----------------------------------------------------------------------------
1488 # gettext stuff from the gettext package
1490 # Authors: Ulrich Drepper <drepper@cygnus.com>, 1996.
1491 # modified by the fvwm workers
1494 AC_DEFUN([AM_GNU_FGETTEXT],
1496   AC_REQUIRE([AM_PO_SUBDIRS])dnl
1498   intl_LIBS=
1499   intl_CFLAGS=
1500   POSUB=
1502   found_gettext=yes
1504   dnl check for the necessary stuff in the libc
1505   dnl the pbs is that we can detect this stuff but in fact the included
1506   dnl libintl.h is from gettext
1507   dnl Moreover, we do not try to use other implementation, but we may try
1508   dnl one day
1509   $UNSET ac_cv_header_intl_h
1510   $UNSET ac_cv_func_gettext
1511   $UNSET ac_cv_func_bindtextdomain
1512   $UNSET ac_cv_func_textdomain
1513   dnl a "gnu extension"
1514   $UNSET ac_cv_func_dgettext
1515   #bind_textdomain_codeset
1516   AC_CHECK_HEADER(libintl.h,
1517     [AC_CHECK_FUNCS(gettext bindtextdomain textdomain dgettext,,
1518       found_gettext=no)], found_gettext=no)
1520   AC_MSG_CHECKING([for gnu gettext in libc])
1521   if test x"$found_gettext" = "xyes"; then
1522     problem_gettext=" (libc)"
1523     AC_MSG_RESULT([yes])
1524     AC_MSG_CHECKING(if a simple gettext program link)
1525     AC_TRY_LINK([
1526       #include <libintl.h>
1527       ],
1528       [const char *c; c = gettext("foo");],
1529       found_gettext=yes;problem_gettext=" (libc)", found_gettext=no)
1530     AC_MSG_RESULT($found_gettext)
1531   else
1532     AC_MSG_RESULT([no])
1533   fi
1535   if test x"$found_gettext" = xno; then
1536     dnl not found, check for libintl
1537     $UNSET ac_cv_header_intl_h
1538     $UNSET ac_cv_lib_intl_bindtextdomain
1539     $UNSET ac_cv_lib_intl_textdomain
1540     $UNSET ac_cv_lib_intl_dgettext
1541     smr_CHECK_LIB(intl, intl, for Native Language Support,
1542       bindtextdomain, libintl.h)
1543     if test x"$intl_LIBS" != x; then
1544       no_textdomain=no
1545       no_dgettext=no
1546       ac_save_CFLAGS="$CFLAGS"
1547       ac_save_LIBS="$LIBS"
1548       AC_CHECK_LIB(intl, textdomain,, no_textdomain=yes,
1549         [$intl_LIBS $iconv_LIBS])
1550       if test "$no_textdomain" != "yes"; then
1551         AC_CHECK_LIB(intl, dgettext,, no_dgettext=yes, [$intl_LIBS $iconv_LIBS])
1552         if test "$no_dgettext" != "yes"; then
1553           CFLAGS="$CFLAGS $intl_LIBS $iconv_LIBS"
1554           LIBS="$LIBS $intl_LIBS $iconv_LIBS"
1555           AC_MSG_CHECKING(if a simple gettext program link)
1556           AC_TRY_LINK([
1557           #include <libintl.h>
1558           ],
1559           [const char *c; c = gettext("foo");],
1560           found_gettext=yes;problem_gettext=" (intl library)", found_gettext=no)
1561           AC_MSG_RESULT($found_gettext)
1562         fi
1563       fi
1564       CFLAGS="$ac_save_CFLAGS"
1565       LIBS="$ac_save_LIBS"
1566     fi
1567   fi
1569   if test "$found_gettext" = "yes"; then
1570     dnl Mark actions to use GNU gettext tools.
1571     CATOBJEXT=.gmo
1572     USE_NLS=yes
1573     dnl We need to process the po/ directory.
1574     POSUB=po
1575   else
1576     USE_NLS=no
1577   fi
1579   dnl Make the po/ variables we use known to autoconf
1583 dnl Checks for all prerequisites of the po subdirectory,
1584 dnl except for USE_NLS.
1585 AC_DEFUN([AM_PO_SUBDIRS],
1587   AC_REQUIRE([AC_PROG_MAKE_SET])dnl
1588   AC_REQUIRE([AC_PROG_INSTALL])dnl
1589   AC_REQUIRE([AM_MKINSTALLDIRS])dnl
1591   dnl Perform the following tests also if --disable-nls has been given,
1592   dnl because they are needed for "make dist" to work.
1594   dnl Search for GNU msgfmt in the PATH.
1595   dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions.
1596   dnl The second test excludes FreeBSD msgfmt.
1597   AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
1598     [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 &&
1599      (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
1600     :)
1601   AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
1603   dnl Search for GNU xgettext 0.11 or newer in the PATH.
1604   dnl The first test excludes Solaris xgettext and early GNU xgettext versions.
1605   dnl The second test excludes FreeBSD xgettext.
1606   AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
1607     [$ac_dir/$ac_word --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
1608      (if $ac_dir/$ac_word --omit-header --copyright-holder= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
1609     :)
1610   dnl Remove leftover from FreeBSD xgettext call.
1611   rm -f messages.po
1613   dnl Search for GNU msgmerge 0.11 or newer in the PATH.
1614   AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
1615     [$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1], :)
1617   dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
1618   dnl Test whether we really found GNU msgfmt.
1619   if test "$GMSGFMT" != ":"; then
1620     dnl If it is no GNU msgfmt we define it as : so that the
1621     dnl Makefiles still can work.
1622     if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 &&
1623        (if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
1624       : ;
1625     else
1626       GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'`
1627       AC_MSG_RESULT(
1628         [found $GMSGFMT program is not GNU msgfmt; ignore it])
1629       GMSGFMT=":"
1630     fi
1631   fi
1633   dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
1634   dnl Test whether we really found GNU xgettext.
1635   if test "$XGETTEXT" != ":"; then
1636     dnl If it is no GNU xgettext we define it as : so that the
1637     dnl Makefiles still can work.
1638     if $XGETTEXT --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
1639        (if $XGETTEXT --omit-header --copyright-holder= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
1640       : ;
1641     else
1642       AC_MSG_RESULT(
1643         [found xgettext program is not GNU xgettext; ignore it])
1644       XGETTEXT=":"
1645     fi
1646     dnl Remove leftover from FreeBSD xgettext call.
1647     rm -f messages.po
1648   fi
1650   AC_PATH_PROG(MSGUNIQ, msguniq, $MSGUNIQ)
1652   AC_MSG_CHECKING([for NLS fvwm messages catalogs])
1653   AC_MSG_RESULT([$ALL_LINGUAS])
1654   POFILES=
1655   GMOFILES=
1656   UPDATEPOFILES=
1657   DUMMYPOFILES=
1658   for lang in $ALL_LINGUAS; do
1659     for dom in $ALL_DOMAINS; do
1660       POFILES="$POFILES $dom.$lang.po"
1661       GMOFILES="$GMOFILES $dom.$lang.gmo"
1662       UPDATEPOFILES="$UPDATEPOFILES $dom.$lang.po-update"
1663       DUMMYPOFILES="$DUMMYPOFILES $dom.$lang.nop"
1664     done
1665   done
1666   # CATALOGS depends on both $ac_dir and the user's LINGUAS environment variable.
1667   INST_LINGUAS=
1668   AC_MSG_CHECKING([for NLS desired catalogs to be installed])
1669   #if test "%UNSET%" != "$LINGUAS"; then
1670   # FIXME: How to check if LINGUAS has been *set* to ""
1671   if test -n "$LINGUAS"; then
1672     AC_MSG_RESULT([$LINGUAS])
1673   else
1674     AC_MSG_RESULT([all])
1675   fi
1676   AC_MSG_CHECKING([for NLS messages catalogs to be installed])
1677   if test -n "$ALL_LINGUAS"; then
1678     for presentlang in $ALL_LINGUAS; do
1679       useit=no
1680       #if test "%UNSET%" != "$LINGUAS"; then
1681       if test -n "$LINGUAS"; then
1682         desiredlanguages="$LINGUAS"
1683       else
1684         desiredlanguages="$ALL_LINGUAS"
1685       fi
1686       for desiredlang in $desiredlanguages; do
1687         # Use the presentlang catalog if desiredlang is
1688         #   a. equal to presentlang, or
1689         #   b. a variant of presentlang (because in this case,
1690         #      presentlang can be used as a fallback for messages
1691         #      which are not translated in the desiredlang catalog).
1692         case "$desiredlang" in
1693           "$presentlang"*) useit=yes;;
1694         esac
1695       done
1696       if test $useit = yes; then
1697         INST_LINGUAS="$INST_LINGUAS $presentlang"
1698       fi
1699     done
1700   fi
1701   AC_MSG_RESULT([$INST_LINGUAS])
1702   CATALOGS=
1703   if test -n "$INST_LINGUAS"; then
1704     for lang in $INST_LINGUAS; do
1705       CATALOGS="$CATALOGS $lang.gmo"
1706     done
1707   fi
1712 AC_DEFUN([AM_MKINSTALLDIRS],
1714   dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
1715   dnl find the mkinstalldirs script in another subdir but $(top_srcdir).
1716   dnl Try to locate is.
1717   MKINSTALLDIRS=
1718   if test -n "$ac_aux_dir"; then
1719     MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
1720   fi
1721   if test -z "$MKINSTALLDIRS"; then
1722     MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
1723   fi
1726 # Search path for a program which passes the given test.
1728 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
1729 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
1730 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
1731 [# Extract the first word of "$2", so it can be a program name with args.
1732 set dummy $2; ac_word=[$]2
1733 AC_MSG_CHECKING([for $ac_word])
1734 AC_CACHE_VAL(ac_cv_path_$1,
1735 [case "[$]$1" in
1736   /*)
1737   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
1738   ;;
1739   *)
1740   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1741   for ac_dir in ifelse([$5], , $PATH, [$5]); do
1742     test -z "$ac_dir" && ac_dir=.
1743     if test -f $ac_dir/$ac_word; then
1744       if [$3]; then
1745         ac_cv_path_$1="$ac_dir/$ac_word"
1746         break
1747       fi
1748     fi
1749   done
1750   IFS="$ac_save_ifs"
1751 dnl If no 4th arg is given, leave the cache variable unset,
1752 dnl so AC_PATH_PROGS will keep looking.
1753 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
1754 ])dnl
1755   ;;
1756 esac])dnl
1757 $1="$ac_cv_path_$1"
1758 if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
1759   AC_MSG_RESULT([$]$1)
1760 else
1761   AC_MSG_RESULT(no)
1763 AC_SUBST($1)dnl
1767 dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
1768 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
1771 #-----------------------------------------------------------------------------
1772 # Safty check for mkstemp
1774 AC_DEFUN([AM_SAFTY_CHECK_MKSTEMP],[
1775   AC_CHECK_FUNCS(mkstemp)
1776   has_safty_mkstemp=no
1777   AC_MSG_CHECKING(if mkstemp is safe)
1778   if test x$ac_cv_func_mkstemp != xno; then
1779     AC_TRY_RUN([
1780 #include <stdio.h>
1781 #include <stdlib.h>
1782 #include <string.h>
1783 int main(void)
1785   char template[128];
1786   char template_orig[128];
1787   int fd;
1789   sprintf(template, "configure-mkstemp-test.XXXXXX");
1790   strcpy(template_orig, template);
1791   fd = mkstemp(template);
1792   if (fd == -1)
1793   {
1794     /* could not create temp file */
1795     return 1;
1796   }
1797   if (strcmp(template, template_orig) == 0)
1798   {
1799     /* mkstemp broken */
1800     return 2;
1801   }
1802   if (close(fd) != 0)
1803   {
1804     /* doh! */
1805     return 3;
1806   }
1807   if (unlink(template))
1808   {
1809      return 4;
1810   }
1811   /* mkstemp works properly */
1812   return 0;
1814     ],
1815     [has_safty_mkstemp=yes], [has_safty_mkstemp=no])
1816   fi
1817   if test x$has_safty_mkstemp = xno; then
1818     AC_MSG_RESULT(no, use our mkstemp)
1819   else
1820     AC_MSG_RESULT(yes)
1821     AC_DEFINE(HAVE_SAFTY_MKSTEMP)
1822   fi