summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 541a455103ecd0f560e95542711a94adca4aeac0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Maintainer:  Marcell Meszaros < marcell.meszaros AT runbox.eu >
# Contributor: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Eric BĂ©langer <eric@archlinux.org>

pkgbase=jasper-git
pkgname=('jasper-git' 'jasper-doc-git')
pkgver=3.0.3.r6.g411571c
pkgrel=2
pkgdesc='Implementation of the JPEG-2000 Part-1 standard codec (git version)'
url='https://www.ece.uvic.ca/~mdadams/jasper/'
arch=('x86_64')
license=('custom:JasPer2.0')
makedepends=('git' 'glibc' 'libjpeg' 'libheif' 'freeglut' 'glu' 'cmake'
             'doxygen'
             'texlive-bin' 'texlive-core' 'texlive-latexextra'
             'biber' 'texlive-bibtexextra' 'texlive-pictures' 
             'texlive-fontsextra' 'texlive-formatsextra' 'texlive-pstricks' 
             'texlive-games' 'texlive-humanities' 'texlive-science'
             'ghostscript' 'plantuml')
options=('staticlibs')
source=("${pkgbase%-git}::git+https://github.com/jasper-software/jasper.git")
sha512sums=('SKIP')

pkgver() {
  cd "${pkgbase%-git}"

  # Generate git tag based version. Count only proper (v)#.#* [#=number] tags.
  local _gitversion=$(git describe --long --tags --match 'version-[0-9].[0-9.][0-9.]*' | sed -e 's|^version-||' | tr '[:upper:]' '[:lower:]') 

  # Format git-based version for pkgver
  echo "${_gitversion}" | sed \
    -e 's|^\([0-9]\.[0-9.]*\)-\([a-zA-Z]\+\)|\1\2|' \
    -e 's|\([0-9]\+-g\)|r\1|' \
    -e 's|-|.|g'
}

build() {
  cd "${pkgbase%-git}"

  # Sourcing JRE in case it was just installed
  local jre_profile='/etc/profile.d/jre.sh'
  if [ -x "${jre_profile}" ]; then
    source "${jre_profile}"
  fi

  local options=(
    -DCMAKE_INSTALL_PREFIX=/usr
    -DCMAKE_C_FLAGS="$CFLAGS -ffat-lto-objects"
    -DJAS_ENABLE_LIBJPEG=ON
    -DJAS_ENABLE_LIBHEIF=ON
    -DJAS_ENABLE_OPENGL=ON
    -DJAS_ENABLE_HIDDEN=OFF
  )

  printf "\nConfiguring build for static lib...\n"
  cmake \
    -B build-static \
    "${options[@]}" \
    -DJAS_ENABLE_SHARED=OFF \
    -DJAS_ENABLE_DOC=OFF \
    -DJAS_ENABLE_LATEX=OFF \
    -DJAS_ENABLE_PROGRAMS=OFF
  printf "\nBuilding static lib...\n"
  make -C build-static

  printf "\nConfiguring build for shared lib...\n"
  cmake \
    -B build-shared \
    "${options[@]}" \
    -DJAS_ENABLE_SHARED=ON \
    -DJAS_ENABLE_DOC=ON \
    -DJAS_ENABLE_LATEX=ON \
    -DJAS_ENABLE_PROGRAMS=ON
  printf "\nRefreshing doc/Doxyfile...\n"
  doxygen -u build-shared/doc/Doxyfile
  printf "\nBuilding shared lib...\n"
  make -j1 -C build-shared
}

check() {
  cd "${pkgbase%-git}/build-shared"
  ctest --parallel 1 --output-on-failure
}

package_jasper-git() {
  depends=('glibc' 'libjpeg' 'libheif')
  optdepends=('jasper-doc-git: documentation'
              'freeglut: jiv support'
              'glu: jiv support')
  provides=("${pkgname%-git}=${pkgver}" 'libjasper.so')
  conflicts=("${pkgname%-git}")

  cd "${pkgbase%-git}"
  make -C build-static DESTDIR="${pkgdir}" install
  make -C build-shared DESTDIR="${pkgdir}" install
  install -Dm 644 LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  rm -r "${pkgdir}/usr/share/doc"
}

package_jasper-doc-git() {
  pkgdesc+=' (documentation)'
  arch=('any')
  optdepends=('jasper-git')
  provides=("${pkgname%-git}=${pkgver}")
  conflicts=("${pkgname%-git}")

  cd "${pkgbase%-git}"
  make -C build-shared DESTDIR="${pkgdir}" install
  install -Dm 644 LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  rm -rf "${pkgdir}/usr/"{bin,include,lib,share/man}
}