2018-07-02 00:12:49 +00:00
|
|
|
#!/bin/sh
|
2019-01-29 08:35:10 +00:00
|
|
|
|
|
|
|
# Replace compiler-gcc.h with one that works with newer GCC versions.
|
|
|
|
# Set REPLACE_GCCH=0 to avoid replacing an existing compiler-gcc.h file.
|
|
|
|
install_gcc_h() {
|
2020-03-08 15:58:05 +00:00
|
|
|
# shellcheck disable=SC2154
|
2019-01-29 08:35:10 +00:00
|
|
|
_gcch="$builddir/include/linux/compiler-gcc.h"
|
|
|
|
if [ -f "$_gcch" ]; then
|
|
|
|
if [ "$REPLACE_GCCH" = "0" ]; then
|
|
|
|
echo "NOTE: *not* replacing $_gcch, because of REPLACE_GCCH=0"
|
|
|
|
return
|
|
|
|
else
|
|
|
|
echo "NOTE: replacing $_gcch! If your build breaks with 'Please"
|
|
|
|
echo "don't include <linux/compiler-gcc.h> directly' or a similar"
|
|
|
|
echo "compiler-gcc.h related error, then set"
|
|
|
|
echo " REPLACE_GCCH=0"
|
|
|
|
echo "in your kernel APKBUILD at the start of the"
|
|
|
|
echo "downstreamkernel_prepare.sh line."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
cp -v "/usr/share/devicepkg-dev/compiler-gcc.h" "$_gcch"
|
|
|
|
}
|
|
|
|
|
2020-03-08 15:58:05 +00:00
|
|
|
if [ "$#" -ne 0 ]; then
|
|
|
|
echo "ERROR: downstreamkernel_prepare should be sourced in APKBUILDs."
|
|
|
|
echo "Related: https://postmarketos.org/downstreamkernel-prepare"
|
2018-07-02 00:12:49 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-03-08 15:58:05 +00:00
|
|
|
# Set _outdir to "." if not set
|
|
|
|
if [ -z "$_outdir" ]; then
|
|
|
|
_outdir="."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Set _hostcc when HOSTCC is set
|
|
|
|
[ -z "$HOSTCC" ] || _hostcc="HOSTCC=$HOSTCC"
|
2020-02-19 23:09:46 +00:00
|
|
|
|
2019-01-29 08:35:10 +00:00
|
|
|
# Support newer GCC versions
|
|
|
|
install_gcc_h
|
2018-07-02 00:12:49 +00:00
|
|
|
|
|
|
|
# Remove -Werror from all makefiles
|
2018-10-10 14:39:15 +00:00
|
|
|
makefiles="$(find "$builddir" -type f -name Makefile)
|
2020-11-19 09:02:16 +00:00
|
|
|
$(find "$builddir" -type f -name Makefile.common)
|
2018-10-10 14:39:15 +00:00
|
|
|
$(find "$builddir" -type f -name Kbuild)"
|
2018-07-02 00:12:49 +00:00
|
|
|
for i in $makefiles; do
|
|
|
|
sed -i 's/-Werror-/-W/g' "$i"
|
2019-01-28 05:04:33 +00:00
|
|
|
sed -i 's/-Werror=/-W/g' "$i"
|
2018-07-02 00:12:49 +00:00
|
|
|
sed -i 's/-Werror//g' "$i"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Prepare kernel config ('yes ""' for kernels lacking olddefconfig)
|
2020-03-08 15:58:05 +00:00
|
|
|
mkdir -p "$builddir/$_outdir"
|
|
|
|
# shellcheck disable=SC2154
|
|
|
|
cp "$srcdir/$_config" "$builddir"/"$_outdir"/.config
|
|
|
|
# shellcheck disable=SC2086,SC2154
|
|
|
|
yes "" | make -C "$builddir" ARCH="$_carch" O="$_outdir" \
|
|
|
|
$_hostcc oldconfig
|