Ross Light avatar Ross Light committed 674286a

Ross Light's work to make builds more portable

Comments (0)

Files changed (3)

+#!/bin/bash
+
+BINUTILS_VERSION=2.21
+GCC_VERSION=4.5.2
+MPFR_VERSION=3.0.1
+GMP_VERSION=5.0.2
+MPC_VERSION=0.8.2
+PATCHROOT="$HOME/src/FIRST/gcc-patches"
+PREFIX="$HOME/vxworks"
+SRC="$HOME/src/FIRST/gcc-src"
+BUILD="$HOME/src/FIRST/gcc-build"
+JOBS=4
+
+function download()
+{
+    [ -e "$SRC/$1" ] || wget -O "$SRC/$1" "$2"
+}
+
+function die()
+{
+    echo "$1"
+    exit 1
+}
+
+export PATH="$PREFIX/bin:$PATH"
+export WIND_BASE="$PREFIX/powerpc-wrs-vxworks/wind_base"
+
+# Download
+echo "Downloading..."
+[ -d "$SRC" ] || mkdir "$SRC"
+download "gccdist.zip" "ftp://ftp.ni.com/pub/devzone/tut/updated_vxworks63gccdist.zip"
+download "binutils-$BINUTILS_VERSION.tar.bz2" "http://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS_VERSION.tar.bz2"
+download "gcc-$GCC_VERSION.tar.bz2" "http://ftp.gnu.org/gnu/gcc/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.bz2"
+download "mpfr-$MPFR_VERSION.tar.bz2" "http://www.mpfr.org/mpfr-current/mpfr-$MPFR_VERSION.tar.bz2"
+download "gmp-$GMP_VERSION.tar.bz2" "ftp://ftp.gmplib.org/pub/gmp-$GMP_VERSION/gmp-$GMP_VERSION.tar.bz2"
+download "mpc-$MPC_VERSION.tar.gz" "http://www.multiprecision.org/mpc/download/mpc-$MPC_VERSION.tar.gz"
+
+# Extract
+echo "Extracting files (this will take a long time)..."
+cd "$SRC"
+echo "  gccdist.zip"
+unzip -q gccdist.zip
+echo "  binutils-$BINUTILS_VERSION.tar.bz2"
+tar --bzip2 -xf "binutils-$BINUTILS_VERSION.tar.bz2"
+echo "  gcc-$GCC_VERSION.tar.bz2"
+tar --bzip2 -xf "gcc-$GCC_VERSION.tar.bz2"
+echo "  mpfr-$MPFR_VERSION.tar.bz2"
+tar --bzip2 -xf "mpfr-$MPFR_VERSION.tar.bz2"
+echo "  gmp-$GMP_VERSION.tar.bz2"
+tar --bzip2 -xf "gmp-$GMP_VERSION.tar.bz2"
+echo "  mpc-$MPC_VERSION.tar.gz"
+tar --gzip -xf "mpc-$MPC_VERSION.tar.gz"
+
+# Patch!
+echo "Patching..."
+cd "$SRC/gccdist/WindRiver/vxworks-6.3/target/h"
+sed "s:/usr/local/powerpc-wrs-vxworks:$(echo $PREFIX):" < "$PATCHROOT/vxworks-headers.patch" | patch -p1
+cd "$SRC/gcc-$GCC_VERSION"
+patch -p2 < "$PATCHROOT/gcc-diff.patch" # -p2 intentional.
+
+# Set up headers
+echo "Headers..."
+[ -d "$PREFIX" ] || mkdir "$PREFIX"
+mkdir -p "$WIND_BASE/target"
+ln -s "$PREFIX/powerpc-wrs-vxworks/sys-include" "$WIND_BASE/target/h"
+cp -R "$SRC/gccdist/WindRiver/vxworks-6.3/host" "$WIND_BASE/host" # must be a copy, because build adds more.
+
+# Build
+[ -d "$BUILD" ] || mkdir "$BUILD"
+cd "$BUILD"
+mkdir binutils gcc libstdc++
+
+echo "binutils:"
+cd "$BUILD/binutils"
+"$SRC/binutils-$BINUTILS_VERSION/configure" --prefix="$PREFIX" --target=powerpc-wrs-vxworks
+make -j "$JOBS" || die "** binutils build failed"
+make -j "$JOBS" install || die "** binutils install failed"
+
+echo "gcc:"
+ln -s "$SRC/mpfr-$MPFR_VERSION" "$SRC/gcc-$GCC_VERSION/mpfr"
+ln -s "$SRC/gmp-$GMP_VERSION" "$SRC/gcc-$GCC_VERSION/gmp"
+ln -s "$SRC/mpc-$MPC_VERSION" "$SRC/gcc-$GCC_VERSION/mpc"
+cd "$BUILD/gcc"
+"$SRC/gcc-$GCC_VERSION/configure" \
+    --prefix="$PREFIX" \
+    --target=powerpc-wrs-vxworks \
+    --with-gnu-as \
+    --with-gnu-ld \
+    --with-headers="$SRC/gccdist/WindRiver/vxworks-6.3/target/h" \
+    --disable-shared \
+    --disable-libssp \
+    --disable-multilib \
+    --with-float=hard \
+    --enable-languages=c,c++ \
+    --enable-threads=vxworks \
+    --without-gconv \
+    --disable-libgomp \
+    --disable-nls \
+    --disable-libmudflap \
+    --with-cpu-PPC603 \
+    CFLAGS="-g -O2" \
+
+# TODO: Document if necessary
+make -j "$JOBS" || die "** gcc build failed"
+make -j "$JOBS" install || die "** gcc install failed"
+
+
+echo "libstdc++:"
+cd "$BUILD/libstdc++"
+"$SRC/gcc-$GCC_VERSION/libstdc++-v3/configure" \
+    --host=powerpc-wrs-vxworks \
+    --prefix="$PREFIX" \
+    --enable-libstdcxx-debug \
+    CFLAGS="-g -isystem $PREFIX/powerpc-wrs-vxworks/sys-include/ -isystem $PREFIX/powerpc-wrs-vxworks/sys-include/wrn/coreip/ -D_WRS_KERNEL -DCPU=PPC603 -DNOMINMAX" \
+    CXXFLAGS="-isystem $PREFIX/powerpc-wrs-vxworks/sys-include/ -isystem $PREFIX/powerpc-wrs-vxworks/sys-include/wrn/coreip/ -D_WRS_KERNEL -DCPU=PPC603 -DNOMINMAX" \
+    CPPFLAGS="-g -isystem $PREFIX/powerpc-wrs-vxworks/sys-include/ -isystem $PREFIX/powerpc-wrs-vxworks/sys-include/wrn/coreip/ -D_WRS_KERNEL -DCPU=PPC603 -DNOMINMAX"
+
+make -j "$JOBS" || die "** libstdc++ build failed"
+make -j "$JOBS" install || die "** libstdc++ install failed" 

