summaryrefslogtreecommitdiff
path: root/libre-multilib/lib32-clang/PKGBUILD
blob: ae840cf9e4567466bb3660eeeb397374779c60a7 (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
110
111
112
113
114
115
# Maintainer (Arch): PitBall
# Maintainer: André Silva <emulatorman@parabola.nu>

pkgname=lib32-clang
pkgver=3.4.2
_base_ver=3.4
pkgrel=1
arch=('x86_64')
url="http://llvm.org/"
license=('custom:University of Illinois/NCSA Open Source License')
makedepends=('lib32-libffi' 'lib32-zlib' 'python2' 'gcc-multilib' 'clang' 'lib32-llvm' 'bc')
source=(http://llvm.org/releases/$pkgver/llvm-$pkgver.src.tar.gz{,.sig}
        http://llvm.org/releases/$pkgver/cfe-$pkgver.src.tar.gz{,.sig}
        http://llvm.org/releases/$_base_ver/compiler-rt-$_base_ver.src.tar.gz{,.sig}
        clang-3.4-fstack-protector-strong.patch)
sha256sums=('17038d47069ad0700c063caed76f0c7259628b0e79651ce2b540d506f2f1efd7'
            'SKIP'
            '5ba6f5772f8d00f445209356a7daf83c5bca2da5acd10de517ad2359ae95bc10'
            'SKIP'
            'f37c89b1383ce462d47537a0245ac798600887a9be9f63073e16b79ed536ab5c'
            'SKIP'
            '7a2a1ddc94f67e643c1ab74601ec07deb6d5d344d4b19ed17c900afb2f6f2863')
options=('staticlibs')

prepare() {
  # Change directory names to release names so we don't need to change the
  # whole PKGBUILD
  mv llvm-$pkgver{.src,}
  mv cfe-$pkgver.src clang-$pkgver

  cd "$srcdir/llvm-$pkgver"

  rm -rf projects/compiler-rt
  mv "$srcdir/clang-$pkgver" tools/clang


  rm -rf projects/compiler-rt
  mv "$srcdir/compiler-rt-$_base_ver" projects/compiler-rt

  # Fix installation directories, ./configure doesn't seem to set them right
  sed -i -e 's:\$(PROJ_prefix)/lib:$(PROJ_prefix)/lib32:' \
         -e 's:\$(PROJ_prefix)/docs/llvm:$(PROJ_prefix)/share/doc/llvm:' \
    Makefile.config.in
  sed -i '/ActiveLibDir = ActivePrefix/s:lib:lib32:' \
    tools/llvm-config/llvm-config.cpp
  sed -i 's:LLVM_LIBDIR="${prefix}/lib":LLVM_LIBDIR="${prefix}/lib32":' \
    autoconf/configure.ac \
    configure

  # Fix insecure rpath (http://bugs.archlinux.org/task/14017)
  sed -i 's:$(RPATH) -Wl,$(\(ToolDir\|LibDir\|ExmplDir\))::g' Makefile.rules

  # Use system lib32-llvm
  install -d $srcdir/llvm-$pkgver/Release/lib
  for file in ` pacman -Ql lib32-llvm |grep /lib32/ |awk '{print $2}' |sed '/\/$/d'`; do
  ln -sf $file $srcdir/llvm-$pkgver/Release/lib/
  done

  # Add command line option -fstack-protector-strong
  # http://reviews.llvm.org/rL201120
  patch -d tools/clang -Np0 -i "$srcdir/clang-3.4-fstack-protector-strong.patch"
}

build() {
  cd "$srcdir/llvm-$pkgver"
  export CC="gcc -m32"
  export CXX="g++ -m32"
  export CLANG="clang -m32"
  export PKG_CONFIG_PATH="/usr/lib32/pkgconfig"
  export LLVM_CONFIG=/usr/bin/llvm-config32

  # Include location of libffi headers in CPPFLAGS
  CPPFLAGS+=" $(pkg-config --cflags libffi)"

  ./configure \
    --prefix=/usr \
    --libdir=/usr/lib32 \
    --sysconfdir=/etc \
    --enable-shared \
    --enable-libffi \
    --enable-targets=x86 \
    --enable-experimental-targets=R600 \
    --enable-bindings=none \
    --disable-expensive-checks \
    --disable-debug-runtime \
    --disable-assertions \
    --with-binutils-include=/usr/include \
    --with-python=/usr/bin/python2 \
    --host=i686-pc-linux-gnu \
    --target=i686-pc-linux-gnu \
    --enable-optimized

#    --disable-clang-static-analyzer \

#  make
  make -C projects/compiler-rt clang_linux
  make -C tools/clang/utils/TableGen
  make -C tools/clang/lib
}

package_lib32-clang() {
  pkgdesc="C language family frontend for LLVM (32-bit)"
  url="http://clang.llvm.org/"
  depends=('clang' 'lib32-llvm' 'gcc-multilib')

  install -d $pkgdir/usr/lib32/clang/$pkgver
  ln -s lib32 $pkgdir/usr/lib

  cd "$srcdir/llvm-$pkgver/tools/clang"
  make -C lib DESTDIR="$pkgdir" install
  # Fix permissions of static libs
  chmod -x "$pkgdir"/usr/lib32/*.a
  mv $pkgdir/usr/lib32/clang{,/$pkgver}/include
  rm -rf $pkgdir/usr/lib
}