#!/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
+###############################################################################
+# Aardvark Linux Build Config
+###############################################################################
+
# Define a variable to point to the root of the project
export AL=$PWD
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
+
--- /dev/null
+###############################################################################
+# 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
+
--- /dev/null
+#!/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"
+