]> git.mdlowis.com Git - proto/aardvark-linux.git/commitdiff
Added initial build script for building the cross compiler
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 16 Jun 2015 22:56:10 +0000 (18:56 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 16 Jun 2015 22:56:10 +0000 (18:56 -0400)
build.sh [new file with mode: 0755]
config [new file with mode: 0644]

diff --git a/build.sh b/build.sh
new file mode 100755 (executable)
index 0000000..32cff52
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+# Turn off command hashing and make the script exit when a command errors.
+set -e
+
+# Load the configuration
+. ./config
+
+# Setup the path to use new tools as they become available
+export PATH=$LFS_TOOLS/bin:$PATH
+
+download(){
+    mkdir -p "$LFS_TARBALLS"
+    if [ ! -f "$LFS_TARBALLS/$1" ]; then
+        curl "$2/$1" > "$LFS_TARBALLS/$1"
+    fi
+}
+
+extract(){
+    if [ ! -d "$2" ]; then
+        mkdir -p "$2"
+        tar -xvf "$1" -C "$2" --strip-components 1
+    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/
+
+# 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"
+
+# Build binutils and install it in the tools prefix
+mkdir -p "$LFS_TARBALLS/binutils/build"
+cd "$LFS_TARBALLS/binutils/build"
+if [ ! -f Makefile ]; then
+    ../configure --disable-shared --with-sysroot --prefix="$LFS_TOOLS"
+fi
+if [ ! -f "$LFS_TOOLS/bin/ar" ]; then
+    make
+    make install
+fi
+cd $LFS
+
+# Test that the new linker works
+echo 'int main(int argc, char** argv) { return 0; }' > test.c
+cc -o test test.c
+rm test test.c
+
+# Build clang and install it in the
+mkdir -p "$LFS_TARBALLS/llvm/build"
+cd "$LFS_TARBALLS/llvm/build"
+if [ ! -f Makefile ]; then
+    cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX="$LFS_TOOLS" ../
+fi
+if [ ! -f "$LFS_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
+
diff --git a/config b/config
new file mode 100644 (file)
index 0000000..642d78b
--- /dev/null
+++ b/config
@@ -0,0 +1,4 @@
+
+export LFS=$PWD
+export LFS_TOOLS=$LFS/tools
+export LFS_TARBALLS=$LFS/tarballs