# Maintainer: PktSurf <smlinux@pktsurf.in>
app=openjpeg
version=2.3.1
build=1sml
homepage="https://github.com/uclouvain/openjpeg"
download="https://github.com/uclouvain/openjpeg/archive/refs/tags/v$version.tar.gz"
desc="An open source JPEG 2000 codec"
requires="libpng lcms2"

prepbuilddir() {
  mkandenterbuilddir
  rm -rf $app-$version

  tar xf $srcdir/$app-$version.tar.?z*
  cd $app-$version
  fixbuilddirpermissions

  applypatch $srcdir/openjpeg2-remove-thirdparty.patch
}

build() {
  mkdir -p smbuild && cd smbuild
  cmake .. \
    -DCMAKE_INSTALL_PREFIX="" \
    -DOPENJPEG_INSTALL_LIB_DIR="lib" \
    -DBUILD_JPWL:BOOL=ON \
    -DBUILD_MJ2:BOOL=ON \
    -DBUILD_JPIP:BOOL=ON \
    -DBUILD_JP3D:BOOL=ON \
    -DBUILD_STATIC_LIBS=OFF

  make
  make install DESTDIR=$pkg

  cp ../LICENSE $pkgdocs/

  mkfinalpkg
}

sha512sums="
e7e9c359ba1e8af5d9eba3fdebcac42b829ba96939f47d33ec484304684782a16f08d8b5de9378c37a95e7dc05b6d0d1b79801eae8fe38129758a21b4547904e  openjpeg-2.3.1.tar.lz
b328a994440b14255faa8b01f48d46ab06ad36ca4b940cf5cf5ec09441f470760e51724ac568af68129c296abcb867508f200020d15af6591d80ca319d8daccc  openjpeg2-remove-thirdparty.patch
"
