summarylogtreecommitdiffstats
path: root/PKGBUILD.stable
blob: 6856fe57d79dbd359965a908dc2e300c827301c7 (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
depends=(
  'gtk3'
  'libao'
  'libgl'
  'libpulse'
  'libudev.so' # systemd-libs
  'openal'
  'sdl2'
)
makedepends=(
  'clang'
  'git'
  'lld'
  'mesa'
)

_pkgsrc="$_pkgname"
source=("$_pkgsrc"::"git+$url.git")
sha256sums=("SKIP")

prepare() {
  cd "$_pkgsrc"
  _tag=$(git tag | grep -Ev '[A-Za-z]{2}' | sort -rV | head -1)
  git checkout -f "$_tag"
}

pkgver() {
  cd "$_pkgsrc"
  git describe --tag | sed -E 's/^[^0-9]+//'
}

build() {
  export CC CXX CFLAGS CXXFLAGS LDFLAGS
  CC=clang
  CXX=clang++
  LDFLAGS+=" -fuse-ld=lld"

  if [[ "${_build_avx::1}" == "t" ]]; then
    CFLAGS="$(echo "$CFLAGS" | sed -E 's@(\s*-(march|mtune)=\S+\s*)@ @g;s@\s*-O[0-9]\s*@ @g;s@\s+@ @g') -march=x86-64-v3 -mtune=generic -O3"
    CXXFLAGS="$(echo "$CXXFLAGS" | sed -E 's@(\s*-(march|mtune)=\S+\s*)@ @g;s@\s*-O[0-9]\s*@ @g;s@\s+@ @g') -march=x86-64-v3 -mtune=generic -O3"
  fi

  # respect compiler flags
  find "$_pkgsrc" -name "GNUmakefile" -exec sed -E -e 's@^(\s*)\b(flags \+=) -march=.*$@\1\2 -Qunused-arguments '"${CXXFLAGS}"'@' -i {} \;

  # respect linker flags
  find "$_pkgsrc" -name "GNUmakefile" -exec sed -E -e 's&(\+@\$\(compiler\))&\1 -Qunused-arguments '"${LDFLAGS}"' &' -i {} \;

  make -C "$_pkgsrc/desktop-ui" hiro=gtk3 compiler=clang++ build=optimized
}

package() {
  depends+=(
    'librashader'
    'vulkan-driver'
    'vulkan-icd-loader'
  )

  # exec
  install -Dm755 "$_pkgsrc/desktop-ui/out/ares" -t "$pkgdir/usr/bin/"

  # icon, launcher
  install -Dm644 "$_pkgsrc/desktop-ui/resource/ares.png" -t "$pkgdir/usr/share/pixmaps/"
  install -Dm644 "$_pkgsrc/desktop-ui/resource/ares.desktop" -t "$pkgdir/usr/share/applications/"

  # shaders and databases
  install -dm755 "$pkgdir/usr/share/ares"
  cp --reflink=auto -a "$_pkgsrc/thirdparty/slang-shaders/" "$pkgdir/usr/share/ares/Shaders/"
  cp --reflink=auto -a "$_pkgsrc/mia/Database/" "$pkgdir/usr/share/ares/Database/"

  # license
  install -Dm644 "$_pkgsrc/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  # permissions
  chmod -R u+rwX,go+rX,go-w "$pkgdir/"
}