aboutsummaryrefslogtreecommitdiffstats
path: root/main/clang/APKBUILD
blob: d37d981851d1b13138b1f5f783decce320a03ed7 (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Contributor Eric Molitor <eric@molitor.org>
# Contributor Travis Tilley <ttilley@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=clang
# Note: Update together with llvm.
pkgver=10.0.0
pkgrel=2
_llvmver=${pkgver%%.*}
pkgdesc="A C language family front-end for LLVM"
arch="all"
url="https://llvm.org/"
license="Apache-2.0"
options="!check" # some 170 failing tests...
makedepends="
	cmake
	isl-dev
	libedit-dev
	libexecinfo-dev
	libxml2-dev
	libxml2-utils
	llvm$_llvmver-dev
	llvm$_llvmver-static
	llvm$_llvmver-test-utils
	samurai
	python3
	py3-sphinx
	"
checkdepends="diffutils bash"
depends_dev="$pkgname=$pkgver-r$pkgrel $pkgname-extra-tools=$pkgver-r$pkgrel"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc $pkgname-libs
	$pkgname-analyzer::noarch
	$pkgname-extra-tools:extra"
source="https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver/clang-$pkgver.src.tar.xz
	https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver/clang-tools-extra-$pkgver.src.tar.xz
	10-add-musl-triples.patch
	20-Enable-stack-protector-by-default-for-Alpine-Linux.patch
	30-fix-python-shebangs.patch
	40-fix-ld-name-on-x86.patch
	"

builddir="$srcdir/clang-$pkgver.src"

prepare() {
	mv "$srcdir/clang-tools-extra-$pkgver.src" "$builddir/tools/extra"
	default_prepare
}

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

	cmake .. -G Ninja -Wno-dev \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_C_FLAGS_MINSIZEREL_INIT="$CFLAGS" \
		-DCMAKE_CXX_FLAGS_MINSIZEREL_INIT="$CXXFLAGS" \
		-DCMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT="$LDFLAGS -Wl,-z,stack-size=2097152" \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_VERBOSE_MAKEFILE=OFF \
		-DCLANG_VENDOR=Alpine \
		-DCLANG_BUILD_EXAMPLES=OFF \
		-DCLANG_INCLUDE_DOCS=ON \
		-DLLVM_BUILD_DOCS=ON \
		-DLLVM_ENABLE_SPHINX=ON \
		-DSPHINX_WARNINGS_AS_ERRORS=OFF \
		-DCLANG_INCLUDE_TESTS=ON \
		-DCLANG_PLUGIN_SUPPORT=ON \
		-DLIBCLANG_BUILD_STATIC=ON \
		-DLLVM_ENABLE_EH=ON \
		-DLLVM_ENABLE_RTTI=ON

	ninja clang-tblgen
	ninja
}

check() {
	cd "$builddir"/build

	case "$CARCH" in
	armhf) return;; # FIXME: tests fails on armhf
	esac
	lit -sv --param clang_site_config=$builddir/build/test/lib.site.cfg $builddir/build/test
}

package() {
	cd "$builddir"/build

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

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

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

dev() {
	default_dev

	# move back usr/lib/clang/x.y.z/include with files such as altivec.h, msa.h etc
	# these are needed to build programs *with* clang, not *against* it.
	mv "$subpkgdir"/usr/lib/clang "$pkgdir"/usr/lib/
}

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/
}

extra() {
	pkgdesc="Extra tools built using Clang’s tooling APIs"

	cd "$pkgdir"

	mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/usr/share/clang

	mv usr/bin/clang-apply-replacements "$subpkgdir"/usr/bin/
	mv usr/bin/clang-reorder-fields "$subpkgdir"/usr/bin/
	mv usr/bin/modularize "$subpkgdir"/usr/bin/
	mv usr/bin/clang-tidy "$subpkgdir"/usr/bin/
	mv usr/share/clang/*clang-tidy* "$subpkgdir"/usr/share/clang
	mv usr/bin/clang-change-namespace "$subpkgdir"/usr/bin/
	mv usr/bin/clang-doc "$subpkgdir"/usr/bin/
	mv usr/bin/clang-include-fixer "$subpkgdir"/usr/bin/
	#mv usr/bin/clang-move "$subpkgdir"/usr/bin/
	mv usr/bin/find-all-symbols "$subpkgdir"/usr/bin/
	mv usr/share/clang/clang-include-fixer* "$subpkgdir"/usr/share/clang
	mv usr/share/clang/run-find-all-symbols.py "$subpkgdir"/usr/share/clang
	mv usr/bin/clang-query "$subpkgdir"/usr/bin/
	mv usr/bin/clangd* "$subpkgdir"/usr/bin/
	#mv usr/bin/pp-trace "$subpkgdir"/usr/bin/
	#mv usr/bin/tool-template "$subpkgdir"/usr/bin/
}

sha512sums="b1cccc13c46abcda3d689f51d486fa613ecec40c581c72d8b15951715100a2b8fb24370161601e6716cdba5a784337439e99ec2f0766f988e9cce92de6d775da  clang-10.0.0.src.tar.xz
33b6019e64e9ac94bd7c000b77a4a927602a2705baa9b370e392a56b53fe09c8dad1ff7d583892729e9eb291440433ad7d71df768a96d927e4dbc1988fc01d99  clang-tools-extra-10.0.0.src.tar.xz
533558863dc7247202b2a739e1bd2d81a99a16be329370cb734d338284b5408ecd14fe78ac836aaf922e377334b7a3ebef532cf8395d91aafe346bf71eb8b7fc  10-add-musl-triples.patch
a8557c5a26774bf98548b9fe77cd54a1b0591bc75beffcb5fbd070986ba954d82255dddbcfcc884c07c3f433b1428c2a6ce649c3a158f4352f30e7057872335b  20-Enable-stack-protector-by-default-for-Alpine-Linux.patch
c7f34b425b0dcea9752eeb7ff3d3a33af9cc45740fd3e77d52e4d610c5fd3daaa4d59138a255b057ef886915615a77ec1e6a447f3818b4b2724129c0ba354932  30-fix-python-shebangs.patch
c945455cd02345ba84343fc69c82a684566fa7a38d59806035b5f07dce0a4b1892b428283005883f1c202ea87d75de60066497c127ab9292c060700e8f8081d7  40-fix-ld-name-on-x86.patch"