aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl/APKBUILD
blob: 2e014840bdbce3a446ba86562c6ffe2941f07f2d (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
146
147
148
149
# Contributor: William Pitcock <nenolod@dereferenced.org>
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=musl
pkgver=0.9.14
pkgrel=4
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
	0001-add-missing-i386-syscall-numbers.patch
	0002-fix-buffer-overflow-in-mbsrtowcs.patch
	0003-fix-off-by-one-error-in-getgrnam_r-and-getgrgid_r-cl.patch
	0004-fix-new-environment-always-being-null-with-execle.patch
	0005-fix-clockid-macro-names-in-time.h-reported-by-Paul-S.patch

	add-rfc3678-mcast-structs.patch
	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="bfb685695aa942e64c63170589e575b2  musl-0.9.14.tar.gz
f116cf69bcbcb7080ef3aa521acce8b8  0001-add-missing-i386-syscall-numbers.patch
bfefbd099f555fe8fd22e7ffc3accbef  0002-fix-buffer-overflow-in-mbsrtowcs.patch
5d722e38a7ca2032c9f202db8ff7e369  0003-fix-off-by-one-error-in-getgrnam_r-and-getgrgid_r-cl.patch
216d6915ea8397102c22a7aeaafdd98f  0004-fix-new-environment-always-being-null-with-execle.patch
aa4c3ccf3e074fcac609420573ce466a  0005-fix-clockid-macro-names-in-time.h-reported-by-Paul-S.patch
b28080b5c8c1d44521277aa3255d280a  add-rfc3678-mcast-structs.patch
7a09c5cd7b3e9532e6902f54a5e928bb  workaround-gcc-pr58245.patch
61c6c1e84ed1df82abbe6d75e90cf21c  getopt_long.c
0df687757221bbb0fc1aa67f1bd646f9  __stack_chk_fail_local.c
ef81489a6258501cf45db58dfc6d5211  getent
33e4fd94e2560e008e2c3b431d0e3419  ldconfig"
sha256sums="982e9de1287cf95f9aa526adba008660d8885bfccc41faf5c613ea47f1922872  musl-0.9.14.tar.gz
84886493008bdca79ad223708e5568baeb948a520499b9f4eea2f1526aefb304  0001-add-missing-i386-syscall-numbers.patch
a6cb8b279e5b737d43c2de1bd6229f5e6599e9514bcb41ddaa411cd44dc65ba7  0002-fix-buffer-overflow-in-mbsrtowcs.patch
b6b161383b287505eecb53595039b8fe26c622508e783c86ee82d38c1ea582f4  0003-fix-off-by-one-error-in-getgrnam_r-and-getgrgid_r-cl.patch
2e9f262bf9c117f1ca59afd9615daa6f8d71aaddb719f5259218b088244622fb  0004-fix-new-environment-always-being-null-with-execle.patch
f2fd3b921bd57190d0bf19c4a4beb5f808a5d19c71092e2962a3e7b1ca08c67e  0005-fix-clockid-macro-names-in-time.h-reported-by-Paul-S.patch
720cb88dd1ef57fc806a22b46b3c47d7a0a38a34d31edb583e97bfa7a47eb44c  add-rfc3678-mcast-structs.patch
45d6efda7450809e4e68f6e951431dcadf6cb7f0260930d50a9f1a8667aca49f  workaround-gcc-pr58245.patch
d9b644ec20bc33e81a7c52b9fcf7973d835923a69faf50f03db45534b811bd96  getopt_long.c
299a7d75a09de3e2e11e7fb4acc3182e4a14e868093d2f30938fce9bfcff13da  __stack_chk_fail_local.c
d6996273f5aaaed429058257e4646b243d9e3a4d8609522f802762453f5be4cb  getent
306c6ca7407560340797866e077e053627ad409277d1b9da58106fce4cf717cb  ldconfig"
sha512sums="e5c3f7b1549dc2f9cbd3359cc413f761d5967607c23705f651c33d0ae93f00582193a41fe1f87158467d58d8eba2d7c09e0fe2f2b2c02c1dda78eee1a4cecff6  musl-0.9.14.tar.gz
e6cdb6b4c87e2488d31ac46898010dc9d41f31f2ed9c6f2f8a763b76e63587a37a54a7557cd7db1c524b1fcbd17e5418ec1058b30dc17cc91c3fb3ac7cd47fc8  0001-add-missing-i386-syscall-numbers.patch
bb1a0025675fc0241a0ae15e04e12cfbb3c12604ccdb8ac9a2a192d76d346c2804d051f6698a636671d9b4154132b1fe4270bc464bdd370a9b2070c4573361e0  0002-fix-buffer-overflow-in-mbsrtowcs.patch
60fd9640ea6a8c46e8724ec80d228bcabb9ae3f0f366d2a21c7e15da4a31395aa6dfadeb480f22c720cbd773b73b245174adc3031ee04e69efecf4c45af8538f  0003-fix-off-by-one-error-in-getgrnam_r-and-getgrgid_r-cl.patch
f37b4bb6e15c0fa02cb7643a3f291158901a13f5c39651d3feda371f9de9a05ce82ce7e81a45440422a4bf9198cd2baa1cb8fbebe267b6726e8d293aa5b836d3  0004-fix-new-environment-always-being-null-with-execle.patch
f3f2f0cad04b58891e42d0846d929c05d793c1c7ab61aa0ac1377f38c1291bce45e39a7acdc62749804859a5de1b20f9ec0839c58a7015cb12c0b7c85c7a6194  0005-fix-clockid-macro-names-in-time.h-reported-by-Paul-S.patch
d63d3ea0c59dbff0cb24cc30ba0b013a33e81bc91de5f6c8b0082fa3e261b0c0dac3f2dc30c3b0370f7d1c4536e2042cd85ecb8e0357a805bd93855e42396d92  add-rfc3678-mcast-structs.patch
69ad3fc851b44f33dd7c98b83fd0adbd149b37263d17b989f4d7338ee0703dfe8994f4299744e2509492300227d652de6f21b6cdba9b633fcefd3d9f7ca0cf20  workaround-gcc-pr58245.patch
140f3f20d30bd95ebce8c41b8cc7f616c6cbedf4ea06c729c21014e74f6043796825cc40ebc5180620ea38173afdba23f09ebf6d8b11fa05440b14d23764fca9  getopt_long.c
062bb49fa54839010acd4af113e20f7263dde1c8a2ca359b5fb2661ef9ed9d84a0f7c3bc10c25dcfa10bb3c5a4874588dff636ac43d5dbb3d748d75400756d0b  __stack_chk_fail_local.c
4d92f934d760cf5157d80f19fd766be6b673c65317229b32ac824d9d192f6abcc414e2382b2416dfd5c2f757b46ced98c18e4762bf91f5a48647e0ee61813b06  getent
69f097faa9ccb981e78c3a914ad68a51771637d9aecd2dbc807003ac30663e6d921091a48ff529dfff27a6cd55b0808f91683118acf7acdf406d37266e622b17  ldconfig"