summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7dc91594c5655570db71a32c7e5eb0efe80ba139 (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
# Maintainer: Ben Poest <ben@poest.com>
# Contributor: Jolly_Roberts
# Contributor: dreieck
# Contributor: Cirk2

_pkgname=libcpufeatures
pkgname="${_pkgname}-git"
pkgver=0.7.0+8.r277.d20220315.188d0d3
pkgrel=2
pkgdesc="A cross-platform C library to retrieve CPU features (such as available instructions) at runtime. By google."
url="https://github.com/google/cpu_features"
arch=(
  'i686'
  'x86_64'
)
license=(Apache)
depends=(
  'glibc'
)
makedepends=(
  'cmake'
  'git'
)
provides=(
  "${_pkgname}=${pkgver}"
)
conflicts=(
  "${_pkgname}"
  'libvolk'
)
source=(
  "${_pkgname}::git+https://github.com/google/cpu_features.git#branch=main"
)
sha256sums=(
  'SKIP'
)

prepare() {
  mkdir -p "${srcdir}/build"
  cd "${srcdir}/build"

  # cmake issued in `prepare()` since it downloads stuff.
  cmake "${srcdir}/${_pkgname}" \
    -DCMAKE_INSTALL_PREFIX=/ \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_SHARED_LIBS=ON \
    -DBUILD_TESTING=OFF
}

pkgver() {
  cd "${srcdir}/${_pkgname}"
  _ver="$(git describe --tags | sed 's|^v||' | awk -F'-' '{print $1}')"
  _subver="$(git describe --tags | awk -F'-' '{print $2}')"
  _rev="$(git rev-list --count HEAD)"
  _hash="$(git rev-parse --short HEAD)"
  _date="$(git log -n 1 --no-show-signature --format=tformat:%ci | awk '{print $1}' | tr -d '-')"
  if [ -z ${_ver} ]; then
    error "Error in ${FUNCNAME[0]}: Version information could not determined."
    return 1
  fi
  printf '%s' "${_ver}+${_subver}.r${_rev}.d${_date}.${_hash}"
}

build() {
  cd "${srcdir}/build"

  make
}

package() {
  cd "${srcdir}/build"
  make DESTDIR="${pkgdir}" install
  install -Dm644 "${srcdir}/${_pkgname}/LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}