From 368b1a7c3c7f4741ade02fdc6bb1dd25f858d530 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Tue, 16 Jun 2015 18:56:10 -0400 Subject: [PATCH] Added initial build script for building the cross compiler --- build.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ config | 4 ++++ 2 files changed, 72 insertions(+) create mode 100755 build.sh create mode 100644 config diff --git a/build.sh b/build.sh new file mode 100755 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 index 0000000..642d78b --- /dev/null +++ b/config @@ -0,0 +1,4 @@ + +export LFS=$PWD +export LFS_TOOLS=$LFS/tools +export LFS_TARBALLS=$LFS/tarballs -- 2.52.0