File kodi.pkg_check_modules.sh of Package kodi

#!/bin/bash
# vim: tabstop=4 shiftwidth=4 expandtab
cmake_dir='cmake/modules'
x() {
    local required='REQUIRED'
    local find=
    local pkgs=
    local hdrs=
    local lib=
    local defs=
    local filename=
    local fullname=
    local target=
    local has_target=
    local msg=
    local pkg=

    until test "$#" -eq 0
    do
        case "$1" in
        --optional) required= ;;
        --target) target=$2 ; has_target='true' ; shift ;;
        --find) find=$2 ; shift ;;
        --pkgconfig) pkgs=($2) ; shift ;;
        --libs_and_headers) libs=$2 hdrs=$3 ; shift ; shift ;;
        --defines) defs=$2 ; shift ;;
        *) echo "$* unhandled" ; return ;;
        esac
        shift
    done
    
    filename="Find${find}"
    fullname="${cmake_dir}/${filename}.cmake"
#
    find="${find^^}"
    test -z "${target}" && target="${find}::${find}"
#
    echo "Updating ${filename}"
    rm -f "${fullname}"
    cat > "${fullname}" <<_EOF_
#.rst:
# ${filename}
# -------
# Finds the ${find} library
#
# This will define the following variables:
#
# ${find}_FOUND - system has ${find}
# ${find}_INCLUDE_DIRS - the ${find} include directory
# ${find}_LIBRARIES - the ${find} libraries
#
# and the following imported targets::
#
#   ${target}   - The ${find} library

