Compile ECWolf on Linux

From ECWolf Wiki
Revision as of 06:31, 6 April 2014 by Skyrimguy (talk | contribs) (Latest stable version)

This guide will demonstrate how to compile the Mercurial version of ECWolf on Linux.

Dependencies

The following programs/libraries are used by ECWolf. The versions listed below are known to work, however other versions may work.

In addition to the above, the following are optional dependencies.

Mercurial is also needed to checkout a copy of the latest source.

Install the following dependencies as superuser:

Debian & Ubuntu

sudo apt-get install cmake g++ libsdl1.2-dev libsdl-mixer1.2-dev \
zlib1g-dev libbz2-dev mercurial make libjpeg-dev libgtk2.0-dev

Fedora

yum install cmake gcc-c++ SDL-devel SDL_mixer-devel zlib-devel \
bzip2-devel mercurial make libjpeg-turbo-devel gtk2-devel

OpenSUSE

zypper install cmake gcc-c++ libSDL-devel libSDL_mixer-devel \
zlib-devel libbz2-devel mercurial make libjpeg-devel gtk2-devel

Mageia

if [ "$(uname -m)" = "x86_64" ]; then 
a="64" 
else
a=""
fi && \
urpmi cmake gcc-c++ lib"$a"SDL-devel lib"$a"SDL_mixer-devel \
lib"$a"zlib-devel lib"$a"bzip2-devel mercurial make \
lib"$a"jpeg-devel lib"$a"gtk+2.0-devel lib"$a"cairo-devel

Arch Linux

pacman -S --needed cmake gcc sdl sdl_mixer zlib bzip2 mercurial make libjpeg-turbo gtk2

Gentoo

emerge -avn dev-util/cmake sys-devel/gcc media-libs/libsdl media-libs/sdl-mixer \
sys-libs/zlib app-arch/bzip2 dev-vcs/mercurial sys-devel/make media-libs/libjpeg-turbo \
x11-libs/gtk+

PCLinuxOS

if [ "$(uname -m)" = "x86_64" ]; then 
a="64" 
else
a=""
fi && \
apt-get install cmake gcc-c++ lib"$a"SDL-devel lib"$a"SDL_mixer1.2-devel \
zlib1-devel lib"$a"bzip2-devel mercurial make lib"$a"jpeg62-devel \
lib"$a"gtk+2.0_0-devel

Do the following steps as normal user.

Make ecwolf_build directory

mkdir -pv $HOME/ecwolf_build

Retrieving the Source

Use Mercurial to retrieve the latest version of the source.

cd $HOME/ecwolf_build
hg clone https://bitbucket.org/Blzut3/ecwolf

Compiling

It is recommended that you create a build directory in the newly created ecwolf directory.

cd ecwolf
mkdir build
cd build

Run CMake to generate a Makefile. Assuming there were no errors, you should be able to run make to compile.

If you are going to recompile, it is recommended to run make clean before the following.

cmake -DCMAKE_BUILD_TYPE=Release -DGPL=ON ..
make

An ecwolf binary should be produced.

./ecwolf

Current release version

If you want to compile the current release version, run the following:

cd $HOME/ecwolf_build/ecwolf && \
hg update -cr "max(tagged())"

and compile.

After compiling the current release version, run the following:

cd $HOME/ecwolf_build/ecwolf && \
hg update default

Backup ECWolf

Follow this step if you want or manually copy (backup) ecwolf and ecwolf.pk3.

Make and name a directory with the corresponding ECWolf version/revision and copy ecwolf and ecwolf.pk3 to it:

cd $HOME/ecwolf_build && \
BACKUPECWOLF="$(sed -n 's/.*#define DOTVERSIONSTR_NOREV "\(.*\)".*/\1/p' \
$HOME/ecwolf_build/ecwolf/src/version.h)\
-r$(sed -n 's/.*#define SVN_REVISION_STRING "\(.*\)".*/\1/p' \
$HOME/ecwolf_build/ecwolf/src/svnrevision.h)" && \
mkdir -pv "$BACKUPECWOLF" && \
cp -v ecwolf/build/{ecwolf,ecwolf.pk3} "$BACKUPECWOLF"

Backup ECWolf (Optional)

Make and name a directory with the current year, month, day, hour and minute and copy ecwolf and ecwolf.pk3 to it:

cd $HOME/ecwolf_build && \
BACKUPECW="$(date +%Y%m%d%H%M)" && \
mkdir -pv "$BACKUPECW" && \
cp -v ecwolf/build/{ecwolf,ecwolf.pk3} "$BACKUPECW"

If you did "Backup ECWolf" or "(Optional)", the previous files should be located at:

/home/<your username>/ecwolf_build/

Update ECWolf

When you wish to update ECWolf, copy and paste the following:

cd $HOME/ecwolf_build/ecwolf && \
hg pull ; hg update

When the update finish, go to Compiling.

Install ECWolf

The following steps contain commands that require to be run as superuser with the sudo command.

If you want to install ECWolf, do the following:

Make /usr/games/ecwolf directory:

sudo mkdir -pv /usr/games/ecwolf

Copy ecwolf and ecwolf.pk3 to /usr/games/ecwolf:

sudo cp -v /home/$USER/ecwolf_build/ecwolf/build/{ecwolf,ecwolf.pk3} /usr/games/ecwolf

Make ecwolf script, add executable permission and copy it to /usr/bin:

cd /tmp && \
touch ecwolf && \
echo '#!/bin/bash' >> ecwolf && \
echo '/usr/games/ecwolf/ecwolf "$@"' >> ecwolf && \
echo 'exit $?' >> ecwolf && \
chmod 755 ecwolf && \
sudo cp -v ecwolf /usr/bin && \
rm -fv ecwolf

Now from a terminal you should be able to execute ecwolf from any user account.

Remove ECWolf

To remove the previous installation steps:

Remove /usr/games/ecwolf directory and all its files:

cd /usr/games && \
sudo rm -rfv ecwolf

Remove ecwolf script:

cd /usr/bin && \
sudo rm -fv ecwolf

Debugging

Prerequisite:

In most cases it is good idea to generate a back trace when ECWolf crashes. To make a debug build of ecwolf simply replace the cmake command with the following.

cmake -DCMAKE_BUILD_TYPE=Debug
make

You should now be able to use gdb to generate a back trace.

gdb ecwolf

You probably want to log the output, so lets output to a file ecwolfdebug.log.

set logging on ecwolfdebug.log

GDB has it's own command prompt. Use "run" to start ecwolf and use "bt" to get the back trace after a crash.

(gdb) run
(gdb) bt

To exit GDB's command prompt, use "quit", "q" or Ctrl-D.

(gdb) quit

Build Options

CMake Build Options
Options Description Example
GPL=ON Switch ECWolf's default original non-commercial license to GNU GPL. OPL emulator is changed from MAME's to the one from Dosbox. cmake -DGPL=ON ..
CMake Build Types
Types Description Example
Debug Debug information, -O1 optimization. cmake -DCMAKE_BUILD_TYPE=Debug ..
Release No debug information, -O3 optimization. cmake -DCMAKE_BUILD_TYPE=Release ..
RelWithDebInfo Debug information, -O3 optimization. Useful for finding optimization bugs that only show up in Release. cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
MinSizeRel Similar to Release but with less optimizations in order to save space. cmake -DCMAKE_BUILD_TYPE=MinSizeRel ..