recipes: Set package category for blacklisted packages
[dragora.git] / recipes / libs / musl / recipe
blob11bc90e48aeb08bf31ae9e5494da0e466c266940
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
18 set -e
20 program=musl
21 version=1.2.2
22 release=6
24 # Define a category for the output of the package name
25 pkgcategory=libs
27 tarname=${program}-${version}.tar.gz
29 # Remote source(s)
30 fetch=https://www.musl-libc.org/releases/$tarname
31 #fetch="
32 #  https://rsync.dragora.org/current/sources/$tarname
33 #  https://mirror.cedia.org.ec/dragora/current/sources/$tarname
36 description="
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}"
54 build()
56     unpack "${tardir}/$tarname"
58     cd "$srcdir"
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'
69     then
70         patch -Np1 -i "${worktree}/patches/musl/musl-nolibcc_stage1.diff"
71     fi
73     ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" \
74      $configure_args \
75      --libdir=/usr/lib${libSuffix} \
76      --syslibdir=/lib \
77      --enable-shared \
78      --enable-static \
79      --enable-optimize
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 -v file
107     if test -n "$ld_path"
108     then
109         mkdir -p "${destdir}/etc"
110         cat << EOF > "${destdir}"/etc/$ld_path
111 /lib${libSuffix}
112 /usr/local/lib${libSuffix}
113 /usr/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"
120     else
121         echo "WARNING: \$ld_path is empty." 1>&2
122     fi
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
132 then
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"
138 then
139     ( cd -- "\${rootdir}/etc" && ln -sf $ld_path ld.so.conf )
144     unset -v ld_path
146     mkdir -p "${destdir}"/usr/sbin
147     cat << EOF > "${destdir}"/usr/sbin/ldconfig
148 #! /bin/true -
150     chmod 755 "${destdir}"/usr/sbin/ldconfig
152     # Copy documentation
153     mkdir -p "${destdir}${docsdir}"
154     cp -p $docs "${destdir}${docsdir}"