Thursday, August 27, 2009
4:58 AM

Compile Nethack in Ubuntu GNU/Linux

Nethack is one of my favourite games. I cannot describe what it is like cause I will fail showing the truth. Nethack website is:
http://www.nethack.org/
From there the average user can download latest source - 3.4.3 and compile it. This source code is dated 2003 year. Latest commits to the source code ( in the form of patches sent by authorised nethack developer) to the code are dated 2006. I do not know why the source code repository is not mentioned on the website. Maybe I didn't look for it well. Anyway I found it on sourceforge cvs repositories. To get latest nethack source code under ubuntu you'll need cvs installed.
then in terminal issue these 2 commands:
command 1:

cvs -d:pserver:anonymous@nethack.cvs.sourceforge.net:/cvsroot/nethack login

then hit enter to access it with no password

type:

cvs -z3 -d:pserver:anonymous@nethack.cvs.sourceforge.net:/cvsroot/nethack co -P nethack


So far so good - we have downloaded sources for nethack. That was quite easy hum ... :)
The fun part begins now.
In terminal type:

apt-get build-dep nethack
#that should install needed dependencies.


I personally recommend applying a patch to the vanilla source code in order to compile.
The patch is in the nethack patch database so it is somehow a trusted one :)

http://bhaak.dyndns.org/nethack/nethack-autoconf-20090217.patch

Instructions for applying it are in the patch itself but basically:
put the downloaded nethack-autoconf-20090217.patch file in nethack folder and from terminal while in nethack folder execute:


patch -p1 <<>nethack-autoconf-20090217.patch


It should apply fine.
After applying the patch type: chmod a+x configure -that makes the newly generated autoconf script
executable.
then type:

./configure --enable- # and pres tab key twice to see the options.
# Be greedy about enabling this options but one warning: enable-user-sounds option fails so you'd better skip it.
# It's there for a reason but not for compiling nethack these days :)


after enabling all the options one full line of configure should look like this one:


./configure --enable-autopickup-exceptions --enable-clipping --enable-data-librarian --enable-elbereth --enable-exp-on-botl --enable-goldobj --enable-kops --enable-redo --enable-reincarnation --enable-score-on-botl --enable-seduce --enable-sinks --enable-steed --enable-tourist --enable-tty-graphics --enable-wallified-maze --enable-wizmode --enable-x11-graphics


Then hit enter and wait to configure
copy: nethack/win/share/tile.h file to nethack/win/X11 folder as well :)
type:

make all
sudo make install


If the deity is not angry with you, nethack should build fine.
Type sudo make install and you'll got nethack installed :)
Nethack has two configuration files for linux:
NetHack.ad and .nethackrc
My files are in these locations:
/usr/local/nethackdir/NetHack.ad
~/.nethackrc
.nethackrc was manually created by me following this example:
http://nethack.kraln.com/rcfiles/ArgonSloth.nethackrc

Edit both files according to your needs. This install of nethack provides 2 interfaces:
traditional tty graphics and x11 tiled graphics , you can switch graphics modes by editing
~/.nethackrc file , change OPTIONS=windowtype:x11, to read OPTIONS=windowtype:tty or vice versa
and voila :)

For those who do not want to apply any patches and want nethack compiled the hard way:
open the source directory read the docs located in:
nethack/sys/unix directory - especially README.linux and Install.unx files. Then decide
which graphical interface you desire - choices are: tty , xx1 , kde , qt , gnome. The five of them
in one compilation should be possible but in reality things seem different.
The instructions for configuring the graphical interface(s) are in:
nethack/win folder - just choose the subfolder you desire like: qt,gnome,tty,x11 ( for kde
the instructions should be in the qt folder) Read the corresponding INSTALL files.
After reading all this nice informations about the great game, having configured 2 makefiles and
one config.h file everything is done. (At least I thought so but I was wrong)
There is a compilation issue which involves editing a termcap.c file or similar. I haven't bothered with qt or kde or gnome
builds. I perfectly realise this source code is OOOOLD and my ubuntu new libraries will most likely cause issues.
That is why applying the above mentioned patch is the method I recommend. It saves time which can be
devoted to premium nethacking :) By the time one is configuring source code by hand, the
patch users will be wearing the amulet of Yendor and returning it to the deity of Open Source.

Happy hacking :)

0 comments:

Post a Comment