cvsimport
[fvwm.git] / acinclude.m4
blobaea350684ee9eb4d9a1b6f70c43a0320b040abc9
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 AS_HELP_STRING([--with-$1-library[=PATH]],[use $1 library]),
193 AS_HELP_STRING([--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 AS_HELP_STRING([--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,AS_HELP_STRING([--with-gtk-prefix=PFX],[prefix for GTK files (optional)]),
353             gtk_config_prefix="$withval", gtk_config_prefix="")
354 AC_ARG_WITH(gtk-exec-prefix,AS_HELP_STRING([--with-gtk-exec-prefix=PFX],
355             [exec prefix for GTK files (optional)]),
356             gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
357 AC_ARG_ENABLE(gtktest,AS_HELP_STRING([--disable-gtktest],
358               [do not try to compile and run a test GTK program]),, enable_gtktest=yes)
360   if test x$gtk_config_exec_prefix != x ; then
361      gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
362      if test x${GTK_CONFIG+set} != xset ; then
363         GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
364      fi
365   fi
366   if test x$gtk_config_prefix != x ; then
367      gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
368      if test x${GTK_CONFIG+set} != xset ; then
369         GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
370      fi
371   fi
373   AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
374   min_gtk_version=ifelse([$1], ,0.99.7,$1)
375   AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
376   no_gtk=""
377   if test "$GTK_CONFIG" = "no" ; then
378     no_gtk=yes
379   else
380     GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
381     GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
382     gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
383            sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\1/'`
384     gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
385            sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\2/'`
386     gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
387            sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\3/'`
388     if test "x$enable_gtktest" = "xyes" ; then
389       ac_save_CFLAGS="$CFLAGS"
390       ac_save_LIBS="$LIBS"
391       CFLAGS="$CFLAGS $GTK_CFLAGS"
392       LIBS="$LIBS $GTK_LIBS"
394 dnl Now check if the installed GTK is sufficiently new. (Also sanity
395 dnl checks the results of gtk-config to some extent
397       rm -f conf.gtktest
398       AC_TRY_RUN([
399 #include <gtk/gtk.h>
400 #include <stdio.h>
401 #include <stdlib.h>
404 main ()
406   int major, minor, micro;
407   char *tmp_version;
409   system ("touch conf.gtktest");
411   /* HP/UX 9 (%@#!) writes to sscanf strings */
412   tmp_version = g_strdup("$min_gtk_version");
413   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
414      printf("%s, bad version string\n", "$min_gtk_version");
415      exit(1);
416    }
418   if ((gtk_major_version != $gtk_config_major_version) ||
419       (gtk_minor_version != $gtk_config_minor_version) ||
420       (gtk_micro_version != $gtk_config_micro_version))
421     {
422       printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
423              $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
424              gtk_major_version, gtk_minor_version, gtk_micro_version);
425       printf ("*** was found! If gtk-config was correct, then it is best\n");
426       printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
427       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
428       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
429       printf("*** required on your system.\n");
430       printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
431       printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
432       printf("*** before re-running configure\n");
433     }
434 #if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
435   else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
436            (gtk_minor_version != GTK_MINOR_VERSION) ||
437            (gtk_micro_version != GTK_MICRO_VERSION))
438     {
439       printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
440              GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
441       printf("*** library (version %d.%d.%d)\n",
442              gtk_major_version, gtk_minor_version, gtk_micro_version);
443     }
444 #endif /* defined (GTK_MAJOR_VERSION) ... */
445   else
446     {
447       if ((gtk_major_version > major) ||
448         ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
449         ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
450       {
451         return 0;
452        }
453      else
454       {
455         printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
456                gtk_major_version, gtk_minor_version, gtk_micro_version);
457         printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
458                major, minor, micro);
459         printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
460         printf("***\n");
461         printf("*** If you have already installed a sufficiently new version, this error\n");
462         printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
463         printf("*** being found. The easiest way to fix this is to remove the old version\n");
464         printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
465         printf("*** correct copy of gtk-config. (In this case, you will have to\n");
466         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
467         printf("*** so that the correct libraries are found at run-time))\n");
468       }
469     }
470   return 1;
472 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
473        CFLAGS="$ac_save_CFLAGS"
474        LIBS="$ac_save_LIBS"
475      fi
476   fi
477   if test "x$no_gtk" = x ; then
478      AC_MSG_RESULT(yes)
479      ifelse([$2], , :, [$2])
480   else
481      AC_MSG_RESULT(no)
482      if test "$GTK_CONFIG" = "no" ; then
483        echo "*** The gtk-config script installed by GTK could not be found"
484        echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
485        echo "*** your path, or set the GTK_CONFIG environment variable to the"
486        echo "*** full path to gtk-config."
487      else
488        if test -f conf.gtktest ; then
489         :
490        else
491           echo "*** Could not run GTK test program, checking why..."
492           CFLAGS="$CFLAGS $GTK_CFLAGS"
493           LIBS="$LIBS $GTK_LIBS"
494           AC_TRY_LINK([
495 #include <gtk/gtk.h>
496 #include <stdio.h>
497 ],      [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
498         [ echo "*** The test program compiled, but did not run. This usually means"
499           echo "*** that the run-time linker is not finding GTK or finding the wrong"
500           echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
501           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
502           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
503           echo "*** is required on your system"
504           echo "***"
505           echo "*** If you have an old version installed, it is best to remove it, although"
506           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
507           echo "***"
508           echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
509           echo "*** came with the system with the command"
510           echo "***"
511           echo "***    rpm --erase --nodeps gtk gtk-devel" ],
512         [ echo "*** The test program failed to compile or link. See the file config.log for the"
513           echo "*** exact error that occured. This usually means GTK was incorrectly installed"
514           echo "*** or that you have moved GTK since it was installed. In the latter case, you"
515           echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
516           CFLAGS="$ac_save_CFLAGS"
517           LIBS="$ac_save_LIBS"
518        fi
519      fi
520      GTK_CFLAGS=""
521      GTK_LIBS=""
522      ifelse([$3], , :, [$3])
523   fi
524   AC_SUBST(GTK_CFLAGS)
525   AC_SUBST(GTK_LIBS)
526   rm -f conf.gtktest
530 # Check for gdk-imlib
531 AC_DEFUN([AM_PATH_GDK_IMLIB],
532 [dnl
533 dnl Get the cflags and libraries from the imlib-config script
535 AC_ARG_WITH(imlib-prefix,AS_HELP_STRING([--with-imlib-prefix=PFX],[prefix for IMLIB files (optional)]),
536             imlib_prefix="$withval", imlib_prefix="")
537 AC_ARG_WITH(imlib-exec-prefix,AS_HELP_STRING([--with-imlib-exec-prefix=PFX],[exec prefix for IMLIB files (optional)]),
538             imlib_exec_prefix="$withval", imlib_exec_prefix="")
539 AC_ARG_ENABLE(imlibtest,AS_HELP_STRING([--disable-imlibtest],[do not try to compile and run a test IMLIB program]),
540             , enable_imlibtest=yes)
542   if test x$imlib_exec_prefix != x ; then
543      imlib_args="$imlib_args --exec-prefix=$imlib_exec_prefix"
544      if test x${IMLIBCONF+set} != xset ; then
545         IMLIBCONF=$imlib_exec_prefix/bin/imlib-config
546      fi
547   fi
548   if test x$imlib_prefix != x ; then
549      imlib_args="$imlib_args --prefix=$imlib_prefix"
550      if test x${IMLIBCONF+set} != xset ; then
551         IMLIBCONF=$imlib_prefix/bin/imlib-config
552      fi
553   fi
555   AC_PATH_PROG(IMLIBCONF, imlib-config, no)
556   min_imlib_version=ifelse([$1], ,1.8.1,$1)
557   AC_MSG_CHECKING(for GDK IMLIB - version >= $min_imlib_version)
558   no_imlib=""
559   if test "$IMLIBCONF" = "no" ; then
560     no_imlib=yes
561   else
562     GDK_IMLIB_CFLAGS=`$IMLIBCONF $imlibconf_args --cflags-gdk`
563     GDK_IMLIB_LIBS=`$IMLIBCONF $imlibconf_args --libs-gdk`
565     imlib_major_version=`$IMLIBCONF $imlib_args --version | \
566            sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\1/'`
567     imlib_minor_version=`$IMLIBCONF $imlib_args --version | \
568            sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\2/'`
569     if test "x$enable_imlibtest" = "xyes" ; then
570       ac_save_CFLAGS="$CFLAGS"
571       ac_save_LIBS="$LIBS"
572       CFLAGS="$CFLAGS $GDK_IMLIB_CFLAGS"
573       LIBS="$LIBS $GDK_IMLIB_LIBS"
575 dnl Now check if the installed IMLIB is sufficiently new. (Also sanity
576 dnl checks the results of imlib-config to some extent
578       rm -f conf.imlibtest
579       AC_TRY_RUN([
580 #include <stdio.h>
581 #include <stdlib.h>
582 #include <gdk_imlib.h>
584 /* migo: originally it was GdkImLibColor with incorrect spelling */
585 GdkImlibImage testimage;
587 int main ()
589   int major, minor;
590   char *tmp_version;
592   system ("touch conf.gdkimlibtest");
594   /* HP/UX 9 (%@#!) writes to sscanf strings */
595   tmp_version = g_strdup("$min_imlib_version");
596   if (sscanf(tmp_version, "%d.%d", &major, &minor) != 2) {
597      printf("%s, bad version string\n", "$min_imlib_version");
598      exit(1);
599    }
601     if (($imlib_major_version > major) ||
602         (($imlib_major_version == major) && ($imlib_minor_version > minor)))
603     {
604       return 0;
605     }
606   else
607     {
608       printf("\n*** 'imlib-config --version' returned %d.%d, but the minimum version\n", $imlib_major_version, $imlib_minor_version);
609       printf("*** of IMLIB required is %d.%d. If imlib-config is correct, then it is\n", major, minor);
610       printf("*** best to upgrade to the required version.\n");
611       printf("*** If imlib-config was wrong, set the environment variable IMLIBCONF\n");
612       printf("*** to point to the correct copy of imlib-config, and remove the file\n");
613       printf("*** config.cache before re-running configure\n");
614       return 1;
615     }
618 ],, no_imlib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
619        CFLAGS="$ac_save_CFLAGS"
620        LIBS="$ac_save_LIBS"
621      fi
622   fi
623   if test "x$no_imlib" = x ; then
624      AC_MSG_RESULT(yes)
625      ifelse([$2], , :, [$2])
626   else
627      AC_MSG_RESULT(no)
628      if test "$IMLIBCONF" = "no" ; then
629                        (echo "*** The imlib-config script installed by IMLIB could not be found" >&5) 2>/dev/null || \
630        echo "*** The imlib-config script installed by IMLIB could not be found"
631                        (echo "*** If IMLIB was installed in PREFIX, make sure PREFIX/bin is in" >&5) 2>/dev/null || \
632        echo "*** If IMLIB was installed in PREFIX, make sure PREFIX/bin is in"
633                        (echo "*** your path, or set the IMLIBCONF environment variable to the" >&5) 2>/dev/null || \
634        echo "*** your path, or set the IMLIBCONF environment variable to the"
635                        (echo "*** full path to imlib-config." >&5) 2>/dev/null || \
636        echo "*** full path to imlib-config."
637      else
638        if test -f conf.gdkimlibtest ; then
639         :
640        else
641                           (echo "*** Could not run IMLIB test program, checking why..." >&5) 2>/dev/null || \
642           echo "*** Could not run IMLIB test program, checking why..."
643           CFLAGS="$CFLAGS $GDK_IMLIB_CFLAGS"
644           LIBS="$LIBS $GDK_IMLIB_LIBS"
645           AC_TRY_LINK([
646 #include <stdio.h>
647 #include <gdk_imlib.h>
648 ],      [ return 0; ],
649         [                 (echo "*** The test program compiled, but did not run. This usually means" >&5) 2>/dev/null || \
650           echo "*** The test program compiled, but did not run. This usually means"
651                           (echo "*** that the run-time linker is not finding IMLIB or finding the wrong" >&5) 2>/dev/null || \
652           echo "*** that the run-time linker is not finding IMLIB or finding the wrong"
653                           (echo "*** version of IMLIB. If it is not finding IMLIB, you'll need to set your" >&5) 2>/dev/null || \
654           echo "*** version of IMLIB. If it is not finding IMLIB, you'll need to set your"
655                           (echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" >&5) 2>/dev/null || \
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" >&5) 2>/dev/null || \
658           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
659                           (echo "*** is required on your system" >&5) 2>/dev/null || \
660           echo "*** is required on your system"
661                           (echo "***" >&5) 2>/dev/null || \
662           echo "***"
663                           (echo "*** If you have an old version installed, it is best to remove it, although" >&5) 2>/dev/null || \
664           echo "*** If you have an old version installed, it is best to remove it, although"
665                           (echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" >&5) 2>/dev/null || \
666           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
667         [                 (echo "*** The test program failed to compile or link. See the file config.log for the" >&5) 2>/dev/null || \
668           echo "*** The test program failed to compile or link. See the file config.log for the"
669                           (echo "*** exact error that occured. This usually means IMLIB was incorrectly installed" >&5) 2>/dev/null || \
670           echo "*** exact error that occured. This usually means IMLIB was incorrectly installed"
671                           (echo "*** or that you have moved IMLIB since it was installed. In the latter case, you" >&5) 2>/dev/null || \
672           echo "*** or that you have moved IMLIB since it was installed. In the latter case, you"
673                           (echo "*** may want to edit the imlib-config script: $IMLIBCONF" >&5) 2>/dev/null || \
674           echo "*** may want to edit the imlib-config script: $IMLIBCONF"])
675           CFLAGS="$ac_save_CFLAGS"
676           LIBS="$ac_save_LIBS"
677        fi
678      fi
679      GDK_IMLIB_CFLAGS=""
680      GDK_IMLIB_LIBS=""
681      ifelse([$3], , :, [$3])
682   fi
683   AC_SUBST(GDK_IMLIB_CFLAGS)
684   AC_SUBST(GDK_IMLIB_LIBS)
685   rm -f conf.gdkimlibtest
689 dnl --------------------------------------------------------------------------
690 dnl from gnome.m4, modified by migo
693 dnl GNOME_INIT_HOOK (script-if-gnome-enabled, [failflag])
695 dnl if failflag is "fail" then GNOME_INIT_HOOK will abort if gnomeConf.sh
696 dnl is not found.
699 AC_DEFUN([GNOME_INIT_HOOK],[
700         AC_SUBST(GNOME_LIBS)
701         AC_SUBST(GNOMEUI_LIBS)
702         AC_SUBST(GNOME_LIBDIR)
703         AC_SUBST(GNOME_INCLUDEDIR)
705         AC_ARG_WITH(gnome-includes,
706                 AS_HELP_STRING([--with-gnome-includes],
707                         [location of GNOME headers]),[
708         CFLAGS="$CFLAGS -I$withval"
709         ])
711         gnome_prefix=$ac_default_prefix/lib
713         AC_ARG_WITH(gnome-libs,
714         AS_HELP_STRING([--with-gnome-libs],[location of GNOME libs]),[
715         LDFLAGS="$LDFLAGS -L$withval"
716         gnome_prefix=$withval
717         ])
719         AC_ARG_WITH(gnome,
720         AS_HELP_STRING([--with-gnome],[no, yes or prefix for GNOME files (for FvwmGtk only)]),
721                 if test x$withval = xyes; then
722                         with_gnomelibs=yes
723                         dnl Note that an empty true branch is not
724                         dnl valid sh syntax.
725                         ifelse([$1], [], :, [$1])
726                 else
727                         if test "x$withval" = xno; then
728                                 with_gnomelibs=no
729                                 problem_gnomelibs=": Explicitly disabled"
730                         else
731                                 with_gnomelibs=yes
732                                 LDFLAGS="$LDFLAGS -L$withval/lib"
733                                 CFLAGS="$CFLAGS -I$withval/include"
734                                 gnome_prefix=$withval/lib
735                         fi
736                 fi,
737                 with_gnomelibs=yes)
739         if test "x$with_gnomelibs" = xyes; then
740             problem_gnomelibs=": Can't find working gnome-config"
742             AC_PATH_PROG(GNOME_CONFIG,gnome-config,no)
743             if test "$GNOME_CONFIG" = "no"; then
744               no_gnome_config="yes"
745             else
746               AC_MSG_CHECKING(whether $GNOME_CONFIG works)
747               if $GNOME_CONFIG --libs-only-l gnome >/dev/null 2>&1; then
748                 AC_MSG_RESULT(yes)
749                 GNOME_LIBS="`$GNOME_CONFIG --libs-only-l gnome`"
750                 GNOMEUI_LIBS="`$GNOME_CONFIG --libs-only-l gnomeui`"
751                 GNOME_LIBDIR="`$GNOME_CONFIG --libs-only-L gnorba gnomeui`"
752                 GNOME_INCLUDEDIR="`$GNOME_CONFIG --cflags gnorba gnomeui`"
753                 $1
754               else
755                 AC_MSG_RESULT(no)
756                 no_gnome_config="yes"
757               fi
758             fi
760             # migo: disable this destructive logic
761 #           if test x$exec_prefix = xNONE; then
762 #               if test x$prefix = xNONE; then
763 #                   gnome_prefix=$ac_default_prefix/lib
764 #               else
765 #                   gnome_prefix=$prefix/lib
766 #               fi
767 #           else
768 #               gnome_prefix=`eval echo \`echo $libdir\``
769 #           fi
771             if test "$no_gnome_config" = "yes"; then
772               AC_MSG_CHECKING(for gnomeConf.sh file in $gnome_prefix)
773               if test -f $gnome_prefix/gnomeConf.sh; then
774                 AC_MSG_RESULT(found)
775                 echo "loading gnome configuration from" \
776                      "$gnome_prefix/gnomeConf.sh"
777                 . $gnome_prefix/gnomeConf.sh
778                 $1
779               else
780                 AC_MSG_RESULT(not found)
781                 if test x$2 = xfail; then
782                   AC_MSG_ERROR([Could not find the gnomeConf.sh file that is generated by gnome-libs install])
783                 fi
784                 with_gnomelibs=no
785               fi
786             fi
787         fi
789         # test whether gnome can be compiled
790         if test "x$with_gnomelibs" = xyes; then
791                 problem_gnomelibs=": Can't compile trivial gnome app"
793                 AC_MSG_CHECKING(whether trivial gnome compilation works)
794                 my_CPPFLAGS="$CPPFLAGS"
795                 my_LIBS="$LIBS"
796                 CPPFLAGS="$CPPFLAGS $GNOME_INCLUDEDIR $GTK_CFLAGS"
797                 LIBS="$LIBS $GNOME_LIBDIR $GNOMEUI_LIBS"
798                 AC_TRY_RUN([
799                         #include <gnome.h>
800                         int main(int c, char **v) {
801                                 /* we can not really run this outside of X */
802                                 if (!c) gnome_init("test-app", "0.0", c, v);
803                                 return 0;
804                         }],
805                         [with_gnomelibs=yes],
806                         [with_gnomelibs=no]
807                 )
808                 AC_MSG_RESULT($with_gnomelibs)
809                 CPPFLAGS="$my_CPPFLAGS"
810                 LIBS="$my_LIBS"
811         else
812                 # just for safety
813                 with_gnomelibs=no
814         fi
816         if test "x$with_gnomelibs" = xyes; then
817                 problem_gnomelibs=""
818         else
819                 GNOME_LIBS=
820                 GNOMEUI_LIBS=
821                 GNOME_LIBDIR=
822                 GNOME_INCLUDEDIR=
823         fi
827 # check if iconv second argument use const char.
829 AC_DEFUN([ICONV_SECOND_ARG],[
830         AC_MSG_CHECKING(check if second arg of iconv is const)
831         AC_TRY_COMPILE([
832 #include <stdlib.h>
833 #include <iconv.h>
834 extern
835 #if defined(__STDC__)
836 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
837 #else
838 size_t iconv();
839 #endif
840 ], [], use_const=no, use_const=yes)
841         AC_MSG_RESULT($use_const)
842         AH_TEMPLATE([ICONV_ARG_CONST],
843                     [define if second arg of iconv use const])
844         if test "x$use_const" = "xyes"; then
845                 AC_DEFINE(ICONV_ARG_CONST, const)
846         else
847                 AC_DEFINE(ICONV_ARG_CONST, )
848         fi
852 # check for  locale_charset if libiconv is used
854 AC_DEFUN([CHECK_LIBCHARSET],[
855         AC_MSG_CHECKING(check for libcharset)
856         ac_save_CFLAGS="$CFLAGS"
857         ac_save_LIBS="$LIBS"
858         CFLAGS="$CFLAGS $iconv_CFLAGS"
859         LIBS="$LIBS $iconv_LIBS"
860         AC_TRY_LINK([
861 #include <libcharset.h>],
862 [const char *c;
863 c = locale_charset ();
864 ], r=yes, r=no)
865         AC_MSG_RESULT($r)
866         if test "x$r" = "xyes"; then
867                 AC_DEFINE(HAVE_LIBCHARSET)
868         fi
869         CFLAGS="$ac_save_CFLAGS"
870         LIBS="$ac_save_LIBS"
873 #-----------------------------------------------------------------------------
874 # pkg-config
878 AC_DEFUN([AM_CHECK_PKG_CONFIG],
879 [dnl
880 dnl Get the cflags and libraries from the freetype-config script
882 AC_ARG_WITH(pkgconfig-prefix,
883 AS_HELP_STRING([--with-pkgconfig-prefix=PFX],[prefix where pkg-config is installed]),
884             pkgconfig_config_prefix="$withval", pkgconfig_config_prefix="")
885 AC_ARG_WITH(pkgconfig-exec-prefix,
886 AS_HELP_STRING([--with-pkgconfig-exec-prefix=PFX],[exec prefix where pkg-config is installed]),
887             pkgconfig_config_exec_prefix="$withval",pkgconfig_config_exec_prefix="")
889 if test x$pkgconfig_config_exec_prefix != x ; then
890   pkgconfig_config_args="$pkgconfig_config_args --exec-prefix=$pkgconfig_config_exec_prefix"
891   if test x${PKG_CONFIG+set} != xset ; then
892     PKG_CONFIG=$pkgconfig_config_exec_prefix/bin/pkg-config
893   fi
895 if test x$pkgconfig_config_prefix != x ; then
896   pkgconfig_config_args="$pkgconfig_config_args --prefix=$pkgconfig_config_prefix"
897   if test x${PKG_CONFIG+set} != xset ; then
898     PKG_CONFIG=$pkgconfig_config_prefix/bin/pkg-config
899   fi
901 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
904 #-----------------------------------------------------------------------------
905 # Configure paths for FreeType2
906 # Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor
908 dnl AM_CHECK_FT2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
909 dnl Test for FreeType2, and define FT2_CFLAGS and FT2_LIBS
911 AC_DEFUN([AM_CHECK_FT2],
912 [dnl
913 dnl Get the cflags and libraries from the freetype-config script
915 AC_ARG_WITH(freetype-prefix,
916 AS_HELP_STRING([--with-freetype-prefix=PFX],[prefix where FreeType is installed (for Xft)]),
917             ft_config_prefix="$withval", ft_config_prefix="")
918 AC_ARG_WITH(freetype-exec-prefix,
919 AS_HELP_STRING([--with-freetype-exec-prefix=PFX],[exec prefix where FreeType is installed]),
920             ft_config_exec_prefix="$withval", ft_config_exec_prefix="")
921 AC_ARG_ENABLE(freetypetest,
922 AS_HELP_STRING([--disable-freetypetest],[do not try to compile and run a test FreeType program]),
923             [], enable_fttest=yes)
925 if test x$ft_config_exec_prefix != x ; then
926   ft_config_args="$ft_config_args --exec-prefix=$ft_config_exec_prefix"
927   if test x${FT2_CONFIG+set} != xset ; then
928     FT2_CONFIG=$ft_config_exec_prefix/bin/freetype-config
929   fi
931 if test x$ft_config_prefix != x ; then
932   ft_config_args="$ft_config_args --prefix=$ft_config_prefix"
933   if test x${FT2_CONFIG+set} != xset ; then
934     FT2_CONFIG=$ft_config_prefix/bin/freetype-config
935   fi
937 AC_PATH_PROG(FT2_CONFIG, freetype-config, no)
939 min_ft_version=ifelse([$1], ,6.1.0,$1)
940 AC_MSG_CHECKING(for FreeType - version >= $min_ft_version)
941 no_ft=""
942 if test "$FT2_CONFIG" = "no" ; then
943   no_ft=yes
944 else
945   FT2_CFLAGS=`$FT2_CONFIG $ft_config_args --cflags`
946   FT2_LIBS=`$FT2_CONFIG $ft_config_args --libs`
947   ft_config_major_version=`$FT2_CONFIG $ft_config_args --version | \
948          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\1/'`
949   ft_config_minor_version=`$FT2_CONFIG $ft_config_args --version | \
950          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\2/'`
951   ft_config_micro_version=`$FT2_CONFIG $ft_config_args --version | \
952          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\3/'`
953   ft_min_major_version=`echo $min_ft_version | \
954          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\1/'`
955   ft_min_minor_version=`echo $min_ft_version | \
956          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\2/'`
957   ft_min_micro_version=`echo $min_ft_version | \
958          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\3/'`
959   if test "x$enable_fttest" = "xyes" ; then
960     ft_config_is_lt=no
961     if test $ft_config_major_version -lt $ft_min_major_version ; then
962       ft_config_is_lt=yes
963     else
964       if test $ft_config_major_version -eq $ft_min_major_version ; then
965         if test $ft_config_minor_version -lt $ft_min_minor_version ; then
966           ft_config_is_lt=yes
967         else
968           if test $ft_config_minor_version -eq $ft_min_minor_version ; then
969             if test $ft_config_micro_version -lt $ft_min_micro_version ; then
970               ft_config_is_lt=yes
971             fi
972           fi
973         fi
974       fi
975     fi
976     if test "x$ft_config_is_lt" = "xyes" ; then
977       ifelse([$3], , :, [$3])
978     else
979       ac_save_CFLAGS="$CFLAGS"
980       ac_save_LIBS="$LIBS"
981       CFLAGS="$CFLAGS $FT2_CFLAGS"
982       LIBS="$FT2_LIBS $LIBS"
984 dnl Sanity checks for the results of freetype-config to some extent
986       AC_TRY_RUN([
987 #include <ft2build.h>
988 #include FT_FREETYPE_H
989 #include <stdio.h>
990 #include <stdlib.h>
993 main()
995   FT_Library library;
996   FT_Error error;
998   error = FT_Init_FreeType(&library);
1000   if (error)
1001     return 1;
1002   else
1003   {
1004     FT_Done_FreeType(library);
1005     return 0;
1006   }
1008 ],, no_ft=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
1009       CFLAGS="$ac_save_CFLAGS"
1010       LIBS="$ac_save_LIBS"
1011     fi             # test $ft_config_version -lt $ft_min_version
1012   fi               # test "x$enable_fttest" = "xyes"
1013 fi                 # test "$FT2_CONFIG" = "no"
1014 if test "x$no_ft" = x ; then
1015    AC_MSG_RESULT(yes)
1016    ifelse([$2], , :, [$2])
1017 else
1018    AC_MSG_RESULT(no)
1019    if test "$FT2_CONFIG" = "no" ; then
1020      echo "*** The freetype-config script installed by FreeType 2 could not be found."
1021      echo "*** If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in"
1022      echo "*** your path, or set the FT2_CONFIG environment variable to the"
1023      echo "*** full path to freetype-config."
1024    else
1025      echo "*** The FreeType test program failed to run.  If your system uses"
1026      echo "*** shared libraries and they are installed outside the normal"
1027      echo "*** system library path, make sure the variable LD_LIBRARY_PATH"
1028      echo "*** (or whatever is appropiate for your system) is correctly set."
1029    fi
1030    FT2_CFLAGS=""
1031    FT2_LIBS=""
1032    ifelse([$3], , :, [$3])
1034 AC_SUBST(FT2_CFLAGS)
1035 AC_SUBST(FT2_LIBS)
1038 #-----------------------------------------------------------------------------
1039 # Configure paths for fontconfig
1040 # Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor
1041 # modified by olicha for fontconfig
1043 dnl AM_CHECK_FC([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
1044 dnl Test for fontconfig, and define FC_CFLAGS and FC_LIBS
1046 AC_DEFUN([AM_CHECK_FC],
1047 [dnl
1048 dnl Get the cflags and libraries from the fontconfig-config script
1050 AC_ARG_WITH(fontconfig-prefix,
1051 AS_HELP_STRING([--with-fontconfig-prefix=PFX],[prefix where fontconfig is installed (for Xft2)]),
1052             fc_config_prefix="$withval", fc_config_prefix="")
1053 AC_ARG_WITH(fontconfig-exec-prefix,
1054 AS_HELP_STRING([--with-fontconfig-exec-prefix=PFX],[exec prefix where fontconfig is installed]),
1055             fc_config_exec_prefix="$withval", fc_config_exec_prefix="")
1056 AC_ARG_ENABLE(fontconfigtest,
1057 AS_HELP_STRING([--disable-fontconfigtest],[do not try to compile and run a test fontconfig program]),
1058             [], enable_fctest=yes)
1060 if test x$fc_config_exec_prefix != x ; then
1061   fc_config_args="$fc_config_args --exec-prefix=$fc_config_exec_prefix"
1062   if test x${FC_CONFIG+set} != xset ; then
1063     FC_CONFIG=$fc_config_exec_prefix/bin/fontconfig-config
1064   fi
1066 if test x$fc_config_prefix != x ; then
1067   fc_config_args="$fc_config_args --prefix=$fc_config_prefix"
1068   if test x${FC_CONFIG+set} != xset ; then
1069     FC_CONFIG=$fc_config_prefix/bin/fontconfig-config
1070   fi
1072 AC_PATH_PROG(FC_CONFIG, fontconfig-config, no)
1074 min_fc_version=ifelse([$1], ,1.0.1,$1)
1075 AC_MSG_CHECKING(for Fontconfig - version >= $min_fc_version)
1076 no_fc=""
1077 pkg_config_fontconfig_exists=""
1079 if test "$FC_CONFIG" = "no" ; then
1080   if test "x$PKG_CONFIG" != "xno" ; then
1081     if $PKG_CONFIG --exists 'fontconfig' ; then
1082       if $PKG_CONFIG --exists 'fontconfig >= $1' ; then
1083         FC_CFLAGS=`$PKG_CONFIG --cflags fontconfig`
1084         FC_LIBS=`$PKG_CONFIG --libs fontconfig`
1085       else
1086         no_fc=yes
1087         fc_config_is_lt=yes
1088       fi
1089     else
1090       pkg_config_fontconfig_exists="maybe"
1091       no_fc=yes
1092     fi
1093   else
1094     no_fc=yes
1095   fi
1096 else
1097   FC_CFLAGS=`$FC_CONFIG $fc_config_args --cflags`
1098   FC_LIBS=`$FC_CONFIG $fc_config_args --libs`
1099   fc_config_major_version=`$FC_CONFIG $fc_config_args --version | \
1100          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\1/'`
1101   fc_config_minor_version=`$FC_CONFIG $fc_config_args --version | \
1102          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\2/'`
1103   fc_config_micro_version=`$FC_CONFIG $fc_config_args --version | \
1104          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\3/'`
1105   fc_min_major_version=`echo $min_fc_version | \
1106          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\1/'`
1107   fc_min_minor_version=`echo $min_fc_version | \
1108          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\2/'`
1109   fc_min_micro_version=`echo $min_fc_version | \
1110          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\3/'`
1111   fc_config_is_lt=no
1112   if test $fc_config_major_version -lt $fc_min_major_version ; then
1113     fc_config_is_lt=yes
1114   else
1115     if test $fc_config_major_version -eq $fc_min_major_version ; then
1116       if test $fc_config_minor_version -lt $fc_min_minor_version ; then
1117         fc_config_is_lt=yes
1118       else
1119         if test $fc_config_minor_version -eq $fc_min_minor_version ; then
1120           if test $fc_config_micro_version -lt $fc_min_micro_version ; then
1121             fc_config_is_lt=yes
1122           fi
1123         fi
1124       fi
1125     fi
1126   fi
1127   if test "x$fc_config_is_lt" = "xyes" ; then
1128     no_fc=yes
1129   fi
1132 if test "x$no_fc" = x ; then
1133   if test "x$enable_fctest" = "xyes" ; then
1134     ac_save_CFLAGS="$CFLAGS"
1135     ac_save_LIBS="$LIBS"
1136     CFLAGS="$CFLAGS $FC_CFLAGS $FT2_CFLAGS"
1137     LIBS="$FC_LIBS $LIBS $FT2_LIBS"
1139 dnl Sanity checks for the results of fontconfig-config/pkg-config to some extent
1141       AC_TRY_RUN([
1142 #include <fontconfig/fontconfig.h>
1143 #include <stdio.h>
1144 #include <stdlib.h>
1147 main()
1149   FcBool result;
1151   result = FcInit();
1153   if (result)
1154   {
1155     return 0;
1156   }
1157   else
1158   {
1159     return 1;
1160   }
1162 ],, no_fc=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
1163     CFLAGS="$ac_save_CFLAGS"
1164     LIBS="$ac_save_LIBS"
1165   fi
1168 if test "x$no_fc" = x; then
1169   AC_MSG_RESULT(yes)
1170   ifelse([$2], , :, [$2])
1171 else
1172   AC_MSG_RESULT(no)
1173   if test "x$fc_config_is_lt" = "xyes"; then
1174     echo "*** Your Fontconfig package version is < $1"
1175   elif test "x$pkg_config_fontconfig_exists" = "xmaybe"; then
1176     echo "*** fontconfig was not found in the pkg-config search path."
1177     echo "*** either fontconfig is not installed or perhaps you should"
1178     echo "*** add the directory containing fontconfig.pc to the "
1179     echo "*** PKG_CONFIG_PATH environment variable."
1180   elif test "$FC_CONFIG" != "no"; then
1181     echo "*** The Fontconfig test program failed to run.  If your system uses"
1182     echo "*** shared libraries and they are installed outside the normal"
1183     echo "*** system library path, make sure the variable LD_LIBRARY_PATH"
1184     echo "*** (or whatever is appropiate for your system) is correctly set."
1185   fi
1186   FC_CFLAGS=""
1187   FC_LIBS=""
1188   ifelse([$3], , :, [$3])
1190 AC_SUBST(FC_CFLAGS)
1191 AC_SUBST(FC_LIBS)
1194 #-----------------------------------------------------------------------------
1195 # Configure paths for xft 2
1196 # Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor
1197 # modified by olicha for xft
1199 dnl AM_CHECK_XFT([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
1200 dnl Test for xft, and define XFT_CFLAGS and XFT_LIBS
1202 AC_DEFUN([AM_CHECK_XFT],
1203 [dnl
1204 dnl Get the cflags and libraries from the xft-config script
1206 AC_ARG_WITH(xft-prefix,
1207 AS_HELP_STRING([--with-xft-prefix=PFX],[prefix where Xft2 is installed (optional)]),
1208             xft_config_prefix="$withval", xft_config_prefix="")
1209 AC_ARG_WITH(xft-exec-prefix,
1210 AS_HELP_STRING([--with-xft-exec-prefix=PFX],[exec prefix where Xft2 is installed]),
1211             xft_config_exec_prefix="$withval", xft_config_exec_prefix="")
1212 AC_ARG_ENABLE(xfttest,
1213 AS_HELP_STRING([--disable-xfttest],[do not try to compile and run a test Xft program]),
1214             [], enable_xfttest=yes)
1216 if test x$xft_config_exec_prefix != x ; then
1217   xft_config_args="$xft_config_args --exec-prefix=$xft_config_exec_prefix"
1218   if test x${XFT_CONFIG+set} != xset ; then
1219     XFT_CONFIG=$xft_config_exec_prefix/bin/xft-config
1220   fi
1222 if test x$xft_config_prefix != x ; then
1223   xft_config_args="$xft_config_args --prefix=$xft_config_prefix"
1224   if test x${XFT_CONFIG+set} != xset ; then
1225     XFT_CONFIG=$xft_config_prefix/bin/xft-config
1226   fi
1228 AC_PATH_PROG(XFT_CONFIG, xft-config, no)
1230 min_xft_version=ifelse([$1], ,2.0.0,$1)
1231 AC_MSG_CHECKING(for Xft - version >= $min_xft_version)
1232 no_xft=""
1233 pkg_config_xft_exists=""
1235 if test "$XFT_CONFIG" = "no" ; then
1236   if test "x$PKG_CONFIG" != "xno" ; then
1237     if $PKG_CONFIG --exists 'xft' ; then
1238       if $PKG_CONFIG --exists 'xft >= $1' ; then
1239         XFT_CFLAGS=`$PKG_CONFIG --cflags xft`
1240         XFT_LIBS=`$PKG_CONFIG --libs xft`
1241       else
1242         no_xft=yes
1243         xft_config_is_lt=yes
1244       fi
1245     else
1246       pkg_config_xft_exists="maybe"
1247       no_xft=yes
1248     fi
1249   else
1250     no_xft=yes
1251   fi
1252 else
1253   XFT_CFLAGS=`$XFT_CONFIG $xft_config_args --cflags`
1254   XFT_LIBS=`$XFT_CONFIG $xft_config_args --libs`
1255   xft_config_major_version=`$XFT_CONFIG $xft_config_args --version | \
1256          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\1/'`
1257   xft_config_minor_version=`$XFT_CONFIG $xft_config_args --version | \
1258          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\2/'`
1259   xft_config_micro_version=`$XFT_CONFIG $xft_config_args --version | \
1260          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\3/'`
1261   xft_min_major_version=`echo $min_xft_version | \
1262          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\1/'`
1263   xft_min_minor_version=`echo $min_xft_version | \
1264          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\2/'`
1265   xft_min_micro_version=`echo $min_xft_version | \
1266          sed 's/^[[^0-9.]]*\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*$/\3/'`
1267   xft_config_is_lt=no
1268   if test $xft_config_major_version -lt $xft_min_major_version ; then
1269     xft_config_is_lt=yes
1270   else
1271     if test $xft_config_major_version -eq $xft_min_major_version ; then
1272       if test $xft_config_minor_version -lt $xft_min_minor_version ; then
1273         xft_config_is_lt=yes
1274       else
1275         if test $xft_config_minor_version -eq $xft_min_minor_version ; then
1276           if test $xft_config_micro_version -lt $xft_min_micro_version ; then
1277             xft_config_is_lt=yes
1278           fi
1279         fi
1280       fi
1281     fi
1282   fi
1283   if test "x$xft_config_is_lt" = "xyes" ; then
1284     ifelse([$3], , :, [$3])
1285   fi
1288 if test "x$no_xft" = x ; then
1289   if test "x$enable_xfttest" = "xyes" ; then
1290     ac_save_CFLAGS="$CFLAGS"
1291     ac_save_LIBS="$LIBS"
1292     CFLAGS="$XFT_CFLAGS $CFLAGS"
1293     LIBS="$XFT_LIBS $LIBS"
1295 dnl Sanity checks for the results of xft-config/pkg-config to some extent
1297       AC_TRY_RUN([
1298 #include <X11/Xft/Xft.h>
1299 #include <stdio.h>
1300 #include <stdlib.h>
1303 main()
1305   FcBool result = 1;
1307   result = XftInit(NULL);
1309   if (result)
1310   {
1311     return 0;
1312   }
1313   else
1314   {
1315     return 1;
1316   }
1318 ],, no_xft=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
1319     CFLAGS="$ac_save_CFLAGS"
1320     LIBS="$ac_save_LIBS"
1321   fi
1324 if test "x$no_xft" = x; then
1325   AC_MSG_RESULT(yes)
1326   ifelse([$2], , :, [$2])
1327 else
1328   AC_MSG_RESULT(no)
1329   if test "x$xft_config_is_lt" = "xyes"; then
1330     echo "*** Your xft2 package version is < $1"
1331   elif test "x$pkg_config_fontconfig_exists" = "xmaybe" ; then
1332     echo "*** xft2 was not found in the pkg-config search path."
1333     echo "*** either xft is not installed or perhaps you should"
1334     echo "*** add the directory containing xft.pc to the "
1335     echo "*** PKG_CONFIG_PATH environment variable."
1336   elif test "$XFT_CONFIG" = "no"; then
1337     echo "*** The xft-config script installed by Xft 2 could not be found."
1338     echo "*** If Xft 2 was installed in PREFIX, make sure PREFIX/bin is in"
1339     echo "*** your path, or set the XFT_CONFIG environment variable to the"
1340     echo "*** full path to xft-config."
1341   else
1342     echo "*** The Xft test program failed to run.  If your system uses"
1343     echo "*** shared libraries and they are installed outside the normal"
1344     echo "*** system library path, make sure the variable LD_LIBRARY_PATH"
1345     echo "*** (or whatever is appropiate for your system) is correctly set."
1346   fi
1347   XFT_CFLAGS=""
1348   XFT_LIBS=""
1349   ifelse([$3], , :, [$3])
1351 AC_SUBST(XFT_CFLAGS)
1352 AC_SUBST(XFT_LIBS)
1355 #-----------------------------------------------------------------------------
1356 # gettext stuff from the gettext package
1358 # Authors: Ulrich Drepper <drepper@cygnus.com>, 1996.
1359 # modified by the fvwm workers
1362 AC_DEFUN([AM_GNU_FGETTEXT],
1364   AC_REQUIRE([AM_PO_SUBDIRS])dnl
1366   intl_LIBS=
1367   intl_CFLAGS=
1368   POSUB=
1370   found_gettext=yes
1372   dnl check for the necessary stuff in the libc
1373   dnl the pbs is that we can detect this stuff but in fact the included
1374   dnl libintl.h is from gettext
1375   dnl Moreover, we do not try to use other implementation, but we may try
1376   dnl one day
1377   $UNSET ac_cv_header_intl_h
1378   $UNSET ac_cv_func_gettext
1379   $UNSET ac_cv_func_bindtextdomain
1380   $UNSET ac_cv_func_textdomain
1381   dnl a "gnu extension"
1382   $UNSET ac_cv_func_dgettext
1383   #bind_textdomain_codeset
1384   AC_CHECK_HEADER(libintl.h,
1385     [AC_CHECK_FUNCS(gettext bindtextdomain textdomain dgettext,,
1386       found_gettext=no)], found_gettext=no)
1388   AC_MSG_CHECKING([for gnu gettext in libc])
1389   if test x"$found_gettext" = "xyes"; then
1390     problem_gettext=" (libc)"
1391     AC_MSG_RESULT([yes])
1392     AC_MSG_CHECKING(if a simple gettext program link)
1393     AC_TRY_LINK([
1394       #include <libintl.h>
1395       ],
1396       [const char *c; c = gettext("foo");],
1397       found_gettext=yes;problem_gettext=" (libc)", found_gettext=no)
1398     AC_MSG_RESULT($found_gettext)
1399   else
1400     AC_MSG_RESULT([no])
1401   fi
1403   if test x"$found_gettext" = xno; then
1404     dnl not found, check for libintl
1405     $UNSET ac_cv_header_intl_h
1406     $UNSET ac_cv_lib_intl_bindtextdomain
1407     $UNSET ac_cv_lib_intl_textdomain
1408     $UNSET ac_cv_lib_intl_dgettext
1409     smr_CHECK_LIB(intl, intl, for Native Language Support,
1410       bindtextdomain, libintl.h)
1411     if test x"$intl_LIBS" != x; then
1412       no_textdomain=no
1413       no_dgettext=no
1414       ac_save_CFLAGS="$CFLAGS"
1415       ac_save_LIBS="$LIBS"
1416       AC_CHECK_LIB(intl, textdomain,, no_textdomain=yes,
1417         [$intl_LIBS $iconv_LIBS])
1418       if test "$no_textdomain" != "yes"; then
1419         AC_CHECK_LIB(intl, dgettext,, no_dgettext=yes, [$intl_LIBS $iconv_LIBS])
1420         if test "$no_dgettext" != "yes"; then
1421           CFLAGS="$CFLAGS $intl_LIBS $iconv_LIBS"
1422           LIBS="$LIBS $intl_LIBS $iconv_LIBS"
1423           AC_MSG_CHECKING(if a simple gettext program link)
1424           AC_TRY_LINK([
1425           #include <libintl.h>
1426           ],
1427           [const char *c; c = gettext("foo");],
1428           found_gettext=yes;problem_gettext=" (intl library)", found_gettext=no)
1429           AC_MSG_RESULT($found_gettext)
1430         fi
1431       fi
1432       CFLAGS="$ac_save_CFLAGS"
1433       LIBS="$ac_save_LIBS"
1434     fi
1435   fi
1437   if test "$found_gettext" = "yes"; then
1438     dnl Mark actions to use GNU gettext tools.
1439     CATOBJEXT=.gmo
1440     USE_NLS=yes
1441     dnl We need to process the po/ directory.
1442     POSUB=po
1443   else
1444     USE_NLS=no
1445   fi
1447   dnl Make the po/ variables we use known to autoconf
1451 dnl Checks for all prerequisites of the po subdirectory,
1452 dnl except for USE_NLS.
1453 AC_DEFUN([AM_PO_SUBDIRS],
1455   AC_REQUIRE([AC_PROG_MAKE_SET])dnl
1456   AC_REQUIRE([AC_PROG_INSTALL])dnl
1457   AC_REQUIRE([AM_MKINSTALLDIRS])dnl
1459   dnl Perform the following tests also if --disable-nls has been given,
1460   dnl because they are needed for "make dist" to work.
1462   dnl Search for GNU msgfmt in the PATH.
1463   dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions.
1464   dnl The second test excludes FreeBSD msgfmt.
1465   AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
1466     [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 &&
1467      (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
1468     :)
1469   AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
1471   dnl Search for GNU xgettext 0.11 or newer in the PATH.
1472   dnl The first test excludes Solaris xgettext and early GNU xgettext versions.
1473   dnl The second test excludes FreeBSD xgettext.
1474   AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
1475     [$ac_dir/$ac_word --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
1476      (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)],
1477     :)
1478   dnl Remove leftover from FreeBSD xgettext call.
1479   rm -f messages.po
1481   dnl Search for GNU msgmerge 0.11 or newer in the PATH.
1482   AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
1483     [$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1], :)
1485   dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
1486   dnl Test whether we really found GNU msgfmt.
1487   if test "$GMSGFMT" != ":"; then
1488     dnl If it is no GNU msgfmt we define it as : so that the
1489     dnl Makefiles still can work.
1490     if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 &&
1491        (if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
1492       : ;
1493     else
1494       GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'`
1495       AC_MSG_RESULT(
1496         [found $GMSGFMT program is not GNU msgfmt; ignore it])
1497       GMSGFMT=":"
1498     fi
1499   fi
1501   dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
1502   dnl Test whether we really found GNU xgettext.
1503   if test "$XGETTEXT" != ":"; then
1504     dnl If it is no GNU xgettext we define it as : so that the
1505     dnl Makefiles still can work.
1506     if $XGETTEXT --omit-header --copyright-holder= /dev/null >/dev/null 2>&1 &&
1507        (if $XGETTEXT --omit-header --copyright-holder= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
1508       : ;
1509     else
1510       AC_MSG_RESULT(
1511         [found xgettext program is not GNU xgettext; ignore it])
1512       XGETTEXT=":"
1513     fi
1514     dnl Remove leftover from FreeBSD xgettext call.
1515     rm -f messages.po
1516   fi
1518   AC_PATH_PROG(MSGUNIQ, msguniq, $MSGUNIQ)
1520   AC_MSG_CHECKING([for NLS fvwm messages catalogs])
1521   AC_MSG_RESULT([$ALL_LINGUAS])
1522   POFILES=
1523   GMOFILES=
1524   UPDATEPOFILES=
1525   DUMMYPOFILES=
1526   for lang in $ALL_LINGUAS; do
1527     for dom in $ALL_DOMAINS; do
1528       POFILES="$POFILES $dom.$lang.po"
1529       GMOFILES="$GMOFILES $dom.$lang.gmo"
1530       UPDATEPOFILES="$UPDATEPOFILES $dom.$lang.po-update"
1531       DUMMYPOFILES="$DUMMYPOFILES $dom.$lang.nop"
1532     done
1533   done
1534   # CATALOGS depends on both $ac_dir and the user's LINGUAS environment variable.
1535   INST_LINGUAS=
1536   AC_MSG_CHECKING([for NLS desired catalogs to be installed])
1537   #if test "%UNSET%" != "$LINGUAS"; then
1538   # FIXME: How to check if LINGUAS has been *set* to ""
1539   if test -n "$LINGUAS"; then
1540     AC_MSG_RESULT([$LINGUAS])
1541   else
1542     AC_MSG_RESULT([all])
1543   fi
1544   AC_MSG_CHECKING([for NLS messages catalogs to be installed])
1545   if test -n "$ALL_LINGUAS"; then
1546     for presentlang in $ALL_LINGUAS; do
1547       useit=no
1548       #if test "%UNSET%" != "$LINGUAS"; then
1549       if test -n "$LINGUAS"; then
1550         desiredlanguages="$LINGUAS"
1551       else
1552         desiredlanguages="$ALL_LINGUAS"
1553       fi
1554       for desiredlang in $desiredlanguages; do
1555         # Use the presentlang catalog if desiredlang is
1556         #   a. equal to presentlang, or
1557         #   b. a variant of presentlang (because in this case,
1558         #      presentlang can be used as a fallback for messages
1559         #      which are not translated in the desiredlang catalog).
1560         case "$desiredlang" in
1561           "$presentlang"*) useit=yes;;
1562         esac
1563       done
1564       if test $useit = yes; then
1565         INST_LINGUAS="$INST_LINGUAS $presentlang"
1566       fi
1567     done
1568   fi
1569   AC_MSG_RESULT([$INST_LINGUAS])
1570   CATALOGS=
1571   if test -n "$INST_LINGUAS"; then
1572     for lang in $INST_LINGUAS; do
1573       CATALOGS="$CATALOGS $lang.gmo"
1574     done
1575   fi
1580 AC_DEFUN([AM_MKINSTALLDIRS],
1582   dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
1583   dnl find the mkinstalldirs script in another subdir but $(top_srcdir).
1584   dnl Try to locate is.
1585   MKINSTALLDIRS=
1586   if test -n "$ac_aux_dir"; then
1587     MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
1588   fi
1589   if test -z "$MKINSTALLDIRS"; then
1590     MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
1591   fi
1594 # Search path for a program which passes the given test.
1596 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
1597 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
1598 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
1599 [# Extract the first word of "$2", so it can be a program name with args.
1600 set dummy $2; ac_word=[$]2
1601 AC_MSG_CHECKING([for $ac_word])
1602 AC_CACHE_VAL(ac_cv_path_$1,
1603 [case "[$]$1" in
1604   /*)
1605   ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
1606   ;;
1607   *)
1608   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
1609   for ac_dir in ifelse([$5], , $PATH, [$5]); do
1610     test -z "$ac_dir" && ac_dir=.
1611     if test -f $ac_dir/$ac_word; then
1612       if [$3]; then
1613         ac_cv_path_$1="$ac_dir/$ac_word"
1614         break
1615       fi
1616     fi
1617   done
1618   IFS="$ac_save_ifs"
1619 dnl If no 4th arg is given, leave the cache variable unset,
1620 dnl so AC_PATH_PROGS will keep looking.
1621 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
1622 ])dnl
1623   ;;
1624 esac])dnl
1625 $1="$ac_cv_path_$1"
1626 if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
1627   AC_MSG_RESULT([$]$1)
1628 else
1629   AC_MSG_RESULT(no)
1631 AC_SUBST($1)dnl
1635 dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
1636 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
1639 #-----------------------------------------------------------------------------
1640 # Safety check for mkstemp
1642 AC_DEFUN([AM_SAFETY_CHECK_MKSTEMP],[
1643   AC_CHECK_FUNCS(mkstemp)
1644   has_safety_mkstemp=no
1645   AC_MSG_CHECKING(if mkstemp is safe)
1646   if test x$ac_cv_func_mkstemp != xno; then
1647     AC_TRY_RUN([
1648 #include <stdio.h>
1649 #include <stdlib.h>
1650 #include <string.h>
1651 int main(void)
1653   char template[128];
1654   char template_orig[128];
1655   int fd;
1657   sprintf(template, "configure-mkstemp-test.XXXXXX");
1658   strcpy(template_orig, template);
1659   fd = mkstemp(template);
1660   if (fd == -1)
1661   {
1662     /* could not create temp file */
1663     return 1;
1664   }
1665   if (strcmp(template, template_orig) == 0)
1666   {
1667     /* mkstemp broken */
1668     return 2;
1669   }
1670   if (close(fd) != 0)
1671   {
1672     /* doh! */
1673     return 3;
1674   }
1675   if (unlink(template))
1676   {
1677      return 4;
1678   }
1679   /* mkstemp works properly */
1680   return 0;
1682     ],
1683     [has_safety_mkstemp=yes], [has_safety_mkstemp=no])
1684   fi
1685   AH_TEMPLATE([HAVE_SAFETY_MKSTEMP],[Enable the use of mkstemp])
1686   if test x$has_safety_mkstemp = xno; then
1687     AC_MSG_RESULT(no, use our mkstemp)
1688   else
1689     AC_MSG_RESULT(yes)
1690     AC_DEFINE(HAVE_SAFETY_MKSTEMP)
1691   fi