summaryrefslogtreecommitdiff
path: root/user/clang/APKBUILD
blob: e5ed50d060f51f8f60fdbb2971b679a18104df8d (plain) (blame)
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
# Contributor Travis Tilley <ttilley@gmail.com>
# Maintainer: A. Wilcox <awilfox@adelielinux.org>
pkgname=clang
# Note: Update together with llvm.
pkgver=8.0.0
pkgrel=0
_llvmver=${pkgver%%.*}
pkgdesc="A C language family front-end for LLVM"
arch="all"
options="!dbg"
url="https://llvm.org/"
license="NCSA"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="cmake isl-dev libedit-dev libexecinfo-dev libxml2-dev libxml2-utils
	llvm-dev>=$_llvmver llvm-static>=$_llvmver llvm-test-utils>=$_llvmver
	z3 z3-dev"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc $pkgname-libs
	$pkgname-analyzer::noarch"
source="https://llvm.org/releases/$pkgver/cfe-$pkgver.src.tar.xz
	0001-Add-support-for-Ad-lie-Linux.patch
	0008-Fix-ClangConfig-cmake-LLVM-path.patch
	cfe-005-ppc64-dynamic-linker-path.patch
	pmmx-musl.patch
	ppc64-elfv2.patch
	secure-plt.patch
	use-llvm-lit.patch
	"
builddir="$srcdir/cfe-$pkgver.src"

build() {
	mkdir -p "$builddir"/build
	cd "$builddir"/build

	CMAKE_PREFIX_PATH=/usr/lib/llvm$_llvmver/lib/cmake \
	cmake .. -Wno-dev \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_VERBOSE_MAKEFILE=OFF \
		-DCLANG_VENDOR=${DISTRO_SHORT_NAME:-Adélie} \
		-DCLANG_BUILD_EXAMPLES=OFF \
		-DCLANG_INCLUDE_DOCS=ON \
		-DCLANG_INCLUDE_TESTS=ON \
		-DCLANG_PLUGIN_SUPPORT=ON \
		-DLIBCLANG_BUILD_STATIC=ON \
		-DLLVM_ENABLE_EH=ON \
		-DLLVM_ENABLE_RTTI=ON

	make clang-tblgen
	# too memory hungry
	if [ -z "$JOBS" -o $JOBS -gt 32 ]; then
		make -j32
	else
		make
	fi
}

check() {
	cd "$builddir"/build
	[ -f bin/llvm-lit ] || ln -s /usr/bin/lit bin/llvm-lit
	make check-clang
}

package() {
	local _dir _file
	cd "$builddir"/build

	make DESTDIR="$pkgdir" install
	install -m 644 lib/libclang.a "$pkgdir"/usr/lib

	# mozilla will never be happy
	mkdir -p "$pkgdir"/usr/lib/llvm$_llvmver/bin
	mkdir -p "$pkgdir"/usr/lib/llvm$_llvmver/lib
	for _dir in bin lib; do
		pushd "$pkgdir"/usr/$_dir
		for _file in *; do
			[ -f $_file ] || continue
			ln -s "../../../$_dir/$_file" \
				"$pkgdir"/usr/lib/llvm$_llvmver/$_dir/$_file
		done
		popd
	done

	# needed for at least Qt Creator
	mkdir -p "$pkgdir"/usr/include/llvm$_llvmver
	ln -s ../clang "$pkgdir"/usr/include/llvm$_llvmver/clang
	ln -s ../clang-c "$pkgdir"/usr/include/llvm$_llvmver/clang-c
}

static() {
	pkgdesc="Static libraries for clang"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/*.a "$subpkgdir"/usr/lib/
	strip -d "$subpkgdir"/usr/lib/*.a
}

analyzer() {
	pkgdesc="Clang source code analysis framework"
	depends="$pkgname=$pkgver-r$pkgrel perl python3"

	cd "$pkgdir"

	mkdir -p "$subpkgdir"/usr/bin \
		"$subpkgdir"/usr/libexec \
		"$subpkgdir"/usr/share/
	mv usr/bin/scan-* "$subpkgdir"/usr/bin/
	mv usr/libexec/*-analyzer "$subpkgdir"/usr/libexec/
	mv usr/share/scan-* "$subpkgdir"/usr/share/
}

sha512sums="98e540222719716985e5d8439116e47469cb01201ea91d1da7e46cb6633da099688d9352c3b65e5c5f660cbbae353b3d79bb803fc66b3be663f2b04b1feed1c3  cfe-8.0.0.src.tar.xz
c3218a1622f53bb6bef65f844e32e1b048a1ed7d5aa444a7592f9b8e8543d41438a0ac032674adb2c1bf0ef8c6fbd6880c34f8c8e778a8fd31bb542968a3547e  0001-Add-support-for-Ad-lie-Linux.patch
9485fe4fd6182df543735ed8f4ce618693d0faeafa86d3f9574a6c7abf50978e2d56e0a94be3ed94d515cc937c388d66ceff1bbc9bb120d371b6d3e95340da00  0008-Fix-ClangConfig-cmake-LLVM-path.patch
e24b0eb5f0f2b58f8d18d7d191dccc76510a179738db1f42624bd68c6de92ea57d323e28f9ee1e4df59e44a2c00a23527ba21c1c1fce9ac5858db9b3049914f2  cfe-005-ppc64-dynamic-linker-path.patch
1a76a74c193ea59b0114b116c5a9a7807b40a449e9c601263379fd7252867adb8ea8d4720f9fc8d801748176976d968990be29323bff9d5f3a03c4cfe80c61c4  pmmx-musl.patch
26b6cb952a77e15f113c88f2417e510ddd496f5c3c3de2e51c1a7cf14a78d0b25cd881f40c5c7e95dde3b2b63bbd3d485544097eed8673669a755b456a1dcd71  ppc64-elfv2.patch
9dad6dfb0097f79939b743dbe7ed20274c463d9c41f061a957841c60070247a4760b676465652e2e844fc75aab9a5b7f9f4dd7632f2ff5dd5b0a335fcbd29312  secure-plt.patch
8a596e7369b5791e7e9c3278320aa5bac30d91f27d9a0df335ea862c359623869353d12145c3b64730f721600522f3acc5abe706428091482e0209e4ff308175  use-llvm-lit.patch"