aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl/APKBUILD
blob: a5ebca83de091f31dfcb02cd9e1a819f1fdfb465 (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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Contributor: William Pitcock <nenolod@dereferenced.org>
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=musl
pkgver=0.9.15
pkgrel=2
pkgdesc="the musl c library (libc) implementation"
url="http://www.musl-libc.org/"
arch="all"
license="MIT"
depends=""
depends_dev=""
makedepends="$depends_dev"
install=""
subpackages="$pkgname-dev $pkgname-utils"
[ "${CTARGET#*musl}" = "$CTARGET" ] && subpackages="$subpackages musl-gcc:crosstool"
source="http://www.musl-libc.org/releases/musl-$pkgver.tar.gz
	1001-add-basic-dns-record-parsing-functions.patch
	1002-add-legacy-functions-setkey-and-encrypt.patch
	1003-use-anonymous-union-to-provide-bsd-and-gnu-variants-.patch
	1004-add-NO_ADDRESS-to-alias-as-NO_DATA-like-glibc-does.patch
	1005-add-TIMEVAL_TO_TIMESPEC-and-TIMESPEC_TO_TIMEVAL.patch
	2001-workaround-gcc-pr58245.patch

	getopt_long.c
	__stack_chk_fail_local.c
	getent
	ldconfig
	"

_builddir="$srcdir"/musl-$pkgver
prepare() {
	local i
	cd "$_builddir"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done

	# use GNU compatible getopt() from BSD
	rm -f src/misc/getopt*.c
	cp "$srcdir"/getopt_long.c src/misc/

	# remove libintl wrappers that we don't want
	rm src/locale/intl.c include/libintl.h
}

install_sysroot_headers() {
	cd "$_builddir"
	if [ -z "${CBUILDROOT}" ]; then
		echo "CBUILDROOT not must be set!"
		return 1
	fi
	case "$CARCH" in
	arm*) ARCH="arm" ;;
	x86) ARCH="i386" ;;
	x86_64) ARCH="x86_64" ;;
	esac
	make ARCH="$ARCH" prefix=/usr DESTDIR="${CBUILDROOT}" install-headers || return 1
}

