APP=openjpeg
VERSION=2.3.1
BUILD=1sml
HOMEPAGE="https://github.com/uclouvain/openjpeg"
DOWNLOAD="https://github.com/uclouvain/openjpeg/archive/refs/tags/v2.3.1.tar.gz"
DESC="An open source JPEG 2000 codec"
REQUIRES="libpng lcms2"

build() {
  mkandenterbuilddir
  rm -rf $APP-$VERSION

  tar xf $SRCDIR/$APP-$VERSION.tar.?z*
  cd $APP-$VERSION
  fixbuilddirpermissions

  patch -p1 < $SRCDIR/openjpeg2-remove-thirdparty.patch

  mkdir 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 

  make
  make install DESTDIR=$PKG

  cp ../LICENSE $PKGDOCS/

  mkfinalpkg
}

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