aboutsummaryrefslogtreecommitdiffstats
path: root/main/pcre2/APKBUILD
blob: 64d68fad3ec4883b1e9b5648f842e185926731c1 (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
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=pcre2
pkgver=10.38
pkgrel=1
pkgdesc="Perl-compatible regular expression library"
url="https://pcre.org/"
arch="all"
license="BSD-3-Clause"
depends_dev="libedit-dev zlib-dev"
makedepends="$depends_dev"
subpackages="$pkgname-dev $pkgname-doc $pkgname-tools
	libpcre2-16:_libpcre libpcre2-32:_libpcre"
source="https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.38/pcre2-$pkgver.tar.bz2
	fix-jit-before-10.39.patch
	"

case "$CARCH" in
	s390x) _enable_jit="";; # https://bugs.exim.org/show_bug.cgi?id=2468
	riscv*) _enable_jit="" ;;
	*) _enable_jit="--enable-jit";;
esac

build() {
	case "$CARCH" in
	mips64*) export CPPFLAGS="$CPPFLAGS -DSLJIT_IS_FPU_AVAILABLE=0";;
	mips*) export CPPFLAGS="$CPPFLAGS -DSLJIT_IS_FPU_AVAILABLE=0 -DSLJIT_MIPS_R1=1";;
	esac

	# Note: Forced -O3 is recommended (needed?) for Julia.
	./configure \
		CFLAGS="$CFLAGS -O3" \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--docdir=/usr/share/doc/$pkgname-$pkgver \
		--htmldir=/usr/share/doc/$pkgname-$pkgver/html \
		--enable-pcre2-16 \
		--enable-pcre2-32 \
		--enable-pcre2grep-libz \
		--enable-pcre2test-libedit \
		--with-match-limit-depth=8192 \
		$_enable_jit
	make
}

# Note: RunTest and pcre2_jit_test generates some binaries in .libs that needs
# to disable MPROTECT on grsecurity kernel. That's why it's so complicated...
check() {
	./RunTest

	if [ -n "$_enable_jit" ]; then
		./pcre2_jit_test
	fi
}

package() {
	make DESTDIR="$pkgdir" install
}

_libpcre() {
	local bits="${subpkgname##*-}"
	pkgdesc="PCRE2 with $bits bit character support"

	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/libpcre2-$bits.so* "$subpkgdir"/usr/lib/
}

tools() {
	pkgdesc="Auxiliary utilities for PCRE2"

	mkdir -p "$subpkgdir"/usr/
	mv "$pkgdir"/usr/bin "$subpkgdir"/usr/
}

sha512sums="
3634cb2db6ccba9720c1b69890bcd9eb7057f6a6cb6981f12b3f2d6b2bb4e75e4e5014f566045f9ba1b79edf01fa5c4d81eb333727b9462e843dfb70f3a58f95  pcre2-10.38.tar.bz2
9962fca55e7f2be66212d89708750f2f1a07e97facb0964e43c94adc6405b723c33c175c3405f4be28e88fe0485b73e6b6d2d264cd9f0255c301c3324eacd2f2  fix-jit-before-10.39.patch
"