summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5fd0c4fc36716420297869b8648409d745f875e7 (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
112
113
114
115
116
117
118
119
120
121
# Maintainer: Damian Höster <damian dot hoester at posteo dot de>

_pkgname=libjxl
pkgname=${_pkgname}-metrics
pkgver=0.11.1
pkgrel=1
pkgdesc='JPEG XL image format reference implementation with butteraugli, ssimulacra, and ssimulacra2 metrics'
arch=(x86_64)
url=https://jpeg.org/jpegxl/
license=(BSD)
depends=(
  brotli
  highway
  gtest
  libpng
  lcms2
  gperftools
)
makedepends=(
  git
  cmake
  clang
  lld
  giflib
  openexr
  libjpeg-turbo
  python
  asciidoc
  gflags
  zlib
)
provides=(
  libjxl
  libjxl.so=0.11
  libjxl_threads.so=0.11
  butteraugli
  ssimulacra
  ssimulacra2
)
conflicts=(
  libjxl
  butteraugli
  ssimulacra
  ssimulacra2
)
optdepends=(
  'gdk-pixbuf2: for gdk-pixbuf loader'
  'gimp: for building gimp jxl plugin'
  'java-environment: for building FNI Java wrapper'
  'libjxl-doc: for documentation'
)
source=(
  $_pkgname::git+https://github.com/libjxl/libjxl.git#tag=v${pkgver}
  brotli::git+https://github.com/google/brotli.git
  Little-CMS::git+https://github.com/mm2/Little-CMS.git
  googletest::git+https://github.com/google/googletest.git
  sjpeg::git+https://github.com/webmproject/sjpeg.git
  skcms::git+https://skia.googlesource.com/skcms.git
  highway::git+https://github.com/google/highway.git
  libpng::git+https://github.com/glennrp/libpng.git
  zlib::git+https://github.com/madler/zlib.git
  gflags::git+https://github.com/gflags/gflags.git
  libjxl-testdata::git+https://github.com/libjxl/testdata.git
)
sha256sums=(
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
  SKIP
)

prepare() {
  git -C libjxl submodule init
  git -C libjxl config --local submodule.third_party/brotli.url "${srcdir}/brotli"
  git -C libjxl config --local submodule.third_party/lcms.url "${srcdir}/Little-CMS"
  git -C libjxl config --local submodule.third_party/googletest.url "${srcdir}/googletest"
  git -C libjxl config --local submodule.third_party/sjpeg.url "${srcdir}/sjpeg"
  git -C libjxl config --local submodule.third_party/skcms.url "${srcdir}/skcms"
  git -C libjxl config --local submodule.third_party/highway.url "${srcdir}/highway"
  git -C libjxl config --local submodule.third_party/libpng.url "${srcdir}/libpng"
  git -C libjxl config --local submodule.third_party/zlib.url "${srcdir}/zlib"
  git -C libjxl config --local submodule.third_party/gflags.url "${srcdir}/gflags"
  git -C libjxl config --local submodule.third_party/testdata.url "${srcdir}/libjxl-testdata"
  git -C libjxl -c protocol.file.allow=always submodule update
}

build() {
  # Using clang and lld as suggested by the repo
  cmake -S $_pkgname -B build \
    -DBUILD_TESTING=0 \
    -DJPEGXL_ENABLE_DEVTOOLS=ON \
    -DJPEGXL_ENABLE_EXAMPLES=OFF \
    -DJPEGXL_ENABLE_PLUGINS=ON \
    -DJPEGXL_ENABLE_FUZZERS=OFF \
    -DJPEGXL_ENABLE_DOXYGEN=OFF \
    -DJPEGXL_FORCE_SYSTEM_BROTLI=TRUE \
    -DJPEGXL_FORCE_SYSTEM_LCMS2=TRUE \
    -DJPEGXL_FORCE_SYSTEM_GTEST=TRUE \
    -DJPEGXL_FORCE_SYSTEM_HWY=TRUE \
    -DCMAKE_C_COMPILER=clang \
    -DCMAKE_C_FLAGS="$CFLAGS -flto=thin" \
    -DCMAKE_CXX_COMPILER=clang++ \
    -DCMAKE_CXX_FLAGS="$CXXFLAGS -flto=thin" \
    -DCMAKE_EXE_LINKER_FLAGS="$LDFLAGS -fuse-ld=lld -Wl,--thinlto-jobs=all" \
    -DCMAKE_INSTALL_PREFIX=/usr
  make -C build "$MAKEFLAGS"
}

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"
}