aboutsummaryrefslogtreecommitdiffstats
path: root/main/llvm/APKBUILD
blob: 98788c41be32a8e764fa4eb47b136a2daf9cb8bb (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
116
117
118
119
120
121
122
# Contributor: William Pitcock <nenolod@dereferenced.org>
# Maintainer: William Pitcock <nenolod@dereferenced.org>
pkgname=llvm
pkgver=3.4.2
pkgrel=0
pkgdesc="low level virtual machine compiler system"
arch="x86 x86_64 armhf"
url="http://llvm.org/"
license="UOI-NCSA"
depends=
depends_dev="perl"
makedepends="$depends_dev groff libffi-dev python chrpath"
install=
subpackages="clang $pkgname-dev $pkgname-doc $pkgname-libs"
source="http://llvm.org/releases/$pkgver/llvm-$pkgver.src.tar.gz
	http://llvm.org/releases/$pkgver/cfe-$pkgver.src.tar.gz
	llvm-alpine-linux.patch
	llvm-musl.patch
	"
# clang hardcodes linker paths; and don't know of a fix like the --with-dynamic-linker
# patch we use for gcc. So llvm-3.2-alpine-linux.patch needs to be updated if/when the
# uClibc ABI version (as of uClibc 0.9.33.2, this is 0.9.32) increases.

_builddir="$srcdir"/build
_srcdir="$srcdir"/"$pkgname-$pkgver.src"

prepare() {
	msg "Preparing CLANG sources..."
	mv "$srcdir"/cfe-$pkgver.src \
		"$srcdir"/$pkgname-$pkgver.src/tools/clang || return 1

	msg "Patching LLVM core..."
	cd "$srcdir"/$pkgname-$pkgver.src || return 1
	update_config_sub || return 1
	for i in $source; do
		case $i in
		*.patch)
			msg "Applying $i..."
			patch -s -p1 -N -i "$srcdir"/$i || return 1
			;;
		esac
	done
	# fails to link
	rm ./unittests/Support/formatted_raw_ostream_test.cpp
}

build() {
	mkdir "$_builddir"
	cd "$_builddir"

	export CBUILD
	sed -i -e '/case "\${UNAME_MACHINE}:\${UNAME_SYSTEM}:\${UNAME_RELEASE}:\${UNAME_VERSION}" in/i \' \
	        -e 'if [ x != "x$CBUILD" ]; then echo "$CBUILD"; exit; fi' \
		../$pkgname-$pkgver.src/autoconf/config.guess \
		../$pkgname-$pkgver.src/projects/sample/autoconf/config.guess \
		|| return 1

	$_srcdir/configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--enable-ffi \
		--enable-shared \
		--enable-optimized \
		|| return 1

	# configure gets it wrong. We do have error_t
	sed -i -e 's/.*undef HAVE_ERROR_T.*/#define HAVE_ERROR_T 1/'  \
		-e '/define error_t/d' \
		./include/llvm/Config/config.h || return 1

	make || return 1
}

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

	#relocate docs
	mkdir -p "$pkgdir"/usr/share/doc
	mv "$pkgdir"/usr/docs/llvm "$pkgdir"/usr/share/doc/ || return 1
	rmdir "$pkgdir"/usr/docs || return 1
	chrpath -d "$pkgdir"/usr/bin/* "$pkgdir"/usr/lib/*.so
}

clang() {
	pkgdesc="A C language family front-end for LLVM"
	mkdir -p "$subpkgdir"/usr/bin \
		"$subpkgdir"/usr/lib "$subpkgdir"/usr/share/clang
	mv "$pkgdir"/usr/bin/clang* "$pkgdir"/usr/bin/c-index-test \
		"$subpkgdir"/usr/bin/ || return 1
	mv "$pkgdir"/usr/lib/clang \
		"$pkgdir"/usr/lib/libclang.so \
		"$subpkgdir"/usr/lib/ || return 1
	cp -r "$_srcdir"/tools/clang/tools/scan-build "$subpkgdir"/usr/share/clang/scan-build
	cp -r "$_srcdir"/tools/clang/tools/scan-view "$subpkgdir"/usr/share/clang/scan-view

	ln -s /usr/share/clang/scan-build/scan-build "$subpkgdir"/usr/bin/scan-build
	ln -s /usr/share/clang/scan-view/scan-view "$subpkgdir"/usr/bin/scan-view
}

libs() {
	pkgdesc="LLVM shared libraries"
	mkdir -p "$subpkgdir"/usr/lib/
	mv "$pkgdir"/usr/lib/*.so "$subpkgdir"/usr/lib/
}

md5sums="a20669f75967440de949ac3b1bad439c  llvm-3.4.2.src.tar.gz
87945973b7c73038871c5f849a818588  cfe-3.4.2.src.tar.gz
524a204746c423bae0b041e4b409a687  llvm-alpine-linux.patch
69892689105e1698988b5be3a763b511  llvm-musl.patch"
sha256sums="17038d47069ad0700c063caed76f0c7259628b0e79651ce2b540d506f2f1efd7  llvm-3.4.2.src.tar.gz
5ba6f5772f8d00f445209356a7daf83c5bca2da5acd10de517ad2359ae95bc10  cfe-3.4.2.src.tar.gz
c741573b6495d307085cf06bfc7d315bd3d6ef92fbb01e4c09cd5f1d84840a6a  llvm-alpine-linux.patch
69bf4a102d50e31853371883da1062560bdf7894bdb289c0a9522a214e0473c8  llvm-musl.patch"
sha512sums="6c1453f7d9d9110257db3574cc4f6227fed8938705cbb09851ac09a868089b48f1556a1b6e758aff6d97520b08b5605d3ed20411ad9dd22cdc573d62176905f0  llvm-3.4.2.src.tar.gz
e01fa8e312e9b3b7b3cb572ac21349161aaa50078ecfe7bded273b75db4a0c44acde524f8fdfcbeec54c61eeeb8339e9917d1f205a8fda18e34fe7ccbe89c36d  cfe-3.4.2.src.tar.gz
fc566961272054e7415d0215712fd6d986341850d9281ccbcfc861c320bac6d9f3bac90571f2b72e940be4f843ad6e9133446d9fce0770514ccf39ad923bc0c8  llvm-alpine-linux.patch
3049ad58c65791549cc696edc5920a1a2fabf87808c92a4c3fc5b70ee88745df63e2f0fd38be50e9df2055d05d922d2ccb3fe2542e9f31b4133c47c2f2b0fa93  llvm-musl.patch"