Difference between revisions of "Compile ECWolf on Linux"

From ECWolf Wiki
Line 17: 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 superuser:
+
Install the following dependencies as root/superuser:
  
 
=== Debian/Ubuntu ===
 
=== Debian/Ubuntu ===
Line 77: Line 77:
 
== Make ecwolf_build directory ==
 
== Make ecwolf_build directory ==
 
<pre>
 
<pre>
mkdir -pv $HOME/ecwolf_build
+
mkdir -pv "$HOME"/ecwolf_build
 
</pre>
 
</pre>
  
 
== Retrieving the Source ==
 
== Retrieving the Source ==
 
Use Mercurial to retrieve the latest version of the source.
 
Use Mercurial to retrieve the latest version of the source.
  cd $HOME/ecwolf_build
+
  cd "$HOME"/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]
  
Line 95: Line 95:
 
  cmake -DCMAKE_BUILD_TYPE=Release -DGPL=ON ..
 
  cmake -DCMAKE_BUILD_TYPE=Release -DGPL=ON ..
 
  make
 
  make
An ecwolf binary should be produced.
+
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.
  
=== Current stable version ===
+
=== Current release version ===
Show the current stable version:
+
Show the current release version:
  cd $HOME/ecwolf_build/ecwolf && \
+
  cd "$HOME"/ecwolf_build/ecwolf && \
  hg identify -r "max(tagged())"
+
  hg identify -r 'max(tagged())'
  
If you want to compile the current stable version, run the following:
+
If you want to compile the current release version, run the following:
  cd $HOME/ecwolf_build/ecwolf && \
+
  cd "$HOME"/ecwolf_build/ecwolf && \
  hg update -cr "max(tagged())"
+
  hg update -cr 'max(tagged())'
 
