mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 04:20:27 +01:00
wrlib: Moved configure's detection of JPEG 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
f8d9e4cd53
commit
777bf28ab3
53
configure.ac
53
configure.ac
@@ -691,26 +691,13 @@ fi
|
|||||||
|
|
||||||
dnl JPEG Support
|
dnl JPEG Support
|
||||||
dnl ============
|
dnl ============
|
||||||
jpeg=yes
|
AC_ARG_ENABLE([jpeg],
|
||||||
ljpeg=""
|
[AS_HELP_STRING([--disable-jpeg], [disable JPEG support through libjpeg])],
|
||||||
AC_ARG_ENABLE(jpeg, AS_HELP_STRING([--disable-jpeg], [disable JPEG support through libjpeg]),
|
[AS_CASE(["$enableval"],
|
||||||
jpeg=$enableval, jpeg=yes, jpeg=no)
|
[yes|no], [],
|
||||||
|
[AC_MSG_ERROR([bad value $enableval for --enable-jpeg])] )],
|
||||||
if test "$jpeg" = yes; then
|
[enable_jpeg=auto])
|
||||||
WM_CHECK_LIB(jpeg, jpeg_destroy_compress)
|
WM_IMGFMT_CHECK_JPEG
|
||||||
|
|
||||||
if test "x$ac_cv_lib_jpeg_jpeg_destroy_compress" = xyes; then
|
|
||||||
|
|
||||||
ljpeg="-ljpeg"
|
|
||||||
|
|
||||||
WM_CHECK_HEADER(jpeglib.h)
|
|
||||||
if test "x$ac_cv_header_jpeglib_h" = xyes; then
|
|
||||||
GFXLIBS="$GFXLIBS -ljpeg"
|
|
||||||
supported_gfx="$supported_gfx JPEG"
|
|
||||||
AC_DEFINE(USE_JPEG, 1, [define if JPEG libraries are available (set by configure)])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
dnl GIF Support
|
dnl GIF Support
|
||||||
@@ -921,19 +908,19 @@ echo
|
|||||||
|
|
||||||
dnl WM_PRINT_REDCRAP_BUG_STATUS
|
dnl WM_PRINT_REDCRAP_BUG_STATUS
|
||||||
|
|
||||||
if test "x$ac_cv_header_jpeglib_h" != xyes; then
|
AS_IF([test "x$enable_jpeg" = xno], [dnl
|
||||||
echo "WARNING WARNING WARNING WARNING WARNING WARNING WARNING"
|
AS_ECHO(["WARNING WARNING WARNING WARNING WARNING WARNING WARNING"])
|
||||||
echo
|
AS_ECHO([])
|
||||||
echo "JPEG support will not be included because the JPEG library is"
|
AS_ECHO(["JPEG support will not be included because the JPEG library is"])
|
||||||
echo "not installed correctly or was not found. Background images"
|
AS_ECHO(["not installed correctly or was not found. Background images"])
|
||||||
echo "from themes will not display as they usually are JPEG files."
|
AS_ECHO(["from themes will not display as they usually are JPEG files."])
|
||||||
echo
|
AS_ECHO([])
|
||||||
echo "To fix, download and install the jpeg library and/or make sure you"
|
AS_ECHO(["To fix, download and install the jpeg library and/or make sure you"])
|
||||||
echo "installed all jpeg related packages, SPECIALLY the development packages"
|
AS_ECHO(["installed all jpeg related packages, SPECIALLY the development packages"])
|
||||||
echo "like jpeg-devel (if you use some prepackaged version of libjpeg)."
|
AS_ECHO(["like jpeg-dev (if you use some prepackaged version of libjpeg)."])
|
||||||
echo
|
AS_ECHO([])
|
||||||
echo "WARNING WARNING WARNING WARNING WARNING WARNING WARNING"
|
AS_ECHO(["WARNING WARNING WARNING WARNING WARNING WARNING WARNING"])dnl
|
||||||
fi
|
])
|
||||||
|
|
||||||
|
|
||||||
dnl This is for Emacs. I'm lazy, I know... (nicolai)
|
dnl This is for Emacs. I'm lazy, I know... (nicolai)
|
||||||
|
|||||||
@@ -79,6 +79,63 @@ const char *filename = "dummy";],
|
|||||||
]) dnl AC_DEFUN
|
]) dnl AC_DEFUN
|
||||||
|
|
||||||
|
|
||||||
|
# WM_IMGFMT_CHECK_JPEG
|
||||||
|
# --------------------
|
||||||
|
#
|
||||||
|
# Check for JPEG file support through 'libjpeg'
|
||||||
|
# The check depends on variable 'enable_jpeg' being either:
|
||||||
|
# yes - detect, fail if not found
|
||||||
|
# no - do not detect, disable support
|
||||||
|
# auto - detect, disable if not found
|
||||||
|
#
|
||||||
|
# When found, append appropriate stuff in GFXLIBS, and append info to
|
||||||
|
# the variable 'supported_gfx'
|
||||||
|
# When not found, append info to variable 'unsupported'
|
||||||
|
AC_DEFUN_ONCE([WM_IMGFMT_CHECK_JPEG],
|
||||||
|
[AC_REQUIRE([_WM_IMGFMT_CHECK_FUNCTS])
|
||||||
|
AS_IF([test "x$enable_jpeg" = "xno"],
|
||||||
|
[unsupported="$unsupported JPEG"],
|
||||||
|
[AC_CACHE_CHECK([for JPEG support library], [wm_cv_imgfmt_jpeg],
|
||||||
|
[wm_cv_imgfmt_jpeg=no
|
||||||
|
wm_save_LIBS="$LIBS"
|
||||||
|
dnl
|
||||||
|
dnl We check first if one of the known libraries is available
|
||||||
|
AS_IF([wm_fn_imgfmt_try_link "jpeg_destroy_compress" "$XLFLAGS $XLIBS -ljpeg"],
|
||||||
|
[wm_cv_imgfmt_jpeg="-ljpeg"])
|
||||||
|
LIBS="$wm_save_LIBS"
|
||||||
|
AS_IF([test "x$enable_jpeg$wm_cv_imgfmt_jpeg" = "xyesno"],
|
||||||
|
[AC_MSG_ERROR([explicit JPEG support requested but no library found])])
|
||||||
|
AS_IF([test "x$wm_cv_imgfmt_jpeg" != "xno"],
|
||||||
|
[dnl
|
||||||
|
dnl A library was found, now check for the appropriate header
|
||||||
|
AC_COMPILE_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM(
|
||||||
|
[@%:@include <stdlib.h>
|
||||||
|
@%:@include <stdio.h>
|
||||||
|
@%:@include <jpeglib.h>],
|
||||||
|
[ struct jpeg_decompress_struct cinfo;
|
||||||
|
|
||||||
|
jpeg_destroy_decompress(&cinfo);])],
|
||||||
|
[],
|
||||||
|
[AS_ECHO([failed])
|
||||||
|
AS_ECHO(["$as_me: error: found $wm_cv_imgfmt_jpeg but cannot compile header"])
|
||||||
|
AS_ECHO(["$as_me: error: - does header 'jpeglib.h' exists? (is package 'jpeg-dev' missing?)"])
|
||||||
|
AS_ECHO(["$as_me: error: - version of header is not supported? (report to dev team)"])
|
||||||
|
AC_MSG_ERROR([JPEG library is not usable, cannot continue])])
|
||||||
|
])
|
||||||
|
])
|
||||||
|
AS_IF([test "x$wm_cv_imgfmt_jpeg" = "xno"],
|
||||||
|
[unsupported="$unsupported JPEG"
|
||||||
|
enable_jpeg="no"],
|
||||||
|
[supported_gfx="$supported_gfx JPEG"
|
||||||
|
GFXLIBS="$GFXLIBS $wm_cv_imgfmt_jpeg"
|
||||||
|
AC_DEFINE([USE_JPEG], [1],
|
||||||
|
[defined when valid JPEG library with header was found])])
|
||||||
|
])
|
||||||
|
AM_CONDITIONAL([USE_JPEG], [test "x$enable_jpeg" != "xno"])dnl
|
||||||
|
]) dnl AC_DEFUN
|
||||||
|
|
||||||
|
|
||||||
# _WM_IMGFMT_CHECK_FUNCTS
|
# _WM_IMGFMT_CHECK_FUNCTS
|
||||||
# -----------------------
|
# -----------------------
|
||||||
# (internal shell functions)
|
# (internal shell functions)
|
||||||
|
|||||||
@@ -39,13 +39,16 @@ libwraster_la_SOURCES = \
|
|||||||
xutil.c \
|
xutil.c \
|
||||||
ppm.c \
|
ppm.c \
|
||||||
png.c \
|
png.c \
|
||||||
jpeg.c \
|
|
||||||
tiff.c
|
tiff.c
|
||||||
|
|
||||||
if USE_GIF
|
if USE_GIF
|
||||||
libwraster_la_SOURCES += gif.c
|
libwraster_la_SOURCES += gif.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if USE_JPEG
|
||||||
|
libwraster_la_SOURCES += jpeg.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//`
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,6 @@
|
|||||||
/* Avoid a compiler warning */
|
/* Avoid a compiler warning */
|
||||||
#undef HAVE_STDLIB_H
|
#undef HAVE_STDLIB_H
|
||||||
|
|
||||||
#ifdef USE_JPEG
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -190,5 +188,3 @@ RImage *RLoadJPEG(const char *file_name)
|
|||||||
|
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* USE_JPEG */
|
|
||||||
|
|||||||
Reference in New Issue
Block a user