qb: Cleanup config.libs.sh.

This commit is contained in:
orbea 2019-01-24 15:38:37 -08:00
parent c8c23ffcfc
commit 0dc40a2d66
3 changed files with 101 additions and 92 deletions

View File

@ -87,7 +87,6 @@ fi
if [ "$HAVE_PRESERVE_DYLIB" = "yes" ]; then if [ "$HAVE_PRESERVE_DYLIB" = "yes" ]; then
die : 'Notice: Disabling dlclose() of shared objects for Valgrind support.' die : 'Notice: Disabling dlclose() of shared objects for Valgrind support.'
add_define MAKEFILE HAVE_PRESERVE_DYLIB "1"
fi fi
if [ "$HAVE_FLOATHARD" = "yes" ]; then if [ "$HAVE_FLOATHARD" = "yes" ]; then
@ -126,9 +125,7 @@ if [ "$HAVE_SSE" = "yes" ]; then
fi fi
if [ "$HAVE_EGL" != "no" ] && [ "$OS" != 'Win32' ]; then if [ "$HAVE_EGL" != "no" ] && [ "$OS" != 'Win32' ]; then
check_pkgconf EGL "$VC_PREFIX"egl check_val '' EGL "-l${VC_PREFIX}EGL $EXTRA_GL_LIBS" '' "${VC_PREFIX}egl" '' ''
# some systems have EGL libs, but no pkgconfig
check_val '' EGL "-l${VC_PREFIX}EGL $EXTRA_GL_LIBS"
if [ "$HAVE_EGL" = "yes" ]; then if [ "$HAVE_EGL" = "yes" ]; then
EGL_LIBS="$EGL_LIBS $EXTRA_GL_LIBS" EGL_LIBS="$EGL_LIBS $EXTRA_GL_LIBS"
fi fi
@ -184,12 +181,6 @@ else
check_lib '' DYLIB "$DYLIB" dlopen check_lib '' DYLIB "$DYLIB" dlopen
fi fi
if [ "$HAVE_CXX" != 'yes' ]; then
HAVE_DISCORD='no'
HAVE_QT='no'
HAVE_VULKAN='no'
fi
check_lib '' NETWORKING "$SOCKETLIB" socket "" "$SOCKETHEADER" check_lib '' NETWORKING "$SOCKETLIB" socket "" "$SOCKETHEADER"
if [ "$HAVE_NETWORKING" = 'yes' ]; then if [ "$HAVE_NETWORKING" = 'yes' ]; then
@ -237,8 +228,7 @@ if [ "$HAVE_DYLIB" = 'no' ] && [ "$HAVE_DYNAMIC" = 'yes' ]; then
die 1 'Error: Dynamic loading of libretro is enabled, but your platform does not appear to have dlopen(), use --disable-dynamic or --with-libretro="-lretro".' die 1 'Error: Dynamic loading of libretro is enabled, but your platform does not appear to have dlopen(), use --disable-dynamic or --with-libretro="-lretro".'
fi fi
check_pkgconf ALSA alsa check_val '' ALSA -lasound alsa alsa '' ''
check_val '' ALSA -lasound alsa
check_lib '' CACA -lcaca check_lib '' CACA -lcaca
check_lib '' SIXEL -lsixel check_lib '' SIXEL -lsixel
@ -271,15 +261,22 @@ fi
check_pkgconf RSOUND rsound 1.1 check_pkgconf RSOUND rsound 1.1
check_pkgconf ROAR libroar check_pkgconf ROAR libroar
check_pkgconf JACK jack 0.120.1 check_val '' JACK -ljack '' jack 0.120.1 ''
check_pkgconf PULSE libpulse check_val '' PULSE -lpulse '' libpulse '' ''
check_pkgconf SDL sdl 1.2.10 check_val '' SDL -lSDL SDL sdl 1.2.10 ''
check_pkgconf SDL2 sdl2 2.0.0 check_val '' SDL2 -lSDL2 SDL2 sdl2 2.0.0 ''
check_val '' JACK -ljack if [ "$HAVE_SDL2" = 'yes' ] && [ "$HAVE_SDL" = 'yes' ]; then
check_val '' PULSE -lpulse die : 'Notice: SDL drivers will be replaced by SDL2 ones.'
check_val '' SDL -lSDL SDL HAVE_SDL=no
check_val '' SDL2 -lSDL2 SDL2 fi
check_enabled DISCORD discord
if [ "$HAVE_DISCORD" != 'no' ]; then
# Enable discord by default if it hasn't been disabled by check_enabled.
HAVE_DISCORD=yes
fi
check_enabled QT 'Qt companion' check_enabled QT 'Qt companion'
@ -307,17 +304,11 @@ if [ "$HAVE_QT" != 'no' ]; then
#fi #fi
fi fi
if [ "$HAVE_SDL2" = 'yes' ] && [ "$HAVE_SDL" = 'yes' ]; then
die : 'Notice: SDL drivers will be replaced by SDL2 ones.'
HAVE_SDL=no
fi
if [ "$HAVE_FLAC" = 'no' ]; then if [ "$HAVE_FLAC" = 'no' ]; then
HAVE_BUILTINFLAC=no HAVE_BUILTINFLAC=no
fi fi
check_pkgconf FLAC flac check_val '' FLAC '-lFLAC' '' flac '' ''
check_val '' FLAC '-lFLAC'
if [ "$HAVE_SSL" = 'no' ]; then if [ "$HAVE_SSL" = 'no' ]; then
HAVE_BUILTINMBEDTLS=no HAVE_BUILTINMBEDTLS=no
@ -350,8 +341,7 @@ if [ "$HAVE_SSL" != 'no' ]; then
fi fi
fi fi
check_pkgconf LIBUSB libusb-1.0 1.0.13 check_val '' LIBUSB -lusb-1.0 libusb-1.0 libusb-1.0 1.0.13 ''
check_val '' LIBUSB -lusb-1.0 libusb-1.0
if [ "$OS" = 'Win32' ]; then if [ "$OS" = 'Win32' ]; then
check_lib '' DINPUT -ldinput8 check_lib '' DINPUT -ldinput8
@ -406,12 +396,10 @@ if [ "$HAVE_ZLIB" = 'no' ]; then
elif [ "$HAVE_BUILTINZLIB" = 'yes' ]; then elif [ "$HAVE_BUILTINZLIB" = 'yes' ]; then
HAVE_ZLIB=yes HAVE_ZLIB=yes
else else
check_pkgconf ZLIB zlib check_val '' ZLIB '-lz' '' zlib '' ''
check_val '' ZLIB '-lz'
fi fi
check_pkgconf MPV mpv check_val '' MPV -lmpv '' mpv '' ''
check_val '' MPV -lmpv
if [ "$HAVE_THREADS" = 'no' ] && [ "$HAVE_FFMPEG" != 'no' ]; then if [ "$HAVE_THREADS" = 'no' ] && [ "$HAVE_FFMPEG" != 'no' ]; then
HAVE_FFMPEG='no' HAVE_FFMPEG='no'
@ -422,21 +410,13 @@ check_header DRMINGW exchndl.h
check_lib '' DRMINGW -lexchndl check_lib '' DRMINGW -lexchndl
if [ "$HAVE_FFMPEG" != 'no' ]; then if [ "$HAVE_FFMPEG" != 'no' ]; then
check_pkgconf AVCODEC libavcodec 54 check_val '' AVCODEC -lavcodec '' libavcodec 54 ''
check_pkgconf AVFORMAT libavformat 54 check_val '' AVFORMAT -lavformat '' libavformat 54 ''
check_pkgconf AVDEVICE libavdevice check_val '' AVDEVICE -lavdevice '' libavdevice '' ''
check_pkgconf SWRESAMPLE libswresample check_val '' SWRESAMPLE -lswresample '' libswresample '' ''
check_pkgconf AVRESAMPLE libavresample check_val '' AVRESAMPLE -lavresample '' libavresample '' ''
check_pkgconf AVUTIL libavutil 51 check_val '' AVUTIL -lavutil '' libavutil 51 ''
check_pkgconf SWSCALE libswscale 2.1 check_val '' SWSCALE -lswscale '' libswscale 2.1 ''
check_val '' AVCODEC -lavcodec
check_val '' AVFORMAT -lavformat
check_val '' AVDEVICE -lavdevice
check_val '' SWRESAMPLE -lswresample
check_val '' AVRESAMPLE -lavresample
check_val '' AVUTIL -lavutil
check_val '' SWSCALE -lswscale
check_header AV_CHANNEL_LAYOUT libavutil/channel_layout.h check_header AV_CHANNEL_LAYOUT libavutil/channel_layout.h
@ -454,10 +434,8 @@ if [ "$OS" != 'Win32' ]; then
fi fi
if [ "$HAVE_KMS" != "no" ]; then if [ "$HAVE_KMS" != "no" ]; then
check_pkgconf GBM gbm 9.0 check_val '' GBM -lgbm '' gbm 9.0 ''
check_pkgconf DRM libdrm check_val '' DRM -ldrm libdrm libdrm '' ''
check_val '' GBM -lgbm
check_val '' DRM -ldrm libdrm
if [ "$HAVE_GBM" = "yes" ] && [ "$HAVE_DRM" = "yes" ] && [ "$HAVE_EGL" = "yes" ]; then if [ "$HAVE_GBM" = "yes" ] && [ "$HAVE_DRM" = "yes" ] && [ "$HAVE_EGL" = "yes" ]; then
HAVE_KMS=yes HAVE_KMS=yes
@ -468,8 +446,7 @@ if [ "$HAVE_KMS" != "no" ]; then
fi fi
fi fi
check_pkgconf LIBXML2 libxml-2.0 check_val '' LIBXML2 -lxml2 libxml2 libxml-2.0 '' ''
check_val '' LIBXML2 -lxml2 libxml2
if [ "$HAVE_EGL" = "yes" ]; then if [ "$HAVE_EGL" = "yes" ]; then
if [ "$HAVE_OPENGLES" != "no" ]; then if [ "$HAVE_OPENGLES" != "no" ]; then
@ -485,34 +462,23 @@ if [ "$HAVE_EGL" = "yes" ]; then
fi fi
fi fi
fi fi
check_pkgconf VG "$VC_PREFIX"vg check_val '' VG "-l${VC_PREFIX}OpenVG $EXTRA_GL_LIBS" '' "${VC_PREFIX}vg" '' ''
check_val '' VG "-l${VC_PREFIX}OpenVG $EXTRA_GL_LIBS"
else else
HAVE_VG=no HAVE_VG=no
HAVE_OPENGLES=no HAVE_OPENGLES=no
fi fi
check_pkgconf V4L2 libv4l2 check_val '' V4L2 -lv4l2 '' libv4l2 '' ''
check_pkgconf FREETYPE freetype2 check_val '' FREETYPE -lfreetype freetype2 freetype2 '' ''
check_pkgconf X11 x11 check_val '' X11 -lX11 '' x11 '' ''
check_pkgconf XCB xcb check_val '' XCB -lxcb '' xcb '' ''
check_pkgconf WAYLAND wayland-egl 1.15 check_val '' WAYLAND '-lwayland-egl -lwayland-client' '' wayland-egl 1.15 ''
check_pkgconf WAYLAND_CURSOR wayland-cursor 1.15 check_val '' WAYLAND_CURSOR -lwayland-cursor '' wayland-cursor 1.15 ''
check_pkgconf WAYLAND_PROTOS wayland-protocols 1.15 check_pkgconf WAYLAND_PROTOS wayland-protocols 1.15
check_pkgconf XKBCOMMON xkbcommon 0.3.2 check_val '' XKBCOMMON -lxkbcommon '' xkbcommon 0.3.2 ''
check_pkgconf DBUS dbus-1 check_pkgconf DBUS dbus-1
check_pkgconf XEXT xext check_val '' XEXT -lXext '' xext '' ''
check_pkgconf XF86VM xxf86vm check_val '' XF86VM -lXxf86vm '' xxf86vm '' ''
check_val '' V4L2 -lv4l2
check_val '' FREETYPE -lfreetype freetype2
check_val '' X11 -lX11
check_val '' XCB -lxcb
check_val '' WAYLAND '-lwayland-egl -lwayland-client'
check_val '' WAYLAND_CURSOR -lwayland-cursor
check_val '' XKBCOMMON -lxkbcommon
check_val '' XEXT -lXext
check_val '' XF86VM -lXxf86vm
if [ "$HAVE_WAYLAND_PROTOS" = yes ] && [ "$HAVE_WAYLAND" = yes ]; then if [ "$HAVE_WAYLAND_PROTOS" = yes ] && [ "$HAVE_WAYLAND" = yes ]; then
check_pkgconf WAYLAND_SCANNER wayland-scanner 1.15 check_pkgconf WAYLAND_SCANNER wayland-scanner 1.15
@ -527,20 +493,17 @@ if [ "$HAVE_X11" = 'no' ]; then
fi fi
check_lib '' XRANDR -lXrandr check_lib '' XRANDR -lXrandr
check_pkgconf XINERAMA xinerama check_val '' XINERAMA -lXinerama '' xinerama '' ''
check_val '' XINERAMA -lXinerama
if [ "$HAVE_X11" = 'yes' ] && [ "$HAVE_XEXT" = 'yes' ] && [ "$HAVE_XF86VM" = 'yes' ]; then if [ "$HAVE_X11" = 'yes' ] && [ "$HAVE_XEXT" = 'yes' ] && [ "$HAVE_XF86VM" = 'yes' ]; then
check_pkgconf XVIDEO xv check_val '' XVIDEO -lXv '' xv '' ''
check_val '' XVIDEO -lXv
else else
die : 'Notice: X11, Xext or xf86vm not present. Skipping X11 code paths.' die : 'Notice: X11, Xext or xf86vm not present. Skipping X11 code paths.'
HAVE_X11='no' HAVE_X11='no'
HAVE_XVIDEO='no' HAVE_XVIDEO='no'
fi fi
check_pkgconf UDEV libudev check_val '' UDEV "-ludev" '' libudev '' ''
check_val '' UDEV "-ludev"
check_header XSHM X11/Xlib.h X11/extensions/XShm.h check_header XSHM X11/Xlib.h X11/extensions/XShm.h
check_header PARPORT linux/parport.h check_header PARPORT linux/parport.h

