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:
committed by
Carlos R. Mafra
parent
311ab6b08c
commit
b66a890404
25
configure.ac
25
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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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//`
|
||||
|
||||
|
||||
@@ -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 <config.h>
|
||||
|
||||
#ifdef USE_XPM
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@@ -271,5 +269,3 @@ RImage *RLoadXPM(RContext * context, const char *file)
|
||||
XpmFreeXpmImage(&xpm);
|
||||
return image;
|
||||
}
|
||||
|
||||
#endif /* USE_XPM */
|
||||
|
||||
Reference in New Issue
Block a user