Compiling Zandronum on Linux: Difference between revisions

From Zandronum Wiki
No edit summary
No edit summary
Line 1: Line 1:
'''Open a terminal and copy and paste the whole code box for each step.'''
'''Open a terminal and copy and paste the whole code box for each step.'''


== Notes ==
== Install dependencies ==
If you are going to compile Zandronum 1.0 (120819-2011) and your Mesa version is 9.x or greater, apply the fix found [http://zandronum.com/tracker/view.php?id=1302 here], otherwise the zandronum client will not compile.
[http://zandronum.com/ Zandronum] needs certain tools and development files in order to compile:
 
* '''Required'''
If you need to compile Zandronum 2.x or lower, you will need to install gcc 4.9 or lower:
** gcc 4.6 or later
<pre>
** make
sudo apt-get install gcc-4.9 g++-4.9
** cmake 2.8.7 or later
</pre>
** SDL 1.2.8 or later 1.2.x versions
 
** libGL and libGLU ''(SDL or libSDL pull in libGLU)'' or any other GL implementation provider.
and set this variables according to the gcc version before compiling:
** [http://zandronum.com/essentials/fmod/ FMOD Ex] 4.24.16
<pre>
** libopenssl ''(for Zandronum 1.3 or later)''
export CC="gcc-4.9"
** SQLite ''(for Zandronum 1.3 or later)''
export CXX="g++-4.9"
* '''Recommended'''
</pre>
** GTK2
 
** mercurial ''(needed in order to [https://bitbucket.org/Torr_Samaho/zandronum download the source] and compile in commit meta data)''
== Prerequisites ==
** nasm 0.98.39 or later ''(x86-32 only)''
Zandronum requires some tools and development files in order to compile:
* '''Optional'''
* gcc - C and C++ compilers >= 3.4.6
** zlib ''(Zandronum has a copy of it and will be statically compiled in if not found)''
* make
** libbzip2 ''(possibly static)''
* cmake >= 2.4
** libjpeg ''(possibly static)''
* SDL >= 1.2.8
* '''Runtime'''
* libGL and libGLU ''(SDL or libSDL pull in libGLU)''; or any other GL implementation provider.
** gxmessage ''(optional - needed to show the crash log in a window)''
* fmodex = 4.24.16
** kdialog ''(optional - for KDE users)''
* nasm >= 0.98.39 ''(optional)''
** fluidsynth or timidity ''(optional - for [http://zdoom.org/wiki/MIDI MIDI] playback)''
* GTK2 ''(optional)''
* zlib ''(optional - possibly static)''
* libbzip2 ''(optional - possibly static)''
* libjpeg ''(optional - possibly static)''
* mercurial ''(needed in order to download the source)''
* fluidsynth ''(optional)''
* libopenssl
* SQLite


Install the following as root/superuser:
Install the following as root/superuser:
Line 37: Line 29:
=== Debian/Ubuntu ===
=== Debian/Ubuntu ===
<pre>
<pre>
sudo apt-get install build-essential zlib1g-dev libsdl1.2-dev libjpeg-dev \
sudo apt-get install g++ make cmake libsdl1.2-dev mercurial zlib1g-dev \
nasm tar libbz2-dev libgtk2.0-dev cmake mercurial libfluidsynth-dev libgl1-mesa-dev \
libbz2-dev libjpeg-dev libfluidsynth-dev libgtk2.0-dev timidity nasm \
libssl-dev libglew-dev
libgl1-mesa-dev libssl-dev tar
</pre>
</pre>


=== Fedora ===
=== Fedora ===
<pre>
<pre>
yum install gcc-c++ make zlib-devel SDL-devel libjpeg-turbo-devel \
dnf install gcc-c++ make cmake SDL-devel mercurial zlib-devel \
nasm tar bzip2-devel gtk2-devel cmake mercurial fluidsynth-devel mesa-libGL-devel \
bzip2-devel libjpeg-turbo-devel fluidsynth-devel gtk2-devel timidity++ nasm \
openssl-devel
mesa-libGL-devel openssl-devel tar
</pre>
</pre>


=== openSUSE ===
=== openSUSE ===
<pre>
<pre>
zypper install gcc-c++ make zlib-devel libSDL-devel libjpeg-devel \
zypper install gcc-c++ make cmake libSDL-devel mercurial zlib-devel \
nasm tar libbz2-devel gtk2-devel cmake mercurial fluidsynth-devel Mesa-libGL-devel \
libbz2-devel libjpeg-devel fluidsynth-devel gtk2-devel timidity nasm \
libopenssl-devel
Mesa-libGL-devel libopenssl-devel tar
</pre>
</pre>


Line 59: Line 51:
<pre>
<pre>
a='' && [ "$(uname -m)" = x86_64 ] && a=64
a='' && [ "$(uname -m)" = x86_64 ] && a=64
urpmi gcc-c++ make lib"$a"zlib-devel lib"$a"SDL-devel \
urpmi gcc-c++ make cmake lib${a}SDL-devel mercurial lib${a}zlib-devel \
lib"$a"jpeg-devel nasm tar lib"$a"bzip2-devel \
lib${a}bzip2-devel lib${a}jpeg-devel lib${a}fluidsynth-devel \
lib"$a"gtk+2.0-devel cmake mercurial lib"$a"fluidsynth-devel \
lib${a}gtk+2.0-devel lib${a}cairo-devel TiMidity++ nasm \
lib"$a"mesagl1-devel lib"$a"cairo-devel lib"$a"openssl-devel
lib${a}mesagl1-devel lib${a}openssl-devel tar
</pre>
</pre>


=== Arch Linux ===
=== Arch Linux ===
<pre>
<pre>
pacman -S --needed gcc make zlib sdl libjpeg-turbo nasm tar bzip2 gtk2 cmake mercurial \
pacman -S --needed gcc make cmake sdl mercurial zlib bzip2 libjpeg-turbo \
fluidsynth mesa glu openssl
fluidsynth gtk2 timidity++ nasm mesa glu openssl tar
</pre>
</pre>


=== Gentoo ===
=== Gentoo ===
<pre>
<pre>
emerge -avn sys-devel/gcc sys-devel/make sys-libs/zlib media-libs/libsdl media-libs/libjpeg-turbo \
emerge -avn sys-devel/gcc sys-devel/make dev-util/cmake media-libs/libsdl \
dev-lang/nasm app-arch/tar app-arch/bzip2 x11-libs/gtk+ dev-util/cmake dev-vcs/mercurial media-sound/fluidsynth \
dev-vcs/mercurial sys-libs/zlib app-arch/bzip2 media-libs/libjpeg-turbo media-sound/fluidsynth \
media-libs/mesa media-libs/glu dev-libs/openssl
x11-libs/gtk+ media-sound/timidity++ dev-lang/nasm media-libs/mesa media-libs/glu \
dev-libs/openssl app-arch/tar
</pre>
</pre>


Line 81: Line 74:
<pre>
<pre>
a='' && [ "$(uname -m)" = x86_64 ] && a=64
a='' && [ "$(uname -m)" = x86_64 ] && a=64
apt-get install gcc-c++ make zlib1-devel lib"$a"SDL-devel \
apt-get install gcc-c++ make cmake lib${a}SDL-devel mercurial zlib1-devel \
lib"$a"jpeg62-devel nasm tar lib"$a"bzip2-devel \
lib${a}bzip2-devel lib${a}jpeg62-devel lib${a}fluidsynth1-devel \
lib"$a"gtk+2.0_0-devel cmake mercurial lib"$a"fluidsynth1-devel \
lib${a}gtk+2.0_0-devel TiMidity++ nasm lib${a}mesagl1-devel \
lib"$a"mesagl1-devel lib"$a"openssl-devel  
lib${a}openssl-devel tar
</pre>
 
=== Solus ===
<pre>
sudo eopkg install g++ make cmake binutils glibc-devel pkg-config \
sdl1-devel mercurial zlib-devel bzip2-devel libjpeg-turbo-devel \
fluidsynth-devel libgtk-2-devel nasm mesalib-devel libglu-devel \
openssl-devel tar
</pre>
</pre>


'''Do the following steps as normal user.'''
'''Do the following sections as normal user.'''


== Make zandronum_build directory ==
== Create zandronum_build directory ==
<pre>
<pre>
mkdir -pv "$HOME"/zandronum_build
mkdir -pv ~/zandronum_build
</pre>
</pre>


== Download the Source ==
== Download and prepare the source ==
Download the Zandronum source and make buildclient and buildserver directories:
Download the Zandronum source and create buildclient and buildserver directories:
<pre>
<pre>
cd "$HOME"/zandronum_build && \
cd ~/zandronum_build &&
hg clone https://bitbucket.org/Torr_Samaho/zandronum && \
hg clone https://bitbucket.org/Torr_Samaho/zandronum &&
mkdir -pv zandronum/{buildclient,buildserver}
mkdir -pv zandronum/buildclient zandronum/buildserver
</pre>
</pre>


Line 105: Line 106:
Download FMOD 4.24.16 32-bit or 64-bit and extract files to zandronum directory:
Download FMOD 4.24.16 32-bit or 64-bit and extract files to zandronum directory:
<pre>
<pre>
cd "$HOME"/zandronum_build && \
a='' && [ "$(uname -m)" = x86_64 ] && a=64
a='' && [ "$(uname -m)" = x86_64 ] && a=64 ; \
cd ~/zandronum_build &&
wget -nc http://zandronum.com/essentials/fmod/fmodapi42416linux"$a".tar.gz && \
wget -nc http://zandronum.com/essentials/fmod/fmodapi42416linux${a}.tar.gz &&
tar -xvzf fmodapi42416linux"$a".tar.gz -C zandronum
tar -xvzf fmodapi42416linux${a}.tar.gz -C zandronum
</pre>
</pre>
=== FMOD Links ===
FMOD 4.24.16 32-bit:<br />
http://zandronum.com/essentials/fmod/fmodapi42416linux.tar.gz
FMOD 4.24.16 64-bit:<br />
http://zandronum.com/essentials/fmod/fmodapi42416linux64.tar.gz


== Compiling ==
== Compiling ==
To compile the development version:
To compile Zandronum client:
 
'''Zandronum client''':
<pre>
<pre>
cd "$HOME"/zandronum_build/zandronum/buildclient && \
a='' && [ "$(uname -m)" = x86_64 ] && a=64
a='' && [ "$(uname -m)" = x86_64 ] && a=64 ; \
c="$(lscpu -p | grep -v '#' | sort -u -t , -k 2,4 | wc -l)" ; [ "$c" -eq 0 ] && c=1
make clean ; \
cd ~/zandronum_build/zandronum/buildclient &&
cmake -DCMAKE_BUILD_TYPE=Release \
rm -f output_sdl/liboutput_sdl.so &&
-DFMOD_LIBRARY="$HOME"/zandronum_build/zandronum/fmodapi42416linux"$a"/api/lib/libfmodex"$a"-4.24.16.so \
if [ -d "../fmodapi42416linux${a}" ]; then
-DFMOD_INCLUDE_DIR="$HOME"/zandronum_build/zandronum/fmodapi42416linux"$a"/api/inc .. && \
f="-DFMOD_LIBRARY=../fmodapi42416linux${a}/api/lib/libfmodex${a}-4.24.16.so \
make
-DFMOD_INCLUDE_DIR=../fmodapi42416linux${a}/api/inc"; else
f='-UFMOD_LIBRARY -UFMOD_INCLUDE_DIR'; fi &&
cmake .. -DCMAKE_BUILD_TYPE=Release -DSERVERONLY=OFF -DRELEASE_WITH_DEBUG_FILE=OFF $f &&
make -j$c
</pre>
</pre>
A development version of Zandronum client will be compiled if you do not do [[#Latest stable version]].
Assuming all goes well, a zandronum binary should be produced. To start Zandronum client, the following command should work:
Assuming all goes well, a zandronum binary should be produced. To start Zandronum client, the following command should work:
<pre>
<pre>
Line 136: Line 133:
</pre>
</pre>


'''Zandronum server''':
To compile Zandronum server:
<pre>
<pre>
cd "$HOME"/zandronum_build/zandronum/buildserver && \
c="$(lscpu -p | grep -v '#' | sort -u -t , -k 2,4 | wc -l)" ; [ "$c" -eq 0 ] && c=1
make clean ; \
cd ~/zandronum_build/zandronum/buildserver &&
cmake -DCMAKE_BUILD_TYPE=Release -DSERVERONLY=ON .. && \
cmake .. -DCMAKE_BUILD_TYPE=Release -DSERVERONLY=ON -DRELEASE_WITH_DEBUG_FILE=OFF &&
make
make -j$c
</pre>
</pre>
A development version of Zandronum server will be compiled if you do not do [[#Latest stable version]].
Assuming all goes well, a zandronum-server binary should be produced. To start Zandronum server, the following command should work:
Assuming all goes well, a zandronum-server binary should be produced. To start Zandronum server, the following command should work:
<pre>
<pre>
./zandronum-server
./zandronum-server
</pre>
</pre>
If Zandronum complains you do not have any IWADs set up, make sure that you have your [[IWAD]] files placed in the same directory as Zandronum, in ~/.config/zandronum, $DOOMWADDIR, or /usr/local/share. Alternatively, you can edit ~/.config/zandronum/zandronum.ini or ~/.zandronum/zandronum.ini to set the path for your IWADs.
If Zandronum complains you do not have any IWADs set up, make sure that you have your [[IWAD]] files placed in the same directory as Zandronum, in ~/.config/zandronum/, ~/.zandronum/, $DOOMWADDIR, or /usr/local/share/. Alternatively, you can edit ~/.config/zandronum/zandronum.ini or ~/.zandronum/zandronum.ini to set the path for your IWADs.


=== Current stable version ===
=== Latest stable version ===
Show the current stable version:
Show the latest stable version:
<pre>
<pre>
cd "$HOME"/zandronum_build/zandronum && \
cd ~/zandronum_build/zandronum &&
hg identify -r 'max(tagged())'
if [ "$(hg log -r 'max(tagged())' --template '{rev}\n')" -ge \
"$(hg log -l1 -k 'BUILD_ID_STR to release' --template '{rev}\n')" ]; then
hg identify -r 'max(tagged())'; else u="$(hg log -l1 -k 'BUILD_ID_STR to release' \
--template '{node|short}\n')"; echo "$u $(hg log -r $u --template '{desc}\n' |
sed -n 's/.*changed the version string to \(.*\)/\1/p')"; fi
</pre>
</pre>


If you want to compile the current stable version, run the following:
If you want to compile the latest stable version, run:
<pre>
<pre>
cd "$HOME"/zandronum_build/zandronum && \
cd ~/zandronum_build/zandronum &&
hg update -cr 'max(tagged())'
if [ "$(hg log -r 'max(tagged())' --template '{rev}\n')" -ge \
"$(hg log -l1 -k 'BUILD_ID_STR to release' --template '{rev}\n')" ]; then
hg update -cr 'max(tagged())'; else hg update -c $(hg log -l1 -k \
'BUILD_ID_STR to release' --template '{node}\n'); fi
</pre>
</pre>
and [[#Compiling|compile]].
and [[#Compiling|compile]].


After compiling, [[#Backup|backing up]] and optionally [[#Installation|installing]] the current stable version, run the following:
After compiling, [[#Backup|backing up]] and optionally [[#Installation|installing]] the latest stable version, run:
<pre>
cd ~/zandronum_build/zandronum &&
hg update
</pre>
 
=== A specific Zandronum version by UTC commit date ===
To compile a specific Zandronum version, for example 3.0-alpha-170806-2040; first, checkout the commit that matches 170806-2040. From left to right, 17 (2017) is the year, 08 is the month, 06 is the day, 20 is the hour, 40 is the minute and the time zone is +0000:
<pre>
cd ~/zandronum_build/zandronum &&
hg update -cd '2017-08-06 20:40 +0000'
</pre>
Now go to [[#Compiling]].
 
After compiling, [[#Backup|backing up]] and optionally [[#Installation|installing]] Zandronum, run:
<pre>
<pre>
cd "$HOME"/zandronum_build/zandronum && \
cd ~/zandronum_build/zandronum &&
hg update
hg update
</pre>
</pre>


== Backup ==
=== Older versions ===
Follow this step if you want or manually copy (backup) zandronum, zandronum.pk3, skulltag_actors.pk3, liboutput_sdl.so and zandronum-server.
First, show the Zandronum version you are currently on:
<pre>
w='r ' && [ "$(uname -s)" = Linux ] && w='d @'
cd ~/zandronum_build/zandronum &&
v="$(sed -n 's/.*#define GAMEVER_STRING "\(.*\)".*/\1/p' src/version.h)\
$(sed -n 's/.*#define DOTVERSIONSTR GAMEVER_STRING "\(.*\)".*/\1/p' src/version.h)\
$(date -u$w$(hg log -r . --template '{date}\n' | cut -d'.' -f1) +'-%y%m%d-%H%M')\
$(hg id -i | sed '/+$/!s/.*//;s/.*+$/M/')" &&
echo $v
</pre>
If the Zandronum version you are currently on is 2.x or lower, do the following:
 
To compile Zandronum 2.x or older versions, you need to install gcc 4.9 or lower:
<pre>
sudo apt-get install gcc-4.9 g++-4.9
</pre>
 
Inside the buildclient and buildserver directories, run cmake with these arguments -DCMAKE_C_COMPILER=/path/to/compiler/gcc -DCMAKE_CXX_COMPILER=/path/to/compiler/g++, for example:
<pre>
cd ~/zandronum_build/zandronum/buildclient &&
cmake .. -DCMAKE_C_COMPILER=/usr/bin/gcc-4.9 \
-DCMAKE_CXX_COMPILER=/usr/bin/g++-4.9
</pre>
 
<pre>
cd ~/zandronum_build/zandronum/buildserver &&
cmake .. -DCMAKE_C_COMPILER=/usr/bin/gcc-4.9 \
-DCMAKE_CXX_COMPILER=/usr/bin/g++-4.9
</pre>
and [[#Compiling|compile]].


Make and name a directory with the corresponding Zandronum version/revision and copy zandronum, zandronum.pk3, skulltag_actors.pk3, liboutput_sdl.so and zandronum-server to it:
If you are going to compile Zandronum 1.0 (120819-2011) and your Mesa version is 9.x or higher:
<pre>
<pre>
cd "$HOME"/zandronum_build/zandronum/src && \
glxinfo | grep 'OpenGL version'
BACKUPZANDRONUM="$(sed -n 's/.*#define GAMEVER_STRING "\(.*\)".*/\1/p' version.h)\
$(sed -n 's/.*#define DOTVERSIONSTR.*GAMEVER_STRING "\(.*\)".*/\1/p' version.h)\
$(sed -n 's/.*#define SVN_REVISION_STRING "\(.*\)".*/\-r\1/p' {svnrevision.h,gitinfo.h} 2>/dev/null)\
$(sed -n 's/.*#define HG_TIME "\(.*\)".*/\-r\1/p' gitinfo.h 2>/dev/null)\
$(sed -n 's/.*#define HG_REVISION_HASH_STRING "\(.*\)".*/\-\1/p' gitinfo.h)" ; \
cd ../.. && mkdir -pv "$BACKUPZANDRONUM" && \
cp -v zandronum/{buildclient/{zandronum,zandronum.pk3,\
skulltag_actors.pk3,output_sdl/liboutput_sdl.so},\
buildserver/zandronum-server} "$BACKUPZANDRONUM"
</pre>
</pre>
apply the fix from commit [https://bitbucket.org/Torr_Samaho/zandronum/commits/a69d59da0f518d52b41e28e19f72611c009c8fac a69d59da0f51], otherwise the Zandronum client will not compile.


=== Backup (Optional) ===
== Backup ==
Make and name a directory with the current year, month, day, hour and minute and copy zandronum, zandronum.pk3, skulltag_actors.pk3, liboutput_sdl.so and zandronum-server to it:
If you want to backup Zandronum, do the following:
 
Create and name a directory with the corresponding Zandronum version/revision, build type and copy zandronum, zandronum-server, zandronum.pk3, skulltag_actors.pk3 and liboutput_sdl.so to it:
<pre>
<pre>
cd "$HOME"/zandronum_build && \
cd ~/zandronum_build/zandronum &&
COPYANDPASTEZAN="$(date +'%Y%m%d-%H%M')" && \
e=buildclient && i=buildserver && if [ -f "$e/CMakeCache.txt" ]; then
mkdir -pv "$COPYANDPASTEZAN" && \
j="$(sed -n 's/.*CMAKE_BUILD_TYPE:STRING=\(.*\)/\1/p' $e/CMakeCache.txt)"; else j=''; fi &&
cp -v zandronum/{buildclient/{zandronum,zandronum.pk3,\
if [ -f "$i/CMakeCache.txt" ]; then
skulltag_actors.pk3,output_sdl/liboutput_sdl.so},\
k="$(sed -n 's/.*CMAKE_BUILD_TYPE:STRING=\(.*\)/\1/p' $i/CMakeCache.txt)"; else k=''; fi &&
buildserver/zandronum-server} "$COPYANDPASTEZAN"
if [ -n "$j" ]; then b="-BuildType$j"; elif [ -n "$k" ]; then b="-BuildType$k"; else b=''; fi &&
r=src/svnrevision.h && if [ -f "$r" ] && [ "$(hg status $r)" != "? $r" ]; then r=$r; else
r=src/gitinfo.h; fi && h="$(sed -n 's/.*#define HG_REVISION_HASH_STRING "\(.*\)".*/\1/p' $r)" &&
BACKUPZANDRONUM="../$(hg cat -r $h src/version.h | sed -n 's/.*#define GAMEVER_STRING "\(.*\)".*/\1/p')\
$(hg cat -r $h src/version.h | sed -n 's/.*#define DOTVERSIONSTR GAMEVER_STRING "\(.*\)".*/\1/p')\
$(sed -n 's/.*#define SVN_REVISION_STRING "\(.*\)".*/\-\1/p' $r)\
$(sed -n 's/.*#define HG_TIME "\(.*\)".*/\-\1/p' $r)-$h$b" &&
mkdir -pv "$BACKUPZANDRONUM" &&
x="$e" && y="$e/zandronum.pk3" && z="$i/zandronum.pk3" &&
if [ -f "$y" ] && [ -f "$z" ] && [ "$z" -nt "$y" ]; then
x="$i"; elif [ ! -f "$y" ] && [ -f "$z" ]; then x="$i"; fi &&
o="$e/output_sdl/liboutput_sdl.so" && if [ -f "$o" ]; then l="$o"; else l=''; fi &&
cp -v $e/zandronum $i/zandronum-server $x/zandronum.pk3 $x/skulltag_actors.pk3 $l \
"$BACKUPZANDRONUM"/
</pre>
</pre>


If you did "Backup" or "Backup (Optional)", the previous files should be located at:
Files are located at:
: '''/home/<your username>/zandronum_build/<your newly created directory>'''
 
/home/<your username>/zandronum_build/<your newly created directory>


== Updating ==
== Updating ==
When you wish to update Zandronum, copy and paste the following:
When you wish to update Zandronum, copy and paste the following:
<pre>
<pre>
cd "$HOME"/zandronum_build/zandronum && \
cd ~/zandronum_build/zandronum &&
hg pull ; hg update
hg pull ; hg update
</pre>
</pre>
Line 210: Line 267:


== Installation ==
== Installation ==
'''The following steps have commands that require to be run as superuser with the sudo command.'''
* '''zandronum''' / '''zandronum-server''' = Stable version
* '''zandronum-alpha''' / '''zandronum-server-alpha''' = Development version
 
Commands beginning with "sudo" will require temporary superuser privileges.


If you want to install Zandronum, do the following:
If you want to install Zandronum, do the following:


Make /usr/games/zandronum and /usr/games/zandronum-alpha directories:
Create /usr/games/zandronum and /usr/games/zandronum-alpha directories:
<pre>
<pre>
sudo mkdir -pv /usr/games/{zandronum,zandronum-alpha}
sudo mkdir -pv /usr/games/zandronum /usr/games/zandronum-alpha
</pre>
</pre>


Copy zandronum, zandronum.pk3, skulltag_actors.pk3, liboutput_sdl.so, zandronum-server and libfmodex64-4.24.16.so or libfmodex-4.24.16.so to /usr/games/zandronum or /usr/games/zandronum-alpha:
Copy zandronum, zandronum-server, zandronum.pk3, skulltag_actors.pk3, liboutput_sdl.so and the FMOD library file to /usr/games/zandronum/ or /usr/games/zandronum-alpha/:
<pre>
<pre>
cd "$HOME"/zandronum_build/zandronum && \
a='' && [ "$(uname -m)" = x86_64 ] && a=64
t="$(hg id -t)" && \
cd ~/zandronum_build/zandronum &&
d='' && [ "$t" = tip ] || [ -z "$t" ] && d=-alpha ; \
e=buildclient && i=buildserver &&
a='' && [ "$(uname -m)" = x86_64 ] && a=64 ; \
if [ -f src/svnrevision.h ] &&
sudo cp -v {buildclient/{zandronum,zandronum.pk3,\
[ "$(hg status src/svnrevision.h)" != "? src/svnrevision.h" ]; then
skulltag_actors.pk3,output_sdl/liboutput_sdl.so},\
r=src/svnrevision.h; else r=src/gitinfo.h; fi &&
buildserver/zandronum-server,fmodapi42416linux"$a"/api/lib/libfmodex"$a"-4.24.16.so} \
h="$(sed -n 's/.*#define HG_REVISION_HASH_STRING "\(.*\)".*/\1/p' $r)" &&
/usr/games/zandronum"$d"
t="$(hg id -tr $h)" &&
</pre>
d='' && if [ -z "$(hg log -r $h -k 'BUILD_ID_STR to release')" ]; then
 
if [ "$t" = tip ] || [ -z "$t" ]; then d=-alpha; fi; fi &&
Make zandronum or zandronum-alpha script, add executable permission and move it to /usr/bin:
x="$e" && y="$e/zandronum.pk3" && z="$i/zandronum.pk3" &&
<pre>
if [ -f "$y" ] && [ -f "$z" ] && [ "$z" -nt "$y" ]; then
cd "$HOME"/zandronum_build/zandronum && \
x="$i"; elif [ ! -f "$y" ] && [ -f "$z" ]; then x="$i"; fi &&
t="$(hg id -t)" && \
o="$e/output_sdl/liboutput_sdl.so" && if [ -f "$o" ]; then l="$o \
d='' && [ "$t" = tip ] || [ -z "$t" ] && d=-alpha ; \
fmodapi42416linux${a}/api/lib/libfmodex${a}-4.24.16.so"; else l=''; fi &&
cd /tmp && \
sudo cp -v $e/zandronum $i/zandronum-server $x/zandronum.pk3 $x/skulltag_actors.pk3 $l \
echo '#!/bin/sh' > zandronum"$d" && \
/usr/games/zandronum$d/
echo >> zandronum"$d" && \
echo "export LD_LIBRARY_PATH=/usr/games/zandronum"$d"" >> zandronum"$d" && \
echo "exec /usr/games/zandronum"$d"/zandronum \"\$@\"" >> zandronum"$d" && \
chmod 755 zandronum"$d" && \
sudo mv -v zandronum"$d" /usr/bin
</pre>
</pre>


Make zandronum-server or zandronum-server-alpha script, add executable permission and move it to /usr/bin:
Create launch scripts:
<pre>
<pre>
cd "$HOME"/zandronum_build/zandronum && \
cd ~/zandronum_build/zandronum &&
t="$(hg id -t)" && \
if [ -f src/svnrevision.h ] &&
d='' && [ "$t" = tip ] || [ -z "$t" ] && d=-alpha ; \
[ "$(hg status src/svnrevision.h)" != "? src/svnrevision.h" ]; then
cd /tmp && \
r=src/svnrevision.h; else r=src/gitinfo.h; fi &&
echo '#!/bin/sh' > zandronum-server"$d" && \
h="$(sed -n 's/.*#define HG_REVISION_HASH_STRING "\(.*\)".*/\1/p' $r)" &&
echo >> zandronum-server"$d" && \
t="$(hg id -tr $h)" &&
echo "exec /usr/games/zandronum"$d"/zandronum-server \"\$@\"" >> zandronum-server"$d" && \
d='' && if [ -z "$(hg log -r $h -k 'BUILD_ID_STR to release')" ]; then
chmod 755 zandronum-server"$d" && \
if [ "$t" = tip ] || [ -z "$t" ]; then d=-alpha; fi; fi &&
sudo mv -v zandronum-server"$d" /usr/bin
printf %s "\
#!/bin/sh
export LD_LIBRARY_PATH=/usr/games/zandronum$d
exec /usr/games/zandronum$d/zandronum \"\$@\"
" > zandronum$d.sh &&
printf %s "\
#!/bin/sh
exec /usr/games/zandronum$d/zandronum-server \"\$@\"
" > zandronum-server$d.sh &&
chmod 755 zandronum$d.sh zandronum-server$d.sh &&
sudo mv -v zandronum$d.sh /usr/bin/zandronum$d &&
sudo mv -v zandronum-server$d.sh /usr/bin/zandronum-server$d
</pre>
</pre>


Now from a terminal you should be able to execute '''zandronum''' / '''zandronum-alpha''' or '''zandronum-server''' / '''zandronum-server-alpha''' from any user account.
Now from a terminal you should be able to run '''zandronum''' / '''zandronum-alpha''' or '''zandronum-server''' / '''zandronum-server-alpha''' from any user account.


=== Uninstallation ===
=== Uninstallation ===
To remove the previous installation steps:
Remove /usr/games/zandronum directory and all its files:
Remove /usr/games/zandronum directory and all its files:
<pre>
<pre>
Line 293: Line 357:
</pre>
</pre>


== Debugging ==
== Developing ==
This page has helped you compile Zandronum, 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 Zandronum client ===
'''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 Zandronum crashes.
Maybe you have found a way to make Zandronum client crash, and are interested in debugging it. First, you need to compile a debug build of Zandronum client. Inside the buildclient directory, invoke CMake to set up for compiling, but this time, the build type is set to Debug:
 
=== Debugging Zandronum client ===
Make debugclient directory:
<pre>
<pre>
mkdir -pv "$HOME"/zandronum_build/zandronum/debugclient
cd ~/zandronum_build/zandronum/buildclient
cmake .. -DCMAKE_BUILD_TYPE=Debug -DSERVERONLY=OFF
</pre>
</pre>
Optionally, you may want to use some of the [[#Build options]].


Make a debug build of Zandronum client:
After CMake is done, run <code>make</code> or to speed up compilation, run <code>make -j<number></code>, a recommended value for the <code>-j</code> option is the number of physical cores:
<pre>
<pre>
cd "$HOME"/zandronum_build/zandronum/debugclient && \
a='' && [ "$(uname -m)" = x86_64 ] && a=64 ; \
make clean ; \
cmake -DCMAKE_BUILD_TYPE=Debug \
-DFMOD_LIBRARY="$HOME"/zandronum_build/zandronum/fmodapi42416linux"$a"/api/lib/libfmodex"$a"-4.24.16.so \
-DFMOD_INCLUDE_DIR="$HOME"/zandronum_build/zandronum/fmodapi42416linux"$a"/api/inc .. && \
make
make
</pre>
</pre>


You should now be able to use gdb to generate a backtrace:
To run Zandronum client under a debugger such as gdb, use the following command:
<pre>
<pre>
gdb zandronum
gdb zandronum
</pre>
</pre>


Now gdb should have you in its own command prompt. You probably want to log the output, so lets output to a file zandronumclientdebug.log:
Now gdb should have you in its own command prompt:
<pre>
(gdb)
</pre>
 
You probably want to log the output, so lets output to a file zandronumclientdebug.log:
<pre>
<pre>
(gdb) set logging on zandronumclientdebug.log
(gdb) set logging on zandronumclientdebug.log
</pre>
</pre>


Use "run" to start zandronum:
Now start Zandronum client by typing in run, and pressing enter:
<pre>
<pre>
(gdb) run
(gdb) run
</pre>
</pre>


To start and pass [[Command Line Parameters|Command Line]] [http://zdoom.org/wiki/Command_line_parameters Parameters] to zandronum:
Or put any [[Command Line Parameters|command line]] [http://zdoom.org/wiki/Command_line_parameters parameters] to zandronum after run:
<pre>
<pre>
(gdb) run <command line parameters>
(gdb) run <command line parameters>
</pre>
</pre>


Use "bt" to get the backtrace after a crash:
If Zandronum client 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:
<pre>
<pre>
(gdb) bt
(gdb) backtrace
</pre>
</pre>
All output will be copied into the zandronumclientdebug.log, which can then be scrutinized later, or perhaps posted to the [http://zandronum.com/tracker/ Bug Tracker] for other developers to look at.
All output will be copied into the zandronumclientdebug.log, which can then be scrutinized later, or perhaps posted to the [http://zandronum.com/tracker/ 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:
<pre>
<pre>
(gdb) quit
(gdb) quit
</pre>
</pre>
If you want to free up space, run <code>make clean</code> to remove the files generated by the compilation.


=== Debugging Zandronum server ===
=== Debugging Zandronum server ===
Make debugserver directory:
'''Prerequisite:'''
 
* [http://www.gnu.org/software/gdb/ gdb]
 
Maybe you have found a way to make Zandronum server crash, and are interested in debugging it. First, you need to compile a debug build of Zandronum server. Inside the buildserver directory, invoke CMake to set up for compiling, but this time, the build type is set to Debug:
<pre>
<pre>
mkdir -pv "$HOME"/zandronum_build/zandronum/debugserver
cd ~/zandronum_build/zandronum/buildserver
cmake .. -DCMAKE_BUILD_TYPE=Debug -DSERVERONLY=ON
</pre>
</pre>
Optionally, you may want to use some of the [[#Build options]].


Make a debug build of Zandronum server:
After CMake is done, run <code>make</code> or to speed up compilation, run <code>make -j<number></code>, a recommended value for the <code>-j</code> option is the number of physical cores:
<pre>
<pre>
cd "$HOME"/zandronum_build/zandronum/debugserver && \
make clean ; \
cmake -DCMAKE_BUILD_TYPE=Debug -DSERVERONLY=ON .. && \
make
make
</pre>
</pre>


You should now be able to use gdb to generate a backtrace:
To run Zandronum server under a debugger such as gdb, use the following command:
<pre>
<pre>
gdb zandronum-server
gdb zandronum-server
</pre>
</pre>


Now gdb should have you in its own command prompt. You probably want to log the output, so lets output to a file zandronumserverdebug.log:
Now gdb should have you in its own command prompt:
<pre>
(gdb)
</pre>
 
You probably want to log the output, so lets output to a file zandronumserverdebug.log:
<pre>
<pre>
(gdb) set logging on zandronumserverdebug.log
(gdb) set logging on zandronumserverdebug.log
</pre>
</pre>


Use "run" to start zandronum-server:
Now start Zandronum server by typing in run, and pressing enter:
<pre>
<pre>
(gdb) run
(gdb) run
</pre>
</pre>


To start and pass [[Command Line Parameters]] to zandronum-server:
Or put any [[Command Line Parameters|command line parameters]] to zandronum-server after run:
<pre>
<pre>
(gdb) run <command line parameters>
(gdb) run <command line parameters>
</pre>
</pre>


Use "bt" to get the backtrace after a crash:
If Zandronum server 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:
<pre>
<pre>
(gdb) bt
(gdb) backtrace
</pre>
</pre>
All output will be copied into the zandronumserverdebug.log, which can then be scrutinized later, or perhaps posted to the [http://zandronum.com/tracker/ Bug Tracker] for other developers to look at.
All output will be copied into the zandronumserverdebug.log, which can then be scrutinized later, or perhaps posted to the [http://zandronum.com/tracker/ 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:
<pre>
<pre>
(gdb) quit
(gdb) quit
</pre>
</pre>
If you want to free up space, run <code>make clean</code> to remove the files generated by the compilation.


== Build Options ==
=== Build options ===
{|class="wikitable" width="72%"
{|class="wikitable" width="72%"
|+ <span style="text-decoration: underline">CMake Build Options</span>
|+ <span style="text-decoration: underline">CMake options</span>
|-
|-
!width="10%"|Options!!width="35%"|Description!!width="55%"|Example
!width="10%"|Options!!width="35%"|Description!!width="55%"|Example
|-
|-
|SERVERONLY=ON||Build a server only binary.||cmake -DSERVERONLY=ON ..
|SERVERONLY=ON||Build a server only binary.||cmake .. -DSERVERONLY=ON
|-
|NO_GTK=ON||Disable GTK+ dialogs.||cmake .. -DNO_GTK=ON
|-
|NO_SOUND=ON||Disable sound support.||cmake .. -DNO_SOUND=ON
|-
|NO_GL=ON||Disable OpenGL support.||cmake .. -DNO_GL=ON
|-
|-
|NO_GTK=ON||Disable GTK+ dialogs.||cmake -DNO_GTK=ON ..
|NO_ASM=ON||Disable assembly code.||cmake .. -DNO_ASM=ON
|-
|-
|NO_SOUND=ON||Disable sound support.||cmake -DNO_SOUND=ON ..
|RELEASE_WITH_DEBUG_FILE=ON||Create the debug symbols file for the release build.||cmake .. -DRELEASE_WITH_DEBUG_FILE=ON
|-
|-
|NO_GL=ON||Disable OpenGL support.||cmake -DNO_GL=ON ..
|FMOD_LIBRARY||Set path for FMOD library file.||cmake .. -DFMOD_LIBRARY=/path/to/libfmodex(64)-x.y.z.so
|-
|-
|NO_ASM=ON||Disable assembly code.||cmake -DNO_ASM=ON ..
|FMOD_INCLUDE_DIR||Set path for FMOD include directory.||cmake .. -DFMOD_INCLUDE_DIR=/path/to/include/dir
|-
|-
|FMOD_LIBRARY||Set path for FMOD library.||cmake -DFMOD_LIBRARY=/path/to/libfmodex(64)-X.Y.Z.so ..
|CMAKE_C_COMPILER||Set path for C compiler.||cmake .. -DCMAKE_C_COMPILER=/path/to/compiler/gcc
|-
|-
|FMOD_INCLUDE_DIR||Set path for FMOD include directory.||cmake -DFMOD_INCLUDE_DIR=/path/to/include/dir ..
|CMAKE_CXX_COMPILER||Set path for C++ compiler.||cmake .. -DCMAKE_CXX_COMPILER=/path/to/compiler/g++
|}
|}


{|class="wikitable" width="72%"
{|class="wikitable" width="72%"
|+ <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
|}
|}


== How to increase Zandronum/GZDoom OpenGL FPS on Intel Graphics ==
== How to increase Zandronum/GZDoom OpenGL FPS ==
Commands beginning with "sudo" will require temporary superuser privileges.
 
Run Zandronum/[http://zdoom.org/wiki/GZDoom GZDoom], start a new game, open [[Console Commands|console]] and type [http://zdoom.org/wiki/CVARs:Debug#vid_fps vid_fps 1], see how many FPS are displayed and exit Zandronum/GZDoom.
 
If you do not use Intel graphics, go to [[#Disable Vertical Synchronization for Zandronum/GZDoom]].
 
=== Enable SandyBridge's New Acceleration ===
'''Prerequisite:'''
'''Prerequisite:'''


Line 452: Line 540:
* x11-driver-video-intel >= 2.19
* x11-driver-video-intel >= 2.19


Run Zandronum/GZDoom, start a new game, open console and type '''vid_fps 1''', see how many FPS are displayed and exit Zandronum/GZDoom.
'''Solus'''
* xorg-driver-video-intel >= 2.19


=== Enable SandyBridge's New Acceleration ===
If your Intel driver version is 2.21.14-1 / 2.21.15-2 or higher:
If your Intel driver version is 2.21.14-1 / 2.21.15-2 or greater, go to [[#Disable Vertical Synchronization for Zandronum/GZDoom|the next part]].
<pre>
grep 'SNA compiled:' /var/log/Xorg.0.log
</pre>
go to [[#Disable Vertical Synchronization for Zandronum/GZDoom]].


Intel SNA is useful on all Intel Graphics, not just SandyBridge.
Intel SNA is useful on all Intel graphics, not just SandyBridge.


Make 99-intel.conf:
Create /etc/X11/xorg.conf.d directory:
<pre>
<pre>
touch 99-intel.conf
sudo mkdir -pv /etc/X11/xorg.conf.d
</pre>
</pre>


Copy and paste the following to 99-intel.conf:
Create 99-intel.conf file:
<pre>
<pre>
cat <<'EOF' > 99-intel.conf
Section "Device"
Section "Device"
    Identifier "Intel Graphics"
    Identifier "Intel Graphics"
    Driver "intel"
    Driver "intel"
    Option "AccelMethod" "sna"
    Option "AccelMethod" "sna"
EndSection
EndSection
</pre>
EOF
and save.
 
Verify if the xorg.conf.d directory already exist:
<pre>
ls /etc/X11
</pre>
 
If it doesn't exist, as root/superuser, make it:
<pre>
mkdir -pv /etc/X11/xorg.conf.d
</pre>
</pre>


As root/superuser, copy 99-intel.conf to /etc/X11/xorg.conf.d:
Move 99-intel.conf to /etc/X11/xorg.conf.d/:
<pre>
<pre>
cp -v 99-intel.conf /etc/X11/xorg.conf.d
sudo mv -v 99-intel.conf /etc/X11/xorg.conf.d/
</pre>
</pre>
and logout and login.
and logout and login.


=== Disable Vertical Synchronization for Zandronum/GZDoom ===
=== Disable Vertical Synchronization for Zandronum/GZDoom ===
Open a terminal, go to your user home directory and verify if the .drirc file already exist:
Do the following step if you are using a GZDoom version prior to commit [https://github.com/coelckers/gzdoom/commit/4eb32a50e3151968e1b2285688ce98da98fedd9f 4eb32a50e]. The following step works for the open-source graphics drivers.
<pre>
cd "$HOME"
ls -la
</pre>


If it doesn't exist; make it:
Create ~/.drirc file:
<pre>
touch drirc
</pre>
otherwise add the configurations of the next step to the already existing .drirc file.
 
Copy and paste the following to drirc:
<pre>
<pre>
cat <<'EOF' > ~/.drirc
<driconf>
<driconf>
     <device screen="0" driver="dri2">
     <device screen="0" driver="dri2">
         <application name="zandronum" executable="zandronum">
         <application name="zandronum" executable="zandronum">
    <option name="vblank_mode" value="0"/>
            <option name="vblank_mode" value="0"/>
</application>
        </application>
<application name="gzdoom" executable="gzdoom">
        <application name="gzdoom" executable="gzdoom">
    <option name="vblank_mode" value="0"/>
            <option name="vblank_mode" value="0"/>
</application>
        </application>
     </device>
     </device>
</driconf>
</driconf>
</pre>
EOF
and save.
 
Rename drirc to .drirc:
<pre>
mv drirc .drirc
</pre>
</pre>


Run Zandronum/GZDoom, start a new game, open console and type '''vid_fps 1''', see how many FPS are displayed, you should get more FPS than before.
Run Zandronum/GZDoom, start a new game, open [[Console Commands|console]] and type [http://zdoom.org/wiki/CVARs:Debug#vid_fps vid_fps 1], see how many FPS are displayed, you should get more FPS than before.


=== Revert All Changes ===
=== Reverting changes ===
Remove .drirc:
Remove ~/.drirc file:
<pre>
<pre>
cd "$HOME"
rm -fv ~/.drirc
rm -fv .drirc
</pre>
</pre>


As root/superuser, remove 99-intel.conf:
Remove 99-intel.conf file:
<pre>
<pre>
cd /etc/X11/xorg.conf.d
sudo rm -fv /etc/X11/xorg.conf.d/99-intel.conf
rm -fv 99-intel.conf
</pre>
</pre>
and logout and login.
and logout and login.


[[Category:Developers Articles]]
[[Category:Developers Articles]]

Revision as of 18:30, 16 December 2017

Open a terminal and copy and paste the whole code box for each step.

Install dependencies

Zandronum needs certain tools and development files in order to compile:

  • Required
    • gcc 4.6 or later
    • make
    • cmake 2.8.7 or later
    • SDL 1.2.8 or later 1.2.x versions
    • libGL and libGLU (SDL or libSDL pull in libGLU) or any other GL implementation provider.
    • FMOD Ex 4.24.16
    • libopenssl (for Zandronum 1.3 or later)
    • SQLite (for Zandronum 1.3 or later)
  • Recommended
    • GTK2
    • mercurial (needed in order to download the source and compile in commit meta data)
    • nasm 0.98.39 or later (x86-32 only)
  • Optional
    • zlib (Zandronum has a copy of it and will be statically compiled in if not found)
    • libbzip2 (possibly static)
    • libjpeg (possibly static)
  • Runtime
    • gxmessage (optional - needed to show the crash log in a window)
    • kdialog (optional - for KDE users)
    • fluidsynth or timidity (optional - for MIDI playback)

Install the following as root/superuser:

Debian/Ubuntu

sudo apt-get install g++ make cmake libsdl1.2-dev mercurial zlib1g-dev \
libbz2-dev libjpeg-dev libfluidsynth-dev libgtk2.0-dev timidity nasm \
libgl1-mesa-dev libssl-dev tar

Fedora

dnf install gcc-c++ make cmake SDL-devel mercurial zlib-devel \
bzip2-devel libjpeg-turbo-devel fluidsynth-devel gtk2-devel timidity++ nasm \
mesa-libGL-devel openssl-devel tar

openSUSE

zypper install gcc-c++ make cmake libSDL-devel mercurial zlib-devel \
libbz2-devel libjpeg-devel fluidsynth-devel gtk2-devel timidity nasm \
Mesa-libGL-devel libopenssl-devel tar

Mageia

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

Arch Linux

pacman -S --needed gcc make cmake sdl mercurial zlib bzip2 libjpeg-turbo \
fluidsynth gtk2 timidity++ nasm mesa glu openssl tar

Gentoo

emerge -avn sys-devel/gcc sys-devel/make dev-util/cmake media-libs/libsdl \
dev-vcs/mercurial sys-libs/zlib app-arch/bzip2 media-libs/libjpeg-turbo media-sound/fluidsynth \
x11-libs/gtk+ media-sound/timidity++ dev-lang/nasm media-libs/mesa media-libs/glu \
dev-libs/openssl app-arch/tar

PCLinuxOS

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

Solus

sudo eopkg install g++ make cmake binutils glibc-devel pkg-config \
sdl1-devel mercurial zlib-devel bzip2-devel libjpeg-turbo-devel \
fluidsynth-devel libgtk-2-devel nasm mesalib-devel libglu-devel \
openssl-devel tar

Do the following sections as normal user.

Create zandronum_build directory

mkdir -pv ~/zandronum_build

Download and prepare the source

Download the Zandronum source and create buildclient and buildserver directories:

cd ~/zandronum_build &&
hg clone https://bitbucket.org/Torr_Samaho/zandronum &&
mkdir -pv zandronum/buildclient zandronum/buildserver

Download FMOD

Download FMOD 4.24.16 32-bit or 64-bit and extract files to zandronum directory:

a='' && [ "$(uname -m)" = x86_64 ] && a=64
cd ~/zandronum_build &&
wget -nc http://zandronum.com/essentials/fmod/fmodapi42416linux${a}.tar.gz &&
tar -xvzf fmodapi42416linux${a}.tar.gz -C zandronum

Compiling

To compile Zandronum client:

a='' && [ "$(uname -m)" = x86_64 ] && a=64
c="$(lscpu -p | grep -v '#' | sort -u -t , -k 2,4 | wc -l)" ; [ "$c" -eq 0 ] && c=1
cd ~/zandronum_build/zandronum/buildclient &&
rm -f output_sdl/liboutput_sdl.so &&
if [ -d "../fmodapi42416linux${a}" ]; then
f="-DFMOD_LIBRARY=../fmodapi42416linux${a}/api/lib/libfmodex${a}-4.24.16.so \
-DFMOD_INCLUDE_DIR=../fmodapi42416linux${a}/api/inc"; else
f='-UFMOD_LIBRARY -UFMOD_INCLUDE_DIR'; fi &&
cmake .. -DCMAKE_BUILD_TYPE=Release -DSERVERONLY=OFF -DRELEASE_WITH_DEBUG_FILE=OFF $f &&
make -j$c

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

Assuming all goes well, a zandronum binary should be produced. To start Zandronum client, the following command should work:

./zandronum

To compile Zandronum server:

c="$(lscpu -p | grep -v '#' | sort -u -t , -k 2,4 | wc -l)" ; [ "$c" -eq 0 ] && c=1
cd ~/zandronum_build/zandronum/buildserver &&
cmake .. -DCMAKE_BUILD_TYPE=Release -DSERVERONLY=ON -DRELEASE_WITH_DEBUG_FILE=OFF &&
make -j$c

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

Assuming all goes well, a zandronum-server binary should be produced. To start Zandronum server, the following command should work:

./zandronum-server

If Zandronum complains you do not have any IWADs set up, make sure that you have your IWAD files placed in the same directory as Zandronum, in ~/.config/zandronum/, ~/.zandronum/, $DOOMWADDIR, or /usr/local/share/. Alternatively, you can edit ~/.config/zandronum/zandronum.ini or ~/.zandronum/zandronum.ini to set the path for your IWADs.

Latest stable version

Show the latest stable version:

cd ~/zandronum_build/zandronum &&
if [ "$(hg log -r 'max(tagged())' --template '{rev}\n')" -ge \
"$(hg log -l1 -k 'BUILD_ID_STR to release' --template '{rev}\n')" ]; then
hg identify -r 'max(tagged())'; else u="$(hg log -l1 -k 'BUILD_ID_STR to release' \
--template '{node|short}\n')"; echo "$u $(hg log -r $u --template '{desc}\n' |
sed -n 's/.*changed the version string to \(.*\)/\1/p')"; fi

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

cd ~/zandronum_build/zandronum &&
if [ "$(hg log -r 'max(tagged())' --template '{rev}\n')" -ge \
"$(hg log -l1 -k 'BUILD_ID_STR to release' --template '{rev}\n')" ]; then
hg update -cr 'max(tagged())'; else hg update -c $(hg log -l1 -k \
'BUILD_ID_STR to release' --template '{node}\n'); fi

and compile.

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

cd ~/zandronum_build/zandronum &&
hg update

A specific Zandronum version by UTC commit date

To compile a specific Zandronum version, for example 3.0-alpha-170806-2040; first, checkout the commit that matches 170806-2040. From left to right, 17 (2017) is the year, 08 is the month, 06 is the day, 20 is the hour, 40 is the minute and the time zone is +0000:

cd ~/zandronum_build/zandronum &&
hg update -cd '2017-08-06 20:40 +0000'

Now go to #Compiling.

After compiling, backing up and optionally installing Zandronum, run:

cd ~/zandronum_build/zandronum &&
hg update

Older versions

First, show the Zandronum version you are currently on:

w='r ' && [ "$(uname -s)" = Linux ] && w='d @'
cd ~/zandronum_build/zandronum &&
v="$(sed -n 's/.*#define GAMEVER_STRING "\(.*\)".*/\1/p' src/version.h)\
$(sed -n 's/.*#define DOTVERSIONSTR GAMEVER_STRING "\(.*\)".*/\1/p' src/version.h)\
$(date -u$w$(hg log -r . --template '{date}\n' | cut -d'.' -f1) +'-%y%m%d-%H%M')\
$(hg id -i | sed '/+$/!s/.*//;s/.*+$/M/')" &&
echo $v

If the Zandronum version you are currently on is 2.x or lower, do the following:

To compile Zandronum 2.x or older versions, you need to install gcc 4.9 or lower:

sudo apt-get install gcc-4.9 g++-4.9

Inside the buildclient and buildserver directories, run cmake with these arguments -DCMAKE_C_COMPILER=/path/to/compiler/gcc -DCMAKE_CXX_COMPILER=/path/to/compiler/g++, for example:

cd ~/zandronum_build/zandronum/buildclient &&
cmake .. -DCMAKE_C_COMPILER=/usr/bin/gcc-4.9 \
-DCMAKE_CXX_COMPILER=/usr/bin/g++-4.9
cd ~/zandronum_build/zandronum/buildserver &&
cmake .. -DCMAKE_C_COMPILER=/usr/bin/gcc-4.9 \
-DCMAKE_CXX_COMPILER=/usr/bin/g++-4.9

and compile.

If you are going to compile Zandronum 1.0 (120819-2011) and your Mesa version is 9.x or higher:

glxinfo | grep 'OpenGL version'

apply the fix from commit a69d59da0f51, otherwise the Zandronum client will not compile.

Backup

If you want to backup Zandronum, do the following:

Create and name a directory with the corresponding Zandronum version/revision, build type and copy zandronum, zandronum-server, zandronum.pk3, skulltag_actors.pk3 and liboutput_sdl.so to it:

cd ~/zandronum_build/zandronum &&
e=buildclient && i=buildserver && if [ -f "$e/CMakeCache.txt" ]; then
j="$(sed -n 's/.*CMAKE_BUILD_TYPE:STRING=\(.*\)/\1/p' $e/CMakeCache.txt)"; else j=''; fi &&
if [ -f "$i/CMakeCache.txt" ]; then
k="$(sed -n 's/.*CMAKE_BUILD_TYPE:STRING=\(.*\)/\1/p' $i/CMakeCache.txt)"; else k=''; fi &&
if [ -n "$j" ]; then b="-BuildType$j"; elif [ -n "$k" ]; then b="-BuildType$k"; else b=''; fi &&
r=src/svnrevision.h && if [ -f "$r" ] && [ "$(hg status $r)" != "? $r" ]; then r=$r; else
r=src/gitinfo.h; fi && h="$(sed -n 's/.*#define HG_REVISION_HASH_STRING "\(.*\)".*/\1/p' $r)" &&
BACKUPZANDRONUM="../$(hg cat -r $h src/version.h | sed -n 's/.*#define GAMEVER_STRING "\(.*\)".*/\1/p')\
$(hg cat -r $h src/version.h | sed -n 's/.*#define DOTVERSIONSTR GAMEVER_STRING "\(.*\)".*/\1/p')\
$(sed -n 's/.*#define SVN_REVISION_STRING "\(.*\)".*/\-\1/p' $r)\
$(sed -n 's/.*#define HG_TIME "\(.*\)".*/\-\1/p' $r)-$h$b" &&
mkdir -pv "$BACKUPZANDRONUM" &&
x="$e" && y="$e/zandronum.pk3" && z="$i/zandronum.pk3" &&
if [ -f "$y" ] && [ -f "$z" ] && [ "$z" -nt "$y" ]; then
x="$i"; elif [ ! -f "$y" ] && [ -f "$z" ]; then x="$i"; fi &&
o="$e/output_sdl/liboutput_sdl.so" && if [ -f "$o" ]; then l="$o"; else l=''; fi &&
cp -v $e/zandronum $i/zandronum-server $x/zandronum.pk3 $x/skulltag_actors.pk3 $l \
"$BACKUPZANDRONUM"/

Files are located at:

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

Updating

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

cd ~/zandronum_build/zandronum &&
hg pull ; hg update

When the update finish, go to #Compiling.

Installation

  • zandronum / zandronum-server = Stable version
  • zandronum-alpha / zandronum-server-alpha = Development version

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

If you want to install Zandronum, do the following:

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

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

Copy zandronum, zandronum-server, zandronum.pk3, skulltag_actors.pk3, liboutput_sdl.so and the FMOD library file to /usr/games/zandronum/ or /usr/games/zandronum-alpha/:

a='' && [ "$(uname -m)" = x86_64 ] && a=64
cd ~/zandronum_build/zandronum &&
e=buildclient && i=buildserver &&
if [ -f src/svnrevision.h ] &&
[ "$(hg status src/svnrevision.h)" != "? src/svnrevision.h" ]; then
r=src/svnrevision.h; else r=src/gitinfo.h; fi &&
h="$(sed -n 's/.*#define HG_REVISION_HASH_STRING "\(.*\)".*/\1/p' $r)" &&
t="$(hg id -tr $h)" &&
d='' && if [ -z "$(hg log -r $h -k 'BUILD_ID_STR to release')" ]; then
if [ "$t" = tip ] || [ -z "$t" ]; then d=-alpha; fi; fi &&
x="$e" && y="$e/zandronum.pk3" && z="$i/zandronum.pk3" &&
if [ -f "$y" ] && [ -f "$z" ] && [ "$z" -nt "$y" ]; then
x="$i"; elif [ ! -f "$y" ] && [ -f "$z" ]; then x="$i"; fi &&
o="$e/output_sdl/liboutput_sdl.so" && if [ -f "$o" ]; then l="$o \
fmodapi42416linux${a}/api/lib/libfmodex${a}-4.24.16.so"; else l=''; fi &&
sudo cp -v $e/zandronum $i/zandronum-server $x/zandronum.pk3 $x/skulltag_actors.pk3 $l \
/usr/games/zandronum$d/

Create launch scripts:

cd ~/zandronum_build/zandronum &&
if [ -f src/svnrevision.h ] &&
[ "$(hg status src/svnrevision.h)" != "? src/svnrevision.h" ]; then
r=src/svnrevision.h; else r=src/gitinfo.h; fi &&
h="$(sed -n 's/.*#define HG_REVISION_HASH_STRING "\(.*\)".*/\1/p' $r)" &&
t="$(hg id -tr $h)" &&
d='' && if [ -z "$(hg log -r $h -k 'BUILD_ID_STR to release')" ]; then
if [ "$t" = tip ] || [ -z "$t" ]; then d=-alpha; fi; fi &&
printf %s "\
#!/bin/sh
export LD_LIBRARY_PATH=/usr/games/zandronum$d
exec /usr/games/zandronum$d/zandronum \"\$@\"
" > zandronum$d.sh &&
printf %s "\
#!/bin/sh
exec /usr/games/zandronum$d/zandronum-server \"\$@\"
" > zandronum-server$d.sh &&
chmod 755 zandronum$d.sh zandronum-server$d.sh &&
sudo mv -v zandronum$d.sh /usr/bin/zandronum$d &&
sudo mv -v zandronum-server$d.sh /usr/bin/zandronum-server$d

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

Uninstallation

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

sudo rm -rfv /usr/games/zandronum

Remove zandronum script:

sudo rm -fv /usr/bin/zandronum

Remove zandronum-server script:

sudo rm -fv /usr/bin/zandronum-server

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

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

Remove zandronum-alpha script:

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

Remove zandronum-server-alpha script:

sudo rm -fv /usr/bin/zandronum-server-alpha

Developing

This page has helped you compile Zandronum, 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 Zandronum client

Prerequisite:

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

cd ~/zandronum_build/zandronum/buildclient
cmake .. -DCMAKE_BUILD_TYPE=Debug -DSERVERONLY=OFF

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 Zandronum client under a debugger such as gdb, use the following command:

gdb zandronum

Now gdb should have you in its own command prompt:

(gdb)

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

(gdb) set logging on zandronumclientdebug.log

Now start Zandronum client by typing in run, and pressing enter:

(gdb) run

Or put any command line parameters to zandronum after run:

(gdb) run <command line parameters>

If Zandronum client 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 zandronumclientdebug.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.

Debugging Zandronum server

Prerequisite:

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

cd ~/zandronum_build/zandronum/buildserver
cmake .. -DCMAKE_BUILD_TYPE=Debug -DSERVERONLY=ON

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 Zandronum server under a debugger such as gdb, use the following command:

gdb zandronum-server

Now gdb should have you in its own command prompt:

(gdb)

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

(gdb) set logging on zandronumserverdebug.log

Now start Zandronum server by typing in run, and pressing enter:

(gdb) run

Or put any command line parameters to zandronum-server after run:

(gdb) run <command line parameters>

If Zandronum server 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 zandronumserverdebug.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
SERVERONLY=ON Build a server only binary. cmake .. -DSERVERONLY=ON
NO_GTK=ON Disable GTK+ dialogs. cmake .. -DNO_GTK=ON
NO_SOUND=ON Disable sound support. cmake .. -DNO_SOUND=ON
NO_GL=ON Disable OpenGL support. cmake .. -DNO_GL=ON
NO_ASM=ON Disable assembly code. cmake .. -DNO_ASM=ON
RELEASE_WITH_DEBUG_FILE=ON Create the debug symbols file for the release build. cmake .. -DRELEASE_WITH_DEBUG_FILE=ON
FMOD_LIBRARY Set path for FMOD library file. cmake .. -DFMOD_LIBRARY=/path/to/libfmodex(64)-x.y.z.so
FMOD_INCLUDE_DIR Set path for FMOD include directory. cmake .. -DFMOD_INCLUDE_DIR=/path/to/include/dir
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

How to increase Zandronum/GZDoom OpenGL FPS

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

Run Zandronum/GZDoom, start a new game, open console and type vid_fps 1, see how many FPS are displayed and exit Zandronum/GZDoom.

If you do not use Intel graphics, go to #Disable Vertical Synchronization for Zandronum/GZDoom.

Enable SandyBridge's New Acceleration

Prerequisite:

Debian/Ubuntu

  • xserver-xorg-video-intel >= 2.19

Fedora

  • xorg-x11-drv-intel >= 2.19

openSUSE

  • xf86-video-intel >= 2.19

Mageia

  • x11-driver-video-intel >= 2.19

Arch Linux

  • xf86-video-intel >= 2.19

Gentoo

  • x11-drivers/xf86-video-intel >= 2.19

PCLinuxOS

  • x11-driver-video-intel >= 2.19

Solus

  • xorg-driver-video-intel >= 2.19

If your Intel driver version is 2.21.14-1 / 2.21.15-2 or higher:

grep 'SNA compiled:' /var/log/Xorg.0.log

go to #Disable Vertical Synchronization for Zandronum/GZDoom.

Intel SNA is useful on all Intel graphics, not just SandyBridge.

Create /etc/X11/xorg.conf.d directory:

sudo mkdir -pv /etc/X11/xorg.conf.d

Create 99-intel.conf file:

cat <<'EOF' > 99-intel.conf
Section "Device"
    Identifier "Intel Graphics"
    Driver "intel"
    Option "AccelMethod" "sna"
EndSection
EOF

Move 99-intel.conf to /etc/X11/xorg.conf.d/:

sudo mv -v 99-intel.conf /etc/X11/xorg.conf.d/

and logout and login.

Disable Vertical Synchronization for Zandronum/GZDoom

Do the following step if you are using a GZDoom version prior to commit 4eb32a50e. The following step works for the open-source graphics drivers.

Create ~/.drirc file:

cat <<'EOF' > ~/.drirc
<driconf>
    <device screen="0" driver="dri2">
        <application name="zandronum" executable="zandronum">
            <option name="vblank_mode" value="0"/>
        </application>
        <application name="gzdoom" executable="gzdoom">
            <option name="vblank_mode" value="0"/>
        </application>
    </device>
</driconf>
EOF

Run Zandronum/GZDoom, start a new game, open console and type vid_fps 1, see how many FPS are displayed, you should get more FPS than before.

Reverting changes

Remove ~/.drirc file:

rm -fv ~/.drirc

Remove 99-intel.conf file:

sudo rm -fv /etc/X11/xorg.conf.d/99-intel.conf

and logout and login.