View File

@ -121,7 +121,7 @@ HAVE_CHEEVOS=yes # Retro Achievements
HAVE_NEW_CHEEVOS=no # Use rcheevos to process RetroAchievements HAVE_NEW_CHEEVOS=no # Use rcheevos to process RetroAchievements
C89_NEW_CHEEVOS=no C89_NEW_CHEEVOS=no
HAVE_LUA=no # Lua support (for Retro Achievements) HAVE_LUA=no # Lua support (for Retro Achievements)
HAVE_DISCORD=yes # Discord Integration HAVE_DISCORD=auto # Discord Integration
C89_DISCORD=no C89_DISCORD=no
HAVE_SHADERPIPELINE=yes # Additional shader-based pipelines HAVE_SHADERPIPELINE=yes # Additional shader-based pipelines
C89_SHADERPIPELINE=no C89_SHADERPIPELINE=no

View File

@ -7,7 +7,10 @@ SHARE_DIR="${SHARE_DIR:-${PREFIX}/share}"
add_define() # $1 = MAKEFILE or CONFIG $2 = define $3 = value add_define() # $1 = MAKEFILE or CONFIG $2 = define $3 = value
{ eval "${1}_DEFINES=\"\${${1}_DEFINES} $2=$3\""; } { eval "${1}_DEFINES=\"\${${1}_DEFINES} $2=$3\""; }
add_dirs() # $1 = INCLUDE or LIBRARY $@ = include or library paths # add_dirs:
# $1 = INCLUDE or LIBRARY
# $@ = include or library paths
add_dirs()
{ ADD="$1"; LINK="${1%"${1#?}"}"; shift { ADD="$1"; LINK="${1%"${1#?}"}"; shift
while [ "$1" ]; do while [ "$1" ]; do
eval "${ADD}_DIRS=\"\${${ADD}_DIRS} -${LINK}${1}\"" eval "${ADD}_DIRS=\"\${${ADD}_DIRS} -${LINK}${1}\""
@ -16,7 +19,10 @@ add_dirs() # $1 = INCLUDE or LIBRARY $@ = include or library paths
eval "${ADD}_DIRS=\"\${${ADD}_DIRS# }\"" eval "${ADD}_DIRS=\"\${${ADD}_DIRS# }\""
} }
check_compiler() # $1 = language $2 = function in lib # check_compiler:
# $1 = language
# $2 = function in lib
check_compiler()
{ if [ "$1" = cxx ]; then { if [ "$1" = cxx ]; then
COMPILER="$CXX" COMPILER="$CXX"
TEMP_CODE="$TEMP_CXX" TEMP_CODE="$TEMP_CXX"
@ -28,7 +34,10 @@ check_compiler() # $1 = language $2 = function in lib
fi fi
} }
check_enabled() # $1 = HAVE_$1 $2 = lib # check_enabled:
# $1 = HAVE_$1
# $2 = lib
check_enabled()
{ [ "$HAVE_CXX" != 'no' ] && return 0 { [ "$HAVE_CXX" != 'no' ] && return 0
tmpval="$(eval "printf %s \"\$HAVE_$1\"")" tmpval="$(eval "printf %s \"\$HAVE_$1\"")"
@ -40,7 +49,16 @@ check_enabled() # $1 = HAVE_$1 $2 = lib
die 1 "Forced to build with $2 support and the C++ compiler is disabled. Exiting ..." die 1 "Forced to build with $2 support and the C++ compiler is disabled. Exiting ..."
} }
check_lib() # $1 = language $2 = HAVE_$2 $3 = lib $4 = function in lib $5 = extralibs $6 = headers $7 = critical error message [checked only if non-empty] # check_lib:
# Compiles a simple test program to check if a library is available.
# $1 = language
# $2 = HAVE_$2
# $3 = lib
# $4 = function in lib
# $5 = extralibs
# $6 = headers
# $7 = critical error message [checked only if non-empty]
check_lib()
{ tmpval="$(eval "printf %s \"\$HAVE_$2\"")" { tmpval="$(eval "printf %s \"\$HAVE_$2\"")"
[ "$tmpval" = 'no' ] && return 0 [ "$tmpval" = 'no' ] && return 0
@ -81,7 +99,13 @@ check_lib() # $1 = language $2 = HAVE_$2 $3 = lib $4 = function in lib $5 =
return 0 return 0
} }
check_pkgconf() # $1 = HAVE_$1 $2 = package $3 = version $4 = critical error message [checked only if non-empty] # check_pkgconf:
# If available uses $PKG_CONF_PATH to find a library.
# $1 = HAVE_$1
# $2 = package
# $3 = version [checked only if non-empty]
# $4 = critical error message [checked only if non-empty]
check_pkgconf()
{ tmpval="$(eval "printf %s \"\$HAVE_$1\"")" { tmpval="$(eval "printf %s \"\$HAVE_$1\"")"
eval "TMP_$1=\$tmpval" eval "TMP_$1=\$tmpval"
[ "$tmpval" = 'no' ] && return 0 [ "$tmpval" = 'no' ] && return 0
@ -115,7 +139,10 @@ check_pkgconf() # $1 = HAVE_$1 $2 = package $3 = version $4 = critical error
fi fi
} }
check_header() #$1 = HAVE_$1 $2, $3, ... = header files # check_header:
# $1 = HAVE_$1
# $@ = header files
check_header()
{ tmpval="$(eval "printf %s \"\$HAVE_$1\"")" { tmpval="$(eval "printf %s \"\$HAVE_$1\"")"
[ "$tmpval" = 'no' ] && return 0 [ "$tmpval" = 'no' ] && return 0
rm -f -- "$TEMP_C" rm -f -- "$TEMP_C"
@ -137,7 +164,11 @@ check_header() #$1 = HAVE_$1 $2, $3, ... = header files
die 1 "Build assumed that $header exists, but cannot locate. Exiting ..." die 1 "Build assumed that $header exists, but cannot locate. Exiting ..."
} }
check_macro() #$1 = HAVE_$1 $2 = macro name $3 = header name [included only if non-empty] # check_macro:
# $1 = HAVE_$1
# $2 = macro name
# $3 = header name [included only if non-empty]
check_macro()
{ tmpval="$(eval "printf %s \"\$HAVE_$1\"")" { tmpval="$(eval "printf %s \"\$HAVE_$1\"")"
[ "$tmpval" = 'no' ] && return 0 [ "$tmpval" = 'no' ] && return 0
if [ "${3}" ]; then if [ "${3}" ]; then
@ -166,7 +197,12 @@ EOF
die 1 "Build assumed that $macro is defined, but it's not. Exiting ..." die 1 "Build assumed that $macro is defined, but it's not. Exiting ..."
} }
check_switch() # $1 = language $2 = HAVE_$2 $3 = switch $4 = critical error message [checked only if non-empty] # check_switch:
# $1 = language
# $2 = HAVE_$2
# $3 = switch
# $4 = critical error message [checked only if non-empty]
check_switch()
{ check_compiler "$1" '' { check_compiler "$1" ''
ECHOBUF="Checking for availability of switch $3 in $COMPILER" ECHOBUF="Checking for availability of switch $3 in $COMPILER"
@ -181,8 +217,18 @@ check_switch() # $1 = language $2 = HAVE_$2 $3 = switch $4 = critical error m
} }
} }
check_val() # $1 = language $2 = HAVE_$2 $3 = lib $4 = include directory [checked only if non-empty] # check_val:
{ tmpval="$(eval "printf %s \"\$HAVE_$2\"")" # Uses check_pkgconf to find a library and falls back to check_lib if false.
# $1 = language
# $2 = HAVE_$2
# $3 = lib
# $4 = include directory [checked only if non-empty]
# $5 = package
# $6 = version [checked only if non-empty]
# $7 = critical error message [checked only if non-empty]
check_val()
{ check_pkgconf "$2" "$5" "$6" "${7:-}"
tmpval="$(eval "printf %s \"\$HAVE_$2\"")"
oldval="$(eval "printf %s \"\$TMP_$2\"")" oldval="$(eval "printf %s \"\$TMP_$2\"")"
if [ "$tmpval" = 'no' ] && [ "$oldval" != 'no' ]; then if [ "$tmpval" = 'no' ] && [ "$oldval" != 'no' ]; then
eval "HAVE_$2=auto" eval "HAVE_$2=auto"