aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl/APKBUILD
blob: d2324c9c3d782a5ec4b9821d8e89f22cca31f26a (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
156
157
158
159
# Contributor: William Pitcock <nenolod@dereferenced.org>
# Maintainer: Timo Teräs <timo.teras@iki.fi>
pkgname=musl
pkgver=1.1.13
pkgrel=2
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"
subpackages="$pkgname-dev $pkgname-utils $pkgname-dbg libc6-compat:compat"
source="http://www.musl-libc.org/releases/musl-$pkgver.tar.gz
	0001-fix-assumption-in-fputs-that-fwrite-returning-0-impl.patch
	0002-fix-unlikely-corner-cases-in-getopt-s-message-printi.patch
	0003-in-crypt-sha-reject-excessive-rounds-as-error-rather.patch

	ldconfig
	__stack_chk_fail_local.c
	getconf.c
	getent.c
	iconv.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
}

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" ;;
	mips*) ARCH="mips" ;;
	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/iconv
	local i
	for i in getconf getent iconv ; do
		${CROSS_COMPILE}gcc $CPPFLAGS $CFLAGS "$srcdir"/$i.c -o $i || return 1
	done

	# 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

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

	# make LDSO the be the real file, and libc the symlink
	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

	# remove libintl.h, currently we don't want by default any NLS
	# and use GNU gettext where needed. the plan is to migrate to
	# musl gettext() later on as fully as possible.
	rm "$pkgdir"/usr/include/libintl.h || return 1
}

utils() {
	depends="!uclibc-utils scanelf"
	replaces="libiconv uclibc-utils"
	license="MIT BSD GPL2+"

	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 \
		"$_builddir"/getconf \
		"$_builddir"/iconv \
		"$subpkgdir"/usr/bin

	install -D -m755 "$srcdir"/ldconfig "$subpkgdir"/sbin
}

compat() {
	pkgdesc="compatibility libraries for glibc"

	case "$CARCH" in
	arm*) _ld="ld-linux-armhf.so.3" ;;
	x86) _ld="ld-linux.so.2" ;;
	x86_64) _ld="ld-linux-x86-64.so.2" ;;
	mips*) _ld="ld.so.1" ;;
	esac

	mkdir -p "$subpkgdir"/lib
	ln -sf "/lib/libc.musl-${CARCH}.so.1" "$subpkgdir/lib/$_ld"

	for i in libc.so.6 libm.so.6 libpthread.so.0 librt.so.1 libutil.so.1; do
		ln -sf "/lib/libc.musl-${CARCH}.so.1" "$subpkgdir/lib/$i"
	done
}

md5sums="b8cb33a04ab461b55edcc807abf82241  musl-1.1.13.tar.gz
b05c1a3f3b773610fdfe1fe44f41c5f8  0001-fix-assumption-in-fputs-that-fwrite-returning-0-impl.patch
5b1ab9ab71069b9daafaf7a62ee3cf8e  0002-fix-unlikely-corner-cases-in-getopt-s-message-printi.patch
bf74e577da2993ccf468787910a3d4d3  0003-in-crypt-sha-reject-excessive-rounds-as-error-rather.patch
830d01f7821b978df770b06db3790921  ldconfig
0df687757221bbb0fc1aa67f1bd646f9  __stack_chk_fail_local.c
57ef2c63b9ec6a2041694ace97d4ffa2  getconf.c
2b941c4251cac44988a4abfc50e21267  getent.c
45f92f8d59cf84d765de698a9578dbf4  iconv.c"
sha256sums="bbacdc64f557d0c4857f7d2daf592c32c29aec1babbb94fcf01a2e05bed15013  musl-1.1.13.tar.gz
f32bfc319bb2e4dd6e20ab81dd838af991c6696dbd70db93926e8e3e446caf50  0001-fix-assumption-in-fputs-that-fwrite-returning-0-impl.patch
e21ad9f7e9ff9089d3be03281366dd01a7487b21fb00dd7b7556f46e84f2e282  0002-fix-unlikely-corner-cases-in-getopt-s-message-printi.patch
4542c63178f1f8d42d54a3e81a3db1978103d76f0d3ffb42b133bfe4b02f5de4  0003-in-crypt-sha-reject-excessive-rounds-as-error-rather.patch
b4a2c06db38742e8c42c3c9838b285a7d8cdac6c091ff3df5ff9a15f1e41b9c7  ldconfig
299a7d75a09de3e2e11e7fb4acc3182e4a14e868093d2f30938fce9bfcff13da  __stack_chk_fail_local.c
d87d0cbb3690ae2c5d8cc218349fd8278b93855dd625deaf7ae50e320aad247c  getconf.c
68373a55e89ce85c562d941ccf588337d6cc6c9c17689d695f65cd7607134bbe  getent.c
f79a2930a2e5bb0624321589edf8b889d1e9b603e01e6b7ae214616605b3fdd7  iconv.c"
sha512sums="d5f4a6fdb6a2cdbd7ab1ad5a8d91b1c690b3bd31d9049dfc022067019bba11952e375374eed982a0ddac7347d17f9ff2300178c4d5f27bdd8480933cc6e67802  musl-1.1.13.tar.gz
c634947ddf6d0b2e462cacff3920326a5677c06a3fc58f40cf99f22496b33882d25b4dce041a368fa2961d23bccbf9145a571fd40ea0d390cea1ab2849e681d7  0001-fix-assumption-in-fputs-that-fwrite-returning-0-impl.patch
2a9b55bedfd13bb6f1ad6a10344294d672eaafbc4402c0f18cc31a9b5a62879a606e7fe4733c09295159a7458502886ed4d0c71170e66dca9a1bd228dbb08123  0002-fix-unlikely-corner-cases-in-getopt-s-message-printi.patch
0a1715fb46204a13d9a29dfa9d86d3335890e75990d0d76c06daccb059f31498858b106966063e4b01c101f67ed139d8a24915d1ebeafec2491213d3e6bfdac9  0003-in-crypt-sha-reject-excessive-rounds-as-error-rather.patch
8d3a2d5315fc56fee7da9abb8b89bb38c6046c33d154c10d168fb35bfde6b0cf9f13042a3bceee34daf091bc409d699223735dcf19f382eeee1f6be34154f26f  ldconfig
062bb49fa54839010acd4af113e20f7263dde1c8a2ca359b5fb2661ef9ed9d84a0f7c3bc10c25dcfa10bb3c5a4874588dff636ac43d5dbb3d748d75400756d0b  __stack_chk_fail_local.c
0d80f37b34a35e3d14b012257c50862dfeb9d2c81139ea2dfa101d981d093b009b9fa450ba27a708ac59377a48626971dfc58e20a3799084a65777a0c32cbc7d  getconf.c
b35de9847353b273516162ed4828a810c6130fc5b7de44ee4433003b3f99647b25792d9b1c40dfc67069add11f3fb850e5c35d4f1912dccac108059bbbdfd5a2  getent.c
9d42d66fb1facce2b85dad919be5be819ee290bd26ca2db00982b2f8e055a0196290a008711cbe2b18ec9eee8d2270e3b3a4692c5a1b807013baa5c2b70a2bbf  iconv.c"