From 54d90ebdeb913130d3b5ec6e5a482e2791647265 Mon Sep 17 00:00:00 2001 From: "Mike D. Lowis" Date: Thu, 3 Sep 2015 15:45:50 -0400 Subject: [PATCH] Checkpoint commit --- build.sh | 123 ++++++++---------- config => config.sh | 33 +++-- musl-cross-config.sh | 27 ++++ .../bootstrap-tools.sh | 0 scripts/build.sh | 31 +++++ 5 files changed, 128 insertions(+), 86 deletions(-) rename config => config.sh (52%) create mode 100644 musl-cross-config.sh rename bootstrap-tools.sh => scripts/bootstrap-tools.sh (100%) create mode 100755 scripts/build.sh diff --git a/build.sh b/build.sh index 6def19d..7389841 100755 --- a/build.sh +++ b/build.sh @@ -1,84 +1,71 @@ #!/bin/sh +############################################################################### +# Configuration Settings +############################################################################### + # Turn off command hashing and make the script exit when a command errors. set -e -# Load the configuration -. ./config +# Load the config settings +. ./config.sh -# Setup the path to use new tools as they become available -export PATH=$AL_TOOLS/bin:$PATH +# Make sure CFLAGS isnt set +unset CFLAGS -download(){ - mkdir -p "$AL_TARBALLS" - if [ ! -f "$AL_TARBALLS/$1" ]; then - curl "$2/$1" > "$AL_TARBALLS/$1" +############################################################################### +# Helper Functions +############################################################################### +fetch(){ + if [ ! -d "$3" ]; then + mkdir -p "$AL_TARBALLS" + if [ ! -f "$AL_TARBALLS/$1" ]; then + echo curl -L --retry 5 "$2/$1" > "$AL_TARBALLS/$1" + curl -L --retry 5 "$2/$1" > "$AL_TARBALLS/$1" + fi + mkdir -p "$3" + tar -xvf "$AL_TARBALLS/$1" -C "$3" --strip-components 1 fi } -extract(){ +gitclone(){ if [ ! -d "$2" ]; then - mkdir -p "$2" - tar -xvf "$1" -C "$2" --strip-components 1 + git clone --depth 1 $1 $2 fi } -# Download tarballs -download binutils-2.25.tar.bz2 http://ftp.gnu.org/gnu/binutils/ -download cfe-3.6.1.src.tar.xz http://llvm.org/releases/3.6.1/ -download llvm-3.6.1.src.tar.xz http://llvm.org/releases/3.6.1/ -#download musl-1.1.10.tar.gz http://www.musl-libc.org/releases/ - -# Extract the tarballs -extract "$AL_TARBALLS/binutils-2.25.tar.bz2" "$AL_TARBALLS/binutils" -extract "$AL_TARBALLS/llvm-3.6.1.src.tar.xz" "$AL_TARBALLS/llvm" -extract "$AL_TARBALLS/cfe-3.6.1.src.tar.xz" "$AL_TARBALLS/llvm/tools/clang" - -# Build binutils and install it in the tools prefix -mkdir -p "$AL_TARBALLS/binutils/build" -cd "$AL_TARBALLS/binutils/build" -if [ ! -f Makefile ]; then - ../configure \ - LDFLAGS="--static" \ - --prefix="$AL_TOOLS" \ - --with-sysroot="$AL" \ - --with-lib-path="$AL_TOOLS" \ - --target="$AL_TGT" \ - --disable-shared \ - --disable-nls \ - --disable-werror -fi -if [ ! -f "$AL_TOOLS/bin/$AL_TGT-ar" ]; then - make - make install -fi -cd $AL +############################################################################### +# Build the Cross-Compiler +############################################################################### +mkdir -vp $AL_TOOLS +gitclone https://github.com/sabotage-linux/musl-cross.git "$AL_SOURCES/musl-cross" +cd "$AL_SOURCES/musl-cross" +cp "$AL/musl-cross-config.sh" config.sh +./build.sh +cd "$AL" -# Build clang and install it in the -mkdir -p "$AL_TARBALLS/llvm/build" -cd "$AL_TARBALLS/llvm/build" -if [ ! -f Makefile ]; then - LDFLAGS="-static" cmake -G"Unix Makefiles" \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX="$AL_TOOLS" \ - -DBUILD_SHARED_LIBS=OFF \ - -DLLVM_BUILD_TOOLS=OFF \ - -DLLVM_BUILD_EXAMPLES=OFF \ - -DLLVM_BUILD_TESTS=OFF \ - ../ -fi -if [ ! -f "$AL_TOOLS/bin/clang" ]; then - make LDFLAGS="-static" clang - make install -fi +################################################################################ +## Setup the Build Environment +################################################################################ +#export CC="$(uname -m)-linux-musl-gcc" +#export CXX="$(uname -m)-linux-musl-g++" +#export AR="$(uname -m)-linux-musl-ar" +#export AS="$(uname -m)-linux-musl-as" +#export LD="$(uname -m)-linux-musl-ld" +#export RANLIB="$(uname -m)-linux-musl-ranlib" +#export READELF="$(uname -m)-linux-musl-readelf" +#export STRIP="$(uname -m)-linux-musl-strip" +#export CFLAGS="-static" +#export LDFLAGS="-static" +# +################################################################################ +## Setup the Build Environment +################################################################################ +# +## Install sbase +#gitclone http://git.suckless.org/sbase $AL_SOURCES/sbase +#cd "$AL_SOURCES/sbase" +#make CC=$CC -j8 +#make PREFIX=$AL_ROOT install +#cd $AL -# Test that the new clang binary works -echo 'int main(int argc, char** argv) { return 0; }' > cctest.c -clang -static -target $AL_TGT -o cctest cctest.c -if [ "0" -ne "`readelf -d cctest | grep -c '0x'`" ]; then - rm cctest cctest.c - echo "Expected toolchain to compile statically but target was dynamically linked." - exit 1 -else - rm cctest cctest.c -fi diff --git a/config b/config.sh similarity index 52% rename from config rename to config.sh index 0b15946..c683129 100644 --- a/config +++ b/config.sh @@ -1,3 +1,7 @@ +############################################################################### +# Aardvark Linux Build Config +############################################################################### + # Define a variable to point to the root of the project export AL=$PWD @@ -6,29 +10,22 @@ export LC_ALL=en_US.UTF-8 export LANG=$LC_ALL export LANGUAGE=$LC_ALL -# Setup the path to use the cross-tools when they're available -export PATH=$AL/tools/bin:$PATH - -# Make sure CFLAGS isnt set -unset CFLAGS - -# Set the host triple for the cross compiler -export AL_HOST=$MACHTYPE - -# Select the target architecture -export AL_ARCH=$(uname -m) - -# Define the target triplet to distinguish it from the host toolchain -export AL_TGT=$AL_ARCH-aardvark-linux-gnu - -# Variable pointing to the toolchain directory -export AL_TOOLS=$AL/tools - # Variable pointing to the target root directory export AL_ROOT=$AL/root +# Variable pointing to the toolchain directory +export AL_TOOLS=$AL_ROOT/tools + # Variable pointing to the tarballs directory export AL_TARBALLS=$AL/tarballs # Variable pointing to the sources directory export AL_SOURCES=$AL/sources + +############################################################################### +# Build Environment Settings +############################################################################### + +# Setup the path to use the cross-tools when they're available +export PATH=$AL_ROOT/tools/$(uname -m)-linux-musl/bin:$PATH + diff --git a/musl-cross-config.sh b/musl-cross-config.sh new file mode 100644 index 0000000..6e492f6 --- /dev/null +++ b/musl-cross-config.sh @@ -0,0 +1,27 @@ +############################################################################### +# Musl-Cross Compiler Build Settings +############################################################################### + +# Tell make how many threads you want it to use +MAKEFLAGS=-j8 + +# Tell the build scripts where the cross compiler should go +CC_BASE_PREFIX="../../root/tools/" + +# If you use arm, you may need more fine-tuning: +# arm hardfloat v7 +#TRIPLE=arm-linux-musleabihf +#GCC_BOOTSTRAP_CONFFLAGS="--with-arch=armv7-a --with-float=hard --with-fpu=vfpv3-d16" +#GCC_CONFFLAGS="--with-arch=armv7-a --with-float=hard --with-fpu=vfpv3-d16" + +# arm softfp +#TRIPLE=arm-linux-musleabi +#GCC_BOOTSTRAP_CONFFLAGS="--with-arch=armv7-a --with-float=softfp" +#GCC_CONFFLAGS="--with-arch=armv7-a --with-float=softfp" + +# Enable this to build the bootstrap gcc (thrown away) without optimization, to reduce build time +GCC_STAGE1_NOOPT=1 + +# Build gmp, mpfr, and mpc along with GCC rather than using the system libs +GCC_BUILTIN_PREREQS=yes + diff --git a/bootstrap-tools.sh b/scripts/bootstrap-tools.sh similarity index 100% rename from bootstrap-tools.sh rename to scripts/bootstrap-tools.sh diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 0000000..6248286 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +############################################################################### +# Configuration Settings +############################################################################### + +# Turn off command hashing and make the script exit when a command errors. +set -e + +# Load the config settings +. ./config.sh + +############################################################################### +# Helper Functions +############################################################################### +gitclone(){ + if [ ! -d "$2" ]; then + git clone --depth 1 $1 $2 + fi +} + +############################################################################### +# Build the Cross-Compiler +############################################################################### +mkdir -vp $AL_TOOLS +gitclone https://github.com/sabotage-linux/musl-cross.git "$AL_SOURCES/musl-cross" +cd "$AL_SOURCES/musl-cross" +cp "$AL/musl-cross-config.sh" config.sh +./build.sh +cd "$AL" + -- 2.55.0