Last active
May 20, 2016 22:33
-
-
Save rightson/18f59251217b6ebcb2b66ecfa1c3d406 to your computer and use it in GitHub Desktop.
A script for creating development environment for MIT JOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export PFX=$HOME/jos-env | |
#export PATH=$PFX/bin:$PATH | |
#export LD_LIBRARY_PATH=$PFX/lib:$LD_LIBRARY_PATH # On Linux, use LD_LIBRARY_PATH | |
#export DYLD_LIBRARY_PATH=$PFX/lib:$DYLD_LIBRARY_PATH # On Mac OS X, use DYLD_LIBRARY_PATH | |
export GPM=gmp-5.0.2 | |
export MPFR=mpfr-3.1.2 | |
export MPC=mpc-0.9 | |
export BINUTILS=binutils-2.21.1 | |
export GCCCORE=gcc-core-4.6.3 | |
export GCC=gcc-4.6.3 | |
export GDB=gdb-7.3.1 | |
export CPU=`python -c 'import multiprocessing as mp; print(mp.cpu_count()-1)'` | |
#export CC=/usr/local/bin/gcc-4.2 | |
cpus() { | |
echo $CPU | |
} | |
prompt_msg() { | |
echo $1 | |
sleep 1 | |
} | |
build_gpm() { | |
prompt_msg "build gpm..." | |
if [ ! -d $GPM ]; then | |
if [ ! -f $GPM.tar.bz2 ]; then | |
wget ftp://ftp.gmplib.org/pub/gmp-5.0.2/$GPM.tar.bz2 | |
fi | |
tar xjf $GPM.tar.bz2 | |
fi | |
cd $GPM | |
./configure --prefix=$PFX | |
make -j $CPU | |
make install # This step may require privilege (sudo make install) | |
cd .. | |
} | |
build_mpfr() { | |
prompt_msg "build mpfr..." | |
if [ ! -d $MPFR ]; then | |
if [ ! -f $MPC.tar.bz2 ]; then | |
wget http://ftp.gnu.org/gnu/mpfr/$MPFR.tar.bz2 | |
fi | |
tar xjf $MPFR.tar.bz2 | |
fi | |
cd $MPFR | |
./configure --prefix=$PFX --with-gmp=$PFX | |
make -j $CPU | |
make install # This step may require privilege (sudo make install) | |
cd .. | |
} | |
build_mpc() { | |
prompt_msg "build mpc..." | |
if [ ! -d $MPC ]; then | |
if [ ! -f $MPC.tar.gz ]; then | |
wget http://www.multiprecision.org/mpc/download/$MPC.tar.gz | |
fi | |
tar xzf $MPC.tar.gz | |
fi | |
cd $MPC | |
./configure --prefix=$PFX --with-gmp=$PFX --with-mpfr=$PFX | |
make -j $CPU | |
make install # This step may require privilege (sudo make install) | |
cd .. | |
} | |
build_binutils() { | |
prompt_msg "build binutils..." | |
if [ ! -d $BINUTILS ]; then | |
if [ ! -f $BINUTILS.tar.bz2 ]; then | |
wget https://ftp.gnu.org/gnu/binutils/$BINUTILS.tar.bz2 | |
fi | |
tar xjf $BINUTILS.tar.bz2 | |
fi | |
cd $BINUTILS | |
./configure --prefix=$PFX --target=i386-jos-elf --disable-werror | |
make -j $CPU | |
make install # This step may require privilege (sudo make install) | |
cd .. | |
$PFX/bin/i386-jos-elf-objdump -i | |
# Should produce output like: | |
# BFD header file version (GNU Binutils) 2.21.1 | |
# elf32-i386 | |
# (header little endian, data little endian) | |
# i386... | |
} | |
build_gcc() { | |
prompt_msg "build gcc..." | |
if [ ! -d $GCC ]; then | |
if [ ! -f $GCCCORE.tar.bz2 ]; then | |
wget https://ftp.gnu.org/gnu/gcc/$GCC/$GCCCORE.tar.bz2 | |
fi | |
tar xjf $GCCCORE.tar.bz2 | |
fi | |
cd $GCC | |
mkdir build # GCC will not compile correctly unless you build in a separate directory | |
cd build | |
# ../configure --prefix=$PFX --with-gmp=$PFX --with-mpfr=$PFX --with-mpc=$PFX \ | |
# --target=i386-jos-elf --disable-werror \ | |
# --disable-libssp --disable-libmudflap --with-newlib \ | |
# --without-headers --enable-languages=c | |
# MAC OS X 10.7 "LION" NOTE: The default clang compiler on Mac OS X 10.7 | |
# cannot build a working version of GCC. Use the following configure | |
# line to work around the problem (this has reported to work with OS X 10.9.4 withXCode 5.1.1 and its Command Line Tools package (for gcc): | |
../configure --prefix=$PFX --with-gmp=$PFX --with-mpfr=$PFX --with-mpc=$PFX \ | |
--target=i386-jos-elf --disable-werror \ | |
--disable-libssp --disable-libmudflap --with-newlib \ | |
--without-headers --enable-languages=c | |
make -j $CPU all-gcc | |
make -j $CPU install-gcc # This step may require privilege (sudo make install-gcc) | |
make -j $CPU all-target-libgcc | |
make -j $CPU install-target-libgcc # This step may require privilege (sudo make install-target-libgcc) | |
cd ../.. | |
$PFX/bin/i386-jos-elf-gcc -v | |
# Should produce output like: | |
# Using built-in specs. | |
# COLLECT_GCC=i386-jos-elf-gcc | |
# COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/i386-jos-elf/4.6.1/lto-wrapper | |
# Target: i386-jos-elf | |
} | |
build_gdb() { | |
prompt_msg "build gdb..." | |
if [ ! -d $GDB ]; then | |
if [ ! -f $DB.tar.bz2 ]; then | |
wget https://ftp.gnu.org/gnu/gdb/$GDB.tar.bz2 | |
fi | |
tar xjf $GDB.tar.bz2 | |
fi | |
cd $GDB | |
./configure --prefix=$PFX --target=i386-jos-elf --program-prefix=i386-jos-elf- \ | |
--disable-werror | |
make -j $CPU all | |
make install # This step may require privilege (sudo make install) | |
cd .. | |
} | |
build_deps() { | |
build_gpm | |
build_mpfr | |
build_mpc | |
build_binutils | |
} | |
build_qemu() { | |
git clone https://github.com/geofft/qemu.git -b 6.828-1.7.0 | |
cd qemu | |
./configure --disable-kvm --prefix=$PFX --target-list="i386-softmmu x86_64-softmmu" | |
make && make install | |
} | |
clean() { | |
rm -rf $GPM $MPFR $MPC $BINUTILS | |
rm -rf $GCC $GDB | |
} | |
if [ -z $1 ]; then | |
echo "Usage: $0 build_deps|build_gcc|build_gdb|build_qemu|clean" | |
else | |
$* | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment