musl upgraded to snapshot #ad795d5
[dragora.git] / recipes / libs / musl / recipe
blobd63f92f92fafb4395664cbb8c990a75654607372
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=ad795d56ba3fb9d69f524ee676e3b1e2355cceb7
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
29 # This is for musl snapshot versions.
31 fetch=http://git.musl-libc.org/cgit/musl/snapshot/$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     # Some tune options for 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     # To print shared library dependencies
85     mkdir -p "${destdir}/usr/bin"
86     ln -sf /usr/lib${libSuffix}/libc.so "${destdir}/usr/bin/ldd"
88     # Create dynamic linker runtime file taking -$(ARCH) as reference
89     for file in "${destdir}"/lib/ld-musl-*.so.1
90     do
91         ld_path="${file##*/}"                   # Basename
92         ld_path="${ld_path%%.so.1}.path"        # Get the rid of .so.1
93         export ld_path
94         break;
95     done
96     unset file
98     if test -n "$ld_path"
99     then
100         mkdir -p "${destdir}/etc"
101         cat << EOF > "${destdir}"/etc/$ld_path
102 /lib
103 /usr/local/lib
104 /usr/lib
105 /usr/$(cc -dumpmachine)/lib
108         chmod 644 "${destdir}"/etc/$ld_path
109         touch "${destdir}/etc/.graft-config"
110     else
111         echo "WARNING: \$ld_path is empty." 1>&2
112     fi
113     unset ld_path
115     # Copy documentation
116     mkdir -p "${destdir}${docsdir}"
117     cp -p $docs "${destdir}${docsdir}"