diff --git a/configure.ac b/configure.ac index 605bc8fa..bdc1bbee 100644 --- a/configure.ac +++ b/configure.ac @@ -124,6 +124,7 @@ AS_IF([test "x$debug" = "xyes"], dnl Tracking on what is detected for final status dnl ============================================= unsupported="" +supported_gfx="" dnl Platform-specific Makefile setup @@ -625,24 +626,14 @@ dnl ============================================== dnl XPM Support dnl =========== -xpm=yes -AC_ARG_ENABLE(xpm, AS_HELP_STRING([--disable-xpm], [disable use of XPM pixmaps through libXpm]), - xpm=$enableval, xpm=yes) +AC_ARG_ENABLE([xpm], + [AS_HELP_STRING([--disable-xpm], [disable use of XPM pixmaps through libXpm])], + [AS_CASE(["$enableval"], + [yes|no], [], + [AC_MSG_ERROR([bad value $enableval for --enable-xpm])] )], + [enable_xpm=auto]) +WM_IMGFMT_CHECK_XPM -if test "$xpm" = yes; then - WM_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [$XLFLAGS $XLIBS]) - - if test "x$ac_cv_lib_Xpm_XpmCreatePixmapFromData" = xyes; then - WM_CHECK_HEADER(X11/xpm.h) - if test "x$ac_cv_header_X11_xpm_h" = xyes; then - GFXLIBS="$GFXLIBS -lXpm" - supported_gfx="XPM" - AC_DEFINE(USE_XPM, 1, [define if XPM libraries are available (set by configure)]) - else - supported_gfx="builtin-XPM" - fi - fi -fi # for wmlib AC_SUBST(XCFLAGS) @@ -835,7 +826,7 @@ echo "Installation path prefix : $prefix" echo "Installation path for binaries : $_bindir" echo "Installation path for libraries : $libdir" echo "Installation path for WPrefs.app : $wprefs_base_dir" | sed -e 's|\${prefix}|'"$prefix|" -echo "Supported graphic format libraries : $supported_gfx" +echo "Supported graphic format libraries :$supported_gfx" echo "Unsupported features :$unsupported" echo "Antialiased text support in WINGs : $xft" echo "Xinerama extension support : $xinerama" diff --git a/m4/wm_imgfmt_check.m4 b/m4/wm_imgfmt_check.m4 index 2ab9a17a..cd276b07 100644 --- a/m4/wm_imgfmt_check.m4 +++ b/m4/wm_imgfmt_check.m4 @@ -248,6 +248,55 @@ AM_CONDITIONAL([USE_TIFF], [test "x$enable_tiff" != "xno"])dnl ]) dnl AC_DEFUN +# WM_IMGFMT_CHECK_XPM +# ------------------- +# +# Check for XPM file support through 'libXpm' +# The check depends on variable 'enable_xpm' being either: +# yes - detect, fail if not found +# no - do not detect, use internal support +# auto - detect, use internal if not found +# +# When found, append appropriate stuff in GFXLIBS, and append info to +# the variable 'supported_gfx' +AC_DEFUN_ONCE([WM_IMGFMT_CHECK_XPM], +[AC_REQUIRE([_WM_IMGFMT_CHECK_FUNCTS]) +AS_IF([test "x$enable_xpm" = "xno"], + [supported_gfx="$supported_gfx builtin-XPM"], + [AC_CACHE_CHECK([for XPM support library], [wm_cv_imgfmt_xpm], + [wm_cv_imgfmt_xpm=no + dnl + dnl We check first if one of the known libraries is available + wm_save_LIBS="$LIBS" + AS_IF([wm_fn_imgfmt_try_link "XpmCreatePixmapFromData" "$XLFLAGS $XLIBS -lXpm"], + [wm_cv_imgfmt_xpm="-lXpm" ; break]) + LIBS="$wm_save_LIBS" + AS_IF([test "x$enable_xpm$wm_cv_imgfmt_xpm" = "xyesno"], + [AC_MSG_ERROR([explicit libXpm support requested but no library found])]) + AS_IF([test "x$wm_cv_imgfmt_xpm" != "xno"], + [dnl + dnl A library was found, now check for the appropriate header + wm_save_CFLAGS="$CFLAGS" + AS_IF([wm_fn_imgfmt_try_compile "X11/xpm.h" "return 0" "$XCFLAGS"], + [], + [AC_MSG_ERROR([found $wm_cv_imgfmt_xpm but could not find appropriate header - are you missing libXpm-dev package?])]) + AS_IF([wm_fn_imgfmt_try_compile "X11/xpm.h" 'XpmReadFileToXpmImage((char *)filename, NULL, NULL)' "$XCFLAGS"], + [], + [AC_MSG_ERROR([found $wm_cv_imgfmt_xpm and header, but cannot compile - unsupported version?])]) + CFLAGS="$wm_save_CFLAGS"]) + ]) + AS_IF([test "x$wm_cv_imgfmt_xpm" = "xno"], + [supported_gfx="$supported_gfx builtin-XPM" + enable_xpm="no"], + [supported_gfx="$supported_gfx XPM" + GFXLIBS="$GFXLIBS $wm_cv_imgfmt_xpm" + AC_DEFINE([USE_XPM], [1], + [defined when valid XPM library with header was found])]) + ]) +AM_CONDITIONAL([USE_XPM], [test "x$enable_xpm" != "xno"])dnl +]) dnl AC_DEFUN + + # _WM_IMGFMT_CHECK_FUNCTS # ----------------------- # (internal shell functions) diff --git a/wrlib/Makefile.am b/wrlib/Makefile.am index 5f4946a1..ded558ed 100644 --- a/wrlib/Makefile.am +++ b/wrlib/Makefile.am @@ -35,7 +35,6 @@ libwraster_la_SOURCES = \ rotate.c \ convolve.c \ nxpm.c \ - xpm.c \ xutil.c \ ppm.c @@ -55,6 +54,10 @@ if USE_TIFF libwraster_la_SOURCES += tiff.c endif +if USE_XPM +libwraster_la_SOURCES += xpm.c +endif + LTCOMPILE2=`echo $(LTCOMPILE) | sed -e s/-fomit-frame-pointer//` COMPILE2=`echo $(COMPILE) | sed -e s/-fomit-frame-pointer//` diff --git a/wrlib/xpm.c b/wrlib/xpm.c index 12aadc60..441d957c 100644 --- a/wrlib/xpm.c +++ b/wrlib/xpm.c @@ -1,4 +1,4 @@ -/* xpm.c - load XPM image from file +/* xpm.c - load XPM image from file using libXpm * * Raster graphics library * @@ -22,8 +22,6 @@ #include -#ifdef USE_XPM - #include #include #include @@ -271,5 +269,3 @@ RImage *RLoadXPM(RContext * context, const char *file) XpmFreeXpmImage(&xpm); return image; } - -#endif /* USE_XPM */