1# Copyright (C) 2014 Khem Raj <raj.khem@gmail.com>
2# Released under the MIT license (see COPYING.MIT for the terms)
3
4require musl.inc
5
6SRCREV = "55df09bfccbfe21fc9dd7d8f94550c0ff25ace04"
7
8PV = "1.1.19+git${SRCPV}"
9
10# mirror is at git://github.com/kraj/musl.git
11
12SRC_URI = "git://git.musl-libc.org/musl \
13           file://0001-Make-dynamic-linker-a-relative-symlink-to-libc.patch \
14          "
15
16S = "${WORKDIR}/git"
17
18PROVIDES += "virtual/libc virtual/${TARGET_PREFIX}libc-for-gcc virtual/libiconv virtual/libintl virtual/crypt"
19
20DEPENDS = "virtual/${TARGET_PREFIX}binutils \
21           virtual/${TARGET_PREFIX}gcc-initial \
22           libgcc-initial \
23           linux-libc-headers \
24           bsd-headers \
25          "
26
27export CROSS_COMPILE="${TARGET_PREFIX}"
28
29LDFLAGS += "-Wl,-soname,libc.so"
30
31# When compiling for Thumb or Thumb2, frame pointers _must_ be disabled since the
32# Thumb frame pointer in r7 clashes with musl's use of inline asm to make syscalls
33# (where r7 is used for the syscall NR). In most cases, frame pointers will be
34# disabled automatically due to the optimisation level, but append an explicit
35# -fomit-frame-pointer to handle cases where optimisation is set to -O0 or frame
36# pointers have been enabled by -fno-omit-frame-pointer earlier in CFLAGS, etc.
37CFLAGS_append_arm = " ${@bb.utils.contains('TUNE_CCARGS', '-mthumb', '-fomit-frame-pointer', '', d)}"
38
39CONFIGUREOPTS = " \
40    --prefix=${prefix} \
41    --exec-prefix=${exec_prefix} \
42    --bindir=${bindir} \
43    --libdir=${libdir} \
44    --includedir=${includedir} \
45    --syslibdir=${base_libdir} \
46"
47
48do_configure() {
49	${S}/configure ${CONFIGUREOPTS}
50}
51
52do_compile() {
53	oe_runmake
54}
55
56do_install() {
57	oe_runmake install DESTDIR='${D}'
58
59	install -d ${D}${bindir}
60	rm -f ${D}${bindir}/ldd
61	lnr ${D}${libdir}/libc.so ${D}${bindir}/ldd
62	for l in crypt dl m pthread resolv rt util xnet
63	do
64		ln -sf libc.so ${D}${libdir}/lib$l.so
65	done
66}
67
68RDEPENDS_${PN}-dev += "linux-libc-headers-dev bsd-headers-dev"
69RPROVIDES_${PN}-dev += "libc-dev virtual-libc-dev"
70RPROVIDES_${PN} += "ldd libsegfault rtld(GNU_HASH)"
71
72LEAD_SONAME = "libc.so"
73