devicepkg-dev: implement out-of-tree build for kernel (!1084)

This commit is contained in:
Dolphin von Chips 2020-03-08 20:58:05 +05:00 committed by Oliver Smith
parent 8af4d8c27a
commit a4b1fb8371
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
3 changed files with 24 additions and 23 deletions

View file

@ -3,6 +3,7 @@
# 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() {
# shellcheck disable=SC2154
_gcch="$builddir/include/linux/compiler-gcc.h"
if [ -f "$_gcch" ]; then
if [ "$REPLACE_GCCH" = "0" ]; then
@ -21,23 +22,19 @@ install_gcc_h() {
cp -v "/usr/share/devicepkg-dev/compiler-gcc.h" "$_gcch"
}
# Parse arguments
srcdir=$1
builddir=$2
_config=$3
_carch=$4
HOSTCC=$5
if [ -z "$srcdir" ] || [ -z "$builddir" ] || [ -z "$_config" ] ||
[ -z "$_carch" ]; then
echo "ERROR: missing argument!"
echo "Please call downstreamkernel_prepare() with \$srcdir, \$builddir,"
echo "\$_config, \$_carch (and optionally \$HOSTCC) as arguments."
if [ "$#" -ne 0 ]; then
echo "ERROR: downstreamkernel_prepare should be sourced in APKBUILDs."
echo "Related: https://postmarketos.org/downstreamkernel-prepare"
exit 1
fi
# Only override HOSTCC if set (to force use of an old gcc)
[ -z "$HOSTCC" ] || HOSTCC="HOSTCC=$HOSTCC"
# Set _outdir to "." if not set
if [ -z "$_outdir" ]; then
_outdir="."
fi
# Set _hostcc when HOSTCC is set
[ -z "$HOSTCC" ] || _hostcc="HOSTCC=$HOSTCC"
# Support newer GCC versions
install_gcc_h
@ -52,6 +49,9 @@ for i in $makefiles; do
done
# Prepare kernel config ('yes ""' for kernels lacking olddefconfig)
cp "$srcdir/$_config" "$builddir"/.config
# shellcheck disable=SC2086
yes "" | make -C "$builddir" ARCH="$_carch" $HOSTCC oldconfig
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