1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

wrlib: Moved configure's detection of XPM support to a dedicated macro

The original check was not compliant with autoconf's syntax, did not
have a very good behaviour for user and was not easy to make evolve.

The new macro:
 - uses as much as possible autoconf macros for portability and code
consistency;
 - provides a consistent behaviour on yes/no/auto (if user explicitly
enables support, do not silently disable if not found; if library is found
but not the header, complain to let user install it or explicitly disable
support);
 - makes uses of shell functions to keep generated configure smaller by
sharing reusable stuff;
 - uses an automake conditional to avoid compiling the file is support is
not enabled

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2013-11-08 18:49:58 +01:00
committed by Carlos R. Mafra
parent 311ab6b08c
commit b66a890404
4 changed files with 63 additions and 24 deletions

View File

@@ -124,6 +124,7 @@ AS_IF([test "x$debug" = "xyes"],
dnl Tracking on what is detected for final status dnl Tracking on what is detected for final status
dnl ============================================= dnl =============================================
unsupported="" unsupported=""
supported_gfx=""
dnl Platform-specific Makefile setup dnl Platform-specific Makefile setup
@@ -625,24 +626,14 @@ dnl ==============================================
dnl XPM Support dnl XPM Support
dnl =========== dnl ===========
xpm=yes AC_ARG_ENABLE([xpm],
AC_ARG_ENABLE(xpm, AS_HELP_STRING([--disable-xpm], [disable use of XPM pixmaps through libXpm]), [AS_HELP_STRING([--disable-xpm], [disable use of XPM pixmaps through libXpm])],
xpm=$enableval, xpm=yes) [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 # for wmlib
AC_SUBST(XCFLAGS) AC_SUBST(XCFLAGS)

View File

@@ -248,6 +248,55 @@ AM_CONDITIONAL([USE_TIFF], [test "x$enable_tiff" != "xno"])dnl
]) dnl AC_DEFUN ]) 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 # _WM_IMGFMT_CHECK_FUNCTS
# ----------------------- # -----------------------
# (internal shell functions) # (internal shell functions)

View File

@@ -35,7 +35,6 @@ libwraster_la_SOURCES = \
rotate.c \ rotate.c \
convolve.c \ convolve.c \
nxpm.c \ nxpm.c \
xpm.c \
xutil.c \ xutil.c \
ppm.c ppm.c
@@ -55,6 +54,10 @@ if USE_TIFF
libwraster_la_SOURCES += tiff.c libwraster_la_SOURCES += tiff.c
endif endif
if USE_XPM
libwraster_la_SOURCES += xpm.c
endif
LTCOMPILE2=`echo $(LTCOMPILE) | sed -e s/-fomit-frame-pointer//` LTCOMPILE2=`echo $(LTCOMPILE) | sed -e s/-fomit-frame-pointer//`
COMPILE2=`echo $(COMPILE) | sed -e s/-fomit-frame-pointer//` COMPILE2=`echo $(COMPILE) | sed -e s/-fomit-frame-pointer//`

View File

@@ -1,4 +1,4 @@
/* xpm.c - load XPM image from file /* xpm.c - load XPM image from file using libXpm
* *
* Raster graphics library * Raster graphics library
* *
@@ -22,8 +22,6 @@
#include <config.h> #include <config.h>
#ifdef USE_XPM
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@@ -271,5 +269,3 @@ RImage *RLoadXPM(RContext * context, const char *file)
XpmFreeXpmImage(&xpm); XpmFreeXpmImage(&xpm);
return image; return image;
} }
#endif /* USE_XPM */