#!/bin/bash set +v set +e ############################################ # Set configuration variables # ############################################ GMP_VER=4.3.1 MPFR_VER=2.4.1 BINUTILS_VER=2.19.1 NEWLIB_VER=1.17.0 GCC_VER=4.4.1 INSIGHT_VER=6.8 ECOS_VER=3.0 GMP_LOC=ftp://ftp.gnu.org/gnu/gmp/ MPFR_LOC=http://www.mpfr.org/mpfr-current BINUTILS_LOC=ftp://sourceware.org/pub/binutils/releases/ GCC_LOC=ftp://sourceware.org/pub/gcc/releases/gcc-${GCC_VER} NEWLIB_LOC=ftp://sourceware.org/pub/newlib/ INSIGHT_LOC=ftp://sourceware.org/pub/insight/releases ECOS_LOC=ftp://sourceware.org/pub/ecos/releases/ecos-${ECOS_VER} ############################################ # Set platform variables # ############################################ TARGET="arm-eabi" TARGET_CPU="arm7tdmi" ############################################ # Set directory variables # ############################################ # AKA source directory # ce repertoire contient ce script et les patches # qui sont les points de depart a la construction de l'environement BASE=${PWD} # AKA destination directory # ce repertoire contient les archives telecharges depuis le net # les dossier decompresses, les builds, etc. WORK=${PWD} # Archives DOWNLOADS=${BASE}/downloads if [ ! -d ${DOWNLOADS} ]; then mkdir ${DOWNLOADS} fi # Where the sources will be extracted SOURCES=${WORK}/sources if [ ! -d ${SOURCES} ]; then mkdir ${SOURCES} fi # Where the sources will be compiled BUILDS=${WORK}/builds if [ ! -d ${BUILDS} ]; then mkdir ${BUILDS} fi # Cross-binutils and cross-compilers will be placed here. PREFIX=${WORK}/xtools if [ ! -d ${PREFIX} ]; then mkdir -p ${PREFIX} fi ############################################ # Set environment # ############################################ PATH=${PREFIX}/bin:${PATH} export PATH LC_ALL=POSIX export LC_ALL unset CFLAGS unset CXXFLAGS ############################################ # Display settings # ############################################ info() { echo "*******************************************************" echo " The directory containing tar.bz2 :" echo " ${DOWNLOADS}" echo " The directory that will contain extracted sources :" echo " ${SOURCES}" echo " The directory that will contain builds :" echo " ${BUILDS}" echo " The directory that will contain the cross tools :" echo " ${PREFIX}" echo " The TARGET is ${TARGET}" echo "*******************************************************" env echo "*******************************************************" ulimit -a echo "*******************************************************" } ############################################ # DOWNLOAD ROUTINE # ############################################ download() { FILE_URL=$1 FILE_NAME=`basename $1` # download if [ ! -f ${DOWNLOADS}/${FILE_NAME} ] ; then cd ${DOWNLOADS} wget -O ${FILE_NAME}.part ${FILE_URL} && \ mv ${FILE_NAME}.part ${FILE_NAME} fi } ############################################ # EXTRACT ROUTINE # ############################################ extract() { FILE_NAME=$1 cd ${SOURCES} tar -xvf ${DOWNLOADS}/${FILE_NAME} } ############################################ # # ############################################ install() { # download if [ -f build.log.download.ok ] ; then rm build.log.download.ok download ${GMP_LOC}/gmp-${GMP_VER}.tar.bz2 download ${MPFR_LOC}/mpfr-${MPFR_VER}.tar.bz2 download ${BINUTILS_LOC}/binutils-${BINUTILS_VER}.tar.bz2 download ${GCC_LOC}/gcc-core-${GCC_VER}.tar.bz2 download ${GCC_LOC}/gcc-g++-${GCC_VER}.tar.bz2 download ${NEWLIB_LOC}/newlib-${NEWLIB_VER}.tar.gz download ${INSIGHT_LOC}/insight-${INSIGHT_VER}.tar.bz2 download ${ECOS_LOC}/ecos-${ECOS_VER}.i386linux.tar.bz2 touch build.log.download.ok fi # extract if [ ! -f build.log.extract.ok ] ; then rm build.log.extract.ok extract gmp-${GMP_VER}.tar.bz2 extract mpfr-${MPFR_VER}.tar.bz2 extract binutils-${BINUTILS_VER}.tar.bz2 extract gcc-core-${GCC_VER}.tar.bz2 extract gcc-g++-${GCC_VER}.tar.bz2 extract newlib-${NEWLIB_VER}.tar.gz extract insight-${INSIGHT_VER}.tar.bz2 extract ecos-${ECOS_VER}.i386linux.tar.bz2 # bug #patch ${SOURCES}/binutils-${BINUTILS_VER}/bfd/configure < ${BASE}/bfd-no_zlib.patch patch ${SOURCES}/binutils-${BINUTILS_VER}/bfd/configure < ${BASE}/bfd-zlib.patch touch build.log.extract.ok fi # make combined-tree if [ ! -f build.log.combined.ok ] ; then rm build.log.combined.ok rm -fr ${SOURCES}/combined cp -R ${SOURCES}/gcc-${GCC_VER} ${SOURCES}/combined ln -s ${SOURCES}/gmp-${GMP_VER} ${SOURCES}/combined/gmp ln -s ${SOURCES}/mpfr-${MPFR_VER} ${SOURCES}/combined/mpfr ln -s ${SOURCES}/binutils-${BINUTILS_VER}/bfd ${SOURCES}/combined/ ln -s ${SOURCES}/binutils-${BINUTILS_VER}/binutils ${SOURCES}/combined/ ln -s ${SOURCES}/binutils-${BINUTILS_VER}/gas ${SOURCES}/combined/ ln -s ${SOURCES}/binutils-${BINUTILS_VER}/ld ${SOURCES}/combined/ ln -s ${SOURCES}/binutils-${BINUTILS_VER}/opcodes ${SOURCES}/combined/ ln -s ${SOURCES}/binutils-${BINUTILS_VER}/include/* ${SOURCES}/combined/include/ ln -s ${SOURCES}/newlib-${NEWLIB_VER}/newlib ${SOURCES}/combined/ ln -s ${SOURCES}/newlib-${NEWLIB_VER}/libgloss ${SOURCES}/combined/ ln -s ${SOURCES}/insight-${INSIGHT_VER}/gdb ${SOURCES}/combined/ ln -s ${SOURCES}/insight-${INSIGHT_VER}/itcl ${SOURCES}/combined/ ln -s ${SOURCES}/insight-${INSIGHT_VER}/libgui ${SOURCES}/combined/ ln -s ${SOURCES}/insight-${INSIGHT_VER}/readline ${SOURCES}/combined/ ln -s ${SOURCES}/insight-${INSIGHT_VER}/sim ${SOURCES}/combined/ ln -s ${SOURCES}/insight-${INSIGHT_VER}/tcl ${SOURCES}/combined/ ln -s ${SOURCES}/insight-${INSIGHT_VER}/tk ${SOURCES}/combined/ touch build.log.combined.ok fi # configure if [ ! -f build.log.configure.ok ] ; then rm build.log.configure.ok rm -fr ${BUILDS}/combined mkdir -p ${BUILDS}/combined cd ${BUILDS}/combined ${SOURCES}/combined/configure \ --prefix=${PREFIX} \ --target=${TARGET} \ --with-cpu=${TARGET_CPU} \ --with-newlib \ --disable-shared \ --disable-nls \ --disable-libgomp \ --disable-libmudflap \ --disable-libssp \ --enable-languages=c,c++ \ -v touch build.log.configure.ok fi # build and install if [ ! -f build.log.make.ok ] ; then rm build.log.make.ok make && make install touch build.log.make.ok fi # mkdir -p ${BUILDS}/insight-${INSIGHT_VER}/gdb/gdbserver # cd ${BUILDS}/insight-${INSIGHT_VER}/gdb/gdbserver # ASFLAGS="${TARGET_ASFLAGS}" \ # CFLAGS="${TARGET_CFLAGS}" \ # ${SOURCES}/insight-${INSIGHT_VER}/gdb/gdbserver/configure \ # --prefix=${SYSROOT} \ # --host=${TARGET} \ # --build=${HOST} # make # make install } ############################################ # PRISE EN CHARGE PARAMETRES # ############################################ if [ ! "$1" ] then echo $"Usage: $0 {install|clean}" exit 1 fi { while [ "$1" ]; do case "$1" in install) info install ;; clean) rm -fr ${SOURCES} rm -fr ${BUILDS} rm -fr ${PREFIX} rm -fr build.log* rm -fr *~ ;; esac shift done } 2>&1 | tee build.log exit 0