1 # Build recipe for musl.
3 # Copyright (c) 2015-2021 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 # Exit immediately on any error
24 # Define a category for the output of the package name
27 tarname=${program}-${version}.tar.gz
30 fetch=https://www.musl-libc.org/releases/$tarname
32 # https://rsync.dragora.org/current/sources/$tarname
33 # https://mirror.cedia.org.ec/dragora/current/sources/$tarname
37 A powerful standard C/POSIX library.
39 Musl is a new standard library to power a new generation of Linux-based
40 devices. Musl is lightweight, fast, simple, free, and strives to be
41 correct in the sense of standards-conformance and safety.
44 homepage=https://www.musl-libc.org
45 license="MIT Expat variant"
47 # Source documentation
48 docs="COPYRIGHT README VERSION WHATSNEW"
49 docsdir="${docdir}/${program}"
51 # Limit package name to the program name
52 full_pkgname="${program}@${pkgcategory}"
56 unpack "${tardir}/$tarname"
60 # Set sane permissions
61 chmod -R u+w,go-w,a+rX-s .
63 patch -Np0 -i "${worktree}/patches/musl/musl-utmp_path.diff"
64 patch -Np1 -i "${worktree}/patches/musl/branch-updates.diff"
66 # Do not use the compiler runtime library from the temporary system,
67 # the toolchain must be adjusted until the native GCC take place
68 if cc -print-libgcc-file-name | grep -q '^/tools'
70 patch -Np1 -i "${worktree}/patches/musl/musl-nolibcc_stage1.diff"
73 ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" \
75 --libdir=/usr/lib${libSuffix} \
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
112 /usr/local/lib${libSuffix}
114 /usr/$(gcc -dumpmachine)/lib
115 /opt/trinity/lib${libSuffix}
116 /opt/trinity/lib${libSuffix}/trinity
118 chmod 644 "${destdir}"/etc/$ld_path
119 touch "${destdir}/etc/.graft-config"
121 echo "WARNING: \$ld_path is empty." 1>&2
124 # Add to the post-install script a symlink for compatibility,
125 # as some 'configure' scripts still have the Glibc name "ld.so.conf".
127 mkdir -p "${destdir}/var/lib/qi"
128 cat << EOF > "${destdir}/var/lib/qi/${full_pkgname}.sh"
130 # Adjust the toolchain only once (as needed)
131 if test -x /tools/bin/adjust-toolchain
133 /tools/bin/adjust-toolchain && chmod 644 /tools/bin/adjust-toolchain
136 # A symlink for compatibility
137 if test ! -e "\${rootdir}/etc/ld.so.conf"
139 ( cd -- "\${rootdir}/etc" && ln -sf $ld_path ld.so.conf )
146 mkdir -p "${destdir}"/usr/sbin
147 cat << EOF > "${destdir}"/usr/sbin/ldconfig
150 chmod 755 "${destdir}"/usr/sbin/ldconfig
153 mkdir -p "${destdir}${docsdir}"
154 cp -p $docs "${destdir}${docsdir}"