. ./config
# Setup the path to use new tools as they become available
-export PATH=$LFS_TOOLS/bin:$PATH
+export PATH=$AL_TOOLS/bin:$PATH
download(){
- mkdir -p "$LFS_TARBALLS"
- if [ ! -f "$LFS_TARBALLS/$1" ]; then
- curl "$2/$1" > "$LFS_TARBALLS/$1"
+ mkdir -p "$AL_TARBALLS"
+ if [ ! -f "$AL_TARBALLS/$1" ]; then
+ curl "$2/$1" > "$AL_TARBALLS/$1"
fi
}
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 "$LFS_TARBALLS/binutils-2.25.tar.bz2" "$LFS_TARBALLS/binutils"
-extract "$LFS_TARBALLS/llvm-3.6.1.src.tar.xz" "$LFS_TARBALLS/llvm"
-extract "$LFS_TARBALLS/cfe-3.6.1.src.tar.xz" "$LFS_TARBALLS/llvm/tools/clang"
+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 "$LFS_TARBALLS/binutils/build"
-cd "$LFS_TARBALLS/binutils/build"
+mkdir -p "$AL_TARBALLS/binutils/build"
+cd "$AL_TARBALLS/binutils/build"
if [ ! -f Makefile ]; then
- ../configure --disable-shared --with-sysroot --prefix="$LFS_TOOLS"
+ ../configure \
+ --prefix="$AL_TOOLS" \
+ --with-sysroot="$AL" \
+ --with-lib-path="$AL_TOOLS" \
+ --target="$AL_TGT" \
+ --disable-shared \
+ --disable-nls \
+ --disable-werror
fi
-if [ ! -f "$LFS_TOOLS/bin/ar" ]; then
+if [ ! -f "$AL_TOOLS/bin/ar" ]; then
make
make install
fi
-cd $LFS
+cd $AL
# Test that the new linker works
echo 'int main(int argc, char** argv) { return 0; }' > test.c
-cc -o test test.c
+gcc -o test test.c
rm test test.c
+which ld
# Build clang and install it in the
-mkdir -p "$LFS_TARBALLS/llvm/build"
-cd "$LFS_TARBALLS/llvm/build"
+mkdir -p "$AL_TARBALLS/llvm/build"
+cd "$AL_TARBALLS/llvm/build"
if [ ! -f Makefile ]; then
- cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$LFS_TOOLS" ../
+ cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$AL_TOOLS" -DBUILD_SHARED_LIBS=OFF ../
fi
-if [ ! -f "$LFS_TOOLS/bin/clang" ]; then
+if [ ! -f "$AL_TOOLS/bin/clang" ]; then
make clang
make install
fi
-# Test that the new clang binary works
-echo 'int main(int argc, char** argv) { return 0; }' > test.c
-clang -o test test.c
-rm test test.c
-
+## Test that the new clang binary works
+#echo 'int main(int argc, char** argv) { return 0; }' > test.c
+#clang -o test test.c
+#if [ "0" -ne "`readelf -d test | grep -c '0x'`" ]; then
+# echo "Expected toolchain to compile statically but target was dynamically linked."
+# exit 1
+#else
+# rm test test.c
+#fi
+# Define the target triplet to distinguish it from the host toolchain
+export AL_TGT=$(uname -m)-aardvark-linux-gnu
-export LFS=$PWD
-export LFS_TOOLS=$LFS/tools
-export LFS_TARBALLS=$LFS/tarballs
+# Define a variable to point to the root of the project
+export AL=$PWD
+
+# Variable point to the toolchain directory
+export AL_TOOLS=$AL/tools
+
+# Variable pointing to the tarballs directory
+export AL_TARBALLS=$AL/tarballs