aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl/APKBUILD
blob: 6d3817af11b556e47842a52c11e783062bd464ce (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
150
151
152
153
154
155
# Contributor: William Pitcock <nenolod@dereferenced.org>
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=musl
pkgver=1.0.0
pkgrel=11
pkgdesc="the musl c library (libc) implementation"
url="http://www.musl-libc.org/"
arch="all"
license="MIT"
depends=""
depends_dev="!uclibc-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-v1.0.0-to-2b74315d.patch
	0002-2b74315d-to-b9b2db2f.patch
	0003-b9b2db2f-to-e94d0692.patch
	0004-e94d0692-to-83c98aac.patch

	1001-add-basic-dns-record-parsing-functions.patch
	1002-reimplement-if_nameindex-and-getifaddrs-using-netlin.patch

	getopt_long.c
	__stack_chk_fail_local.c
	getconf.c
	getent.c
	"

_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

	# getconf/getent
	${CROSS_COMPILE}gcc $CPPFLAGS $CFLAGS "$srcdir"/getconf.c -o getconf || return 1
	${CROSS_COMPILE}gcc $CPPFLAGS $CFLAGS "$srcdir"/getent.c -o getent || 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() {
	replaces="uclibc-utils"
	mkdir -p "$subpkgdir"/usr/bin "$subpkgdir"/sbin
	mv "$pkgdir"/usr/bin/ldd "$subpkgdir"/usr/bin
	find "$pkgdir" -type d -delete 2>/dev/null
	install -D "$_builddir"/getent "$subpkgdir"/usr/bin/getent
	install -D "$_builddir"/getconf "$subpkgdir"/usr/bin/getconf
	cat <<EOF > "$subpkgdir"/sbin/ldconfig
#!/bin/sh
exit 0
EOF
}

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="e54664fdf211d27737e328c4462b545e  musl-1.0.0.tar.gz
d081fc3424229c639e636be2dd00d221  0001-v1.0.0-to-2b74315d.patch
48fa02a48a33bbcb8149edf6540d02f9  0002-2b74315d-to-b9b2db2f.patch
d0a6498cede60e70c468d9a44b968abe  0003-b9b2db2f-to-e94d0692.patch
1bd1787e961189215e0a60e9ed863529  0004-e94d0692-to-83c98aac.patch
a3810683ef61ac27e2f6ec9801280c81  1001-add-basic-dns-record-parsing-functions.patch
83c3bd2a50b1de5ef948704d3f4e0583  1002-reimplement-if_nameindex-and-getifaddrs-using-netlin.patch
61c6c1e84ed1df82abbe6d75e90cf21c  getopt_long.c
0df687757221bbb0fc1aa67f1bd646f9  __stack_chk_fail_local.c
7b391300396e58fe9073866b5a80cfe8  getconf.c
2b941c4251cac44988a4abfc50e21267  getent.c"
sha256sums="1ad7f45d2972daff19c9e6a92714e6d70f4aad003cd8c3d1e6113432114c1a32  musl-1.0.0.tar.gz
aa632b635d472d5a6a49800899ce34cddc89a63a489690faa683d08622b9cd60  0001-v1.0.0-to-2b74315d.patch
edc0cebaabd16f894d91c1860bfb70d3f2d9a70cf558c5455689610374447f7d  0002-2b74315d-to-b9b2db2f.patch
8ee26d42062a4bc91a7fc95fe3f257b9ffcbef600a6344257f7681f358a4a012  0003-b9b2db2f-to-e94d0692.patch
48a906fd2390b9d9015807c2d3d200c96fa4983faf229661d7158b62ae5dcfd2  0004-e94d0692-to-83c98aac.patch
758390768b1bc4159d56908ca332b9640cd0552ed3b4b2b8d4a6d499c54c11a1  1001-add-basic-dns-record-parsing-functions.patch
1c25880095e869b827f02997e864fdf4bf157a4e923e52d97dbd05e657aedb70  1002-reimplement-if_nameindex-and-getifaddrs-using-netlin.patch
d9b644ec20bc33e81a7c52b9fcf7973d835923a69faf50f03db45534b811bd96  getopt_long.c
299a7d75a09de3e2e11e7fb4acc3182e4a14e868093d2f30938fce9bfcff13da  __stack_chk_fail_local.c
530ea449f93d53fafcb377fa0a23a7564f2961e49c07a8fdef6c960110317301  getconf.c
68373a55e89ce85c562d941ccf588337d6cc6c9c17689d695f65cd7607134bbe  getent.c"
sha512sums="c76cbfe60cbe9b1ceb1faedddf2dcce0f11c942c8f74e4f217efe63e8e1d7be70fcb6cf1182eeaee90441152c4493d678682cb247a0dbc7537d24f943a7bbdf8  musl-1.0.0.tar.gz
e04f0f9de2859d18cb13aa8bfd839cc757aa9d835f133e46b48a760c7e689a92c641abe1e84dcaab6134c22500603e66d9a880f9b80b77e36a063348f5879878  0001-v1.0.0-to-2b74315d.patch
19c09e09d61ba31caeece27ea4241be4f14f73ab958da7f37fc4f0c8391fcaa912a750a2b79c29b3fec24ad22995244c91d1f0372d9b8481c99411e2442c2d4e  0002-2b74315d-to-b9b2db2f.patch
352b7c0693ebe6093e71d4e9cb704ff569e0e0ae2dcc576d3dc4883e7dddd1ffbc09d8365cceabbeec6b974496dddb9ed7bfacaa244c92c2735caf08c843593a  0003-b9b2db2f-to-e94d0692.patch
13b22003bb8b40786e524df42ec9560d56f45265a531faf82e2285cc0c2e893937f4c32159ec75b99c7953dbeeef15b24c2e8dbe2145728e9b011ae8952a81f5  0004-e94d0692-to-83c98aac.patch
dad965258daf69371b844f76bfe5a914b0eca0ca76f3fc340b8fd7acf598b5f87bbe6d68b1f43ed0293ee0ed3bfd85d5173ccc169aa6265646248d5b8a906708  1001-add-basic-dns-record-parsing-functions.patch
72cf33738d2cf31f6ec02312bc494d754c17470b519172bb8bd7e2e29ac3b119023088a2b3fbc0dbc2fddd0078ccbae62096106cae361f8c31d6a9950043af25  1002-reimplement-if_nameindex-and-getifaddrs-using-netlin.patch
140f3f20d30bd95ebce8c41b8cc7f616c6cbedf4ea06c729c21014e74f6043796825cc40ebc5180620ea38173afdba23f09ebf6d8b11fa05440b14d23764fca9  getopt_long.c
062bb49fa54839010acd4af113e20f7263dde1c8a2ca359b5fb2661ef9ed9d84a0f7c3bc10c25dcfa10bb3c5a4874588dff636ac43d5dbb3d748d75400756d0b  __stack_chk_fail_local.c
d638cdd02371351190fd0545fb83f44b822fa8c930e9fb47ef93d32a1aaee27641f875e10fa2e9833f1a56dfc2055fb89932a89c88da3e2eb17529bca58f5182  getconf.c
b35de9847353b273516162ed4828a810c6130fc5b7de44ee4433003b3f99647b25792d9b1c40dfc67069add11f3fb850e5c35d4f1912dccac108059bbbdfd5a2  getent.c"