_EOF_
#
if test ${#pkgs[@]} -gt 0
then
    if test ${#pkgs[@]} -gt 1
    then
        for pkg in ${pkgs[@]}
        do
            pkg="${pkg%%>*}"
            msg="${msg} ${pkg} \${${find}_${pkg}_VERSION};"
        done
    else
            pkg="${pkgs[@]}"
            msg=" ${pkg%%>*} \${${find}_VERSION}"
    fi
    cat >> "${fullname}" <<_EOF_
if(PKG_CONFIG_FOUND)
  message(STATUS "${filename} checking for ${pkgs[@]}")
  pkg_check_modules(${find} ${required} ${pkgs[@]} QUIET)
  if (${find}_FOUND)
    message(STATUS "${filename} found${msg}")
_EOF_
    if test -n "${has_target}"
    then
        cat >> "${fullname}" <<_EOF_
    message(STATUS "${filename} found libs: \${${find}_LIBRARIES}")
    list(APPEND _liblist_${find} \${${find}_LIBRARIES})
    foreach(_lib IN LISTS _liblist_${find})
      message(STATUS "${filename} _lib \${_lib}")
      unset(${find}_so CACHE)
      find_library(${find}_so NAMES \${_lib})
      message(STATUS "${filename} \${_lib} maps to \${${find}_so}")
      set(${find}_LIBRARY \${${find}_LIBRARY} \${${find}_so})
    endforeach()
    unset(_lib CACHE)
    message(STATUS "${filename} ${find}_LIBRARY: \${${find}_LIBRARY}")
    set(${find}_LIBRARIES \${${find}_LIBRARY})
_EOF_
    fi
    cat >> "${fullname}" <<_EOF_
  endif()
_EOF_
fi
if test -n "${hdrs}${libs}"
then
  cat >> "${fullname}" <<_EOF_
endif()
if (NOT ${find}_FOUND)
_EOF_
fi
#
if test -n "${hdrs}"
then
  cat >> "${fullname}" <<_EOF_
  find_path(${find}_INCLUDE_DIR NAMES ${hdrs})
_EOF_
fi
#
if test -n "${libs}"
then
  cat >> "${fullname}" <<_EOF_
  find_library(${find}_LIBRARY NAMES ${libs})
_EOF_
fi
#
if test -n "${libs}"
then
  cat >> "${fullname}" <<_EOF_
  include(FindPackageHandleStandardArgs)
  find_package_handle_standard_args(${find}
                                    REQUIRED_VARS
                                    ${find}_INCLUDE_DIR
                                    ${find}_LIBRARY
                                    )
  if (${find}_FOUND)
    set(${find}_LIBRARIES \${${find}_LIBRARY})
    set(${find}_INCLUDE_DIRS \${${find}_INCLUDE_DIR})
  endif()
  mark_as_advanced(${find}_INCLUDE_DIR ${find}_LIBRARY)
_EOF_
fi
#
if test ${#pkgs[@]} -gt 0
then
  cat >> "${fullname}" <<_EOF_
endif()
_EOF_
fi
#
cat >> "${fullname}" <<_EOF_

if(${find}_FOUND)
_EOF_
#
#
cat >> "${fullname}" <<_EOF_
  set(${find}_DEFINITIONS \${${find}_CFLAGS_OTHER} ${defs})
  if(NOT TARGET ${target})
    add_library(${target} UNKNOWN IMPORTED)
    set_target_properties(${target}
                          PROPERTIES
                          IMPORTED_LOCATION "\${${find}_LIBRARY}"
                          INTERFACE_INCLUDE_DIRECTORIES "\${${find}_INCLUDE_DIR}")
  endif()
else()
    message(STATUS "${filename} misses pkgconfig(${pkgs[@]})")
endif()
_EOF_
#
#cat "${fullname}"
}

#x --find "ASS" --pkgconfig "libass" --libs_and_headers "ass libass" "ass/ass.h" --defines ""
#x --find "Alsa" --pkgconfig "alsa>=1.0.27" --libs_and_headers "asound" "alsa/asoundlib.h" --defines "-DHAS_ALSA=1"
#x --find "Avahi" --pkgconfig "avahi-client" --libs_and_headers "avahi-client avahi-common" "avahi-client/client.h avahi-common/defs.h" --defines "-DHAS_AVAHI=1 -DHAS_ZEROCONF=1"
#x --find "Bluetooth" --pkgconfig "bluez" --libs_and_headers "bluetooth libbluetooth" "bluetooth/bluetooth.h" --defines ""
#x --find "Bluray" --pkgconfig "libbluray>=0.9.3" --libs_and_headers "bluray libbluray" "libbluray/bluray.h" --defines "-DHAVE_LIBBLURAY=1 -DHAVE_LIBBLURAY_BDJ=1"
#x --optional --find "CAP" --pkgconfig "libcap" --libs_and_headers "cap libcap" "sys/capability.h" --defines ""
#x --find "CEC" --pkgconfig "libcec>=4.0.0" --libs_and_headers "cec" "libcec/cec.h libCEC/CEC.h" --defines "-DHAVE_LIBCEC=1"
#x --find "CWiid" --pkgconfig "cwiid" --libs_and_headers "cwiid" "cwiid.h" --defines ""
#x --find "Cdio" --pkgconfig "libcdio>=0.78 libiso9660" --libs_and_headers "cdio libcdio iso9660" "cdio/cdio.h cdio/iso9660.h" --defines ""
#x --find "Curl" --pkgconfig "libcurl" --libs_and_headers "curl libcurl libcurl_imp" "curl/curl.h" --defines ""
#x --find "DBus" --pkgconfig "dbus-1" --libs_and_headers "dbus-1" "dbus/dbus.h" --defines "-DHAS_DBUS=1"
#x --find "EGL" --pkgconfig "egl" --libs_and_headers "EGL egl" "EGL/egl.h" --defines "-DHAS_EGL=1"
#x --target "ffmpeg" --find "FFMPEG" \
#    --pkgconfig "libavcodec>=58.18.100 libavfilter>=7.16.100 libavformat>=58.12.100 libavutil>=56.14.100 libswscale>=5.1.100 libswresample>=3.1.100 libpostproc>=55.1.100" \
#    --libs_and_headers "" "" --defines "-DFFMPEG_VER_SHA=\\\"\${FFMPEG_VERSION}\\\""
#x --target "fmt" --find "Fmt" --pkgconfig "fmt" --libs_and_headers "fmt" "fmt/format.h" --defines ""
#x --find "FreeType" --pkgconfig "freetype2" --libs_and_headers "freetype freetype246MT" "freetype/freetype.h freetype.h" --defines ""
#x --find "FriBidi" --pkgconfig "fribidi" --libs_and_headers "fribidi libfribidi" "fribidi/fribidi.h" --defines ""
#x --optional --find "GLX" --pkgconfig "glx" --libs_and_headers "GL" "GL/glx.h" --defines "-DHAS_GLX=1"
#x --find "LCMS2" --pkgconfig "lcms2" --libs_and_headers "lcms2 liblcms2" "lcms2.h" --defines "-DHAVE_LCMS2=1"
#x --find "LibDRM" --pkgconfig "libdrm>=2.4.74" --libs_and_headers "drm" "drm.h" --defines ""
x --target "dvdnav" --find "LibDvd" --pkgconfig "dvdnav" --libs_and_headers "" "" --defines ""
#x --find "LibInput" --pkgconfig "libinput" --libs_and_headers "input" "libinput.h" --defines ""
#x --find "LibUSB" --pkgconfig "libusb" --libs_and_headers "usb" "libusb.h" --defines "-DUSE_LIBUSB=1"
#x --find "LircClient" --pkgconfig "lirc" --libs_and_headers "lirc_client" "lirc/lirc_client.h" --defines "-DHAS_LIRC=1"
#x --find "MariaDBClient" --pkgconfig "mariadb" --libs_and_headers "mariadbclient mariadb" "mariadb/mysql.h mariadb/server/mysql.h" --defines "-DHAS_MARIADB=1"
#x --find "MicroHttpd" --pkgconfig "libmicrohttpd>=0.9.40" --libs_and_headers "microhttpd libmicrohttpd" "microhttpd.h" --defines "-DHAS_WEB_SERVER=1 -DHAS_WEB_INTERFACE=1"
#x --find "NFS" --pkgconfig "libnfs" --libs_and_headers "nfs libnfs" "nfsc/libnfs.h" --defines "-DHAS_FILESYSTEM_NFS=1"
#x --find "OpenGLES" --pkgconfig "glesv2" --libs_and_headers "GLESv2" "GLES2/gl2.h" --defines "-DHAS_GLES=3"
#x --find "OpenGl" --pkgconfig "gl glu" --libs_and_headers "GL GLU" "GL/gl.h" --defines "-DHAS_GL=1"
#x --find "PCRE" --pkgconfig "libpcrecpp" --libs_and_headers "" "" --defines ""
#x --find "Plist" --pkgconfig "libplist" --libs_and_headers "plist" "plist/plist.h" --defines "-DHAS_AIRPLAY=1"
#x --find "PulseAudio" --pkgconfig "libpulse>=2.0.0 libpulse-mainloop-glib libpulse-simple" --libs_and_headers "" "" --defines "-DHAS_PULSEAUDIO=1"
#x --find "Python" --pkgconfig "python>=2.7" --libs_and_headers "" "" --defines "-DHAS_PYTHON=1"
#x --find "RapidJSON" --pkgconfig "RapidJSON>=1.0.2" --libs_and_headers "" "" --defines ""
#x --find "Sdl" --pkgconfig "sdl" --libs_and_headers "SDL" "SDL/SDL.h" --defines "-DHAVE_SDL=1"
#x --find "SmbClient" --pkgconfig "smbclient" --libs_and_headers "smbclient" "libsmbclient.h" --defines "-DHAS_FILESYSTEM_SMB=1"
#x --find "Sqlite3" --pkgconfig "sqlite3" --libs_and_headers "sqlite3" "sqlite3.h" --defines ""
#x --find "TagLib" --pkgconfig "taglib>=1.9.0" --libs_and_headers "tag" "taglib/tag.h" --defines ""
#x --optional --find "TinyXML" --pkgconfig "tinyxml" --libs_and_headers "tinyxml" "tinyxml.h" --defines ""
#x --optional --find "UDEV" --pkgconfig "udev" --libs_and_headers "udev" "libudev.h" --defines "-DHAVE_LIBUDEV=1"
#x --find "UUID" --pkgconfig "uuid" --libs_and_headers "uuid" "uuid/uuid.h" --defines ""
#x --find "VAAPI" --pkgconfig "libva libva-drm libva-wayland libva-x11" --libs_and_headers "" "" --defines "-DHAVE_LIBVA=1"
#x --find "VDPAU" --pkgconfig "vdpau" --libs_and_headers "vdpau" "vdpau/vdpau.h vdpau/vdpau_x11.h" --defines "-DHAVE_LIBVDPAU=1"
#x --find "Waylandpp" --pkgconfig "wayland-client++ wayland-egl++ wayland-cursor++" --libs_and_headers "" "" --defines "-DHAVE_WAYLAND=1"
#x --find "Wayland" --pkgconfig "wayland-client wayland-egl wayland-cursor" --libs_and_headers "wayland" "wayland/wayland-client-core.h" --defines "-DHAVE_WAYLAND=1"
#x --find "X" --pkgconfig "x11 xext" --libs_and_headers "X11 Xext" "X11/Xlib.h" --defines "-DHAVE_X11=1"
#x --find "XRandR" --pkgconfig "xrandr" --libs_and_headers "Xrandr" "X11/extensions/Xrandr.h" --defines "-DHAVE_LIBXRANDR=1"
#x --find "XSLT" --pkgconfig "libxslt" --libs_and_headers "xslt libxslt" "libxslt/xslt.h" --defines "-DHAVE_LIBXSLT=1"
#x --find "Xkbcommon" --pkgconfig "xkbcommon" --libs_and_headers "xkbcommon" "xkbcommon/xkbcommon.h" --defines ""
#x --find "Zip" --pkgconfig "libzip" --libs_and_headers "zip" "zip.h" --defines ""
#x --target "fstrcmp" --find "fstrcmp" --pkgconfig "fstrcmp" --libs_and_headers "fstrcmp" "fstrcmp.h" --defines ""
x --target "crossguid" --find "CrossGUID" --pkgconfig "crossguid" --libs_and_headers "crossguid" "crossguid/guid.hpp" --defines ""
#x --target "libcpluff" --find "Cpluff" --pkgconfig "libcpluff" --libs_and_headers "cpluff" "cpluff.h" --defines ""
openSUSE Build Service is sponsored by