Compiling Zandronum on Linux: Difference between revisions

(Created page with "== Prerequisites == Zandronum requires some development files in order to compile: * gcc - C and C++ compilers >= 3.4.6 * make * cmake >= 2.4 * SDL >= 1.2.8 * libGL and libGLU...")
 
Line 1: Line 1:
'''Open a terminal and copy and paste the whole code box for each step.'''
== Notes ==
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.
If you need to compile Zandronum 2.x or lower, you will need to install gcc 4.9 or lower:
<pre>
sudo apt-get install gcc-4.9 g++-4.9
</pre>
and set this variables according to the gcc version before compiling:
<pre>
export CC="gcc-4.9"
export CXX="g++-4.9"
</pre>
== Prerequisites ==
== Prerequisites ==
Zandronum requires some development files in order to compile:
Zandronum requires some development files in order to compile:
Line 84: Line 100:
== Make zandronum_build directory ==
== Make zandronum_build directory ==
<pre>
<pre>
mkdir -pv $HOME/zandronum_build
mkdir -pv "$HOME"/zandronum_build
</pre>
</pre>


== Download the Source ==
== Download the Source ==
Download the Zandronum source and make buildclient and buildserver directories:
Download the Zandronum source and make buildclient and buildserver directories:
<pre>
<pre>
cd $HOME/zandronum_build && \
cd "$HOME"/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,buildserver}
Line 98: Line 112:


== Download FMOD ==
== Download FMOD ==
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 && \
cd "$HOME"/zandronum_build && \
if [ "$(uname -m)" = "x86_64" ]; then  
if [ "$(uname -m)" = "x86_64" ]; then  
FMODFOLDER="fmodapi42416linux64"  
a="64"  
else
else
FMODFOLDER="fmodapi42416linux"
a=""
fi && \
fi && \
wget -nc http://zandronum.com/essentials/fmod/$FMODFOLDER.tar.gz && \
wget -nc http://zandronum.com/essentials/fmod/fmodapi42416linux"$a".tar.gz && \
tar -xvzf $FMODFOLDER.tar.gz -C zandronum
tar -xvzf fmodapi42416linux"$a".tar.gz -C zandronum
</pre>
</pre>


=== FMOD Links ===
=== FMOD Links ===
FMOD 4.24.16 32-bit:<br />
FMOD 4.24.16 32-bit:<br />
http://zandronum.com/essentials/fmod/fmodapi42416linux.tar.gz
http://zandronum.com/essentials/fmod/fmodapi42416linux.tar.gz
Line 122: Line 134:
To compile the development version:
To compile the development version:


Zandronum client:
'''Zandronum client''':
<pre>
<pre>
cd $HOME/zandronum_build/zandronum/buildclient && \
cd "$HOME"/zandronum_build/zandronum/buildclient && \
if [ "$(uname -m)" = "x86_64" ]; then
if [ "$(uname -m)" = "x86_64" ]; then
FMODFOLDER="fmodapi42416linux64"
a="64"
FMODFILE="libfmodex64-4.24.16"
else
else
FMODFOLDER="fmodapi42416linux"
a=""
FMODFILE="libfmodex-4.24.16"
fi && \
fi && \
make clean ; \
make clean ; \
cmake -DCMAKE_BUILD_TYPE=Release \
cmake -DCMAKE_BUILD_TYPE=Release \
-DFMOD_LIBRARY=$HOME/zandronum_build/zandronum/$FMODFOLDER/api/lib/$FMODFILE.so \
-DFMOD_LIBRARY="$HOME"/zandronum_build/zandronum/fmodapi42416linux"$a"/api/lib/libfmodex"$a"-4.24.16.so \
-DFMOD_INCLUDE_DIR=$HOME/zandronum_build/zandronum/$FMODFOLDER/api/inc .. && \
-DFMOD_INCLUDE_DIR="$HOME"/zandronum_build/zandronum/fmodapi42416linux"$a"/api/inc .. && \
make
make
</pre>
Assuming all goes well, a zandronum binary should be produced. To start Zandronum client, the following command should work:
<pre>
./zandronum
</pre>
</pre>


