Browse Source

Support cross compiling

Donald Carr 7 years ago
parent
commit
15d22ce3a6
2 changed files with 51 additions and 10 deletions
  1. 39 10
      PKGBUILD
  2. 12 0
      build_outside_makepkg

+ 39 - 10
PKGBUILD

@@ -6,16 +6,20 @@ pkgname=linux-spudd
 provides=("linux-spudd")
 # The firmware the kernel produces blows: don't falsify this lightly
 # "linux-firmware=20170309.695f2d6-1"
-#conflicts=("linux-firmware")
+conflicts=("linux")
 pkgrel=1
-pkgver=4.16.rc6.r91.ge07907ece302
+pkgver=4.16.rc7.r220.gd095ee200d45
 pkgdesc="Kernel build from head"
-arch=("x86_64")
+arch=("x86_64" "aarch64")
 license=("GPL2.1")
-install=spudd.install
-_xcompile_args="ARCH=arm64 CROSS_COMPILE=/opt/aarch64-rpi3-linux-gnueabi/bin/aarch64-rpi3-linux-gnueabi-"
 _kernel_src_dir=/opt/dev/src/OSS/linux
 
+if [ -z "${LOCAL_PI_VER}" ]; then
+    install=spudd.install
+fi
+
+_make_cmd="make ${_xcompile_args}"
+
 pkgver() {
   cd $_kernel_src_dir
   git describe --tags | cut -c2- | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
@@ -23,7 +27,7 @@ pkgver() {
 
 build() {
   cd $_kernel_src_dir && git clean -xdf
-  make
+  ${_make_cmd}
 }
 
 package() {
@@ -33,14 +37,39 @@ package() {
   preset_dir=${pkgdir}/etc/mkinitcpio.d
 
   cd $_kernel_src_dir
-  INSTALL_MOD_PATH=${usr_dir} make modules_install
+  INSTALL_MOD_PATH=${usr_dir} ${_make_cmd} modules_install
   mkdir -p ${boot_dir}
-  mkdir -p ${preset_dir}
-  cp arch/x86/boot/bzImage ${boot_dir}/vmlinuz-spudd
-  cp ${startdir}/spudd.preset ${preset_dir}
+
+  if [ "${LOCAL_PI_VER}" = "3" ]; then
+    cp arch/arm64/boot/Image ${boot_dir}
+  else
+    cp arch/x86/boot/bzImage ${boot_dir}/vmlinuz-spudd
+
+    mkdir -p ${preset_dir}
+    cp ${startdir}/spudd.preset ${preset_dir}
+  fi
 
   rm -Rf ${startdir}/firmware
   if [[ -d ${firmware_dir} ]]; then
     mv ${firmware_dir} ${startdir}
   fi
 }
+
+if [ -n "${LOCAL_PI_VER}" ]; then
+    case ${LOCAL_PI_VER} in
+    3)
+        echo "Compiling for the RPi 3 aarch64"
+        cp ${_kernel_src_dir}/configs/rpi3 ${_kernel_src_dir}/.config
+        _xcompile_args="ARCH=arm64 CROSS_COMPILE=/opt/x-tools/aarch64-rpi3-linux-gnu/bin/aarch64-rpi3-linux-gnu-"
+    ;;
+    *)
+        echo "Only supports the rpi3 at this point in time"
+        exit 1
+    ;;
+    esac
+else
+    echo "Compiling for desktop"
+    cp ${_kernel_src_dir}/configs/desktop ${_kernel_src_dir}/.config
+fi
+
+_make_cmd="make ${_xcompile_args}"

+ 12 - 0
build_outside_makepkg

@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+SCRIPT_DIR=$(dirname $(readlink -f ${BASH_SOURCE[0]}))
+ROOT_DIR=$(cd $SCRIPT_DIR/.. && pwd)
+
+cd ${SCRIPT_DIR}
+. PKGBUILD
+
+build
+
+cd ${SCRIPT_DIR}
+makepkg -R CARCH=aarch64