From dfb572772726c46ee88deb6e2538af8a9848f880 Mon Sep 17 00:00:00 2001
From: Britney Fransen <brfransen@gmail.com>
Date: Tue, 7 Feb 2017 21:23:03 +0000
Subject: openjpeg2: update to 2.1.2

---
 abs/extra/openjpeg2/PKGBUILD | 59 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 47 insertions(+), 12 deletions(-)

diff --git a/abs/extra/openjpeg2/PKGBUILD b/abs/extra/openjpeg2/PKGBUILD
index 974266d..90f3161 100644
--- a/abs/extra/openjpeg2/PKGBUILD
+++ b/abs/extra/openjpeg2/PKGBUILD
@@ -1,25 +1,60 @@
-# $Id: PKGBUILD 99936 2013-10-31 02:34:11Z allan $
-# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
+# $Id$
+# Maintainer: Andreas Radke <andyrtr@archlinux.org>
+# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>
 
 pkgname=openjpeg2
-pkgver=2.1.0
-pkgrel=1
+pkgver=2.1.2
+pkgrel=2
 pkgdesc="An open source JPEG 2000 codec, version ${pkgver}"
 arch=(i686 x86_64)
-license=('BSD')
+license=('custom: BSD')
 url="http://www.openjpeg.org"
-makedepends=('cmake')
-depends=('zlib')
-source=(http://downloads.sourceforge.net/project/openjpeg.mirror/$pkgver/openjpeg-$pkgver.tar.gz)
-md5sums=('f6419fcc233df84f9a81eb36633c6db6')
+makedepends=('cmake' 'doxygen')
+             #'fcgi' 'xerces2-java')
+depends=('zlib' 'libpng' 'libtiff' 'lcms2')
+source=("$pkgname-$pkgver.tar.gz::https://github.com/uclouvain/openjpeg/archive/v$pkgver.tar.gz"
+        repair_bugs_of_871_and_872.patch::https://github.com/szukw000/openjpeg/commit/cadff5fb.patch)
+sha256sums=('4ce77b6ef538ef090d9bde1d5eeff8b3069ab56c4906f083475517c2c023dfa7'
+            'e352e9480925a31804d965c673545eeaa32d0a47605abaaa09b515ca956058ba')
+
+prepare() {
+  cd ${srcdir}
+  mkdir build
+  # Install doxygen docs to the right directory
+  sed -i -e "s:DESTINATION\ share/doc:DESTINATION\ share/doc/${pkgname}:" openjpeg-${pkgver}/doc/CMakeLists.txt
+  # http://seclists.org/oss-sec/2016/q4/649
+  cd ${srcdir}/openjpeg-$pkgver
+  patch -Np1 -i  ../repair_bugs_of_871_and_872.patch
+}
 
 build() {
-  cd "${srcdir}/openjpeg-${pkgver}"
-  cmake -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_DOC=on .
+  cd "${srcdir}/build"
+
+  # CMAKE flags
+  # MJ2 executables: '-DBUILD_MJ2:bool=on' (default: 'OFF')
+  # JPWL executables and JPWL library: '-DBUILD_JPWL:bool=on' (default: 'OFF')
+  # JPIP client (java compiler recommended) library and executables: '-DBUILD_JPIP:bool=on' (default: 'OFF')
+  # JPIP server (need fcgi) library and executables: '-DBUILD_JPIP_SERVER:bool=on' (default: 'OFF')
+
+  cmake "../openjpeg-${pkgver}" \
+    -DCMAKE_BUILD_TYPE=Release \
+    -DCMAKE_INSTALL_PREFIX=/usr \
+    -DBUILD_DOC=on
+
+#    -DBUILD_MJ2=ON \
+#    -DBUILD_JPWL=ON \
+#    -DBUILD_JPIP=ON \
+#    -DBUILD_JPIP_SERVER=ON \
+#    -DBUILD_JP3D=ON # --help -LAH
+
   make
 }
 
 package() {
-  cd "${srcdir}/openjpeg-${pkgver}"
+  cd "${srcdir}/build"
   make DESTDIR="${pkgdir}" install
+  
+  install -m755 -d "${pkgdir}/usr/share/licenses/openjpeg2"
+  mv ${pkgdir}/usr/share/doc/openjpeg-2.1/LICENSE ${pkgdir}/usr/share/licenses/openjpeg2
+  rmdir ${pkgdir}/usr/share/doc/openjpeg-2.1
 }
-- 
cgit v0.12

