musl upgraded to release 1.2.1
[dragora.git] / recipes / libs / musl / recipe
blob1c25d88a3c594d671c7cc880c231d35d583a8b80
1 # Build recipe for musl.
3 # Copyright (c) 2015-2020 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.2.1
19 release=1
21 # Define a category for the output of the package name
22 pkgcategory=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     ./configure CFLAGS="$QICFLAGS" \
72      $configure_args \
73      --libdir=/usr/lib${libSuffix} \
74      --syslibdir=/lib \
75      --enable-shared \
76      --enable-static \
77      --enable-optimize
79     make -j${jobs}
80     make -j${jobs} install DESTDIR="$destdir"
82     # Provide minimal libssp_nonshared.a
84     cc -c "${worktree}/archive/gcc/__stack_chk_fail_local.c" \
85        -o __stack_chk_fail_local.o
86     ar rc libssp_nonshared.a __stack_chk_fail_local.o
87     ranlib libssp_nonshared.a
88     cp -p libssp_nonshared.a "${destdir}/usr/lib${libSuffix}"
89     strip -g "${destdir}/usr/lib${libSuffix}/libssp_nonshared.a"
91     # To print shared library dependencies
92     mkdir -p "${destdir}/usr/bin"
93     ln -sf /usr/lib${libSuffix}/libc.so "${destdir}/usr/bin/ldd"
95     # Create dynamic linker runtime file taking -$(ARCH) as reference
96     for file in "${destdir}"/lib/ld-musl-*.so.1
97     do
98         ld_path="${file##*/}"                   # Basename
99         ld_path="${ld_path%%.so.1}.path"        # Get the rid of .so.1
100         export ld_path
101         break;
102     done
103     unset file
105     if test -n "$ld_path"
106     then
107         mkdir -p "${destdir}/etc"
108         cat << EOF > "${destdir}"/etc/$ld_path
109 /lib
110 /usr/local/lib
111 /usr/lib
112 /usr/$(gcc -dumpmachine)/lib
113 /opt/trinity/lib
114 /opt/trinity/lib/tqt3/lib
116         chmod 644 "${destdir}"/etc/$ld_path
117         touch "${destdir}/etc/.graft-config"
118     else
119         echo "WARNING: \$ld_path is empty." 1>&2
120     fi
121     unset ld_path
123     mkdir -p "${destdir}"/usr/sbin
124     cat << EOF > "${destdir}"/usr/sbin/ldconfig
125 #! /bin/true -
127     chmod 755 "${destdir}"/usr/sbin/ldconfig
129     # Copy documentation
130     mkdir -p "${destdir}${docsdir}"
131     cp -p $docs "${destdir}${docsdir}"