== Cross-compiling (advanced) == We'll learn how to compile the Windows version from a Linux box. This is more advanced and more complete (we show you how to compile everything, including the libs). You can adapt these instructions to compile Open Surge in other systems (particularly on *nix). If you came here from the web, you can follow these instructions to cross compile Allegro 4.4 as well: === Install MinGW === First of all, we need to install the cross-compiler. Get MinGW on [http://www.mingw.org its website] or, on Debian-based distributions, simply run: sudo apt-get install mingw-w64-i686-dev Now, check where the cross-compiler has been installed. Then, run the following commands (adapt as necessary): TOOLSET="i686-w64-mingw32" MINGDIR="/usr/i686-w64-mingw32" '''Note:''' the 32-bit version of the compiler is required for Allegro 4.4. === Install CMake === Get CMake if you haven't yet. Download it on [https://www.cmake.org its website] or, on Debian-based distributions, run: sudo apt-get install cmake We'll use this tool to help us compile some things. === Compile zlib === Compiling zlib is pretty straighforward: wget https://zlib.net/zlib-1.2.11.tar.gz tar xvzf zlib-1.2.11.tar.gz cd zlib-1.2.11 sed -e s/"PREFIX ="/"PREFIX = ${TOOLSET}-"/ -i win32/Makefile.gcc make -f win32/Makefile.gcc sudo BINARY_PATH=${MINGDIR}/bin \ INCLUDE_PATH=${MINGDIR}/include \ LIBRARY_PATH=${MINGDIR}/lib \ make -f win32/Makefile.gcc install cd .. === Compile libpng === You'll need libpng version 1.2: wget https://download.sourceforge.net/libpng/libpng-1.2.59.tar.gz tar xvzf libpng-1.2.59.tar.gz cd libpng-1.2.59 ./configure \ CC="${TOOLSET}-gcc" \ AR="${TOOLSET}-ar" \ STRIP="${TOOLSET}-strip" \ RANLIB="${TOOLSET}-ranlib" \ CFLAGS="-I${MINGDIR}/include/" \ LDFLAGS="-L${MINGDIR}/lib/" \ --disable-shared \ --target=$TOOLSET \ --host=$TOOLSET \ --prefix=$MINGDIR make sudo make install === Compile libogg === Run this: wget http://downloads.xiph.org/releases/ogg/libogg-1.3.3.tar.gz tar xvzf libogg-1.3.3.tar.gz cd libogg-1.3.3 ./configure \ CC="${TOOLSET}-gcc" \ AR="${TOOLSET}-ar" \ STRIP="${TOOLSET}-strip" \ RANLIB="${TOOLSET}-ranlib" \ CFLAGS="-I${MINGDIR}/include/" \ LDFLAGS="-L${MINGDIR}/lib/" \ --disable-shared \ --target=$TOOLSET \ --host=$TOOLSET \ --prefix=$MINGDIR make sudo make install === Compile libvorbis === Run that: wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.6.tar.gz tar xvzf libvorbis-1.3.6.tar.gz cd libvorbis-1.3.6 ./configure \ CC="${TOOLSET}-gcc" \ AR="${TOOLSET}-ar" \ STRIP="${TOOLSET}-strip" \ RANLIB="${TOOLSET}-ranlib" \ CFLAGS="-I${MINGDIR}/include/" \ LDFLAGS="-L${MINGDIR}/lib/" \ --disable-shared \ --target=$TOOLSET \ --host=$TOOLSET \ --prefix=$MINGDIR make sudo make install === Install the DirectX SDK for MinGW === This will install the DirectX SDK for MinGW: wget https://download.tuxfamily.org/allegro/files/dx70_mgw.zip sudo unzip -a -d$MINGDIR dx70_mgw.zip === Compile Allegro 4.4.2 === To compile Allegro 4.4, first run: wget https://github.com/liballeg/allegro5/releases/download/4.4.2/allegro-4.4.2.zip unzip -a allegro-4.4.2.zip cd allegro In '''cmake/Toolchain-mingw.cmake''', adjust CMAKE_C_COMPILER, CMAKE_CXX_COMPILER and CMAKE_FIND_ROOT_PATH to ${which i686-w64-mingw32-gcc}, ${which i686-w64-mingw32-g++} and $MINGDIR, respectively (evaluate these values yourself and write their paths on the toolchain file). Additionally, set CMAKE_RC_COMPILER to ${which i686-w64-mingw32-windres} and add the command link_libraries("-static-libgcc") to the file. The result will be like this: # # Values to be placed in cmake/Toolchain-mingw.cmake # set(CMAKE_C_COMPILER /usr/bin/i686-w64-mingw32-gcc) set(CMAKE_CXX_COMPILER /usr/bin/i686-w64-mingw32-g++) set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32) set(CMAKE_RC_COMPILER /usr/bin/i686-w64-mingw32-windres) link_libraries("-static-libgcc") Then, run: mkdir build && cd build cmake \ -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw.cmake \ -DCMAKE_INSTALL_PREFIX=$MINGDIR \ -DWANT_EXAMPLES=ON \ -DWANT_ALLEGROGL=OFF \ .. make -j`nproc` sudo make install You're done compiling Allegro! Additionally, run: sudo ln -s $MINGDIR/lib/liballeg44.dll.a $MINGDIR/lib/liballeg.dll.a === Compile Modified Alfont 2.0.9 === Compiling Modified Alfont is a bit more tricky. See [http://opensnc.sourceforge.net/alfont its website] for more information. Run the commands: wget http://opensnc.sourceforge.net/alfont/AlFont209.rar unrar x AlFont209.rar cd alfont wget http://opensnc.sourceforge.net/alfont/alfont.c -O src/alfont.c sh ./fixunix.sh sed -e s/"TARGET=DJGPP_STATIC"/"TARGET=MINGW32_STATIC"/ -i Makefile sed -e s/"CC=gcc"/"CC=${TOOLSET}-gcc"/ -i Makefile make sudo install -m 755 lib/mingw32/libalfont.a ${MINGDIR}/lib sudo install -m 644 include/alfont*.h ${MINGDIR}/include === Compile Open Surge === If you've managed to come so far, congratulations. We're almost there! Get the source code of the game (a recent version) and unpack it to $HOME/opensurge (preferably). Then: cd ~/opensurge mkdir build && cd build cmake \ -DCMAKE_SYSTEM_NAME=Windows \ -DCMAKE_FIND_ROOT_PATH=$MINGDIR \ -DCMAKE_RC_COMPILER=${TOOLSET}-windres \ -DCMAKE_C_COMPILER=${TOOLSET}-gcc \ -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ .. make If everything went well, the opensurge executable will be in the opensurge folder. Make sure to include the Allegro DLL in the folder: cp $MINGDIR/bin/alleg44.dll ~/opensurge That's it! === Testing === '''Optional:''' if you have wine installed in your system, you can test the executable by running wine ~/opensurge/opensurge.exe