# Description: audio editing suite
# URL:         http://codeberg.org/tenacityteam/
# Maintainer:  John McQuah, jmcquah at disroot dot org
# Depends on:  lilv libmad libsoxr portaudio wxgtk3 
# Optional:    soundtouch suil pulseaudio ladspa libid3tag

name=tenacity
version=1.3.3
libnyq_commit=6bbad2bac5661bca9ac650b40022c54881ea380b
release=2
source=(https://codeberg.org/tenacityteam/$name/archive/v$version.tar.gz
        https://codeberg.org/tenacityteam/libnyquist/archive/$libnyq_commit.tar.gz)
renames=($name-v$version.tar.gz
         libnyquist-$libnyq_commit.tar.gz)

build(){
  cd $name

  mv ../libnyquist/* lib-src/libnyquist
  sed -e "/CMAKE_MODULE_PATH/s/cmake/cmake-modules/" \
      -i lib-src/libnyquist/CMakeLists.txt

  sed -e '/^set. CMAKE_INSTALL_RPATH /s|ORIGIN/..|{INSTALL_PREFIX}|' \
      -e '/CMAKE_BUILD_WITH_INSTALL_RPATH/s/FALSE/TRUE/' \
      -i CMakeLists.txt

  cmake -G Ninja -S . -B build \
        -D CMAKE_C_FLAGS="$CFLAGS" \
        -D CMAKE_CXX_FLAGS="$CXXFLAGS" \
        -D CMAKE_INSTALL_PREFIX=/usr \
        -D CMAKE_INSTALL_LIBDIR=lib \
	-Wno-dev

  ninja -C build -j ${JOBS:-1}
  DESTDIR=$PKG ninja -C build install
  rm -rf $PKG/usr/{tenacity,share/doc,share/locale}

  mkdir -p $PKG/etc/revdep.d
  echo "/usr/lib/tenacity" > $PKG/etc/revdep.d/tenacity
}