build.sh

-#!/bin/bash
-
-# For now, run this as root so install works.  Not ideal, but it works...
-# If someone wants to, getting GCC to stage everything would be a lot better, but I'm lazy
-BINUTILS_VERSION=2.21
-GCC_VERSION=4.5.2
-MPFR_VERSION=3.0.1
-GMP_VERSION=5.0.2
-PREFIX=/usr/local/powerpc-wrs-vxworks
-
-export PATH=$PATH:$PREFIX/bin
-
-echo "Getting the vxworks header files."
-[ -e updated_vxworks63gccdist.zip ] || wget ftp://ftp.ni.com/pub/devzone/tut/updated_vxworks63gccdist.zip
-unzip updated_vxworks63gccdist.zip
-
-echo "Patching the header files"
-cd gccdist/WindRiver/vxworks-6.3/target/h/
-ln -s vxWorks.h VxWorks.h
-cat ../../../../../vxworks-headers.patch | sed "s/\/usr\/local\/powerpc-wrs-vxworks/`echo $PREFIX | sed 's/\\//\\\\\\//g'`/" | patch -p1
-
-cd ../../../../../
-
-mkdir -p $PREFIX/powerpc-wrs-vxworks/wind_base
-mkdir $PREFIX/powerpc-wrs-vxworks/wind_base/target
-ln -s ../../sys-include/ $PREFIX/powerpc-wrs-vxworks/wind_base/target/h
-cp -rp gccdist/WindRiver/vxworks-6.3/host $PREFIX/powerpc-wrs-vxworks/wind_base/host
-
-echo "Building binutils"
-[ -e http://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS_VERSION.tar.bz2 ] || wget http://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS_VERSION.tar.bz2
-echo "Extracting binutils-2.21.tar.bz2"
-tar xjf binutils-2.21.tar.bz2
-mkdir binutils-2.21-build-x64
-cd binutils-2.21-build-x64
-../binutils-2.21/configure --prefix=$PREFIX --target=powerpc-wrs-vxworks
-make -j32
-make install -j2
-cd ..
-
-echo "Building gcc"
-[ -e http://ftp.gnu.org/gnu/gcc/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.bz2 ] || wget http://ftp.gnu.org/gnu/gcc/gcc-$GCC_VERSION/gcc-$GCC_VERSION.tar.bz2
-echo "Extracting gcc-$GCC_VERSION.tar.bz2"
-tar xjf gcc-$GCC_VERSION.tar.bz2
-[ -e wget http://www.mpfr.org/mpfr-current/mpfr-$MPFR_VERSION.tar.bz2 ] || wget http://www.mpfr.org/mpfr-current/mpfr-$MPFR_VERSION.tar.bz2 
-echo "Extracting mpfr-$MPFR_VERSION.tar.bz2"
-tar xjf mpfr-$MPFR_VERSION.tar.bz2
-[ -e wget ftp://ftp.gmplib.org/pub/gmp-$GMP_VERSION/gmp-$GMP_VERSION.tar.bz2] || wget ftp://ftp.gmplib.org/pub/gmp-$GMP_VERSION/gmp-$GMP_VERSION.tar.bz2
-echo "Extracting gmp-$GMP_VERSION.tar.bz2"
-tar xjf gmp-$GMP_VERSION.tar.bz2
-cd gcc-$GCC_VERSION
-ln -s ../mpfr-$MPFR_VERSION mpfr
-ln -s ../gmp-$GMP_VERSION gmp
-cd ..
-
-cat gcc-diff.patch | patch -p1
-
-mkdir gcc-$GCC_VERSION-build-x64
-cd gcc-$GCC_VERSION-build-x64
-
-../gcc-$GCC_VERSION/configure --prefix=$PREFIX --target=powerpc-wrs-vxworks --with-gnu-as --with-gnu-ld --with-headers=../gccdist/WindRiver/vxworks-6.3/target/h --disable-shared --disable-libssp CFLAGS='-D_WRS_KERNEL -g -O2' --disable-multilib --with-float=hard --enable-languages=c,c++ --enable-threads=vxworks --without-gconv --disable-libgomp --disable-nls --disable-libmudflap --with-cpu-PPC603
-export WIND_BASE=$PREFIX/powerpc-wrs-vxworks/wind_base/
-
-# Build gcc propper
-make all-gcc -j32
-make install-gcc -j2
-
-# Make the library
-make -j32
-make install -j2
-cd ..
-
-echo "Building the stdlib"
-mkdir libstdc++-v3-build-x64
-cd libstdc++-v3-build-x64
-
-../gcc-$GCC_VERSION/libstdc++-v3/configure --host=powerpc-wrs-vxworks --prefix=$PREFIX/ CFLAGS="-g -isystem $PREFIX/powerpc-wrs-vxworks/sys-include/ -isystem $PREFIX/powerpc-wrs-vxworks/sys-include/wrn/coreip/ -D_WRS_KERNEL -DCPU=PPC603 -DNOMINMAX" CXXFLAGS="-isystem $PREFIX/powerpc-wrs-vxworks/sys-include/ -isystem $PREFIX/powerpc-wrs-vxworks/sys-include/wrn/coreip/ -D_WRS_KERNEL -DCPU=PPC603 -DNOMINMAX" CCFLAGS="-g -isystem $PREFIX/powerpc-wrs-vxworks/sys-include/wrn/coreip/ -isystem $PREFIX/powerpc-wrs-vxworks/sys-include/ -D_WRS_KERNEL -DCPU=PPC603 -DNOMINMAX" CPPFLAGS="-g -isystem $PREFIX/powerpc-wrs-vxworks/sys-include/ -isystem $PREFIX/powerpc-wrs-vxworks/sys-include/wrn/coreip/ -D_WRS_KERNEL -DCPU=PPC603 -DNOMINMAX" --enable-libstdcxx-debug
-make -j32
-make install -j2
 diff -u -r a/gcc-4.5.2/gcc/config/rs6000/vxworks.h b/gcc-4.5.2/gcc/config/rs6000/vxworks.h
 --- a/gcc-4.5.2/gcc/config/rs6000/vxworks.h	2009-10-10 11:43:31.000000000 -0700
 +++ b/gcc-4.5.2/gcc/config/rs6000/vxworks.h	2011-05-23 12:48:16.857388980 -0700
-@@ -34,6 +34,9 @@
+@@ -34,6 +34,10 @@
    do						\
      {						\
        builtin_define ("__ppc");			\
 +      builtin_define ("__ppc__");		\
 +      builtin_define ("__PPC__");		\
 +      builtin_define ("__PPC");		\
++      builtin_define ("_WRS_KERNEL");		\
        builtin_define ("__EABI__");		\
        builtin_define ("__ELF__");		\
        builtin_define ("__vxworks");		\
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.