#!/bin/bash TARGET_PATH=$1 [[ "$TARGET_PATH" == "" ]] && TARGET_PATH="/home/share/tool" [[ ! -d "$TARGET_PATH" ]] && mkdir -p $TARGET_PATH BUILD_PATH=$TARGET_PATH/mingw-build STAGE_PATH=$TARGET_PATH/mingw-staging THIS_PATH=$(pwd) # setup environment export XTOOLDIR=$TARGET_PATH/mingw export STAGEDIR=$STAGE_PATH export TARGET=i686-pc-mingw32 export BUILDHOST=i686-slackware-linux # staging should not be existing! [[ -d "$STAGE_PATH" ]] && echo "$STAGE_PATH exists! Check path!" && exit 1 # create build and staging directories mkdir -p $BUILD_PATH $STAGE_PATH # copy the two source files into build for src in *-mingw32-src.tar.lzma ; do cp $src $BUILD_PATH ; done # copy the rest into staging for pkg in *.lzma *.gz ; do [[ "${pkg//-mingw32-src/}" != $pkg ]] && continue ; cp $pkg $STAGE_PATH; done # extract the files in staging cd $STAGE_PATH ; for pkg in *.lzma *.gz ; do tar xf $pkg ; rm $pkg ; done # build binutils cd $BUILD_PATH tar xf binutils-2.21-3-mingw32-src.tar.lzma # binutils package should already be extracted here mkdir binutils-build cd binutils-build ../binutils-2.21/configure --prefix=$XTOOLDIR --build=$BUILDHOST --host=$BUILDHOST \ --target=$TARGET --disable-nls --disable-interwork --disable-multilib \ --with-headers=$STAGEDIR/include --with-libs=$STAGEDIR/lib --with-sysroot=$STAGEDIR make make install # build gcc cd $BUILD_PATH tar xf gcc-4.5.2-1-mingw32-src.tar.lzma tar xf gcc-4.5.2.tar.bz2 # gcc package should already be extracted here mkdir gcc-build cd gcc-build export PATH=$XTOOLDIR/bin:$PATH ../gcc-4.5.2/configure --prefix=$XTOOLDIR --build=$BUILDHOST --host=$BUILDHOST \ --target=$TARGET --disable-nls --enable-interwork --disable-multilib \ --enable-threads --enable-languages=c,c++ --with-headers=$STAGEDIR/include \ --with-libs=$STAGEDIR/lib --with-sysroot=$STAGEDIR # create dummy folder to satisfy fixinc.sh ( cd $STAGEDIR; mkdir mingw; cd mingw; ln -sf ../include include ) make make install cd $THIS_PATH # build wxwidgets if available WXWIDGETS_NAME="wxWidgets" WXWIDGETS_VERS="2.9.4" WXWIDGETS_FULL="${WXWIDGETS_NAME}-${WXWIDGETS_VERS}" if [[ -f "${THIS_PATH}/${WXWIDGETS_FULL}.tar.bz2" ]] ; then echo "Building ${WXWIDGETS_FULL}..." cd $BUILD_PATH tar xf ${THIS_PATH}/${WXWIDGETS_FULL}.tar.bz2 cd ${WXWIDGETS_FULL} CFLAGS="-I$XTOOLDIR/include" CXXFLAGS="-I$XTOOLDIR/include" PATH=$XTOOLDIR/bin:$PATH ./configure --prefix=$XTOOLDIR \ --build=$BUILDHOST --host=$TARGET --disable-unicode --disable-shared CFLAGS="-I$XTOOLDIR/include" CXXFLAGS="-I$XTOOLDIR/include" PATH=$XTOOLDIR/bin:$PATH make CFLAGS="-I$XTOOLDIR/include" CXXFLAGS="-I$XTOOLDIR/include" PATH=$XTOOLDIR/bin:$PATH make install echo "Done." fi