summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 03003afe9e3e64ac0e72fff72e7d60dfd02e8263 (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
# Maintainer:

: ${_branch:=master}

_pkgname="hal-emsec"
pkgname="$_pkgname-git"
pkgver=4.4.1.r241.gf715873
pkgrel=1
pkgdesc='Hardware Analyzer for Hardware Reversing from emsec'
url="https://github.com/emsec/hal"
license=('MIT')
arch=('x86_64')

depends=(
  'graphviz'
  'igraph'
  'python'
  'qt5-svg'
  'quazip-qt5'
  'spdlog'
  'z3'
)
makedepends=(
  'boost'
  'cmake'
  'git'
  'ninja'
  'nlohmann-json'
  'pybind11'
  'rapidjson'
)

_source_main() {
  provides=("$_pkgname")
  conflicts=("$_pkgname")

  _pkgsrc="$_pkgname"
  source=("$_pkgsrc"::"git+$url.git#branch=${_branch:-master}")
  sha256sums=('SKIP')
}

_source_patch() {
  source+=(
    "0001-add-algorithm-header-f67c717.patch"::"https://github.com/emsec/hal/commit/f67c7170eb9f8416d0133200c22469d7a723562a.diff"
    "0002-cast-Z3_decl_kind-c3d3b81.patch"::"https://github.com/emsec/hal/commit/c3d3b814aa4c428497354dba6920ceeff7ad3516.diff"
  )
  sha256sums+=(
    '6b731f233cc2b94e0f98340ad52bf91a4c09d5cdf057d2260b9b2747da6ce30b'
    '7c53acedb6a066f0dba1db756f3c7038a35bec5f2f24ab3b788f87cd36683cf8'
  )
}

_source_main
_source_patch

pkgver() {
  cd "$_pkgsrc"
  git describe --long --tags --abbrev=7 --exclude='*[a-zA-Z][a-zA-Z]*' \
    | sed -E 's/^[^0-9]*//;s/([^-]*-g)/r\1/;s/-/./g'
}

prepare() {
  cd "$_pkgsrc"

  # igraph on Arch Linux requires build type None
  sed -E -e '/AVAILABLE_BUILD_TYPES/s&Perf&None&' -i CMakeLists.txt
  sed -E -e 's&IMPORTED_LOCATION_RELEASE&IMPORTED_LOCATION_NONE&g' -i cmake/detect_dependencies.cmake

  local src
  for src in "${source[@]}"; do
    src="${src%%::*}"
    src="${src##*/}"
    src="${src%.zst}"
    if [[ $src == *.patch ]]; then
      printf '\nApplying patch: %s\n' "$src"
      patch -Np1 -F100 -i "${srcdir:?}/$src"
    fi
  done
}

build() {
  local _cmake_options=(
    -B build
    -S "$_pkgsrc"
    -G Ninja
    -DCMAKE_BUILD_TYPE=None
    -DCMAKE_INSTALL_PREFIX='/usr'
    -DBUILD_DOCUMENTATION=OFF
    -DENABLE_INSTALL_LDCONFIG=OFF
    -DENABLE_PPA=OFF
    -DUSE_LIBCXX=OFF
    -DUSE_VENDORED_IGRAPH=OFF
    -DUSE_VENDORED_PYBIND11=OFF
    -DUSE_VENDORED_QUAZIP=OFF
    -DUSE_VENDORED_SPDLOG=OFF
    -DUSE_VENDORED_NLOHMANN_JSON=OFF
    #-DBUILD_ALL_PLUGINS=ON
    -DBUILD_TESTS=OFF
    -Wno-dev
  )

  cmake "${_cmake_options[@]}"
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build
  install -Dm644 "$_pkgsrc/LICENSE" -t "$pkgdir/usr/share/licenses/$pkgname/"
}