Compile ECWolf on Linux

From ECWolf Wiki

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 root/superuser:

Debian/Ubuntu

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

Fedora

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

openSUSE

zypper install cmake gcc-c++ libSDL-devel libSDL_mixer-devel libSDL_net-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"SDL_net-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 sdl_net zlib bzip2 mercurial make libjpeg-turbo gtk2

Gentoo

emerge -avn dev-util/cmake sys-devel/gcc media-libs/libsdl media-libs/sdl-mixer media-libs/sdl-net \
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_mixer-devel lib"$a"SDL_net-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. To start ECWolf, the following command should work:

./ecwolf

If ECWolf complains you do not have any base game data set up, make sure that you have your Game data files placed in the same directory as ECWolf, in ~/.config/ecwolf or $PROGDIR. Alternatively, you can edit ~/.config/ecwolf/ecwolf.cfg to add the path for your game data to BaseDataPaths.

Current release version

Show the current release version:

cd "$HOME"/ecwolf_build/ecwolf && \
hg identify -r 'max(tagged())'

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, backing up and optionally installing the current release version, run the following:

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

Backup

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

Backup (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" or "Backup (Optional)", the previous files should be located at:

/home/<your username>/ecwolf_build/<your newly created directory>

Updating

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.

Installation

  • ecwolf = Release version
  • ecwolf-alpha = Non-release version

The following steps have 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 and /usr/games/ecwolf-alpha directories:

sudo mkdir -pv /usr/games/{ecwolf,ecwolf-alpha}

Copy ecwolf and ecwolf.pk3 to /usr/games/ecwolf or /usr/games/ecwolf-alpha:

cd "$HOME"/ecwolf_build/ecwolf && \
t="$(hg id -t)" && \
if [ "$t" = "tip" ] || [ -z "$t" ]; then
d="-alpha"
else
d=""
fi && \
sudo cp -v build/{ecwolf,ecwolf.pk3} /usr/games/ecwolf"$d"

Make ecwolf or ecwolf-alpha script, add executable permission and move it to /usr/bin:

cd "$HOME"/ecwolf_build/ecwolf && \
t="$(hg id -t)" && \
if [ "$t" = "tip" ] || [ -z "$t" ]; then
d="-alpha"
else
d=""
fi && cd /tmp && \
echo '#!/bin/sh' > ecwolf"$d" && \
echo >> ecwolf"$d" && \
echo "exec /usr/games/ecwolf"$d"/ecwolf \"\$@\"" >> ecwolf"$d" && \
chmod 755 ecwolf"$d" && \
sudo mv -v ecwolf"$d" /usr/bin

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

Uninstallation

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

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

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

Remove ecwolf-alpha script:

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

Debugging

Prerequisite:

In most cases it is good idea to generate a backtrace 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 backtrace.

gdb ecwolf

Now gdb should have you in its own command prompt. You probably want to log the output, so lets output to a file ecwolfdebug.log.

(gdb) set logging on ecwolfdebug.log

Use "run" to start ecwolf.

(gdb) run

To start and pass command line parameters to ecwolf.

(gdb) run <command line parameters>

Use "bt" to get the backtrace after a crash.

(gdb) bt

All output will be copied into the ecwolfdebug.log, which can then be scrutinized later, or perhaps posted to the Bug Tracker for other developers to look at.

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 ..
USE_LIBTEXTSCREEN=ON Use libtextscreen IWAD picker. Only available in the GPL edition. cmake -DGPL=ON -DUSE_LIBTEXTSCREEN=ON ..
NO_GTK=ON Disable GTK+ IWAD picker. cmake -DNO_GTK=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 ..