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
|
done
|
||||||
AS_VAR_POPDEF([VAR])dnl
|
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'
|
# the variable 'supported_gfx'
|
||||||
# When not found, append info to variable 'unsupported'
|
# When not found, append info to variable 'unsupported'
|
||||||
AC_DEFUN_ONCE([WM_IMGFMT_CHECK_JPEG],
|
AC_DEFUN_ONCE([WM_IMGFMT_CHECK_JPEG],
|
||||||
[AC_REQUIRE([_WM_LIB_CHECK_FUNCTS])
|
[WM_LIB_CHECK([JPEG], [-ljpeg], [jpeg_destroy_compress], [$XLFLAGS $XLIBS],
|
||||||
AS_IF([test "x$enable_jpeg" = "xno"],
|
[AC_COMPILE_IFELSE(
|
||||||
[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(
|
|
||||||
[AC_LANG_PROGRAM(
|
[AC_LANG_PROGRAM(
|
||||||
[@%:@include <stdlib.h>
|
[@%:@include <stdlib.h>
|
||||||
@%:@include <stdio.h>
|
@%:@include <stdio.h>
|
||||||
@@ -118,21 +103,12 @@ AS_IF([test "x$enable_jpeg" = "xno"],
|
|||||||
jpeg_destroy_decompress(&cinfo);])],
|
jpeg_destroy_decompress(&cinfo);])],
|
||||||
[],
|
[],
|
||||||
[AS_ECHO([failed])
|
[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: - 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)"])
|
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])])
|
AC_MSG_ERROR([JPEG library is not usable, cannot continue])])
|
||||||
])
|
],
|
||||||
])
|
[supported_gfx], [GFXLIBS])dnl
|
||||||
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
|
|
||||||
]) dnl AC_DEFUN
|
]) dnl AC_DEFUN
|
||||||
|
|
||||||
|
|
||||||
@@ -149,42 +125,16 @@ AM_CONDITIONAL([USE_JPEG], [test "x$enable_jpeg" != "xno"])dnl
|
|||||||
# the variable 'supported_gfx'
|
# the variable 'supported_gfx'
|
||||||
# When not found, append info to variable 'unsupported'
|
# When not found, append info to variable 'unsupported'
|
||||||
AC_DEFUN_ONCE([WM_IMGFMT_CHECK_PNG],
|
AC_DEFUN_ONCE([WM_IMGFMT_CHECK_PNG],
|
||||||
[AC_REQUIRE([_WM_LIB_CHECK_FUNCTS])
|
[WM_LIB_CHECK([PNG], ["-lpng" "-lpng -lz" "-lpng -lz -lm"], [png_get_valid], [$XLFLAGS $XLIBS],
|
||||||
AS_IF([test "x$enable_png" = "xno"],
|
[wm_save_CFLAGS="$CFLAGS"
|
||||||
[unsupported="$unsupported PNG"],
|
AS_IF([wm_fn_lib_try_compile "png.h" "" "return 0" ""],
|
||||||
[AC_CACHE_CHECK([for PNG support library], [wm_cv_imgfmt_png],
|
[],
|
||||||
[wm_cv_imgfmt_png=no
|
[AC_MSG_ERROR([found $CACHEVAR but could not find appropriate header - are you missing libpng-dev package?])])
|
||||||
dnl
|
AS_IF([wm_fn_lib_try_compile "png.h" "" "png_get_valid(NULL, NULL, PNG_INFO_tRNS)" ""],
|
||||||
dnl We check first if one of the known libraries is available
|
[],
|
||||||
wm_save_LIBS="$LIBS"
|
[AC_MSG_ERROR([found $CACHEVAR and header, but cannot compile - unsupported version?])])
|
||||||
for wm_arg in "-lpng" "-lpng -lz" "-lpng -lz -lm" ; do
|
CFLAGS="$wm_save_CFLAGS"],
|
||||||
AS_IF([wm_fn_lib_try_link "png_get_valid" "$XLFLAGS $XLIBS $wm_arg"],
|
[supported_gfx], [GFXLIBS])dnl
|
||||||
[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
|
|
||||||
]) dnl AC_DEFUN
|
]) dnl AC_DEFUN
|
||||||
|
|
||||||
|
|
||||||
@@ -201,50 +151,26 @@ AM_CONDITIONAL([USE_PNG], [test "x$enable_png" != "xno"])dnl
|
|||||||
# the variable 'supported_gfx'
|
# the variable 'supported_gfx'
|
||||||
# When not found, append info to variable 'unsupported'
|
# When not found, append info to variable 'unsupported'
|
||||||
AC_DEFUN_ONCE([WM_IMGFMT_CHECK_TIFF],
|
AC_DEFUN_ONCE([WM_IMGFMT_CHECK_TIFF],
|
||||||
[AC_REQUIRE([_WM_LIB_CHECK_FUNCTS])
|
[WM_LIB_CHECK([TIFF],
|
||||||
AS_IF([test "x$enable_tiff" = "xno"],
|
["-ltiff" \
|
||||||
[unsupported="$unsupported TIFF"],
|
dnl TIFF can have a dependancy over zlib
|
||||||
[AC_CACHE_CHECK([for TIFF support library], [wm_cv_imgfmt_tiff],
|
"-ltiff -lz" "-ltiff -lz -lm" \
|
||||||
[wm_cv_imgfmt_tiff=no
|
dnl It may also have a dependancy to jpeg_lib
|
||||||
dnl
|
"-ltiff -ljpeg" "-ltiff -ljpeg -lz" "-ltiff -ljpeg -lz -lm" \
|
||||||
dnl We check first if one of the known libraries is available
|
dnl There is also a possible dependancy on JBIGKit
|
||||||
wm_save_LIBS="$LIBS"
|
"-ltiff -ljpeg -ljbig -lz" \
|
||||||
for wm_arg in "-ltiff" \
|
dnl Probably for historical reasons?
|
||||||
dnl TIFF can have a dependancy over zlib
|
"-ltiff34" "-ltiff34 -ljpeg" "-ltiff34 -ljpeg -lm"],
|
||||||
"-ltiff -lz" "-ltiff -lz -lm" \
|
[TIFFGetVersion], [$XLFLAGS $XLIBS],
|
||||||
dnl It may also have a dependancy to jpeg_lib
|
[wm_save_CFLAGS="$CFLAGS"
|
||||||
"-ltiff -ljpeg" "-ltiff -ljpeg -lz" "-ltiff -ljpeg -lz -lm" \
|
AS_IF([wm_fn_lib_try_compile "tiffio.h" "" "return 0" ""],
|
||||||
dnl There is also a possible dependancy on JBIGKit
|
[],
|
||||||
"-ltiff -ljpeg -ljbig -lz" \
|
[AC_MSG_ERROR([found $CACHEVAR but could not find appropriate header - are you missing libtiff-dev package?])])
|
||||||
dnl Probably for historical reasons?
|
AS_IF([wm_fn_lib_try_compile "tiffio.h" 'const char *filename = "dummy";' 'TIFFOpen(filename, "r")' ""],
|
||||||
"-ltiff34" "-ltiff34 -ljpeg" "-ltiff34 -ljpeg -lm" ; do
|
[],
|
||||||
AS_IF([wm_fn_lib_try_link "TIFFGetVersion" "$XLFLAGS $XLIBS $wm_arg"],
|
[AC_MSG_ERROR([found $CACHEVAR and header, but cannot compile - unsupported version?])])
|
||||||
[wm_cv_imgfmt_tiff="$wm_arg" ; break])
|
CFLAGS="$wm_save_CFLAGS"],
|
||||||
done
|
[supported_gfx], [GFXLIBS])dnl
|
||||||
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
|
|
||||||
]) dnl AC_DEFUN
|
]) dnl AC_DEFUN
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user