webperimental: killstack decides stack protects.
[freeciv.git] / m4 / magickwand.m4
blob931c4ed256216bf5619c16218d81308c52d15609
1 # Check for MagickWand (ImageMagick)
3 # FC_CHECK_MAGICKWAND([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
5 AC_DEFUN([FC_CHECK_MAGICKWAND],
7   AC_ARG_WITH([magickwand],
8     AS_HELP_STRING([--with-magickwand[=DIR]], [Imagemagick installation directory (optional)]),
9 [magickwand_dir="$withval"], [magickwand_dir=""])
11   WAND_CONFIG_PATH=""
12   if test "x$magickwand_dir" = "x" ; then
13     PKG_CHECK_MODULES([WAND], [MagickWand], [wand=yes], [wand=no])
15     if test "x$wand" = "xno" ; then
16       AC_MSG_CHECKING([for MagickWand-config in default path])
18       for i in /usr/local /usr;
19       do
20         test -r $i/bin/${host}-MagicWand-config &&
21         WAND_CONFIG_PATH=$i/bin && WAND_CONFIG_NAME=${host}-MagickWand-config &&
22         break
23       done
25       if test x$WAND_CONFIG_PATH = x ; then
26         for i in /usr/local /usr;
27         do
28           test -r $i/bin/MagickWand-config &&
29           WAND_CONFIG_PATH=$i/bin && WAND_CONFIG_NAME=MagickWand-config && break
30         done
31       fi
32     fi
33   else
34     AC_MSG_CHECKING([for MagickWand-config])
36     if test -r $magickwand_dir/${host}-MagickWand-config &&
37     WAND_CONFIG_PATH=$magickwand_dir && WAND_CONFIG_NAME=${host}-MagickWand-config
38     then
39       :
40     else
41       test -r $magickwand_dir/MagickWand-config &&
42       WAND_CONFIG_PATH=$magickwand_dir && WAND_CONFIG_NAME=MagickWand-config
43     fi
44   fi
46   if test "x$wand" != "xyes" ; then
47     if test -z "$WAND_CONFIG_PATH" ; then
48       AC_MSG_RESULT([no])
49     else
50       AC_MSG_RESULT([found in $WAND_CONFIG_PATH])
52       AC_MSG_CHECKING([for $WAND_CONFIG_NAME --cflags])
53       WAND_CFLAGS="`$WAND_CONFIG_PATH/$WAND_CONFIG_NAME --cflags`"
54       AC_MSG_RESULT([$WAND_CFLAGS])
56       AC_MSG_CHECKING([for $WAND_CONFIG_NAME --libs])
57       WAND_LIBS="`$WAND_CONFIG_PATH/$WAND_CONFIG_NAME --libs`"
58       AC_MSG_RESULT([$WAND_LIBS])
60       wand=yes
61     fi
62   fi
64   if test "x$wand" = "xyes" ; then
65     dnl
66     dnl MagickWand uses -lbz2 (at least on opensuse) - test it
67     dnl
68     ac_save_CFLAGS="$CFLAGS"
69     ac_save_LIBS="$LIBS"
70     CFLAGS="$CFLAGS $WAND_CFLAGS"
71     LIBS="$WAND_LIBS $LIBS"
73     AC_MSG_CHECKING([for all development tools needed for MagickWand])
74     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <wand/magick_wand.h>]],
75 [MagickWand *mw = NewMagickWand();])], [AC_MSG_RESULT([yes])],
76 [AC_MSG_RESULT([no])
77 wand=no
78 AC_MSG_WARN([MagickWand deactivated due to missing development packages.])])
80     dnl
81     dnl reset variables to old values
82     dnl
83     CFLAGS="$ac_save_CFLAGS"
84     LIBS="$ac_save_LIBS"
85   fi
87   AC_SUBST([WAND_CFLAGS])
88   AC_SUBST([WAND_LIBS])
90   if test "x$wand" = "xyes" ; then
91     ifelse([$1], , :, [$1])
92   else
93     ifelse([$2], , :, [$2])
94   fi