summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d0dbedfaa308b78c0f4df2c62f1b1dbcd8cc324d (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
# Maintainer:
# Contributor: Vincent Bernardoff <vb AT luminar.eu.org>

_pkgname="nng"
pkgname="$_pkgname-git"
pkgver=1.10.1.r570.g5b886b5
pkgrel=1
pkgdesc="A lightweight, broker-less library"
url="https://github.com/nanomsg/nng"
license=('MIT')
arch=('x86_64')

depends=(
  'wolfssl'
)
makedepends=(
  'cmake'
  'git'
  'ninja'
)

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

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

pkgver() {
  cd "$_pkgsrc"
  local _tag _version _revision _hash
  _tag=$(git tag -l 'v[0-9]*' | grep -Ev '[A-Za-z][A-Za-z]' | sort -rV | head -1)
  _version="${_tag#v}"
  _revision=$(git rev-list --count --cherry-pick "$_tag"...HEAD)
  _commit=$(git rev-parse --short=7 HEAD)
  printf '%s.r%s.g%s' "${_version:?}" "${_revision:?}" "${_commit:?}"
}

build() {
  local _cmake_options=(
    -B build
    -S "$_pkgsrc"
    -G Ninja
    -DCMAKE_BUILD_TYPE=None
    -DCMAKE_INSTALL_PREFIX='/usr'
    -DNNG_ENABLE_TLS=ON
    -DBUILD_SHARED_LIBS=ON
    -DNNG_ENABLE_TLS=ON
    -DNNG_TLS_ENGINE=wolf
    -Wno-dev
  )

  if ((CHECKFUNC)); then
    _cmake_options+=(-DNNG_TESTS=ON)
  else
    _cmake_options+=(-DNNG_TESTS=OFF)
  fi

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

check() {
  ctest --test-dir build --output-on-failure || :
}

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