summaryrefslogtreecommitdiff
path: root/user/clang/APKBUILD
blob: 10253a69779564d88758a813746cbd1e6de54bb6 (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
# Contributor Travis Tilley <ttilley@gmail.com>
# Maintainer: A. Wilcox <awilfox@adelielinux.org>
pkgname=clang
# Note: Update together with llvm.
pkgver=7.0.1
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"
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
	use-llvm-lit.patch
	secure-plt.patch
	"
builddir="$srcdir/cfe-$pkgver.src"

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

	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/llvm6
	ln -s ../clang "$pkgdir"/usr/include/llvm6/clang
	ln -s ../clang-c "$pkgdir"/usr/include/llvm6/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="df2f38153ebdc261bcfa6a569567f759bbb1a803192882a9d4eca55a47878166ac9057151a94ad341dc1281136547e4faa783a68070dfde2307b48cacd4b9194  cfe-7.0.1.src.tar.xz
44aa152d50822a9e1a223b9e07e150ffa830c55deb4c4ca29e6218a0103eb263a00b41fd1ca84390e65fa08005901a0a0f88cf529bff8764220e99d06adef5fc  0001-Add-support-for-Ad-lie-Linux.patch
9485fe4fd6182df543735ed8f4ce618693d0faeafa86d3f9574a6c7abf50978e2d56e0a94be3ed94d515cc937c388d66ceff1bbc9bb120d371b6d3e95340da00  0008-Fix-ClangConfig-cmake-LLVM-path.patch
8a596e7369b5791e7e9c3278320aa5bac30d91f27d9a0df335ea862c359623869353d12145c3b64730f721600522f3acc5abe706428091482e0209e4ff308175  use-llvm-lit.patch
9dad6dfb0097f79939b743dbe7ed20274c463d9c41f061a957841c60070247a4760b676465652e2e844fc75aab9a5b7f9f4dd7632f2ff5dd5b0a335fcbd29312  secure-plt.patch"