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

_pkgname=libjxl
pkgname=$_pkgname-metrics-git
pkgver=0.11.1.r190.0c1aba1d
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
  jpegli
)
conflicts=(
  $_pkgname
  butteraugli
  ssimulacra
  ssimulacra2
  jpegli
)
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
  git+https://github.com/libjpeg-turbo/libjpeg-turbo.git
)
sha256sums=(
  SKIP
  SKIP
  SKIP
  SKIP
)

prepare() {
  git -C $_pkgname submodule init third_party/{skcms,sjpeg,libjpeg-turbo}
  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 config submodule.third_party/libjpeg-turbo.url "$srcdir/libjpeg-turbo"
  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.%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_PLUGINS=OFF \
    -DJPEGXL_FORCE_SYSTEM_BROTLI=ON \
    -DJPEGXL_FORCE_SYSTEM_HWY=ON
  make -C build
}

package() {
  DESTDIR="$pkgdir" make -C build install
  install -Dm644 $_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"
}