and [[#Compiling|compile]].
 
and [[#Compiling|compile]].
  
After compiling and backing up the current stable version, run the following:
+
After compiling, [[#Backup|backing up]] and optionally [[#Installation|installing]] the current release version, run the following:
  cd $HOME/ecwolf_build/ecwolf && \
+
  cd "$HOME"/ecwolf_build/ecwolf && \
 
  hg update default
 
  hg update default
  
Line 117: Line 118:
 
Make and name a directory with the corresponding ECWolf version/revision and copy ecwolf and ecwolf.pk3 to it:
 
Make and name a directory with the corresponding ECWolf version/revision and copy ecwolf and ecwolf.pk3 to it:
 
<pre>
 
<pre>
cd $HOME/ecwolf_build && \
+
cd "$HOME"/ecwolf_build/ecwolf/src && \
BACKUPECWOLF="$(sed -n 's/.*#define DOTVERSIONSTR_NOREV "\(.*\)".*/\1/p' \
+
BACKUPECWOLF="$(sed -n 's/.*#define DOTVERSIONSTR_NOREV "\(.*\)".*/\1/p' version.h)\
ecwolf/src/version.h)\
+
$(sed -n 's/.*#define SVN_REVISION_STRING "\(.*\)".*/\-r\1/p' svnrevision.h)" && \
$(sed -n 's/.*#define SVN_REVISION_STRING "\(.*\)".*/\-r\1/p' \
+
cd ../.. && mkdir -pv "$BACKUPECWOLF" && \
ecwolf/src/svnrevision.h)" && \
 
mkdir -pv "$BACKUPECWOLF" && \
 
 
cp -v ecwolf/build/{ecwolf,ecwolf.pk3} "$BACKUPECWOLF"
 
cp -v ecwolf/build/{ecwolf,ecwolf.pk3} "$BACKUPECWOLF"
 
</pre>
 
</pre>
Line 129: Line 128:
 
Make and name a directory with the current year, month, day, hour and minute and copy ecwolf and ecwolf.pk3 to it:
 
Make and name a directory with the current year, month, day, hour and minute and copy ecwolf and ecwolf.pk3 to it:
 
<pre>
 
<pre>
cd $HOME/ecwolf_build && \
+
cd "$HOME"/ecwolf_build && \
BACKUPECW="$(date +%Y%m%d%H%M)" && \
+
BACKUPECW="$(date +'%Y%m%d-%H%M')" && \
 
mkdir -pv "$BACKUPECW" && \
 
mkdir -pv "$BACKUPECW" && \
 
cp -v ecwolf/build/{ecwolf,ecwolf.pk3} "$BACKUPECW"
 
cp -v ecwolf/build/{ecwolf,ecwolf.pk3} "$BACKUPECW"
Line 136: Line 135:
  
 
If you did "Backup" or "Backup (Optional)", the previous files should be located at:
 
If you did "Backup" or "Backup (Optional)", the previous files should be located at:
: '''/home/<your username>/ecwolf_build/'''
+
: '''/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>
 
<pre>
cd $HOME/ecwolf_build/ecwolf && \
+
cd "$HOME"/ecwolf_build/ecwolf && \
 
hg pull ; hg update
 
hg pull ; hg update
 
</pre>
 
</pre>
Line 148: Line 147:
  
 
== Installation ==
 
== Installation ==
'''The following steps contain commands that require to be run as superuser with the sudo command.'''
+
* '''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:
 
If you want to install ECWolf, do the following:
  
Make /usr/games/ecwolf directory:
+
Make /usr/games/ecwolf and /usr/games/ecwolf-alpha directories:
 
<pre>
 
<pre>
sudo mkdir -pv /usr/games/ecwolf
+
sudo mkdir -pv /usr/games/{ecwolf,ecwolf-alpha}
 
</pre>
 
</pre>
  
Copy ecwolf and ecwolf.pk3 to /usr/games/ecwolf:
+
Copy ecwolf and ecwolf.pk3 to /usr/games/ecwolf or /usr/games/ecwolf-alpha:
 
<pre>
 
<pre>
sudo cp -v /home/$USER/ecwolf_build/ecwolf/build/{ecwolf,ecwolf.pk3} /usr/games/ecwolf
+
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"
 
</pre>
 
</pre>
  
Make ecwolf script, add executable permission and copy it to /usr/bin:
+
Make ecwolf or ecwolf-alpha script, add executable permission and move it to /usr/bin:
 
<pre>
 
<pre>
cd /tmp && \
+
cd "$HOME"/ecwolf_build/ecwolf && \
echo '#!/bin/sh' > ecwolf && \
+
t="$(hg id -t)" && \
echo >> ecwolf && \
+
if [ "$t" = "tip" ] || [ -z "$t" ]; then
echo 'exec /usr/games/ecwolf/ecwolf "$@"' >> ecwolf && \
+
d="-alpha"
chmod 755 ecwolf && \
+
else
sudo cp -v ecwolf /usr/bin && \
+
d=""
rm -fv ecwolf
+
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
 
</pre>
 
</pre>
  
Now from a terminal you should be able to execute '''ecwolf''' from any user account.
+
Now from a terminal you should be able to execute '''ecwolf''' or '''ecwolf-alpha''' from any user account.
  
 
=== Uninstallation ===
 
=== Uninstallation ===
Line 188: Line 202:
 
cd /usr/bin && \
 
cd /usr/bin && \
 
sudo rm -fv ecwolf
 
sudo rm -fv ecwolf
 +
</pre>
 +
 +
Remove /usr/games/ecwolf-alpha directory and all its files:
 +
<pre>
 +
cd /usr/games && \
 +
sudo rm -rfv ecwolf-alpha
 +
</pre>
 +
 +
Remove ecwolf-alpha script:
 +
<pre>
 +
cd /usr/bin && \
 +
sudo rm -fv ecwolf-alpha
 
</pre>
 
</pre>
  
Line 195: Line 221:
 
* [http://www.gnu.org/software/gdb/ gdb]
 
* [http://www.gnu.org/software/gdb/ gdb]
  
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.
+
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
 
  cmake -DCMAKE_BUILD_TYPE=Debug
 
  make
 
  make
You should now be able to use gdb to generate a back trace.
+
You should now be able to use gdb to generate a backtrace.
 
  gdb ecwolf
 
  gdb ecwolf
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. You probably want to log the output, so lets output to a file ecwolfdebug.log.
  set logging on ecwolfdebug.log
+
  (gdb) set logging on ecwolfdebug.log
GDB has it's own command prompt. Use "run" to start ecwolf.
+
Use "run" to start ecwolf.
 
  (gdb) run
 
  (gdb) run
 
To start and pass command line parameters to ecwolf.
 
To start and pass command line parameters to ecwolf.
 
  (gdb) run <command line parameters>
 
  (gdb) run <command line parameters>
Use "bt" to get the back trace after a crash.
+
Use "bt" to get the backtrace after a crash.
 
  (gdb) bt
 
  (gdb) bt
To exit GDB's command prompt, use "quit", "q" or Ctrl-D.
+
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.
 
  (gdb) quit
 
  (gdb) quit
  

Revision as of 23:03, 23 September 2016

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 \
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. 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 ..