summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: b1c962d228ad8c47964636337ed3381d6499a661 (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
pkgname=remill-git
pkgver=20171206_ac62ffc
pkgrel=1
arch=('x86_64')

pkgdesc="Library for lifting of x86, amd64, and aarch64 machine code to LLVM bitcode"
url="https://github.com/trailofbits/remill"
license=('Apache')

depends=('clang39' 'llvm39' 'llvm39-libs')
makedepends=('git' 'curl' 'patchelf' 'cmake')

provides=('remill')
conflicts=('remill')

source=("${pkgname}::git+https://github.com/trailofbits/remill.git#branch=alessandro/feature/archlinux-package")
sha1sums=('SKIP')

pkgver() {
  cd "${srcdir}/${pkgname}"
  git log -1 --date=format:%Y%m%d --pretty=format:%ad_%h
}

build() {
  local clang_version=`clang --version | head -n 1 | awk '{ print $3 }' | tr -d '.' | cut -c -2`
  local cxxcommon_tarball_name="libraries-llvm${clang_version}-ubuntu1604-amd64.tar.gz"
  local cxxcommon_tarball_url="https://s3.amazonaws.com/cxx-common/${cxxcommon_tarball_name}"

  if [ ! -f "${cxxcommon_tarball_name}" ] ; then
    echo "Dowloading: ${cxxcommon_tarball_url}"
    curl "${cxxcommon_tarball_url}" -O
  fi

  if [ ! -d "libraries" ] ; then
    tar xzf "${cxxcommon_tarball_name}"

    # use the system llvm/clang packages
    rm -rf "libraries/llvm"
    sed -i '/llvm/d' "libraries/cmake_modules/repository.cmake"
  fi

  export CXX=clang++
  export CC=clang
  export TRAILOFBITS_LIBRARIES="$(realpath libraries)"

  if [ -d build ] ; then
    rm -rf build
  fi

  mkdir build
  cd build

  cmake -DCMAKE_C_COMPILER="${CC}" -DCMAKE_CXX_COMPILER="${CXX}" -DCMAKE_INSTALL_PREFIX="/usr" -DCMAKE_VERBOSE_MAKEFILE=True "${srcdir}/${pkgname}"
  make -j `nproc`
}

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