# Description: Codec JPEG-2000 Part-1 standard
# URL: https://www.ece.uvic.ca/~frodo/jasper/
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: freeglut libjpeg-turbo xorg-libxmu

name=jasper
version=4.2.3
release=1
source=(https://github.com/jasper-software/jasper/releases/download/version-$version/jasper-$version.tar.gz)

build() {
  local config="
    -D CMAKE_INSTALL_PREFIX=/usr
    -D CMAKE_INSTALL_LIBDIR=lib
    -D CMAKE_BUILD_TYPE=Release
    -D CMAKE_SKIP_BUILD_RPATH=ON
    -D JAS_ENABLE_OPENGL=ON
    -D JAS_ENABLE_LIBJPEG=ON
    -D CMAKE_SKIP_RPATH=ON
    -D OpenGL_GL_PREFERENCE=GLVND"

  #build static lib
  ( cmake -S $name-$version -B build-static -G Ninja $config \
    -D JAS_ENABLE_SHARED=OFF
  cmake --build build-static
  )

  #build shared lib
  ( cmake -S $name-$version -B build-shared -G Ninja $config \
    -D JAS_ENABLE_SHARED=ON
  cmake --build build-shared
  )

  DESTDIR=$PKG cmake --install build-static
  DESTDIR=$PKG cmake --install build-shared

  rm -r $PKG/usr/share/doc
}