Zandronum server:
'''Zandronum server''':
<pre>
<pre>
cd $HOME/zandronum_build/zandronum/buildserver && \
cd "$HOME"/zandronum_build/zandronum/buildserver && \
make clean ; \
make clean ; \
cmake -DCMAKE_BUILD_TYPE=Release -DSERVERONLY=ON .. && \
cmake -DCMAKE_BUILD_TYPE=Release -DSERVERONLY=ON .. && \
make
make
</pre>
</pre>
Assuming all goes well, a zandronum-server binary should be produced. To start Zandronum server, the following command should work:
<pre>
./zandronum-server
</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 and set the path for your IWADs.


=== Current stable version ===
=== Current stable version ===
Show the current stable version:
Show the current stable version:
<pre>
<pre>
cd $HOME/zandronum_build/zandronum && \
cd "$HOME"/zandronum_build/zandronum && \
hg identify -r "max(tagged())"
hg identify -r 'max(tagged())'
</pre>
</pre>


If you want to compile the current stable version, run the following:
If you want to compile the current stable version, run the following:
<pre>
<pre>
cd $HOME/zandronum_build/zandronum && \
cd "$HOME"/zandronum_build/zandronum && \
hg update -cr "max(tagged())"
hg update -cr 'max(tagged())'
</pre>
</pre>
and [[#Compiling|compile]].
and [[#Compiling|compile]].


After compiling and backing up the current stable version, run the following:
After compiling, backing up and optionally [[#Installation|installing]] the current stable version, run the following:
<pre>
<pre>
cd $HOME/zandronum_build/zandronum && \
cd "$HOME"/zandronum_build/zandronum && \
hg update
hg update
</pre>
</pre>


== Backup ==
== Backup ==
Follow this step if you want or manually copy (backup) zandronum, zandronum.pk3, skulltag_actors.pk3, liboutput_sdl.so and zandronum-server.
Follow this step if you want or manually copy (backup) zandronum, zandronum.pk3, skulltag_actors.pk3, liboutput_sdl.so and zandronum-server.


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:
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:
<pre>
<pre>
cd $HOME/zandronum_build && \
cd "$HOME"/zandronum_build/zandronum/src && \
BACKUPZANDRONUM="$(sed -n 's/.*#define GAMEVER_STRING "\(.*\)".*/\1/p' \
BACKUPZANDRONUM="$(sed -n 's/.*#define GAMEVER_STRING "\(.*\)".*/\1/p' version.h)\
zandronum/src/version.h)\
$(sed -n 's/.*#define DOTVERSIONSTR.*GAMEVER_STRING "\(.*\)".*/\1/p' version.h)\
$(sed -n 's/.*#define DOTVERSIONSTR.*GAMEVER_STRING "\(.*\)".*/\1/p' \
$(sed -n 's/.*#define SVN_REVISION_STRING "\(.*\)".*/\-r\1/p' {svnrevision.h,gitinfo.h})\
zandronum/src/version.h)\
$(sed -n 's/.*#define HG_TIME "\(.*\)".*/\-r\1/p' gitinfo.h)\
$(sed -n 's/.*#define SVN_REVISION_STRING "\(.*\)".*/\-r\1/p' \
$(sed -n 's/.*#define HG_REVISION_HASH_STRING "\(.*\)".*/\-\1/p' gitinfo.h)" ; \
zandronum/src/svnrevision.h)" && \
cd ../.. && mkdir -pv "$BACKUPZANDRONUM" && \
mkdir -pv "$BACKUPZANDRONUM" && \
cp -v zandronum/{buildclient/{zandronum,zandronum.pk3,\
skulltag_actors.pk3,output_sdl/liboutput_sdl.so},\
buildserver/zandronum-server} "$BACKUPZANDRONUM"
</pre>
 
If the above fails, try this:
<pre>
cd $HOME/zandronum_build && \
BACKUPZANDRONUM="$(sed -n 's/.*#define GAMEVER_STRING "\(.*\)".*/\1/p' \
zandronum/src/version.h)\
$(sed -n 's/.*#define DOTVERSIONSTR.*GAMEVER_STRING "\(.*\)".*/\1/p' \
zandronum/src/version.h)\
$(sed -n 's/.*#define SVN_REVISION_STRING "\(.*\)".*/\-r\1/p' \
zandronum/src/gitinfo.h)\
$(sed -n 's/.*#define HG_TIME "\(.*\)".*/\-r\1/p' \
zandronum/src/gitinfo.h)\
$(sed -n 's/.*#define HG_REVISION_HASH_STRING "\(.*\)".*/\-\1/p' \
zandronum/src/gitinfo.h)" && \
mkdir -pv "$BACKUPZANDRONUM" && \
cp -v zandronum/{buildclient/{zandronum,zandronum.pk3,\
cp -v zandronum/{buildclient/{zandronum,zandronum.pk3,\
skulltag_actors.pk3,output_sdl/liboutput_sdl.so},\
skulltag_actors.pk3,output_sdl/liboutput_sdl.so},\
Line 206: Line 204:


=== Backup (Optional) ===
=== Backup (Optional) ===
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:
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:
<pre>
<pre>
cd $HOME/zandronum_build && \
cd "$HOME"/zandronum_build && \
COPYANDPASTEZAN="$(date +%Y%m%d%H%M)" && \
COPYANDPASTEZAN="$(date +%Y%m%d%H%M)" && \
mkdir -pv "$COPYANDPASTEZAN" && \
mkdir -pv "$COPYANDPASTEZAN" && \
Line 221: Line 218:


== 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 "$HOME"/zandronum_build/zandronum && \
hg pull ; hg update
hg pull ; hg update
</pre>
</pre>
Line 231: Line 227:


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


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


Make /usr/games/zandronum directory:
Make /usr/games/zandronum and /usr/games/zandronum-alpha directories:
<pre>
<pre>
sudo mkdir -pv /usr/games/zandronum
sudo mkdir -pv /usr/games/{zandronum,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:
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:
<pre>
<pre>
cd "$HOME"/zandronum_build/zandronum && \
t="$(hg id -t)" && \
if [ "$t" = "tip" ] || [ -z "$t" ]; then
d="-alpha"
else
d=""
fi && \
if [ "$(uname -m)" = "x86_64" ]; then
if [ "$(uname -m)" = "x86_64" ]; then
FMODFOLDER="fmodapi42416linux64"
a="64"
FMODFILE="libfmodex64-4.24.16"
else
else
FMODFOLDER="fmodapi42416linux"
a=""
FMODFILE="libfmodex-4.24.16"
fi && \
fi && \
sudo cp -v /home/$USER/zandronum_build/zandronum/{buildclient/{zandronum,\
sudo cp -v {buildclient/{zandronum,zandronum.pk3,\
zandronum.pk3,skulltag_actors.pk3,output_sdl/liboutput_sdl.so},\
skulltag_actors.pk3,output_sdl/liboutput_sdl.so},\
buildserver/zandronum-server,$FMODFOLDER/api/lib/$FMODFILE.so} \
buildserver/zandronum-server,fmodapi42416linux"$a"/api/lib/libfmodex"$a"-4.24.16.so} \
/usr/games/zandronum
/usr/games/zandronum"$d"
</pre>
</pre>


Make zandronum script, add executable permission and copy it to /usr/bin:
Make zandronum or zandronum-alpha script, add executable permission and move it to /usr/bin:
<pre>
<pre>
cd /tmp && \
cd "$HOME"/zandronum_build/zandronum && \
echo '#!/bin/sh' > zandronum && \
t="$(hg id -t)" && \
echo >> zandronum && \
if [ "$t" = "tip" ] || [ -z "$t" ]; then
echo 'export LD_LIBRARY_PATH=/usr/games/zandronum' >> zandronum && \
d="-alpha"
echo 'exec /usr/games/zandronum/zandronum "$@"' >> zandronum && \
else
chmod 755 zandronum && \
d=""
sudo cp -v zandronum /usr/bin && \
fi && cd /tmp && \
rm -fv zandronum
echo '#!/bin/sh' > 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 script, add executable permission and copy it to /usr/bin:
Make zandronum-server or zandronum-server-alpha script, add executable permission and move it to /usr/bin:
<pre>
<pre>
cd /tmp && \
cd "$HOME"/zandronum_build/zandronum && \
echo '#!/bin/sh' > zandronum-server && \
t="$(hg id -t)" && \
echo >> zandronum-server && \
if [ "$t" = "tip" ] || [ -z "$t" ]; then
echo 'exec /usr/games/zandronum/zandronum-server "$@"' >> zandronum-server && \
d="-alpha"
chmod 755 zandronum-server && \
else
sudo cp -v zandronum-server /usr/bin && \
d=""
rm -fv zandronum-server
fi && cd /tmp && \
echo '#!/bin/sh' > zandronum-server"$d" && \
echo >> zandronum-server"$d" && \
echo "exec /usr/games/zandronum"$d"/zandronum-server \"\$@\"" >> zandronum-server"$d" && \
chmod 755 zandronum-server"$d" && \
sudo mv -v zandronum-server"$d" /usr/bin
</pre>
</pre>


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


=== Uninstallation ===
=== Uninstallation ===
To remove the previous installation steps:
To remove the previous installation steps:


Line 301: Line 310:
cd /usr/bin && \
cd /usr/bin && \
sudo rm -fv zandronum-server
sudo rm -fv zandronum-server
</pre>
Remove /usr/games/zandronum-alpha directory and all its files:
<pre>
cd /usr/games && \
sudo rm -rfv zandronum-alpha
</pre>
Remove zandronum-alpha script:
<pre>
cd /usr/bin && \
sudo rm -fv zandronum-alpha
</pre>
Remove zandronum-server-alpha script:
<pre>
cd /usr/bin && \
sudo rm -fv zandronum-server-alpha
</pre>
</pre>


Line 313: Line 340:
Make debugclient directory.
Make debugclient directory.
<pre>
<pre>
mkdir -pv $HOME/zandronum_build/zandronum/debugclient
mkdir -pv "$HOME"/zandronum_build/zandronum/debugclient
</pre>
</pre>


Make a debug build of zandronum client.
Make a debug build of zandronum client.
<pre>
<pre>
cd $HOME/zandronum_build/zandronum/debugclient && \
cd "$HOME"/zandronum_build/zandronum/debugclient && \
if [ "$(uname -m)" = "x86_64" ]; then
if [ "$(uname -m)" = "x86_64" ]; then
FMODFOLDER="fmodapi42416linux64"
a="64"
FMODFILE="libfmodex64-4.24.16"
else
else
FMODFOLDER="fmodapi42416linux"
a=""
FMODFILE="libfmodex-4.24.16"
fi && \
fi && \
make clean ; \
make clean ; \
cmake -DCMAKE_BUILD_TYPE=Debug \
cmake -DCMAKE_BUILD_TYPE=Debug \
-DFMOD_LIBRARY=$HOME/zandronum_build/zandronum/$FMODFOLDER/api/lib/$FMODFILE.so \
-DFMOD_LIBRARY="$HOME"/zandronum_build/zandronum/fmodapi42416linux"$a"/api/lib/libfmodex"$a"-4.24.16.so \
-DFMOD_INCLUDE_DIR=$HOME/zandronum_build/zandronum/$FMODFOLDER/api/inc .. && \
-DFMOD_INCLUDE_DIR="$HOME"/zandronum_build/zandronum/fmodapi42416linux"$a"/api/inc .. && \
make
make
</pre>
</pre>
Line 366: Line 391:
Make debugserver directory.
Make debugserver directory.
<pre>
<pre>
mkdir -pv $HOME/zandronum_build/zandronum/debugserver
mkdir -pv "$HOME"/zandronum_build/zandronum/debugserver
</pre>
</pre>


Make a debug build of zandronum-server.
Make a debug build of zandronum-server.
<pre>
<pre>
cd $HOME/zandronum_build/zandronum/debugserver && \
cd "$HOME"/zandronum_build/zandronum/debugserver && \
make clean ; \
make clean ; \
cmake -DCMAKE_BUILD_TYPE=Debug -DSERVERONLY=ON .. && \
cmake -DCMAKE_BUILD_TYPE=Debug -DSERVERONLY=ON .. && \
Line 408: Line 433:


== Build Options ==
== Build Options ==
{|class="wikitable" width="65%"
{|class="wikitable" width="72%"
|+ <span style="text-decoration: underline">CMake Build Options</span>
|+ <span style="text-decoration: underline">CMake Build Options</span>
|-
|-
Line 428: Line 453:
|}
|}


{|class="wikitable" width="65%"
{|class="wikitable" width="72%"
|+ <span style="text-decoration: underline">CMake Build Types</span>
|+ <span style="text-decoration: underline">CMake Build Types</span>
|-
|-
Line 507: Line 532:
Open a terminal, go to your user home directory and verify if the .drirc file already exist:
Open a terminal, go to your user home directory and verify if the .drirc file already exist:
<pre>
<pre>
cd $HOME
cd "$HOME"
ls -la
ls -la
</pre>
</pre>
Line 542: Line 567:
Remove .drirc:
Remove .drirc:
<pre>
<pre>
cd $HOME
cd "$HOME"
rm -fv .drirc
rm -fv .drirc
</pre>
</pre>
20

edits