Files
userland/buildme
Dave Stevenson 8b8f6571b6 buildme: Add option for ARM64 builds via either native or cross compile
Supports native builds on aarch64 machines.

Supports making a 64-bit build via either cross compiling, or on
aarch64 machines.
Both options require the addition of --aarch64 to the command line,
otherwise 32-bit libraries will be built.

Cross compiling requires the aarch64-linux-gnu- compile tools to
be installed (packages gcc-5-aarch64-linux-gnu and g++-aarch64-linux-gnu
on Ubuntu).
2019-03-05 10:53:04 +00:00

54 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
BUILDTYPE=Release
ARCH=`arch`
ARM64=OFF
CMAKE_TOOLCHAIN_FILE=../../../makefiles/cmake/toolchains/arm-linux-gnueabihf.cmake
if [ "$1" = "--debug" ]; then
BUILDTYPE=Debug
shift
fi
if [ "$1" = "--arm64" ]; then
ARM64=ON
CMAKE_TOOLCHAIN_FILE=../../../makefiles/cmake/toolchains/aarch64-linux-gnu.cmake
shift
fi
BUILDSUBDIR=`echo $BUILDTYPE | tr '[A-Z]' '[a-z]'`;
if [ $ARCH = "armv6l" ] || [ $ARCH = "armv7l" ] || [ $ARCH = "aarch64" ]; then
# Native compile on the Raspberry Pi
mkdir -p build/raspberry/$BUILDSUBDIR
pushd build/raspberry/$BUILDSUBDIR
cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE -DARM64=$ARM64 ../../..
if [ $ARCH = "armv6l" ]; then
make
else
make -j4
fi
if [ "$1" != "" ]; then
sudo make install DESTDIR=$1
else
sudo make install
fi
elif [ "$1" = "--native" ]; then
# Build natively on the host
mkdir -p build/native/$BUILDSUBDIR
pushd build/native/$BUILDSUBDIR
cmake -DCMAKE_BUILD_TYPE=$BUILDTYPE ../../..
shift
make -j `nproc` $*
else
# Cross compile on a more capable machine
mkdir -p build/arm-linux/$BUILDSUBDIR
pushd build/arm-linux/$BUILDSUBDIR
cmake -DCMAKE_TOOLCHAIN_FILE=$CMAKE_TOOLCHAIN_FILE -DCMAKE_BUILD_TYPE=$BUILDTYPE -DARM64=$ARM64 ../../..
make -j `nproc`
if [ "$1" != "" ]; then
sudo make install DESTDIR=$1
fi
fi
popd