From: Christophe CURIS <christophe.cu...@free.fr>

Took the opportunity to expand the WM_LIB_CHECK macro because it is not
suited for the case where compilation flags can be queried but was meant
for the case when they have to be guessed

Signed-off-by: Christophe CURIS <christophe.cu...@free.fr>
---
 configure.ac          | 25 -------------------------
 m4/wm_imgfmt_check.m4 | 50 +++++++++++++++++++++++++++++++++++++++++++-------
 2 files changed, 43 insertions(+), 32 deletions(-)

diff --git a/configure.ac b/configure.ac
index f077da5..6b9bca2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -322,11 +322,6 @@ dnl ==========
 dnl AC_ARG_VAR(PKGCONFIG, [pkg-config command])
 AC_CHECK_PROG(PKGCONFIG, pkg-config, pkg-config) 
 
-dnl MagickWand-config
-dnl ==========
-dnl AC_ARG_VAR(MAGICKWCONFIG, [MagickWand-config command])
-AC_CHECK_PROG(MAGICKWCONFIG, MagickWand-config, MagickWand-config)
-
 dnl gettext
 dnl =======
 
@@ -564,26 +559,6 @@ else
 fi
 AC_SUBST(FCLIBS)
 
-dnl
-dnl libMagickWand
-dnl
-AC_MSG_CHECKING([for libmagickwand header])
-MAGICKFLAGS=`$MAGICKWCONFIG --cflags`
-if test "x$MAGICKFLAGS" = "x" ; then
-        AC_MSG_RESULT([not found])
-else
-        AC_MSG_RESULT([found])
-fi
-AC_SUBST(MAGICKFLAGS)
-
-AC_MSG_CHECKING([for libmagickwand library])
-MAGICKLIBS=`$MAGICKWCONFIG --ldflags`
-if test "x$MAGICKLIBS" = "x" ; then
-        AC_MSG_RESULT([not found])
-else
-        AC_MSG_RESULT([found])
-fi
-AC_SUBST(MAGICKLIBS)
 
 dnl Xft2 antialiased font support
 dnl =============================
diff --git a/m4/wm_imgfmt_check.m4 b/m4/wm_imgfmt_check.m4
index 2bf9e74..8e003bf 100644
--- a/m4/wm_imgfmt_check.m4
+++ b/m4/wm_imgfmt_check.m4
@@ -259,11 +259,47 @@ AM_CONDITIONAL([USE_XPM], [test "x$enable_xpm" != 
"xno"])dnl
 # and MAGICKLIBS, and append info to the variable 'supported_gfx'
 # When not found, append info to variable 'unsupported'
 AC_DEFUN_ONCE([WM_IMGFMT_CHECK_MAGICK],
-[WM_LIB_CHECK([MAGICK], ["$MAGICKLIBS"], [MagickGetImagePixels], [$XLFLAGS 
$XLIBS],
-    [wm_save_CFLAGS="$CFLAGS $MAGICKLIBS"
-     AS_IF([wm_fn_lib_try_compile "wand/magick_wand.h" "" "return 0" ""],
-         [],
-         [AC_MSG_ERROR([found $CACHEVAR but could not find appropriate header 
- are you missing libmagickwand package?])])
-     CFLAGS="$wm_save_CFLAGS"],
-    [supported_gfx], [GFXLIBS])dnl
+[AC_REQUIRE([_WM_LIB_CHECK_FUNCTS])
+AS_IF([test "x$enable_magick" = "xno"],
+    [unsupported="$unsupported Magick"],
+    [AC_CHECK_PROG([MAGICKWCONFIG], [MagickWand-config], [MagickWand-config])
+     AS_IF([test "x$MAGICKWCONFIG" = "x"],
+         [AS_IF([test "x$enable_magick" = "xyes"],
+             [AC_MSG_ERROR([explicit Magick support requested but 
MagickWand-config not found])])
+          enable_magick=no
+          unsupported="$unsupported Magick"],
+         [AC_CACHE_CHECK([for Magick support library], [wm_cv_libchk_magick],
+             [wm_cv_libchk_magick=no
+              wm_cv_libchk_magick_cflags=`$MAGICKWCONFIG --cflags`
+              wm_cv_libchk_magick_libs=`$MAGICKWCONFIG --ldflags`
+              wm_save_LIBS="$LIBS"
+              dnl
+              dnl We check that the library is available
+              AS_IF([wm_fn_lib_try_link "MagickGetImagePixels" 
"$wm_cv_libchk_magick_libs"],
+                  [wm_cv_libchk_magick=maybe])
+              LIBS="$wm_save_LIBS"
+              AS_IF([test "x$enable_magick$wm_cv_libchk_magick" = "xyesno"],
+                  [AC_MSG_ERROR([explicit Magick support requested but library 
does not link])])
+              dnl
+              dnl The library was found, check if header is available and 
compiles
+              AS_IF([test "x$wm_cv_libchk_magick" != "xno"],
+                  [wm_save_CFLAGS="$CFLAGS"
+                   AS_IF([wm_fn_lib_try_compile "wand/magick_wand.h" "" 
"return 0" "$wm_cv_libchk_magick_cflags"],
+                       [wm_cv_libchk_magick="$wm_cv_libchk_magick_cflags % 
$wm_cv_libchk_magick_libs"],
+                       [AC_MSG_ERROR([found Magick library but could not 
compile appropriate header - are you missing libmagickwand-dev package?])])
+                   CFLAGS="$wm_save_CFLAGS"])
+             ])
+          AS_IF([test "x$wm_cv_libchk_magick" = "xno"],
+             [unsupported="$unsupported Magick"
+              enable_magick="no"],
+             [supported_gfx="$supported_gfx Magick"
+              MAGICKFLAGS=`echo "$wm_cv_libchk_magick" | sed -e 's, *%.*$,,' `
+               MAGICKLIBS=`echo "$wm_cv_libchk_magick" | sed -e 's,^.*% *,,' `
+              AC_DEFINE([USE_MAGICK], [1],
+                  [defined when MagickWand library with header was found])])
+         ])dnl AS_IF(MAGICKWCONFIG != "")
+    ])
+AM_CONDITIONAL([USE_MAGICK], [test "x$enable_magick" != "xno"])dnl
+AC_SUBST(MAGICKFLAGS)dnl
+AC_SUBST(MAGICKLIBS)dnl
 ]) dnl AC_DEFUN
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to