1
0
Fork 0
mirror of https://github.com/pygos/build.git synced 2024-11-22 11:09:46 +01:00
build/pkg/musl/build
David Oberhollenzer 21342dee8e Cleanup: move path filtering into pkg_scan_dir
Instead of prefixing the search path with $PKGDEPLOYDIR and then
stripping the prefix off again every single time, do that inside
the pkg_scan_dir function.

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2020-04-16 15:16:58 +02:00

85 lines
2.1 KiB
Text
Executable file

VERSION="1.2.0"
SRCDIR="musl-$VERSION"
TARBALL="$SRCDIR.tar.gz"
URL="https://www.musl-libc.org/releases"
SHA256SUM="c6de7b191139142d3f9a7b5b702c9cae1b5ee6e7f57e582da9328629408fd4e8"
DEPENDS="tc-gcc1 linux-dev fortify-headers tc-pkgtool"
SUBPKG="libc libc-dev"
build() {
local cflags="-O2 -Os"
local ldflags=""
if [ "x$TC_HARDENING" = "xyes" ]; then
cflags="$cflags -fPIE -fPIC -fstack-protector-all"
ldflags="$ldflags -z noexecstack -z relro -z now"
fi
${TARGET}-gcc -c "$SCRIPTDIR/pkg/$PKGNAME/__stack_chk_fail_local.c" -o __stack_chk_fail_local.o
${TARGET}-ar r libssp_nonshared.a __stack_chk_fail_local.o
CFLAGS="$cflags" LDFLAGS="$ldflags" \
CROSS_COMPILE="${TARGET}-" $1/configure --prefix=/ --target="$TARGET"
CROSS_COMPILE="${TARGET}-" make -j $NUMJOBS
}
deploy() {
local INPUT="$1"
local MUSL_CPU=""
case "$TARGET" in
i*86-*)
MUSL_CPU="i386"
;;
x86_64-*)
MUSL_CPU="x86_64"
;;
arm-*-*hf)
MUSL_CPU="armhf"
;;
arm-*)
MUSL_CPU="arm"
;;
*)
echo "don't know how to map $TARGET to Musl arch"
exit 1
;;
esac
DESTDIR="$PKGDEPLOYDIR" make install-headers
DESTDIR="$PKGDEPLOYDIR" make install-libs
cp "$SCRIPTDIR/pkg/$PKGNAME/sys-cdefs.h" \
"$PKGDEPLOYDIR/include/sys/cdefs.h"
cp "$SCRIPTDIR/pkg/$PKGNAME/sys-queue.h" \
"$PKGDEPLOYDIR/include/sys/queue.h"
cp "$SCRIPTDIR/pkg/$PKGNAME/sys-tree.h" \
"$PKGDEPLOYDIR/include/sys/tree.h"
cat_file_merge "LDPATH" > "$PKGDEPLOYDIR/LDPATH"
cp libssp_nonshared.a "$PKGDEPLOYDIR/lib"
cp "$SCRIPTDIR/pkg/$PKGNAME/libc-dev.files" "$PKGDEPLOYDIR"
pkg_scan_dir "include" >> "$PKGDEPLOYDIR/libc-dev.files"
if [ "x$TC_HARDENING" = "xyes" ]; then
echo "requires libc linux-dev fortify-headers" > \
"$PKGDEPLOYDIR/libc-dev.desc"
else
echo "requires libc linux-dev" > "$PKGDEPLOYDIR/libc-dev.desc"
fi
touch "$PKGDEPLOYDIR/libc.desc"
cat > "$PKGDEPLOYDIR/libc.files" <<_EOF
dir lib 0755 0 0
dir etc 0755 0 0
file lib/libc.so 0755 0 0 $PKGDEPLOYDIR/lib/libc.so
slink lib/ld-musl-${MUSL_CPU}.so.1 0777 0 0 libc.so
file etc/ld-musl-${MUSL_CPU}.path 0644 0 0 $PKGDEPLOYDIR/LDPATH
_EOF
}
check_update() {
check_update_simple "$URL" "musl" "tar.gz"
}