Skip to content

Instantly share code, notes, and snippets.

@notmatt notmatt/hello.c forked from AlainODea/hello.c
Last active Dec 27, 2015

Embed
What would you like to do?
#include<stdio.h>
main()
{
printf("Hello World");
}
#!/bin/bash
# Derived from: https://gist.github.com/AlainODea/6679613
#
# Prerequisites (in the loose sense of "worked for me"):
# brew install binutils
# brew install gcc47
#
# SMARTOS_HOST - a smartos host with ssh access as a source for the target
# system libraries. I was using a JPC 'manta-build' image, which has numerous
# pre-installed packages. Adjustments may be necessary if using stock smartos.
#
# Results in an OSX->SmartOS cross-compiler installed at $PREFIX/bin
# 32/64 bit. Ensure smartos host zone has similar pkgsrc.
export TARGET=i386-sun-solaris2.11
# export TARGET=x86_64-sun-solaris2.11
export PREFIX=$HOME/code/gcc/cross/$TARGET
export SYSROOT=$PREFIX/sysroot
export PATH=$PATH:$PREFIX/bin
export SCRATCH=$HOME/code/gcc/scratch
export SMARTOS_HOST=walter
# ensure matches brew versions above.
export BINUTILS=binutils-2.23.2
export GCC=gcc-4.7.3
mkdir $PREFIX
mkdir $SYSROOT
pushd $SYSROOT/
# It's likely that not everything below is strictly necessary.
ssh $SMARTOS_HOST "pkgin -y up && pkgin -y ug && pkgin -y in gmp"
ssh $SMARTOS_HOST "tar -cf - /usr/include" | tar -xvf -
ssh $SMARTOS_HOST "tar -cf - /opt/local/include" | tar -xvf -
ssh $SMARTOS_HOST "tar -cf - /opt/local/gcc47/include" | tar -xvf -
ssh $SMARTOS_HOST "tar -cf - /lib" | tar -xvf -
ssh $SMARTOS_HOST "tar -cf - /usr/lib" | tar -xvf -
ssh $SMARTOS_HOST "tar -cf - /usr/gnu/lib" | tar -xvf -
mkdir $SCRATCH
pushd $SCRATCH/
wget http://ftp.gnu.org/gnu/binutils/$BINUTILS.tar.gz
tar -xvzf $BINUTILS.tar.gz
mkdir $SCRATCH/build-binutils
pushd $SCRATCH/build-binutils/
../$BINUTILS/configure -target=$TARGET --prefix=$PREFIX --with-sysroot=$SYSROOT -v
make all && make install
popd
wget http://ftp.gnu.org/gnu/gcc/$GCC/$GCC.tar.gz
tar -xvzf $GCC.tar.gz
mkdir $SCRATCH/build-gcc
pushd $SCRATCH/build-gcc/
../$GCC/configure --target=$TARGET --with-gnu-as --with-gnu-ld --with-gmp \
--with-mpfr --with-mpc --prefix=$PREFIX --with-sysroot=$SYSROOT \
--disable-libgcj --disable-libssp --disable-libada \
--disable-libgomp --enable-languages=c,c++ -v
make all && make install
popd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.