qb: Improve the check_val function.

This accomplishes two things for the fallback path without pkg-config.

1. If --disable-foo is passed to configure it will explicitly skip
   check_val. This has the benefit of reducing checks in
   qb/config.libs.sh which are easy to break due to human error.

2. When a fallback path exists and --enable-foo is passed to configure,
   but fails due to the missing -lfoo check_val will now bail and print
   a configure error. However --enable-foo will still be ignored if
   there is no fallback path and pkg-config is not installed.

One issue with this is that if pkg-config is installed and the package
foo is not, it will still check if -lfoo works. As not all pkg-config
implemenations can be trusted to work even if they exist this seems
unavoidable.
This commit is contained in:
orbea 2017-12-30 08:08:08 -08:00
parent 06e3a9e762
commit a37d624967
2 changed files with 19 additions and 20 deletions

View File

@ -389,10 +389,8 @@ if [ "$HAVE_EGL" = "yes" ]; then
fi
fi
fi
if [ "$HAVE_VG" != "no" ]; then
check_pkgconf VG "$VC_PREFIX"vg
check_val '' VG "-l${VC_PREFIX}OpenVG $EXTRA_GL_LIBS"
fi
check_pkgconf VG "$VC_PREFIX"vg
check_val '' VG "-l${VC_PREFIX}OpenVG $EXTRA_GL_LIBS"
else
HAVE_VG=no
HAVE_OPENGLES=no
@ -400,12 +398,7 @@ fi
check_pkgconf V4L2 libv4l2
check_pkgconf FREETYPE freetype2
if [ "$HAVE_X11" != 'no' ]; then
check_pkgconf X11 x11
check_val '' X11 -lX11
fi
check_pkgconf X11 x11
check_pkgconf XCB xcb
check_pkgconf WAYLAND wayland-egl
check_pkgconf WAYLAND_CURSOR wayland-cursor
@ -414,14 +407,16 @@ check_pkgconf DBUS dbus-1
check_pkgconf XEXT xext
check_pkgconf XF86VM xxf86vm
if [ "$HAVE_X11" != "no" ]; then
check_val '' XEXT -lXext
check_val '' XF86VM -lXxf86vm
else
check_val '' X11 -lX11
check_val '' XEXT -lXext
check_val '' XF86VM -lXxf86vm
if [ "$HAVE_X11" = "no" ]; then
HAVE_XEXT=no; HAVE_XF86VM=no; HAVE_XINERAMA=no; HAVE_XSHM=no
fi
check_pkgconf XINERAMA xinerama
if [ "$HAVE_X11" = 'yes' ] && [ "$HAVE_XEXT" = 'yes' ] && [ "$HAVE_XF86VM" = 'yes' ]; then
check_pkgconf XVIDEO xv
else
@ -430,19 +425,17 @@ else
HAVE_XVIDEO='no'
fi
if [ "$HAVE_UDEV" != "no" ]; then
check_pkgconf UDEV libudev
check_val '' UDEV "-ludev"
fi
check_pkgconf UDEV libudev
check_val '' UDEV "-ludev"
check_header XSHM X11/Xlib.h X11/extensions/XShm.h
check_header PARPORT linux/parport.h
check_header PARPORT linux/ppdev.h
if [ "$OS" != 'Win32' ] && [ "$OS" != 'Linux' ]; then
check_lib '' STRL "$CLIB" strlcpy
fi
check_lib '' STRCASESTR "$CLIB" strcasestr
check_lib '' MMAP "$CLIB" mmap
check_lib '' VULKAN -lvulkan vkCreateInstance

View File

@ -70,6 +70,7 @@ check_lib() # $1 = language $2 = HAVE_$2 $3 = lib $4 = function in lib $5 =
check_pkgconf() # $1 = HAVE_$1 $2 = package $3 = version $4 = critical error message [checked only if non-empty]
{ tmpval="$(eval "printf %s \"\$HAVE_$1\"")"
eval "TMP_$1=\$tmpval"
[ "$tmpval" = 'no' ] && return 0
ECHOBUF="Checking presence of package $2"
@ -161,9 +162,14 @@ check_switch() # $1 = language $2 = HAVE_$2 $3 = switch $4 = critical error m
check_val() # $1 = language $2 = HAVE_$2 $3 = lib
{ tmpval="$(eval "printf %s \"\$HAVE_$2\"")"
if [ "$tmpval" = 'no' ]; then
oldval="$(eval "printf %s \"\$TMP_$2\"")"
if [ "$tmpval" = 'no' ] && [ "$oldval" != 'no' ]; then
eval "HAVE_$2=auto"
check_lib "$1" "$2" "$3"
if [ "$answer" = 'no' ] && [ "$oldval" = 'yes' ]; then
die 1 "Forced to build with library $lib, but cannot locate. Exiting ..."
fi
fi
}