mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
configure: Created new macro to perform the repetitive part of Library check
There are a number of steps in the library check procedure that are a bit repetitive, and have been placed into the macro WM_LIB_CHECK to make the code simpler to write. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
da597a4b87
commit
64a95b73c3
@@ -121,3 +121,64 @@ for wm_arg in $1 ; do
|
||||
done
|
||||
AS_VAR_POPDEF([VAR])dnl
|
||||
])
|
||||
|
||||
|
||||
# WM_LIB_CHECK
|
||||
# ------------
|
||||
#
|
||||
# Check if a library exists (can be linked to) and check if its header can
|
||||
# compile (using code in parameter to the macro), then update the appropriate
|
||||
# stuff accordingly
|
||||
#
|
||||
# Usage: WM_LIB_CHECK([name], [lflaglist], [lfunc], [extralibs], [headercheck], [supvar], [libvar], [enable_var], [cond_name])
|
||||
# $1 name: name of the feature used in messages and in supvar
|
||||
# $2 lflaglist: the list of linker '-l' options to try, stopping on first success
|
||||
# $3 lfunc: the name of the function to look for when linking
|
||||
# $4 extralibs: optional, additional libraries included in the link check
|
||||
# $5 headercheck: the code that checks for the header
|
||||
# $6 supvar: if the library was found, append $name to this variable,
|
||||
# otherwise append $name to 'unsupported'
|
||||
# $7 libvar: if the library was found, append the working $lflag to this variable
|
||||
# $8 enable_var: variable to check for user's feature request, if empty we use "lowercase(enable_$1)"
|
||||
# $9 cond_name: name of the AC_DEFINE and the AM_CONDITIONAL
|
||||
# if empty, use "uppercase(USE_$1)", if equals "-" same but do not create AM_CONDITIONAL
|
||||
AC_DEFUN([WM_LIB_CHECK],
|
||||
[AC_REQUIRE([_WM_LIB_CHECK_FUNCTS])
|
||||
m4_pushdef([ENABLEVAR], [m4_ifnblank([$8], [$8], enable_[]m4_tolower($1))])dnl
|
||||
m4_pushdef([CACHEVAR], [wm_cv_libchk_[]m4_tolower($1)])dnl
|
||||
m4_pushdef([USEVAR], [m4_bmatch([$9], [^-?$], [USE_[]m4_toupper($1)], [$9])])dnl
|
||||
AS_IF([test "x$ENABLEVAR" = "xno"],
|
||||
[unsupported="$unsupported $1"],
|
||||
[AC_CACHE_CHECK([for $1 support library], CACHEVAR,
|
||||
[CACHEVAR=no
|
||||
wm_save_LIBS="$LIBS"
|
||||
dnl
|
||||
dnl We check that the library is available
|
||||
m4_bmatch([$2], [ ], dnl Any space in 'lflaglist' means we have a list of flags
|
||||
[for wm_arg in $2 ; do
|
||||
AS_IF([wm_fn_lib_try_link "$3" "$4 $wm_arg"],
|
||||
[CACHEVAR="$wm_arg" ; break])
|
||||
done],
|
||||
[AS_IF([wm_fn_lib_try_link "$3" "$4 $2"],
|
||||
[CACHEVAR="$2"]) ])
|
||||
LIBS="$wm_save_LIBS"
|
||||
AS_IF([test "x$ENABLEVAR$CACHEVAR" = "xyesno"],
|
||||
[AC_MSG_ERROR([explicit $1 support requested but no library found])])
|
||||
dnl
|
||||
dnl A library was found, check if header is available and compile
|
||||
AS_IF([test "x$CACHEVAR" != "xno"], [$5])
|
||||
])
|
||||
AS_IF([test "x$CACHEVAR" = "xno"],
|
||||
[unsupported="$unsupported $1"
|
||||
ENABLEVAR="no"],
|
||||
[$6="$$6 $1"
|
||||
WM_APPEND_ONCE([$CACHEVAR], [$7])
|
||||
AC_DEFINE(USEVAR, [1],
|
||||
[defined when valid $1 library with header was found])])
|
||||
])
|
||||
m4_bmatch([$9], [^-$], [],
|
||||
[AM_CONDITIONAL(USEVAR, [test "x$ENABLEVAR" != "xno"])])dnl
|
||||
m4_popdef([ENABLEVAR])dnl
|
||||
m4_popdef([CACHEVAR])dnl
|
||||
m4_popdef([USEVAR])dnl
|
||||
])
|
||||
|
||||
@@ -92,23 +92,8 @@ AM_CONDITIONAL([USE_GIF], [test "x$enable_gif" != "xno"])dnl
|
||||
# the variable 'supported_gfx'
|
||||
# When not found, append info to variable 'unsupported'
|
||||
AC_DEFUN_ONCE([WM_IMGFMT_CHECK_JPEG],
|
||||
[AC_REQUIRE([_WM_LIB_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_lib_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(
|
||||
[WM_LIB_CHECK([JPEG], [-ljpeg], [jpeg_destroy_compress], [$XLFLAGS $XLIBS],
|
||||
[AC_COMPILE_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[@%:@include <stdlib.h>
|
||||
@%:@include <stdio.h>
|
||||
@@ -118,21 +103,12 @@ AS_IF([test "x$enable_jpeg" = "xno"],
|
||||
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: found $CACHEVAR 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"
|
||||
WM_APPEND_ONCE([$wm_cv_imgfmt_jpeg], [GFXLIBS])
|
||||
AC_DEFINE([USE_JPEG], [1],
|
||||
[defined when valid JPEG library with header was found])])
|
||||
])
|
||||
AM_CONDITIONAL([USE_JPEG], [test "x$enable_jpeg" != "xno"])dnl
|
||||
],
|
||||
[supported_gfx], [GFXLIBS])dnl
|
||||
]) dnl AC_DEFUN
|
||||
|
||||
|
||||
@@ -149,42 +125,16 @@ AM_CONDITIONAL([USE_JPEG], [test "x$enable_jpeg" != "xno"])dnl
|
||||
# the variable 'supported_gfx'
|
||||
# When not found, append info to variable 'unsupported'
|
||||
AC_DEFUN_ONCE([WM_IMGFMT_CHECK_PNG],
|
||||
[AC_REQUIRE([_WM_LIB_CHECK_FUNCTS])
|
||||
AS_IF([test "x$enable_png" = "xno"],
|
||||
[unsupported="$unsupported PNG"],
|
||||
[AC_CACHE_CHECK([for PNG support library], [wm_cv_imgfmt_png],
|
||||
[wm_cv_imgfmt_png=no
|
||||
dnl
|
||||
dnl We check first if one of the known libraries is available
|
||||
wm_save_LIBS="$LIBS"
|
||||
for wm_arg in "-lpng" "-lpng -lz" "-lpng -lz -lm" ; do
|
||||
AS_IF([wm_fn_lib_try_link "png_get_valid" "$XLFLAGS $XLIBS $wm_arg"],
|
||||
[wm_cv_imgfmt_png="$wm_arg" ; break])
|
||||
done
|
||||
LIBS="$wm_save_LIBS"
|
||||
AS_IF([test "x$enable_png$wm_cv_imgfmt_png" = "xyesno"],
|
||||
[AC_MSG_ERROR([explicit PNG support requested but no library found])])
|
||||
AS_IF([test "x$wm_cv_imgfmt_png" != "xno"],
|
||||
[dnl
|
||||
dnl A library was found, now check for the appropriate header
|
||||
wm_save_CFLAGS="$CFLAGS"
|
||||
AS_IF([wm_fn_lib_try_compile "png.h" "" "return 0" ""],
|
||||
[],
|
||||
[AC_MSG_ERROR([found $wm_cv_imgfmt_png but could not find appropriate header - are you missing libpng-dev package?])])
|
||||
AS_IF([wm_fn_lib_try_compile "png.h" "" "png_get_valid(NULL, NULL, PNG_INFO_tRNS)" ""],
|
||||
[],
|
||||
[AC_MSG_ERROR([found $wm_cv_imgfmt_png and header, but cannot compile - unsupported version?])])
|
||||
CFLAGS="$wm_save_CFLAGS"])
|
||||
])
|
||||
AS_IF([test "x$wm_cv_imgfmt_png" = "xno"],
|
||||
[unsupported="$unsupported PNG"
|
||||
enable_png="no"],
|
||||
[supported_gfx="$supported_gfx PNG"
|
||||
WM_APPEND_ONCE([$wm_cv_imgfmt_png], [GFXLIBS])
|
||||
AC_DEFINE([USE_PNG], [1],
|
||||
[defined when valid PNG library with header was found])])
|
||||
])
|
||||
AM_CONDITIONAL([USE_PNG], [test "x$enable_png" != "xno"])dnl
|
||||
[WM_LIB_CHECK([PNG], ["-lpng" "-lpng -lz" "-lpng -lz -lm"], [png_get_valid], [$XLFLAGS $XLIBS],
|
||||
[wm_save_CFLAGS="$CFLAGS"
|
||||
AS_IF([wm_fn_lib_try_compile "png.h" "" "return 0" ""],
|
||||
[],
|
||||
[AC_MSG_ERROR([found $CACHEVAR but could not find appropriate header - are you missing libpng-dev package?])])
|
||||
AS_IF([wm_fn_lib_try_compile "png.h" "" "png_get_valid(NULL, NULL, PNG_INFO_tRNS)" ""],
|
||||
[],
|
||||
[AC_MSG_ERROR([found $CACHEVAR and header, but cannot compile - unsupported version?])])
|
||||
CFLAGS="$wm_save_CFLAGS"],
|
||||
[supported_gfx], [GFXLIBS])dnl
|
||||
]) dnl AC_DEFUN
|
||||
|
||||
|
||||
@@ -201,50 +151,26 @@ AM_CONDITIONAL([USE_PNG], [test "x$enable_png" != "xno"])dnl
|
||||
# the variable 'supported_gfx'
|
||||
# When not found, append info to variable 'unsupported'
|
||||
AC_DEFUN_ONCE([WM_IMGFMT_CHECK_TIFF],
|
||||
[AC_REQUIRE([_WM_LIB_CHECK_FUNCTS])
|
||||
AS_IF([test "x$enable_tiff" = "xno"],
|
||||
[unsupported="$unsupported TIFF"],
|
||||
[AC_CACHE_CHECK([for TIFF support library], [wm_cv_imgfmt_tiff],
|
||||
[wm_cv_imgfmt_tiff=no
|
||||
dnl
|
||||
dnl We check first if one of the known libraries is available
|
||||
wm_save_LIBS="$LIBS"
|
||||
for wm_arg in "-ltiff" \
|
||||
dnl TIFF can have a dependancy over zlib
|
||||
"-ltiff -lz" "-ltiff -lz -lm" \
|
||||
dnl It may also have a dependancy to jpeg_lib
|
||||
"-ltiff -ljpeg" "-ltiff -ljpeg -lz" "-ltiff -ljpeg -lz -lm" \
|
||||
dnl There is also a possible dependancy on JBIGKit
|
||||
"-ltiff -ljpeg -ljbig -lz" \
|
||||
dnl Probably for historical reasons?
|
||||
"-ltiff34" "-ltiff34 -ljpeg" "-ltiff34 -ljpeg -lm" ; do
|
||||
AS_IF([wm_fn_lib_try_link "TIFFGetVersion" "$XLFLAGS $XLIBS $wm_arg"],
|
||||
[wm_cv_imgfmt_tiff="$wm_arg" ; break])
|
||||
done
|
||||
LIBS="$wm_save_LIBS"
|
||||
AS_IF([test "x$enable_tiff$wm_cv_imgfmt_tiff" = "xyesno"],
|
||||
[AC_MSG_ERROR([explicit TIFF support requested but no library found])])
|
||||
AS_IF([test "x$wm_cv_imgfmt_tiff" != "xno"],
|
||||
[dnl
|
||||
dnl A library was found, now check for the appropriate header
|
||||
wm_save_CFLAGS="$CFLAGS"
|
||||
AS_IF([wm_fn_lib_try_compile "tiffio.h" "" "return 0" ""],
|
||||
[],
|
||||
[AC_MSG_ERROR([found $wm_cv_imgfmt_tiff but could not find appropriate header - are you missing libtiff-dev package?])])
|
||||
AS_IF([wm_fn_lib_try_compile "tiffio.h" 'const char *filename = "dummy";' 'TIFFOpen(filename, "r")' ""],
|
||||
[],
|
||||
[AC_MSG_ERROR([found $wm_cv_imgfmt_tiff and header, but cannot compile - unsupported version?])])
|
||||
CFLAGS="$wm_save_CFLAGS"])
|
||||
])
|
||||
AS_IF([test "x$wm_cv_imgfmt_tiff" = "xno"],
|
||||
[unsupported="$unsupported TIFF"
|
||||
enable_tiff="no"],
|
||||
[supported_gfx="$supported_gfx TIFF"
|
||||
WM_APPEND_ONCE([$wm_cv_imgfmt_tiff], [GFXLIBS])
|
||||
AC_DEFINE([USE_TIFF], [1],
|
||||
[defined when valid TIFF library with header was found])])
|
||||
])
|
||||
AM_CONDITIONAL([USE_TIFF], [test "x$enable_tiff" != "xno"])dnl
|
||||
[WM_LIB_CHECK([TIFF],
|
||||
["-ltiff" \
|
||||
dnl TIFF can have a dependancy over zlib
|
||||
"-ltiff -lz" "-ltiff -lz -lm" \
|
||||
dnl It may also have a dependancy to jpeg_lib
|
||||
"-ltiff -ljpeg" "-ltiff -ljpeg -lz" "-ltiff -ljpeg -lz -lm" \
|
||||
dnl There is also a possible dependancy on JBIGKit
|
||||
"-ltiff -ljpeg -ljbig -lz" \
|
||||
dnl Probably for historical reasons?
|
||||
"-ltiff34" "-ltiff34 -ljpeg" "-ltiff34 -ljpeg -lm"],
|
||||
[TIFFGetVersion], [$XLFLAGS $XLIBS],
|
||||
[wm_save_CFLAGS="$CFLAGS"
|
||||
AS_IF([wm_fn_lib_try_compile "tiffio.h" "" "return 0" ""],
|
||||
[],
|
||||
[AC_MSG_ERROR([found $CACHEVAR but could not find appropriate header - are you missing libtiff-dev package?])])
|
||||
AS_IF([wm_fn_lib_try_compile "tiffio.h" 'const char *filename = "dummy";' 'TIFFOpen(filename, "r")' ""],
|
||||
[],
|
||||
[AC_MSG_ERROR([found $CACHEVAR and header, but cannot compile - unsupported version?])])
|
||||
CFLAGS="$wm_save_CFLAGS"],
|
||||
[supported_gfx], [GFXLIBS])dnl
|
||||
]) dnl AC_DEFUN
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user