summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 774e8042da1acaa4828c92668555a5ee9e57d3dc (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
# Maintainer: Damian Höster <damian dot hoester at posteo dot de>

_pkgname=libjxl
pkgname=${_pkgname}-metrics-git
pkgver=0.11.1.r164.ge85462bb
pkgrel=1
pkgdesc='JPEG XL image format reference implementation with butteraugli, ssimulacra, and ssimulacra2 metrics (git version)'
arch=(x86_64)
url=https://jpeg.org/jpegxl/
license=(BSD-3-Clause)
depends=(
  brotli
  highway
  libpng
  libjpeg
  giflib
  openexr
  gperftools
)
makedepends=(
  git
  cmake
  clang
  lld
  python
  asciidoc
  gdk-pixbuf2 # for building gdk-pixbuf loader
  gimp # for building GIMP plugin
  java-environment # for building JNI bindings
)
provides=(
  $_pkgname
  libjxl.so
  libjxl_threads.so
  butteraugli
  ssimulacra
  ssimulacra2
)
conflicts=(
  $_pkgname
  butteraugli
  ssimulacra
  ssimulacra2
)
optdepends=(
  'libjxl-doc: for documentation'
)
options=(!lto) # Disabling pacman's LTO, as ThinLTO is enforced
source=(
  git+https://github.com/libjxl/$_pkgname.git
  git+https://skia.googlesource.com/skcms.git
  git+https://github.com/webmproject/sjpeg.git
)
sha256sums=(
  SKIP
  SKIP
  SKIP
)

prepare() {
  git -C $_pkgname submodule init third_party/{skcms,sjpeg}
  git -C $_pkgname config submodule.third_party/skcms.url "${srcdir}/skcms"
  git -C $_pkgname config submodule.third_party/sjpeg.url "${srcdir}/sjpeg"
  git -C $_pkgname -c protocol.file.allow=always submodule update
}

pkgver() {
    local _tag=$(git -C $_pkgname tag --list --sort=-v:refname 'v[[:digit:]]*' | \
                 sed 's/^v//;/[[:alpha:]]/d' | head -n1)
    printf $_tag.r%s.g%s $(git -C $_pkgname rev-list --count v$_tag..HEAD) \
                         $(git -C $_pkgname rev-parse --short HEAD)
}

build() {
  export CC=clang CXX=clang++
  export CFLAGS+=' -flto=thin' CXXFLAGS+=' -flto=thin'
  export LDFLAGS+=' -fuse-ld=lld'
  cmake -S $_pkgname -B build \
    -DBUILD_TESTING=OFF \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DJPEGXL_ENABLE_DEVTOOLS=ON \
    -DJPEGXL_ENABLE_DOXYGEN=OFF \
    -DJPEGXL_ENABLE_EXAMPLES=OFF \
    -DJPEGXL_ENABLE_JPEGLI=OFF \
    -DJPEGXL_ENABLE_PLUGINS=ON \
    -DJPEGXL_FORCE_SYSTEM_BROTLI=ON \
    -DJPEGXL_FORCE_SYSTEM_HWY=ON
  make -C build
}

package() {
  DESTDIR="$pkgdir" make -C build install
  install -Dvm644 $_pkgname/{LICENSE,PATENTS} -t "$pkgdir/usr/share/licenses/$_pkgname/"
  ln -s /usr/bin/butteraugli_main "$pkgdir/usr/bin/butteraugli"
  ln -s /usr/bin/ssimulacra_main "$pkgdir/usr/bin/ssimulacra"
}