summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 3e5acd82575bc49618e896e224e8f8d43656787f (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
# Contributor: Marcell Meszaros < marcell.meszaros AT runbox.eu >
# Contributor: aksr <aksr at t-com dot me>
# Contributor: Lucky <archlinux@builds.lucky.li>
## Based on libtorrent [community]

pkgname='libtorrent-git'
_pkgbase="${pkgname%-git}"
pkgver=0.13.8.r20.g53596afc
pkgrel=3
pkgdesc='BitTorrent library with a focus on high performance and good code'
arch=('x86_64' 'i686')
url='https://github.com/rakshasa/libtorrent'
license=('GPL2')
depends=(
  'gcc-libs'
  'openssl'
  'zlib'
)
makedepends=(
  'cppunit'
  'git'
)
provides=("${_pkgbase}=${pkgver%.r*}")
conflicts=("${_pkgbase}")
source=("${pkgname}::git+${url}.git")
b2sums=('SKIP')

pkgver() {
  cd "${pkgname}"

  # Generate git tag based version. Count only proper v#.#* [#=number] tags.
  local _gitversion=$(git describe --long --tags --match 'v[0-9][0-9.][0-9.]*' | sed -e 's|^v||' | tr '[:upper:]' '[:lower:]') 

  # Format git-based version for pkgver
  echo "${_gitversion}" | sed \
    -e 's|^\([0-9][0-9.]*\)-\([a-zA-Z]\+\)|\1\2|' \
    -e 's|\([0-9]\+-g\)|r\1|' \
    -e 's|-|.|g'
}

prepare() {
  cd "${pkgname}"

  echo "Editing 'test/configure.ac': removing hardcoded 'cppunit' path (main configure script finds it via pkg-config)"
  sed '/AM_PATH_CPPUNIT/d' -i 'test/configure.ac'

  echo "Editing 'configure.ac': don't force-link 'cppunit' dependency to runtime libraries, needed only in 'make test'"
  sed -E 's/[    ]*\$CPPUNIT_CFLAGS[    ]*/ /g
          s/[    ]*\$CPPUNIT_LIBS[    ]*/ /g' \
          -i 'configure.ac'
  echo

  echo "Regenerating autoconf scripts and make files..."
  autoreconf --verbose --force --install --symlink
  echo

  printf 'Checking if debug is enabled in makepkg config... '
  if ! check_option "debug" "y"; then
    echo 'no'
  else
    echo 'yes'

    echo '-- Enabling debug options for build'
    export _extra_configure_options=('--enable-debug' '--enable-extra-debug')
  fi

  echo "Configuring the env vars for the build"
  echo '-- Adding CPPFLAGS to CXXFLAGS, otherwise the build scripts ignore it'
  echo '-- Adding LDFLAGS to CXXFLAGS, otherwise the build scripts ignore it'
  export CXXFLAGS+=" ${CPPFLAGS} ${LDFLAGS}"
  echo

  echo "Running 'configure' script..."
  ./configure "${_extra_configure_options[@]}" \
    --prefix='/usr' \
    --disable-silent-rules
}

build() {
  cd "${pkgname}"
  make
}

check() {
  cd "${pkgname}"
  make check
}

package() {
  cd "${pkgname}"
  make DESTDIR="${pkgdir}" install
}