1 # Build recipe for musl.
3 # Copyright (c) 2015-2019 Matias Fonzo, <selk@dragora.org>.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
21 # Set 'outdir' for a nice and well-organized output directory
22 outdir="${outdir}/${arch}/libs"
24 tarname=${program}-${version}.tar.gz
27 fetch=http://www.musl-libc.org/releases/$tarname
29 # http://rsync.dragora.org/current/sources/$tarname
30 # http://mirror.cedia.org.ec/dragora/current/sources/$tarname
34 A powerful standard C/POSIX library.
36 Musl is a new standard library to power a new generation of Linux-based
37 devices. Musl is lightweight, fast, simple, free, and strives to be
38 correct in the sense of standards-conformance and safety.
41 homepage=http://www.musl-libc.org
42 license="MIT Expat variant"
44 # Source documentation
45 docs="COPYRIGHT README VERSION WHATSNEW"
46 docsdir="${docdir}/${program}"
48 # Limit package name to the program name
55 unpack "${tardir}/$tarname"
59 # Set sane permissions
60 chmod -R u+w,go-w,a+rX-s .
62 patch -Np0 -i "${worktree}/patches/musl/musl-utmp_path.diff"
64 # Do not use the compiler runtime library from the temporary system,
65 # the toolchain must be adjusted until the native GCC take place
66 if cc -print-libgcc-file-name | grep -q '^/tools'
68 patch -Np1 -i "${worktree}/patches/musl/musl-nolibcc_stage1.diff"
71 # Tune up some options to optimize i586/x86_64
72 patch -Np1 -i "${worktree}/patches/musl/musl-tune.diff"
74 ./configure $configure_args \
75 --libdir=/usr/lib${libSuffix} \
79 --enable-optimize=size
82 make -j${jobs} install DESTDIR="$destdir"
84 # Provide minimal libssp_nonshared.a
86 cc -c "${worktree}/archive/gcc/__stack_chk_fail_local.c" \
87 -o __stack_chk_fail_local.o
88 ar rc libssp_nonshared.a __stack_chk_fail_local.o
89 ranlib libssp_nonshared.a
90 cp -p libssp_nonshared.a "${destdir}/usr/lib${libSuffix}"
91 strip -g "${destdir}/usr/lib${libSuffix}/libssp_nonshared.a"
93 # To print shared library dependencies
94 mkdir -p "${destdir}/usr/bin"
95 ln -sf /usr/lib${libSuffix}/libc.so "${destdir}/usr/bin/ldd"
97 # Create dynamic linker runtime file taking -$(ARCH) as reference
98 for file in "${destdir}"/lib/ld-musl-*.so.1
100 ld_path="${file##*/}" # Basename
101 ld_path="${ld_path%%.so.1}.path" # Get the rid of .so.1
107 if test -n "$ld_path"
109 mkdir -p "${destdir}/etc"
110 cat << EOF > "${destdir}"/etc/$ld_path
114 /usr/$(cc -dumpmachine)/lib
117 chmod 644 "${destdir}"/etc/$ld_path
118 touch "${destdir}/etc/.graft-config"
120 echo "WARNING: \$ld_path is empty." 1>&2
125 mkdir -p "${destdir}${docsdir}"
126 cp -p $docs "${destdir}${docsdir}"