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