Difference between revisions of "Compile ECWolf on Linux"

From ECWolf Wiki
(Fedora)
Line 1: Line 1:
 
This guide will demonstrate how to compile the Mercurial version of ECWolf on Linux.
 
This guide will demonstrate how to compile the Mercurial version of ECWolf on Linux.
  
== Dependencies ==
+
== Install dependencies ==
 
 
 
The following programs/libraries are used by ECWolf.  The versions listed below are known to work, however other versions may work.
 
The following programs/libraries are used by ECWolf.  The versions listed below are known to work, however other versions may work.
* [http://cmake.org/ CMake] 2.6
 
 
* [http://gcc.gnu.org/ GCC] 4.4.1
 
* [http://gcc.gnu.org/ GCC] 4.4.1
 
* [http://www.gnu.org/software/make/ make]
 
* [http://www.gnu.org/software/make/ make]
 +
* [http://cmake.org/ CMake] 2.6
 
* [http://www.libsdl.org/ libsdl] 1.2
 
* [http://www.libsdl.org/ libsdl] 1.2
 
* [http://maniacsvault.net/ecwolf/files/tools/dev/ SDL_mixer for ECWolf] (Standard [http://www.libsdl.org/projects/SDL_mixer/release-1.2.html SDL_mixer] 1.2 will also work, but features will be disabled.)
 
* [http://maniacsvault.net/ecwolf/files/tools/dev/ SDL_mixer for ECWolf] (Standard [http://www.libsdl.org/projects/SDL_mixer/release-1.2.html SDL_mixer] 1.2 will also work, but features will be disabled.)
Line 18: Line 17:
 
[http://tortoisehg.bitbucket.org/ Mercurial] is also needed to checkout a copy of the latest source.
 
[http://tortoisehg.bitbucket.org/ Mercurial] is also needed to checkout a copy of the latest source.
  
Install the following dependencies as root/superuser:
+
Install the following as root/superuser:
  
 
=== Debian/Ubuntu ===
 
=== Debian/Ubuntu ===
 
<pre>
 
<pre>
sudo apt-get install cmake g++ libsdl1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev \
+
sudo apt-get install g++ make cmake libsdl1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev \
zlib1g-dev libbz2-dev mercurial make libjpeg-dev libgtk2.0-dev
+
mercurial zlib1g-dev libbz2-dev libjpeg-dev libgtk2.0-dev
 
</pre>
 
</pre>
  
 
=== Fedora ===
 
=== Fedora ===
 
<pre>
 
<pre>
dnf install cmake gcc-c++ SDL-devel SDL_mixer-devel SDL_net-devel zlib-devel \
+
dnf install gcc-c++ make cmake SDL-devel SDL_mixer-devel SDL_net-devel mercurial \
bzip2-devel mercurial make libjpeg-turbo-devel gtk2-devel
+
zlib-devel bzip2-devel libjpeg-turbo-devel gtk2-devel
 
</pre>
 
</pre>
  
 
=== openSUSE ===
 
=== openSUSE ===
 
<pre>
 
<pre>
zypper install cmake gcc-c++ libSDL-devel libSDL_mixer-devel libSDL_net-devel \
+
zypper install gcc-c++ make cmake libSDL-devel libSDL_mixer-devel libSDL_net-devel \
zlib-devel libbz2-devel mercurial make libjpeg-devel gtk2-devel
+
mercurial zlib-devel libbz2-devel libjpeg-devel gtk2-devel
 
</pre>
 
</pre>
  
Line 41: Line 40:
 
<pre>
 
<pre>
 
a='' && [ "$(uname -m)" = x86_64 ] && a=64
 
a='' && [ "$(uname -m)" = x86_64 ] && a=64
urpmi cmake gcc-c++ lib"$a"SDL-devel lib"$a"SDL_mixer-devel lib"$a"SDL_net-devel \
+
urpmi gcc-c++ make cmake lib${a}SDL-devel lib${a}SDL_mixer-devel \
lib"$a"zlib-devel lib"$a"bzip2-devel mercurial make \
+
lib${a}SDL_net-devel mercurial lib${a}zlib-devel lib${a}bzip2-devel \
lib"$a"jpeg-devel lib"$a"gtk+2.0-devel lib"$a"cairo-devel
+
lib${a}jpeg-devel lib${a}gtk+2.0-devel lib${a}cairo-devel
 
</pre>
 
</pre>
  
 
=== Arch Linux ===
 
=== Arch Linux ===
 
<pre>
 
<pre>
pacman -S --needed cmake gcc sdl sdl_mixer sdl_net zlib bzip2 mercurial make libjpeg-turbo gtk2
+
pacman -S --needed gcc make cmake sdl sdl_mixer sdl_net mercurial zlib bzip2 libjpeg-turbo gtk2
 
</pre>
 
</pre>
  
 
=== Gentoo ===
 
=== Gentoo ===
 
<pre>
 
<pre>
emerge -avn dev-util/cmake sys-devel/gcc media-libs/libsdl media-libs/sdl-mixer media-libs/sdl-net \
+
emerge -avn sys-devel/gcc sys-devel/make dev-util/cmake media-libs/libsdl \
sys-libs/zlib app-arch/bzip2 dev-vcs/mercurial sys-devel/make media-libs/libjpeg-turbo \
+
media-libs/sdl-mixer media-libs/sdl-net dev-vcs/mercurial sys-libs/zlib \
x11-libs/gtk+
+
app-arch/bzip2 media-libs/libjpeg-turbo x11-libs/gtk+
 
</pre>
 
</pre>
  
Line 61: Line 60:
 
<pre>
 
<pre>
 
a='' && [ "$(uname -m)" = x86_64 ] && a=64
 
a='' && [ "$(uname -m)" = x86_64 ] && a=64
apt-get install cmake gcc-c++ lib"$a"SDL-devel lib"$a"SDL_mixer-devel lib"$a"SDL_net-devel \
+
apt-get install gcc-c++ make cmake lib${a}SDL-devel lib${a}SDL_mixer-devel \
zlib1-devel lib"$a"bzip2-devel mercurial make lib"$a"jpeg62-devel \
+
lib${a}SDL_net-devel mercurial zlib1-devel lib${a}bzip2-devel lib${a}jpeg62-devel \
lib"$a"gtk+2.0_0-devel
+
lib${a}gtk+2.0_0-devel
 
</pre>
 
</pre>
  
'''Do the following steps as normal user.'''
+
=== Solus ===
 
 
== Make ecwolf_build directory ==
 
 
<pre>
 
<pre>
mkdir -pv "$HOME"/ecwolf_build
+
sudo eopkg install g++ make cmake binutils glibc-devel pkg-config \
 +
sdl1-devel sdl1-mixer-devel sdl1-net-devel mercurial zlib-devel \
 +
bzip2-devel libjpeg-turbo-devel libgtk-2-devel
 
</pre>
 
</pre>
  
== Retrieving the Source ==
+
'''Do the following sections as normal user.'''
Use Mercurial to retrieve the latest version of the source.
+
 
  cd "$HOME"/ecwolf_build
+
== Create ecwolf_build directory ==
 +
mkdir -pv ~/ecwolf_build
 +
 
 +
== Download and prepare the source ==
 +
Use Mercurial to download the ECWolf source:
 +
  cd ~/ecwolf_build
 
  hg clone [https://bitbucket.org/Blzut3/ecwolf https://bitbucket.org/Blzut3/ecwolf]
 
  hg clone [https://bitbucket.org/Blzut3/ecwolf https://bitbucket.org/Blzut3/ecwolf]
 +
and create an out of tree build directory in the newly created ecwolf directory:
 +
mkdir -pv ecwolf/build
  
 
== Compiling ==
 
== Compiling ==
It is recommended that you create a build directory in the newly created ecwolf directory.
+
Inside the build directory, run CMake to generate a Makefile:
  cd ecwolf
+
  cd ~/ecwolf_build/ecwolf/build
mkdir build
+
  cmake .. -DCMAKE_BUILD_TYPE=Release -DGPL=ON
  cd build
+
Assuming there were no errors, you should be able to run make to compile:
Run CMake to generate a Makefile.  Assuming there were no errors, you should be able to run make to compile.
+
make
 +
A development version of ECWolf will be compiled if you do not do [[#Latest stable version]].
  
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:
 
An ecwolf binary should be produced. To start ECWolf, the following command should work:
 
  ./ecwolf
 
  ./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.
 
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 ===
+
=== Latest stable version ===
Show the current release version:
+
Show the latest stable version:
  cd "$HOME"/ecwolf_build/ecwolf && \
+
  cd ~/ecwolf_build/ecwolf &&
 
  hg identify -r 'max(tagged())'
 
  hg identify -r 'max(tagged())'
  
If you want to compile the current release version, run the following:
+
If you want to compile the latest stable version, run:
  cd "$HOME"/ecwolf_build/ecwolf && \
+
  cd ~/ecwolf_build/ecwolf &&
 
  hg update -cr 'max(tagged())'
 
  hg update -cr 'max(tagged())'
 
and [[#Compiling|compile]].
 
and [[#Compiling|compile]].
  
After compiling, [[#Backup|backing up]] and optionally [[#Installation|installing]] the current release version, run the following:
+
After compiling, [[#Backup|backing up]] and optionally [[#Installation|installing]] the latest stable version, run:
  cd "$HOME"/ecwolf_build/ecwolf && \
+
  cd ~/ecwolf_build/ecwolf &&
 
  hg update default
 
  hg update default
  
 
== Backup ==
 
== Backup ==
Follow this step if you want or manually copy (backup) ecwolf and ecwolf.pk3.
+
If you want to backup ECWolf, do the following:
  
Make and name a directory with the corresponding ECWolf version/revision and copy ecwolf and ecwolf.pk3 to it:
+
Create and name a directory with the corresponding ECWolf version/revision, build type and copy ecwolf and ecwolf.pk3 to it:
 
<pre>
 
<pre>
cd "$HOME"/ecwolf_build/ecwolf/src && \
+
cd ~/ecwolf_build/ecwolf/build &&
BACKUPECWOLF="$(sed -n 's/.*#define DOTVERSIONSTR_NOREV "\(.*\)".*/\1/p' version.h)\
+
if [ -f CMakeCache.txt ]; then
$(sed -n 's/.*#define SVN_REVISION_STRING "\(.*\)".*/\-r\1/p' svnrevision.h)" && \
+
k="$(sed -n 's/.*CMAKE_BUILD_TYPE:STRING=\(.*\)/\1/p' CMakeCache.txt)"; else k=''; fi &&
cd ../.. && mkdir -pv "$BACKUPECWOLF" && \
+
if [ -n "$k" ]; then b="-BuildType$k"; else b=''; fi &&
cp -v ecwolf/build/{ecwolf,ecwolf.pk3} "$BACKUPECWOLF"
+
h="$(sed -n 's/.*#define HG_REVISION_HASH_STRING "\(.*\)".*/\1/p' ../src/svnrevision.h)" &&
 +
BACKUPECWOLF="../../$(hg cat -r $h ../src/version.h | sed -n 's/.*#define DOTVERSIONSTR_NOREV "\(.*\)".*/\1/p')\
 +
$(sed -n 's/.*#define SVN_REVISION_STRING "\(.*\)".*/\-r\1/p' ../src/svnrevision.h)-$h$b" &&
 +
mkdir -pv "$BACKUPECWOLF" &&
 +
cp -v ecwolf ecwolf.pk3 "$BACKUPECWOLF"/
 
</pre>
 
</pre>
  
=== Backup (Optional) ===
+
Files are located at:
Make and name a directory with the current year, month, day, hour and minute and copy ecwolf and ecwolf.pk3 to it:
 
<pre>
 
cd "$HOME"/ecwolf_build && \
 
BACKUPECW="$(date +'%Y%m%d-%H%M')" && \
 
mkdir -pv "$BACKUPECW" && \
 
cp -v ecwolf/build/{ecwolf,ecwolf.pk3} "$BACKUPECW"
 
</pre>
 
  
If you did "Backup" or "Backup (Optional)", the previous files should be located at:
+
/home/<your username>/ecwolf_build/<your newly created directory>
: '''/home/<your username>/ecwolf_build/<your newly created directory>'''
 
  
 
== Updating ==
 
== Updating ==
 
When you wish to update ECWolf, copy and paste the following:
 
When you wish to update ECWolf, copy and paste the following:
<pre>
+
cd ~/ecwolf_build/ecwolf &&
cd "$HOME"/ecwolf_build/ecwolf && \
+
hg pull ; hg update
hg pull ; hg update
 
</pre>
 
  
 
When the update finish, go to [[#Compiling]].
 
When the update finish, go to [[#Compiling]].
  
 
== Installation ==
 
== Installation ==
* '''ecwolf''' = Release version
+
* '''ecwolf''' = Stable version
* '''ecwolf-alpha''' = Non-release version
+
* '''ecwolf-alpha''' = Development version
  
'''The following steps have commands that require to be run as superuser with the sudo command.'''
+
Commands beginning with "sudo" will require temporary superuser privileges.
  
 
If you want to install ECWolf, do the following:
 
If you want to install ECWolf, do the following:
  
Make /usr/games/ecwolf and /usr/games/ecwolf-alpha directories:
+
Create /usr/games/ecwolf and /usr/games/ecwolf-alpha directories:
<pre>
+
sudo mkdir -pv /usr/games/ecwolf /usr/games/ecwolf-alpha
sudo mkdir -pv /usr/games/{ecwolf,ecwolf-alpha}
 
</pre>
 
  
Copy ecwolf and ecwolf.pk3 to /usr/games/ecwolf or /usr/games/ecwolf-alpha:
+
Copy ecwolf and ecwolf.pk3 to /usr/games/ecwolf/ or /usr/games/ecwolf-alpha/:
 
<pre>
 
<pre>
cd "$HOME"/ecwolf_build/ecwolf && \
+
cd ~/ecwolf_build/ecwolf/build &&
t="$(hg id -t)" && \
+
h="$(sed -n 's/.*#define HG_REVISION_HASH_STRING "\(.*\)".*/\1/p' ../src/svnrevision.h)" &&
d='' && [ "$t" = tip ] || [ -z "$t" ] && d=-alpha ; \
+
t="$(hg id -tr $h)" &&
sudo cp -v build/{ecwolf,ecwolf.pk3} /usr/games/ecwolf"$d"
+
if [ "$t" = tip ] || [ -z "$t" ]; then d=-alpha; else d=''; fi &&
 +
sudo cp -v ecwolf ecwolf.pk3 /usr/games/ecwolf$d/
 
</pre>
 
</pre>
  
Make ecwolf or ecwolf-alpha script, add executable permission and move it to /usr/bin:
+
Create launch script:
 
<pre>
 
<pre>
cd "$HOME"/ecwolf_build/ecwolf && \
+
cd ~/ecwolf_build/ecwolf/build &&
t="$(hg id -t)" && \
+
h="$(sed -n 's/.*#define HG_REVISION_HASH_STRING "\(.*\)".*/\1/p' ../src/svnrevision.h)" &&
d='' && [ "$t" = tip ] || [ -z "$t" ] && d=-alpha ; \
+
t="$(hg id -tr $h)" &&
cd /tmp && \
+
if [ "$t" = tip ] || [ -z "$t" ]; then d=-alpha; else d=''; fi &&
echo '#!/bin/sh' > ecwolf"$d" && \
+
printf %s "\
echo >> ecwolf"$d" && \
+
#!/bin/sh
echo "exec /usr/games/ecwolf"$d"/ecwolf \"\$@\"" >> ecwolf"$d" && \
+
exec /usr/games/ecwolf$d/ecwolf \"\$@\"
chmod 755 ecwolf"$d" && \
+
" > ecwolf$d.sh &&
sudo mv -v ecwolf"$d" /usr/bin
+
chmod 755 ecwolf$d.sh &&
 +
sudo mv -v ecwolf$d.sh /usr/bin/ecwolf$d
 
</pre>
 
</pre>
  
Now from a terminal you should be able to execute '''ecwolf''' or '''ecwolf-alpha''' from any user account.
+
Now from a terminal you should be able to run '''ecwolf''' or '''ecwolf-alpha''' from any user account.
  
 
=== Uninstallation ===
 
=== Uninstallation ===
To remove the previous installation steps:
 
 
 
Remove /usr/games/ecwolf directory and all its files:
 
Remove /usr/games/ecwolf directory and all its files:
<pre>
+
sudo rm -rfv /usr/games/ecwolf
sudo rm -rfv /usr/games/ecwolf
 
</pre>
 
  
 
Remove ecwolf script:
 
Remove ecwolf script:
<pre>
+
sudo rm -fv /usr/bin/ecwolf
sudo rm -fv /usr/bin/ecwolf
 
</pre>
 
  
 
Remove /usr/games/ecwolf-alpha directory and all its files:
 
Remove /usr/games/ecwolf-alpha directory and all its files:
<pre>
+
sudo rm -rfv /usr/games/ecwolf-alpha
sudo rm -rfv /usr/games/ecwolf-alpha
 
</pre>
 
  
 
Remove ecwolf-alpha script:
 
Remove ecwolf-alpha script:
<pre>
+
sudo rm -fv /usr/bin/ecwolf-alpha
sudo rm -fv /usr/bin/ecwolf-alpha
+
 
</pre>
+
== Developing ==
 +
This page has helped you compile ECWolf, but perhaps you are interested in debugging the code or submitting code changes or fixes for inclusion. This section is intended for more advanced users who may be unfamiliar to CMake or debugging on Linux systems.
  
== Debugging ==
+
=== Debugging ===
 
'''Prerequisite:'''
 
'''Prerequisite:'''
  
 
* [http://www.gnu.org/software/gdb/ gdb]
 
* [http://www.gnu.org/software/gdb/ gdb]
  
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.
+
Maybe you have found a way to make ECWolf crash, and are interested in debugging it. First, you need to compile a debug build of ECWolf. Inside the build directory, invoke CMake to set up for compiling, but this time, the build type is set to Debug:
  cmake -DCMAKE_BUILD_TYPE=Debug
+
cd ~/ecwolf_build/ecwolf/build
 +
  cmake .. -DCMAKE_BUILD_TYPE=Debug
 +
Optionally, you may want to use some of the [[#Build options]].
 +
 
 +
After CMake is done, run "make" or to speed up compilation, run "make -j<number>", a recommended value for the "-j" option is the number of physical cores:
 
  make
 
  make
You should now be able to use gdb to generate a backtrace.
+
 
 +
To run ECWolf under a debugger such as gdb, use the following command:
 
  gdb ecwolf
 
  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.
+
 
 +
Now gdb should have you in its own command prompt:
 +
(gdb)
 +
 
 +
You probably want to log the output, so lets output to a file ecwolfdebug.log:
 
  (gdb) set logging on ecwolfdebug.log
 
  (gdb) set logging on ecwolfdebug.log
Use "run" to start ecwolf.
+
 
 +
Now start ECWolf by typing in run, and pressing enter:
 
  (gdb) run
 
  (gdb) run
To start and pass command line parameters to ecwolf.
+
 
 +
Or put any command line parameters to ecwolf after run:
 
  (gdb) run <command line parameters>
 
  (gdb) run <command line parameters>
Use "bt" to get the backtrace after a crash.
+
To see the available command line parameters for ECWolf, type "run --help" and press enter.
  (gdb) bt
+
 
 +
If ECWolf crashes, gdb may be able to tell you the source file and line number it crashed in. Typing in the command backtrace or bt will produce information telling the last function calls, showing how execution got to the point where it crashed:
 +
  (gdb) backtrace
 
All output will be copied into the ecwolfdebug.log, which can then be scrutinized later, or perhaps posted to the [https://bitbucket.org/Blzut3/ecwolf/issues Bug Tracker] for other developers to look at.
 
All output will be copied into the ecwolfdebug.log, which can then be scrutinized later, or perhaps posted to the [https://bitbucket.org/Blzut3/ecwolf/issues Bug Tracker] for other developers to look at.
  
To exit gdb's command prompt, use "quit", "q" or Ctrl-D.
+
To exit gdb's command prompt, type quit, q or press Ctrl-D:
 
  (gdb) quit
 
  (gdb) quit
 +
If you want to free up space, run "make clean" to remove the files generated by the compilation.
  
== Build Options ==
+
=== Build options ===
 
{|class="wikitable" width="100%"
 
{|class="wikitable" width="100%"
|+ <span style="text-decoration: underline">CMake Build Options</span>
+
|+ <span style="text-decoration: underline">CMake options</span>
 
|-
 
|-
 
!width="15%"|Options!!width="45%"|Description!!width="40%"|Example
 
!width="15%"|Options!!width="45%"|Description!!width="40%"|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 ..
+
|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
 
|-
 
|-
|USE_LIBTEXTSCREEN=ON||Use libtextscreen IWAD picker. Only available in the GPL edition.||cmake -DGPL=ON -DUSE_LIBTEXTSCREEN=ON ..
+
|CMAKE_C_COMPILER||Set path for C compiler.||cmake .. -DCMAKE_C_COMPILER=/path/to/compiler/gcc
 
|-
 
|-
|NO_GTK=ON||Disable GTK+ IWAD picker.||cmake -DNO_GTK=ON ..
+
|CMAKE_CXX_COMPILER||Set path for C++ compiler.||cmake .. -DCMAKE_CXX_COMPILER=/path/to/compiler/g++
 
|}
 
|}
  
{|class="wikitable" width="80%"
+
{|class="wikitable" width="100%"
|+ <span style="text-decoration: underline">CMake Build Types</span>
+
|+ <span style="text-decoration: underline">CMake build types</span>
 
|-
 
|-
 
!width="10%"|Types!!width="45%"|Description!!width="45%"|Example
 
!width="10%"|Types!!width="45%"|Description!!width="45%"|Example
 
|-
 
|-
|Debug||Debug information, -O1 optimization.||cmake -DCMAKE_BUILD_TYPE=Debug ..
+
|Debug||Debug information, -O1 optimization.||cmake .. -DCMAKE_BUILD_TYPE=Debug
 
|-
 
|-
|Release||No debug information, -O3 optimization.||cmake -DCMAKE_BUILD_TYPE=Release ..
+
|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 ..
+
|RelWithDebInfo||Debug information, -O2 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 ..
+
|MinSizeRel||Similar to Release but with less optimizations in order to save space.||cmake .. -DCMAKE_BUILD_TYPE=MinSizeRel
 
|}
 
|}

Revision as of 00:41, 23 December 2017

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

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

Debian/Ubuntu

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

Fedora

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

openSUSE

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

Mageia

a='' && [ "$(uname -m)" = x86_64 ] && a=64
urpmi gcc-c++ make cmake lib${a}SDL-devel lib${a}SDL_mixer-devel \
lib${a}SDL_net-devel mercurial lib${a}zlib-devel lib${a}bzip2-devel \
lib${a}jpeg-devel lib${a}gtk+2.0-devel lib${a}cairo-devel

Arch Linux

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

Gentoo

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

PCLinuxOS

a='' && [ "$(uname -m)" = x86_64 ] && a=64
apt-get install gcc-c++ make cmake lib${a}SDL-devel lib${a}SDL_mixer-devel \
lib${a}SDL_net-devel mercurial zlib1-devel lib${a}bzip2-devel lib${a}jpeg62-devel \
lib${a}gtk+2.0_0-devel

Solus

sudo eopkg install g++ make cmake binutils glibc-devel pkg-config \
sdl1-devel sdl1-mixer-devel sdl1-net-devel mercurial zlib-devel \
bzip2-devel libjpeg-turbo-devel libgtk-2-devel

Do the following sections as normal user.

Create ecwolf_build directory

mkdir -pv ~/ecwolf_build

Download and prepare the source

Use Mercurial to download the ECWolf source:

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

and create an out of tree build directory in the newly created ecwolf directory:

mkdir -pv ecwolf/build

Compiling

Inside the build directory, run CMake to generate a Makefile:

cd ~/ecwolf_build/ecwolf/build
cmake .. -DCMAKE_BUILD_TYPE=Release -DGPL=ON

Assuming there were no errors, you should be able to run make to compile:

make

A development version of ECWolf will be compiled if you do not do #Latest stable version.

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.

Latest stable version

Show the latest stable version:

cd ~/ecwolf_build/ecwolf &&
hg identify -r 'max(tagged())'

If you want to compile the latest stable version, run:

cd ~/ecwolf_build/ecwolf &&
hg update -cr 'max(tagged())'

and compile.

After compiling, backing up and optionally installing the latest stable version, run:

cd ~/ecwolf_build/ecwolf &&
hg update default

Backup

If you want to backup ECWolf, do the following:

Create and name a directory with the corresponding ECWolf version/revision, build type and copy ecwolf and ecwolf.pk3 to it:

cd ~/ecwolf_build/ecwolf/build &&
if [ -f CMakeCache.txt ]; then
k="$(sed -n 's/.*CMAKE_BUILD_TYPE:STRING=\(.*\)/\1/p' CMakeCache.txt)"; else k=''; fi &&
if [ -n "$k" ]; then b="-BuildType$k"; else b=''; fi &&
h="$(sed -n 's/.*#define HG_REVISION_HASH_STRING "\(.*\)".*/\1/p' ../src/svnrevision.h)" &&
BACKUPECWOLF="../../$(hg cat -r $h ../src/version.h | sed -n 's/.*#define DOTVERSIONSTR_NOREV "\(.*\)".*/\1/p')\
$(sed -n 's/.*#define SVN_REVISION_STRING "\(.*\)".*/\-r\1/p' ../src/svnrevision.h)-$h$b" &&
mkdir -pv "$BACKUPECWOLF" &&
cp -v ecwolf ecwolf.pk3 "$BACKUPECWOLF"/

Files are located at:

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

Updating

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

cd ~/ecwolf_build/ecwolf &&
hg pull ; hg update

When the update finish, go to #Compiling.

Installation

  • ecwolf = Stable version
  • ecwolf-alpha = Development version

Commands beginning with "sudo" will require temporary superuser privileges.

If you want to install ECWolf, do the following:

Create /usr/games/ecwolf and /usr/games/ecwolf-alpha directories:

sudo mkdir -pv /usr/games/ecwolf /usr/games/ecwolf-alpha

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

cd ~/ecwolf_build/ecwolf/build &&
h="$(sed -n 's/.*#define HG_REVISION_HASH_STRING "\(.*\)".*/\1/p' ../src/svnrevision.h)" &&
t="$(hg id -tr $h)" &&
if [ "$t" = tip ] || [ -z "$t" ]; then d=-alpha; else d=''; fi &&
sudo cp -v ecwolf ecwolf.pk3 /usr/games/ecwolf$d/

Create launch script:

cd ~/ecwolf_build/ecwolf/build &&
h="$(sed -n 's/.*#define HG_REVISION_HASH_STRING "\(.*\)".*/\1/p' ../src/svnrevision.h)" &&
t="$(hg id -tr $h)" &&
if [ "$t" = tip ] || [ -z "$t" ]; then d=-alpha; else d=''; fi &&
printf %s "\
#!/bin/sh
exec /usr/games/ecwolf$d/ecwolf \"\$@\"
" > ecwolf$d.sh &&
chmod 755 ecwolf$d.sh &&
sudo mv -v ecwolf$d.sh /usr/bin/ecwolf$d

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

Uninstallation

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

sudo rm -rfv /usr/games/ecwolf

Remove ecwolf script:

sudo rm -fv /usr/bin/ecwolf

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

sudo rm -rfv /usr/games/ecwolf-alpha

Remove ecwolf-alpha script:

sudo rm -fv /usr/bin/ecwolf-alpha

Developing

This page has helped you compile ECWolf, but perhaps you are interested in debugging the code or submitting code changes or fixes for inclusion. This section is intended for more advanced users who may be unfamiliar to CMake or debugging on Linux systems.

Debugging

Prerequisite:

Maybe you have found a way to make ECWolf crash, and are interested in debugging it. First, you need to compile a debug build of ECWolf. Inside the build directory, invoke CMake to set up for compiling, but this time, the build type is set to Debug:

cd ~/ecwolf_build/ecwolf/build
cmake .. -DCMAKE_BUILD_TYPE=Debug

Optionally, you may want to use some of the #Build options.

After CMake is done, run "make" or to speed up compilation, run "make -j<number>", a recommended value for the "-j" option is the number of physical cores:

make

To run ECWolf under a debugger such as gdb, use the following command:

gdb ecwolf

Now gdb should have you in its own command prompt:

(gdb)

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

(gdb) set logging on ecwolfdebug.log

Now start ECWolf by typing in run, and pressing enter:

(gdb) run

Or put any command line parameters to ecwolf after run:

(gdb) run <command line parameters>

To see the available command line parameters for ECWolf, type "run --help" and press enter.

If ECWolf crashes, gdb may be able to tell you the source file and line number it crashed in. Typing in the command backtrace or bt will produce information telling the last function calls, showing how execution got to the point where it crashed:

(gdb) backtrace

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, type quit, q or press Ctrl-D:

(gdb) quit

If you want to free up space, run "make clean" to remove the files generated by the compilation.

Build options

CMake 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_C_COMPILER Set path for C compiler. cmake .. -DCMAKE_C_COMPILER=/path/to/compiler/gcc
CMAKE_CXX_COMPILER Set path for C++ compiler. cmake .. -DCMAKE_CXX_COMPILER=/path/to/compiler/g++
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, -O2 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