diff build.sh @ 3:1b721a51e9c6

Extract headers, build cross-binutils, build cross-gcc. Needs a C library.
author landley@driftwood
date Tue, 15 Aug 2006 23:32:28 -0400
parents 9add2b1ccdfa
children 0068264ad65a
line wrap: on
line diff
--- a/build.sh	Sun Aug 13 22:30:17 2006 -0400
+++ b/build.sh	Tue Aug 15 23:32:28 2006 -0400
@@ -1,5 +1,9 @@
 #!/bin/sh
 
+# Memo: How should I pass this in?
+
+ARCH=x86_64
+
 function dienow()
 {
   echo "Exiting due to errors"
@@ -22,13 +26,24 @@
   echo
 }
 
+# Extract package $1, use work directory $2 (or $1 if no $2)
+
 function setupfor()
 {
   echo "=== Building $1"
   echo -n "Extracting"
   cd "${WORK}" &&
-  tar xvjf "${SOURCES}/${STAGE}/$1".tar.bz2 | dotprogress
-  cd "$1"* || dienow
+  { tar xvjf "${SOURCES}/${STAGE}/$1".tar.bz2 || dienow
+  } | dotprogress
+  if [ -z "$2" ]
+  then
+    cd "$1"* || dienow
+  else
+    mkdir "$2"
+    cd "$2" || dienow
+  fi
+  export CURSRC="${WORK}/$1"*
+  [ ! -d "${CURSRC}" ] && dienow
 }
 
 # Setup
@@ -36,14 +51,12 @@
 umask 022
 unset CFLAGS CXXFLAGS
 
-ARCH=x86_64
-
 # Find/create directories
 
 TOP=`pwd`
+export SOURCES="${TOP}/sources"
 export CROSS="${TOP}/build/cross-compiler"
 export WORK="${TOP}/build/temp"
-export SOURCES="${TOP}/sources"
 mkdir -p "${CROSS}" "${WORK}"
 
 [ $? -ne 0 ] && dienow
@@ -51,16 +64,19 @@
 # For bash: check the $PATH for new executables added after startup.
 set +h
 # Put the cross compiler in the path
-export PATH=`pwd`/cross:/bin:/usr/bin
+export PATH=${CROSS}/bin:/bin:/usr/bin
 
 # Which platform are we building for?
 
 [ "$ARCH" == x86_64 ] && export BUILD64="-m64"
-export LFS_HOST=i686-pc-linux-gnu
-export LFS_TARGET=${ARCH}-unknown-linux-gnu
+export CROSS_HOST=i686-pc-linux-gnu
+export CROSS_TARGET=${ARCH}-unknown-linux-gnu
 
 export STAGE=build-cross
 
+if false
+then
+
 echo === Install linux-headers.
 
 setupfor linux-headers
@@ -76,5 +92,37 @@
 
 [ $? -ne 0 ] && dienow
 
-setupfor binutils
-/bin/sh
+setupfor binutils build-binutils
+"${CURSRC}/configure" --prefix="${CROSS}" --host=${CROSS_HOST} \
+	--target=${CROSS_TARGET} --with-lib-path=lib --disable-nls \
+	--disable-shared --enable-64-bit-bfd --disable-multilib &&
+make configure-host &&
+make &&
+make install &&
+cd .. &&
+cp binutils-*/include/libiberty.h "${CROSS}/include" &&
+rm -rf binutils-* build-binutils
+
+[ $? -ne 0 ] && dienow
+
+
+setupfor gcc-core build-gcc
+# Remove /usr/libexec/gcc and /usr/lib/gcc from gcc's search path.  (Don't grab
+# random host libraries when cross-compiling, it's not polite.)
+sed -ie 's/standard_exec_prefix_//;T;N;d' "${CURSRC}/gcc/gcc.c" &&
+# Adjust StartFile Spec to point to cross libraries.
+#echo -e "\n#undef STARTFILE_PREFIX_SPEC\n#define STARTFILE_PREFIX_SPEC \"${CROSS}/lib/\"" >> ../gcc-*/gcc/config/linux.h &&
+# Adjust preprocessor's default search path
+#sed -ire "s@(^CROSS_SYSTEM_HEADER_DIR =).*@\1 ${CROSS}/include@g" ../gcc-*/gcc/Makefile.in &&
+"${CURSRC}/configure" --prefix="${CROSS}" --host=${CROSS_HOST} \
+	--target=${CROSS_TARGET} --with-local-prefix="${CROSS}" \
+	--disable-multilib --disable-nls --disable-shared --disable-threads \
+	--enable-languages=c &&
+make all-gcc &&
+make install-gcc &&
+cd .. &&
+rm -rf "${CURSRC}" build-gcc
+
+fi
+
+[ $? -ne 0 ] && dienow