aboutsummaryrefslogtreecommitdiffstats
path: root/main/llvm/APKBUILD
blob: b90fe36d4ebf94f0e1dc3a2a2d9405f857b0e2a2 (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.1
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="b90697f4de35563ad6c35924defa8dd1  llvm-3.4.1.src.tar.gz
c64fdc567383211c9ac212d6f7b69263  cfe-3.4.1.src.tar.gz
524a204746c423bae0b041e4b409a687  llvm-alpine-linux.patch
69892689105e1698988b5be3a763b511  llvm-musl.patch"
sha256sums="7d28bb6eca243a2bb6d65a05743ab915b57958a7770277364e93534b63eef93a  llvm-3.4.1.src.tar.gz
ab83f30951b34d75729026e0e73c180a728a140f2a02cbb8915805051a9d6bb7  cfe-3.4.1.src.tar.gz
c741573b6495d307085cf06bfc7d315bd3d6ef92fbb01e4c09cd5f1d84840a6a  llvm-alpine-linux.patch
69bf4a102d50e31853371883da1062560bdf7894bdb289c0a9522a214e0473c8  llvm-musl.patch"
sha512sums="a8d19f8560604cd1a62b9868aca8848c0675895c5354dfcbc81ef940d4a38f56f8239a49aec853dd7d432134fa0b5feb9b070579226400874b761dcf124f7a7b  llvm-3.4.1.src.tar.gz
3886d2e362aab52f29520150a81271ee24433118e0519dd5d1c58cfacc3b1c7da4cbab49c7e82d6b4a90c278b5028f5aa1f5d79478b13d0b11a15c491a6c00d5  cfe-3.4.1.src.tar.gz
fc566961272054e7415d0215712fd6d986341850d9281ccbcfc861c320bac6d9f3bac90571f2b72e940be4f843ad6e9133446d9fce0770514ccf39ad923bc0c8  llvm-alpine-linux.patch
3049ad58c65791549cc696edc5920a1a2fabf87808c92a4c3fc5b70ee88745df63e2f0fd38be50e9df2055d05d922d2ccb3fe2542e9f31b4133c47c2f2b0fa93  llvm-musl.patch"