musl upgraded to release 1.1.24
[dragora.git] / recipes / libs / musl / recipe
blob195e6e672d22c6a7dbdd7c6fbbecf8a446fe75e2
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.
17 program=musl
18 version=1.1.24
19 release=1
21 # Set 'outdir' for a nice and well-organized output directory
22 outdir="${outdir}/${arch}/libs"
24 tarname=${program}-${version}.tar.gz
26 # Remote source(s)
27 fetch=http://www.musl-libc.org/releases/$tarname
28 #fetch="
29 #  http://rsync.dragora.org/current/sources/$tarname
30 #  http://mirror.cedia.org.ec/dragora/current/sources/$tarname
33 description="
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
49 full_pkgname=$program
51 build()
53     set -e
55     unpack "${tardir}/$tarname"
57     cd "$srcdir"
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'
67     then
68         patch -Np1 -i "${worktree}/patches/musl/musl-nolibcc_stage1.diff"
69     fi
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} \
76      --syslibdir=/lib \
77      --enable-shared \
78      --enable-static \
79      --enable-optimize=size
81     make -j${jobs}
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
99     do
100         ld_path="${file##*/}"                   # Basename
101         ld_path="${ld_path%%.so.1}.path"        # Get the rid of .so.1
102         export ld_path
103         break;
104     done
105     unset file
107     if test -n "$ld_path"
108     then
109         mkdir -p "${destdir}/etc"
110         cat << EOF > "${destdir}"/etc/$ld_path
111 /lib
112 /usr/local/lib
113 /usr/lib
114 /usr/$(cc -dumpmachine)/lib
117         chmod 644 "${destdir}"/etc/$ld_path
118         touch "${destdir}/etc/.graft-config"
119     else
120         echo "WARNING: \$ld_path is empty." 1>&2
121     fi
122     unset ld_path
124     # Copy documentation
125     mkdir -p "${destdir}${docsdir}"
126     cp -p $docs "${destdir}${docsdir}"