0 Building an autotools package: throwaway version
Frank Dana edited this page 2019-10-26 08:22:35 -04:00

Throwaway build to see how MXE works before setting up permanently.

Fetch MXE

export MXE_DIR=~/tmp/mxe
rm -rf $MXE_DIR
git clone --depth 1 --branch master https://github.com/mxe/mxe.git $MXE_DIR

Build cross compiler and required libraries

export MXE_TARGETS='i686-w64-mingw32.static i686-w64-mingw32.static'
make -C $MXE_DIR MXE_TARGETS="$MXE_TARGETS" curl pthreads pdcurses

Read the docs while you wait

There is also a copy in $MXE_DIR/index.html

Create repeatable environment

unset `env | \
    grep -vi '^EDITOR=\|^HOME=\|^LANG=\|MXE\|^PATH=' | \
    grep -vi 'PKG_CONFIG\|PROXY\|^PS1=\|^TERM=' | \
    cut -d '=' -f1 | tr '\n' ' '`

Fetch and build cgminer

export PATH=$MXE_DIR/usr/bin:$PATH
export CGMINER_DIR=~/tmp/cgminer
export INSTALL_PREFIX=$CGMINER_DIR/../usr/local
rm -rf $CGMINER_DIR
git clone --depth 1 --branch master https://github.com/ckolivas/cgminer.git $CGMINER_DIR
cd $CGMINER_DIR && autoreconf -fi

for tgt in $MXE_TARGETS; do \
    rm -rf $CGMINER_DIR.$tgt.build && \
    mkdir $CGMINER_DIR.$tgt.build && \
    cd $CGMINER_DIR.$tgt.build && \
    $CGMINER_DIR/configure \
    --prefix=$INSTALL_PREFIX/$tgt \
    --host=$tgt \
    `[[ $tgt =~ static ]] && echo --disable-shared` \
    --enable-avalon \
    CFLAGS="`$tgt-curl-config --cflags`" && \
    make -j8 && \
    make install; \
done

Confirm the newly installed executables

file $INSTALL_PREFIX/*/bin/* | sed "s,$INSTALL_PREFIX/,,"
ls -lh $INSTALL_PREFIX/*/bin/* | sed "s,$INSTALL_PREFIX/,,"

You should now be able to copy the contents of $INSTALL_PREFIX to a windows machine and test the executables.

MXE is not relocatable, so move the pkg directory from $MXE_DIR to the final installation path before deleting $MXE_DIR.