diff --git a/qb/config.libs.sh b/qb/config.libs.sh index c3f7b55bda..0b3bb404d5 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -41,7 +41,7 @@ fi add_define_make DYLIB_LIB "$DYLIB" -check_lib SYSTEMD -lsystemd sd_get_machine_names +check_lib '' SYSTEMD -lsystemd sd_get_machine_names if [ "$HAVE_VIDEOCORE" != "no" ]; then check_pkgconf VC_TEST bcm_host @@ -49,7 +49,7 @@ if [ "$HAVE_VIDEOCORE" != "no" ]; then # use fallback if pkgconfig is not available if [ ! "$VC_TEST_LIBS" ]; then [ -d /opt/vc/lib ] && add_library_dirs /opt/vc/lib && add_library_dirs /opt/vc/lib/GL - check_lib VIDEOCORE -lbcm_host bcm_host_init "-lvcos -lvchiq_arm" + check_lib '' VIDEOCORE -lbcm_host bcm_host_init "-lvcos -lvchiq_arm" else HAVE_VIDEOCORE="$HAVE_VC_TEST" fi @@ -122,7 +122,7 @@ if [ "$HAVE_EGL" != "no" ] && [ "$OS" != 'Win32' ]; then check_pkgconf EGL "$VC_PREFIX"egl # some systems have EGL libs, but no pkgconfig if [ "$HAVE_EGL" = "no" ]; then - HAVE_EGL=auto; check_lib EGL "-l${VC_PREFIX}EGL $EXTRA_GL_LIBS" + HAVE_EGL=auto; check_lib '' EGL "-l${VC_PREFIX}EGL $EXTRA_GL_LIBS" [ "$HAVE_EGL" = "yes" ] && EGL_LIBS=-l"$VC_PREFIX"EGL else EGL_LIBS="$EGL_LIBS $EXTRA_GL_LIBS" @@ -130,7 +130,7 @@ if [ "$HAVE_EGL" != "no" ] && [ "$OS" != 'Win32' ]; then fi if [ "$HAVE_SSA" != "no" ]; then - check_lib SSA -lass ass_library_init + check_lib '' SSA -lass ass_library_init fi if [ "$HAVE_EXYNOS" != "no" ]; then @@ -149,8 +149,8 @@ else LIBRETRO="-lretro" fi [ "$HAVE_DYNAMIC" = 'yes' ] || { - #check_lib RETRO "$LIBRETRO" retro_init "$DYLIB" "Cannot find libretro, did you forget --with-libretro=\"-lretro\"?" - check_lib RETRO "$LIBRETRO" "$DYLIB" "Cannot find libretro, did you forget --with-libretro=\"-lretro\"?" + #check_lib '' RETRO "$LIBRETRO" retro_init "$DYLIB" "Cannot find libretro, did you forget --with-libretro=\"-lretro\"?" + check_lib '' RETRO "$LIBRETRO" "$DYLIB" "Cannot find libretro, did you forget --with-libretro=\"-lretro\"?" add_define_make libretro "$LIBRETRO" } @@ -173,18 +173,18 @@ if [ "$OS" = 'Win32' ]; then HAVE_THREAD_STORAGE=yes HAVE_DYLIB=yes else - check_lib THREADS "$PTHREADLIB" pthread_create + check_lib '' THREADS "$PTHREADLIB" pthread_create if [ "$HAVE_THREADS" = 'yes' ]; then - check_lib THREAD_STORAGE "$PTHREADLIB" pthread_key_create + check_lib '' THREAD_STORAGE "$PTHREADLIB" pthread_key_create else HAVE_THREAD_STORAGE=no fi - check_lib DYLIB "$DYLIB" dlopen + check_lib '' DYLIB "$DYLIB" dlopen fi -check_lib NETWORKING "$SOCKETLIB" socket "" "$SOCKETHEADER" +check_lib '' NETWORKING "$SOCKETLIB" socket "" "$SOCKETHEADER" if [ "$HAVE_NETWORKING" = 'yes' ]; then HAVE_GETADDRINFO=auto @@ -194,7 +194,7 @@ if [ "$HAVE_NETWORKING" = 'yes' ]; then if [ "$OS" = 'Win32' ]; then HAVE_GETADDRINFO=yes else - check_lib GETADDRINFO "$SOCKETLIB" getaddrinfo + check_lib '' GETADDRINFO "$SOCKETLIB" getaddrinfo if [ "$HAVE_GETADDRINFO" != 'yes' ]; then HAVE_SOCKET_LEGACY=yes echo "Notice: RetroArch will use legacy socket support" @@ -204,7 +204,7 @@ if [ "$HAVE_NETWORKING" = 'yes' ]; then HAVE_NETWORKGAMEPAD=yes if [ "$HAVE_MINIUPNPC" != "no" ]; then - check_lib MINIUPNPC "-lminiupnpc" + check_lib '' MINIUPNPC "-lminiupnpc" fi if [ "$HAVE_BUILTINMINIUPNPC" = "yes" ]; then @@ -218,7 +218,7 @@ else HAVE_CHEEVOS='no' fi -check_lib STDIN_CMD "$CLIB" fcntl +check_lib '' STDIN_CMD "$CLIB" fcntl if [ "$HAVE_NETWORK_CMD" = "yes" ] || [ "$HAVE_STDIN_CMD" = "yes" ]; then HAVE_COMMAND='yes' @@ -226,7 +226,7 @@ else HAVE_COMMAND='no' fi -check_lib GETOPT_LONG "$CLIB" getopt_long +check_lib '' GETOPT_LONG "$CLIB" getopt_long if [ "$HAVE_DYLIB" = 'no' ] && [ "$HAVE_DYNAMIC" = 'yes' ]; then echo "Error: Dynamic loading of libretro is enabled, but your platform does not appear to have dlopen(), use --disable-dynamic or --with-libretro=\"-lretro\"". @@ -234,27 +234,27 @@ if [ "$HAVE_DYLIB" = 'no' ] && [ "$HAVE_DYNAMIC" = 'yes' ]; then fi check_pkgconf ALSA alsa -check_lib CACA -lcaca +check_lib '' CACA -lcaca check_header OSS sys/soundcard.h check_header OSS_BSD soundcard.h -check_lib OSS_LIB -lossaudio +check_lib '' OSS_LIB -lossaudio if [ "$OS" = 'Linux' ]; then HAVE_TINYALSA=yes fi if [ "$OS" = 'Darwin' ]; then - check_lib COREAUDIO "-framework AudioUnit" AudioUnitInitialize - check_lib CORETEXT "-framework CoreText" CTFontCreateWithName - check_lib COCOA "-framework AppKit" NSApplicationMain - check_lib AVFOUNDATION "-framework AVFoundation" - check_lib CORELOCATION "-framework CoreLocation" - check_lib IOHIDMANAGER "-framework IOKit" IOHIDManagerCreate - check_lib AL "-framework OpenAL" alcOpenDevice + check_lib '' COREAUDIO "-framework AudioUnit" AudioUnitInitialize + check_lib '' CORETEXT "-framework CoreText" CTFontCreateWithName + check_lib '' COCOA "-framework AppKit" NSApplicationMain + check_lib '' AVFOUNDATION "-framework AVFoundation" + check_lib '' CORELOCATION "-framework CoreLocation" + check_lib '' IOHIDMANAGER "-framework IOKit" IOHIDManagerCreate + check_lib '' AL "-framework OpenAL" alcOpenDevice HAVE_X11=no # X11 breaks on recent OSXes even if present. HAVE_SDL=no else - check_lib AL -lopenal alcOpenDevice + check_lib '' AL -lopenal alcOpenDevice fi check_pkgconf RSOUND rsound 1.1 @@ -277,9 +277,9 @@ fi check_pkgconf LIBUSB libusb-1.0 1.0.16 if [ "$OS" = 'Win32' ]; then - check_lib DINPUT -ldinput8 - check_lib D3D9 -ld3d9 - check_lib DSOUND -ldsound + check_lib '' DINPUT -ldinput8 + check_lib '' D3D9 -ld3d9 + check_lib '' DSOUND -ldsound if [ "$HAVE_DINPUT" != 'no' ]; then HAVE_XINPUT=yes @@ -294,25 +294,25 @@ fi if [ "$HAVE_OPENGL" != 'no' ] && [ "$HAVE_OPENGLES" != 'yes' ]; then if [ "$OS" = 'Darwin' ]; then check_header OPENGL "OpenGL/gl.h" - check_lib OPENGL "-framework OpenGL" + check_lib '' OPENGL "-framework OpenGL" elif [ "$OS" = 'Win32' ]; then check_header OPENGL "GL/gl.h" - check_lib OPENGL -lopengl32 + check_lib '' OPENGL -lopengl32 else check_header OPENGL "GL/gl.h" - check_lib OPENGL -lGL + check_lib '' OPENGL -lGL fi if [ "$HAVE_OPENGL" = 'yes' ]; then if [ "$OS" = 'Darwin' ]; then - check_lib CG "-framework Cg" cgCreateContext + check_lib '' CG "-framework Cg" cgCreateContext [ "$HAVE_CG" = 'yes' ] && CG_LIBS='-framework Cg' elif [ "$OS" = 'Win32' ]; then - check_lib_cxx CG -lcg cgCreateContext + check_lib cxx CG -lcg cgCreateContext [ "$HAVE_CG" = 'yes' ] && CG_LIBS='-lcg -lcgGL' else # On some distros, -lCg doesn't link against -lstdc++ it seems ... - check_lib_cxx CG -lCg cgCreateContext + check_lib cxx CG -lCg cgCreateContext [ "$HAVE_CG" = 'yes' ] && CG_LIBS='-lCg -lCgGL' fi @@ -331,7 +331,7 @@ if [ "$HAVE_ZLIB" != 'no' ]; then if [ "$HAVE_ZLIB" = 'no' ]; then HAVE_ZLIB='auto' - check_lib ZLIB '-lz' + check_lib '' ZLIB '-lz' fi fi @@ -358,7 +358,7 @@ else fi if [ "$OS" != 'Win32' ]; then - check_lib DYNAMIC "$DYLIB" dlopen + check_lib '' DYNAMIC "$DYLIB" dlopen fi if [ "$HAVE_KMS" != "no" ]; then @@ -385,7 +385,7 @@ if [ "$HAVE_EGL" = "yes" ]; then else HAVE_OPENGLES=auto; check_pkgconf OPENGLES "$VC_PREFIX"glesv2 if [ "$HAVE_OPENGLES" = "no" ]; then - HAVE_OPENGLES=auto; check_lib OPENGLES "-l${VC_PREFIX}GLESv2 $EXTRA_GL_LIBS" + HAVE_OPENGLES=auto; check_lib '' OPENGLES "-l${VC_PREFIX}GLESv2 $EXTRA_GL_LIBS" add_define_make OPENGLES_LIBS "-l${VC_PREFIX}GLESv2 $EXTRA_GL_LIBS" fi fi @@ -393,7 +393,7 @@ if [ "$HAVE_EGL" = "yes" ]; then if [ "$HAVE_VG" != "no" ]; then check_pkgconf VG "$VC_PREFIX"vg if [ "$HAVE_VG" = "no" ]; then - HAVE_VG=auto; check_lib VG "-l${VC_PREFIX}OpenVG $EXTRA_GL_LIBS" + HAVE_VG=auto; check_lib '' VG "-l${VC_PREFIX}OpenVG $EXTRA_GL_LIBS" [ "$HAVE_VG" = "yes" ] && VG_LIBS=-l"$VC_PREFIX"OpenVG fi fi @@ -405,14 +405,14 @@ fi check_pkgconf V4L2 libv4l2 if [ "$OS" = 'Darwin' ]; then - check_lib FBO "-framework OpenGL" glFramebufferTexture2D + check_lib '' FBO "-framework OpenGL" glFramebufferTexture2D elif [ "$OS" = 'Win32' ]; then HAVE_FBO=yes else if [ "$HAVE_OPENGLES" = "yes" ]; then [ $HAVE_FBO != "no" ] && HAVE_FBO=yes else - check_lib FBO -lGL glFramebufferTexture2D + check_lib '' FBO -lGL glFramebufferTexture2D fi fi @@ -440,7 +440,7 @@ fi if [ "$HAVE_UDEV" != "no" ]; then check_pkgconf UDEV libudev if [ "$HAVE_UDEV" = "no" ]; then - HAVE_UDEV=auto; check_lib UDEV "-ludev" + HAVE_UDEV=auto; check_lib '' UDEV "-ludev" [ "$HAVE_UDEV" = "yes" ] && UDEV_LIBS=-ludev fi fi @@ -451,11 +451,11 @@ check_header PARPORT linux/parport.h check_header PARPORT linux/ppdev.h if [ "$OS" != 'Win32' ] && [ "$OS" != 'Linux' ]; then - check_lib STRL "$CLIB" strlcpy + check_lib '' STRL "$CLIB" strlcpy fi -check_lib STRCASESTR "$CLIB" strcasestr -check_lib MMAP "$CLIB" mmap -check_lib VULKAN -lvulkan vkCreateInstance +check_lib '' STRCASESTR "$CLIB" strcasestr +check_lib '' MMAP "$CLIB" mmap +check_lib '' VULKAN -lvulkan vkCreateInstance if [ "$HAVE_VULKAN" != 'no' ] && [ ! -e deps/glslang/glslang/README.md ]; then echo "Warning: glslang submodule not loaded, can't use Vulkan." diff --git a/qb/qb.libs.sh b/qb/qb.libs.sh index 42f2eaa782..6235f4a513 100644 --- a/qb/qb.libs.sh +++ b/qb/qb.libs.sh @@ -23,74 +23,52 @@ add_library_dirs() LIBRARY_DIRS="${LIBRARY_DIRS#* }" } -check_lib() #$1 = HAVE_$1 $2 = lib $3 = function in lib $4 = extralibs $5 = headers -{ tmpval="$(eval echo \$HAVE_$1)" +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] +{ tmpval="$(eval echo \$HAVE_$2)" [ "$tmpval" = 'no' ] && return 0 - if [ "$3" ]; then - ECHOBUF="Checking function $3 in ${2% }" - if [ "$5" ]; then - printf %s\\n "$5" "int main(void) { void *p = (void*)$3; return 0; }" > $TEMP_C + if [ "$1" = cxx ]; then + COMPILER="$CXX" + TEMP_CODE="$TEMP_CXX" + TEST_C="extern \"C\" { void $4(void); } int main() { $4(); }" + else + COMPILER="$CC" + TEMP_CODE="$TEMP_C" + TEST_C="void $4(void); int main(void) { $4(); return 0; }" + fi + + if [ "$4" ]; then + ECHOBUF="Checking function $4 in ${3% }" + if [ "$6" ]; then + printf %s\\n "$6" "int main(void) { void *p = (void*)$4; return 0; }" > "$TEMP_CODE" else - echo "void $3(void); int main(void) { $3(); return 0; }" > $TEMP_C + echo "$TEST_C" > "$TEMP_CODE" fi else - ECHOBUF="Checking existence of ${2% }" - echo "int main(void) { return 0; }" > $TEMP_C + ECHOBUF="Checking existence of ${3% }" + echo "int main(void) { return 0; }" > "$TEMP_CODE" fi answer='no' # echo -n "$ECHOBUF" - "$CC" -o \ + "$COMPILER" -o \ "$TEMP_EXE" \ - "$TEMP_C" \ + "$TEMP_CODE" \ $INCLUDE_DIRS \ $LIBRARY_DIRS \ - $(printf %s "$4") \ + $(printf %s "$5") \ $CFLAGS \ $LDFLAGS \ - $(printf %s "$2") >>config.log 2>&1 && answer='yes' - eval HAVE_$1="$answer"; echo "$ECHOBUF ... $answer" - rm "$TEMP_C" "$TEMP_EXE" >/dev/null 2>&1 - - [ "$tmpval" = 'yes' ] && [ "$answer" = 'no' ] && { - echo "Forced to build with library $2, but cannot locate. Exiting ..." - exit 1 - } + $(printf %s "$3") >>config.log 2>&1 && answer='yes' + eval HAVE_$2="$answer"; echo "$ECHOBUF ... $answer" + rm "$TEMP_CODE" "$TEMP_EXE" >/dev/null 2>&1 - return 0 -} - -check_lib_cxx() #$1 = HAVE_$1 $2 = lib $3 = function in lib $4 = extralibs $5 = critical error message [checked only if non-empty] -{ tmpval="$(eval echo \$HAVE_$1)" - [ "$tmpval" = 'no' ] && return 0 - - if [ "$3" ]; then - ECHOBUF="Checking function $3 in ${2% }" - echo "extern \"C\" { void $3(void); } int main() { $3(); }" > $TEMP_CXX - else - ECHOBUF="Checking existence of ${2% }" - echo "int main() { return 0; }" > $TEMP_CXX - fi - answer='no' -# echo -n "$ECHOBUF" - "$CXX" -o \ - "$TEMP_EXE" \ - "$TEMP_CXX" \ - $INCLUDE_DIRS \ - $LIBRARY_DIRS \ - $(printf %s "$4") \ - $CFLAGS \ - $LDFLAGS \ - $(printf %s "$2") >>config.log 2>&1 && answer='yes' - eval HAVE_$1="$answer"; echo "$ECHOBUF ... $answer" - rm "$TEMP_CXX" "$TEMP_EXE" >/dev/null 2>&1 [ "$answer" = 'no' ] && { - [ "$5" ] && { echo "$5"; exit 1;} + [ "$7" ] && { echo "$7"; exit 1;} [ "$tmpval" = 'yes' ] && { - echo "Forced to build with library $2, but cannot locate. Exiting ..." + echo "Forced to build with library $3, but cannot locate. Exiting ..." exit 1 } - + } return 0