File PKGBUILD of Package mediastreamer2

# Get some information about the machine we are building on:
_numberOfProcessorsOnMachine=$(nproc)
_wantedJobs=$(echo "1.25*${_numberOfProcessorsOnMachine}" | bc -l)
_jobsIget=$(echo ${_wantedJobs} | awk '{print int($1+0.5)}')
_TOTAL_DISK=$(df -h --total | awk 'END{print $2}')
_FREEMEM=$(free --mega)
_TOTAL_MEM=$(free --total --mega | xargs | awk '{print $19"MB"}')
_TOTAL_RAM=$(free --total --mega | xargs | awk '{print $8"MB"}')
_TOTAL_SWAP=$(free --total --mega | xargs | awk '{print $15"MB"}')
pkgname=mediastreamer2
pkgver=5.3.1
pkgrel=1
pkgdesc='A library written in C that allows you to create and run audio and video streams'
arch=(x86_64)
url='https://gitlab.linphone.org/'
license=(GPL)
depends=("ortp>=5.3.5" ffmpeg "bzrtp>=5.3.5" glew libsrtp zxing-cpp libdecaf)
# Source code incompatible with system package zxing-cpp:
# removed makedepends packages: zxing-cpp temporarily
# "bctoolbox>=$pkgver"
makedepends=(cmake python doxygen 
  'bcg729>=1.1.1' 'broadvoice16>=1.2' 'bcmatroska2>=5.2.1'
  "bctoolbox>=5.3.5" 'bcunit>=5.3.5' "bzrtp>=5.3.5" "ortp>=5.3.5"
  "liboqs>=0.7.1" "postquantumcryptoengine>=5.3.0"
  libogg opus gsm speex speexdsp libtheora
  pipewire-v4l2 pipewire-media-session libvpx libxv ffmpeg libjpeg-turbo
  glew mesa libyuv sqlite3 libebml sdl12-compat libx11 libxext "mbedtls2=2.28.0"
  libxml2 libupnp libpcap graphviz libsrtp git libdecaf procps-ng bc gzip zxing-cpp
  qt5-base qt5-declarative aom dav1d)
source=(https://gitlab.linphone.org/BC/public/${pkgname}/-/archive/$pkgver/${pkgname}-$pkgver.tar.bz2)
sha1sums=(SKIP)
_uploaddir=/usr/src/packages/SOURCES
_sourcedir=/usr/src/packages/BUILD/${pkgname}/src/${pkgname}-${pkgver}
# srcdir is already defined as
# ${srcdir}=/usr/src/packages/BUILD/${pkgname}/src
_builddir=/usr/src/packages/BUILD/${pkgname}/build
_pkgdir=/usr/src/packages/BUILD/${pkgname}/pkg/${pkgname}
_installToDir=${_pkgdir}/usr


prepare() {
  # --- Apply patches ---
  cd "$sourcedir"
  # patch -d ${pkgname}-$pkgver -p1 < ${_pkgname}-0001-fix.patch
  # patch --forward --strip=1 --input="${srcdir}/${_pkgname}-0001-fix.patch"
  # patch -d "${_sourcedir}" --forward --strip=1 --input="${srcdir}/${pkgname}-0001-fix.patch"
  # or
  # patch -d "${_sourcedir}" --forward --strip=1 --input="${_uploaddir}/${pkgname}-0001-fix.patch"
  #
  #
  # patch -d "${_sourcedir}" --forward --strip=1 --input="${_uploaddir}/${pkgname}-00-fix-pkgconfig.patch"
  # patch -d "${_sourcedir}" --forward --strip=1 --input="${_uploaddir}/${pkgname}-01-fix-build-ffmpeg5.patch"
  # patch -d "${_sourcedir}" --forward --strip=1 --input="${_uploaddir}/${pkgname}-fix-Archlinux-compilation.patch"
}



build() {
  patch -d "${_sourcedir}" --forward --strip=1 --input="${_uploaddir}/${pkgname}-00-fix-pkgconfig.patch"
  patch -d "${_sourcedir}" --forward --strip=1 --input="${_uploaddir}/${pkgname}-01-fix-build-ffmpeg5.patch"
  patch -d "${_sourcedir}" --forward --strip=1 --input="${_uploaddir}/${pkgname}-fix-Archlinux-compilation.patch"
  # Fix for Zxing not found, but source code incompatible with system package zxing-cpp
  # echo "Replace FindZxing.cmake so Zxing can be found"
  # Method 1:
  # find /usr/src/packages/BUILD/${pkgname}/src/${pkgname}-$pkgver/cmake -name FindZxing.cmake -delete
  # mv -v /usr/src/packages/SOURCES/FindZXing.cmake /usr/src/packages/SOURCES/FindZxing.cmake
  # Method 2:
  # cp -v /usr/src/packages/SOURCES/FindZXing.cmake /usr/src/packages/BUILD/${pkgname}/src/${pkgname}-$pkgver/cmake/FindZxing.cmake  
  # Cmake options:     
  # -DENABLE_QT_GL=ON # this has to be set
  # -DENABLE_QRCODE=ON # this can cause issues
  cmake -B build -S ${pkgname}-$pkgver \
    -DCMAKE_BUILD_PARALLEL_LEVEL=${_jobsIget} \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_MODULE_PATH="${CMAKE_MODULE_PATH};/usr/src/packages/SOURCES" \
    -DENABLE_UNIT_TESTS=OFF \
    -DENABLE_TOOLS=OFF \
    -DENABLE_STATIC=OFF \
    -DENABLE_STRICT=OFF \
    -DENABLE_QRCODE=OFF \
    -DENABLE_QT_GL=ON
  cmake --build build --parallel ${_jobsIget}
}



package() {
  DESTDIR="$pkgdir" cmake --install build
  # TODO: Is the following code obsolete?
  rm -r "$pkgdir"/usr/include/OpenGL
}
openSUSE Build Service is sponsored by