build() {
	cd "$_builddir"

	# provide minimal libssp_nonshared.a so we don't need libssp from gcc
	${CROSS_COMPILE}gcc $CPPFLAGS $CFLAGS -c "$srcdir"/__stack_chk_fail_local.c -o __stack_chk_fail_local.o || return 1
	${CROSS_COMPILE}ar r libssp_nonshared.a __stack_chk_fail_local.o || return 1

	# note: not autotools
	LDFLAGS="$LDFLAGS -Wl,-soname,libc.musl-${CARCH}.so.1" \
	./configure \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		|| return 1
	make || return 1
}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir" install || return 1
	rm -f "$pkgdir"/usr/lib/*.la

	cp libssp_nonshared.a "$pkgdir"/usr/lib || return 1

	# make LDSO the be the real file, and libc the symlink (will be upstream change)
	local LDSO=$(make -f Makefile --eval "$(echo -e 'print-ldso:\n\t@echo $$(basename $(LDSO_PATHNAME))')" print-ldso)
	mv -f "$pkgdir"/usr/lib/libc.so "$pkgdir"/lib/"$LDSO" || return 1
	ln -sf "$LDSO" "$pkgdir"/lib/libc.musl-${CARCH}.so.1 || return 1
	ln -sf ../../lib/"$LDSO" "$pkgdir"/usr/lib/libc.so || return 1
	mkdir -p "$pkgdir"/usr/bin
	ln -sf ../../lib/"$LDSO" "$pkgdir"/usr/bin/ldd || return 1
}

utils() {
	mkdir -p "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/bin/ldd "$subpkgdir"/usr/bin
	find "$pkgdir" -type d -delete 2>/dev/null
	install -D "$srcdir"/getent "$subpkgdir"/usr/bin/getent
	install -D "$srcdir"/ldconfig "$subpkgdir"/sbin/ldconfig
}

crosstool() {
	mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/bin/musl-gcc "$subpkgdir"/usr/bin
	mv "$pkgdir"/usr/lib/musl-gcc.specs "$subpkgdir"/usr/lib
	find "$pkgdir" -type d -delete 2>/dev/null
}

md5sums="06f590a38c85722ee9343db2416425f4  musl-0.9.15.tar.gz
a3810683ef61ac27e2f6ec9801280c81  1001-add-basic-dns-record-parsing-functions.patch
ab5e596aae4a55ea3a0c17004c28c991  1002-add-legacy-functions-setkey-and-encrypt.patch
405bd5b61acc9e44c39a8badb82f15bd  1003-use-anonymous-union-to-provide-bsd-and-gnu-variants-.patch
08956121f90f9f16d0c26df767309c0b  1004-add-NO_ADDRESS-to-alias-as-NO_DATA-like-glibc-does.patch
e8b0d4ab4364a8581162d5727383f427  1005-add-TIMEVAL_TO_TIMESPEC-and-TIMESPEC_TO_TIMEVAL.patch
7a09c5cd7b3e9532e6902f54a5e928bb  2001-workaround-gcc-pr58245.patch
61c6c1e84ed1df82abbe6d75e90cf21c  getopt_long.c
0df687757221bbb0fc1aa67f1bd646f9  __stack_chk_fail_local.c
ef81489a6258501cf45db58dfc6d5211  getent
33e4fd94e2560e008e2c3b431d0e3419  ldconfig"
sha256sums="4a7baab8f295511196dee48d33b8b82a159a81233facb89433707c792033cbe7  musl-0.9.15.tar.gz
758390768b1bc4159d56908ca332b9640cd0552ed3b4b2b8d4a6d499c54c11a1  1001-add-basic-dns-record-parsing-functions.patch
45ab39525f5902d17913185817769d654611f193d81fa36bc6faed905451bdbb  1002-add-legacy-functions-setkey-and-encrypt.patch
d7e6dc31feb23b07063a62e7ad4f63216dd83ab4bdbde0e5750095c8b18d8c20  1003-use-anonymous-union-to-provide-bsd-and-gnu-variants-.patch
c3bb37b28cb8e5724ec81314a2188e774412e2caa567c1d0f499d0d2f1c74c9d  1004-add-NO_ADDRESS-to-alias-as-NO_DATA-like-glibc-does.patch
b22e83321a8f872a0000e4c63e878d460d8f278759216369d97ed943ba8eef01  1005-add-TIMEVAL_TO_TIMESPEC-and-TIMESPEC_TO_TIMEVAL.patch
45d6efda7450809e4e68f6e951431dcadf6cb7f0260930d50a9f1a8667aca49f  2001-workaround-gcc-pr58245.patch
d9b644ec20bc33e81a7c52b9fcf7973d835923a69faf50f03db45534b811bd96  getopt_long.c
299a7d75a09de3e2e11e7fb4acc3182e4a14e868093d2f30938fce9bfcff13da  __stack_chk_fail_local.c
d6996273f5aaaed429058257e4646b243d9e3a4d8609522f802762453f5be4cb  getent
306c6ca7407560340797866e077e053627ad409277d1b9da58106fce4cf717cb  ldconfig"
sha512sums="2c5f3e742cf29fd76db8079b6012b1b359eda635593995ea8add008abc9744f0ca504e915f7828692aeafc3bddc66e0716492182cd5696e2fa24d9a2289601b8  musl-0.9.15.tar.gz
dad965258daf69371b844f76bfe5a914b0eca0ca76f3fc340b8fd7acf598b5f87bbe6d68b1f43ed0293ee0ed3bfd85d5173ccc169aa6265646248d5b8a906708  1001-add-basic-dns-record-parsing-functions.patch
1b3c162985fa9b1699004007c811ca1f3ff8e144722c7d3bae7f118b8c46694888f125d00aef66eef4c836cbc2000daa0f5c7a728981eb7746c84d64b1bc3d96  1002-add-legacy-functions-setkey-and-encrypt.patch
33b3d574cd508f557d799f11d8aa884fe9404384093ea869efbe3677e642eeb761ac95ccb9125eaadf0a2b4433e8fd7aa3ea9d52e3919696c2735273e68108c4  1003-use-anonymous-union-to-provide-bsd-and-gnu-variants-.patch
b4eee38bb18883cee2c9317cc06a0fce7b805206afb3846e1dbd86be75f161f70ad5a6b4918dbbfcfdbec9300400ebd2b8e65e233a1b409898e40479d45cbb1d  1004-add-NO_ADDRESS-to-alias-as-NO_DATA-like-glibc-does.patch
3cea9ba259362455526f841b9dac79a4d50016e58581db071ba7c5fb1c176e4f994744286c3491b376ff3b5a0815f2a76d382a37474c5b09bcaa06dcf283e4d4  1005-add-TIMEVAL_TO_TIMESPEC-and-TIMESPEC_TO_TIMEVAL.patch
69ad3fc851b44f33dd7c98b83fd0adbd149b37263d17b989f4d7338ee0703dfe8994f4299744e2509492300227d652de6f21b6cdba9b633fcefd3d9f7ca0cf20  2001-workaround-gcc-pr58245.patch
140f3f20d30bd95ebce8c41b8cc7f616c6cbedf4ea06c729c21014e74f6043796825cc40ebc5180620ea38173afdba23f09ebf6d8b11fa05440b14d23764fca9  getopt_long.c
062bb49fa54839010acd4af113e20f7263dde1c8a2ca359b5fb2661ef9ed9d84a0f7c3bc10c25dcfa10bb3c5a4874588dff636ac43d5dbb3d748d75400756d0b  __stack_chk_fail_local.c
4d92f934d760cf5157d80f19fd766be6b673c65317229b32ac824d9d192f6abcc414e2382b2416dfd5c2f757b46ced98c18e4762bf91f5a48647e0ee61813b06  getent
69f097faa9ccb981e78c3a914ad68a51771637d9aecd2dbc807003ac30663e6d921091a48ff529dfff27a6cd55b0808f91683118acf7acdf406d37266e622b17  ldconfig"