# Copyright 1999-2003 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 # $Header: /home/cvsroot/gentoo-x86/app-games/nethack/nethack-3.4.1.ebuild,v 1.1 2003/02/27 12:36:15 vapier Exp $ inherit games eutils SRC_URI="ftp://ftp.nethack.org/pub/nethack/nh341/src/nethack-341.tgz" DESCRIPTION="The ultimate old-school single player dungeon exploration game" HOMEPAGE="http://www.nethack.org/" KEYWORDS="x86" SLOT="0" LICENSE="nethack" IUSE="X qt gnome" DEPEND="virtual/glibc dev-util/yacc >=sys-libs/ncurses-5.2-r5 X? ( x11-base/xfree ) qt? ( =x11-libs/qt-2* ) gnome? ( >=gnome-base/gnome-libs-1.4.1.4-r2 )" # Where nethack data is to be kept HACKDIR=${GAMES_DATADIR}/${PN} src_unpack() { unpack ${A} cd ${S} # epatch ${FILESDIR}/${PF}-gentoo.patch # epatch ${FILESDIR}/${PV}-errno.patch # This copies the /sys/unix Makefile.*s to their correct places for # seding and compiling. cd ${S}/sys/unix source setup.sh || die # Nethack doesn't use ./configure. Platform options have to be edited # manually. This also sets up /usr/share/nethackdir instead of # /usr/games/lib/nethackdir. cd ${S}/include mv config.h config.h.orig sed -e 's:^\(#define COMPRESS\) .*:\1 "/bin/gzip":' \ -e 's:^\(#define COMPRESS_EXTENSION\) .*:\1 ".gz":' \ -e 's:^/\* \(#define DLB\) .*:\1:' \ -e 's:/usr/games/lib/nethackdir:'${HACKDIR}':' \ -e 's:^/\* \(#define VISION_TABLES\) .*:\1:' \ config.h.orig >config.h || die # test, remove me if config.h ok rm config.h.orig cd ${S}/include mv unixconf.h unixconf.h.orig sed -e 's:^/\* \(#define LINUX\) .*:\1:' \ -e 's:^/\* \(#define TIMED_DELAY\) .*:\1:' \ unixconf.h.orig >unixconf.h || die rm unixconf.h.orig cd ${S}/src mv Makefile Makefile.orig sed -e 's:^\(WINTTYLIB =\).*:\1 -lncurses:' \ Makefile.orig >Makefile || die rm Makefile.orig if [ `use X` ] ; then cd ${S}/include mv config.h config.h.orig sed -e 's:^/\* \(#define X11_GRAPHICS\) .*:\1:' \ -e 's:^/\* \(# define USE_XPM\) .*:\1:' \ config.h.orig >config.h || die rm config.h.orig cd ${S} mv Makefile Makefile.orig sed -e 's:^\(VARDATND =.*\):\1 x11tiles pet_mark.xbm rip.xpm:' \ Makefile.orig >Makefile || die rm Makefile.orig # Add the X11 stuffs to the make list cd ${S}/src mv Makefile Makefile.orig sed -e 's:^\(WINSRC = .*\):\1 $(WINX11SRC):' \ -e 's:^\(WINOBJ = .*\):\1 $(WINX11OBJ):' \ -e 's:^\(WINLIB = .*\):\1 $(WINX11LIB):' \ -e 's:^\(WINX11LIB =.*\):\1 -lXpm:' \ Makefile.orig >Makefile || die rm Makefile.orig if [ `use qt` ] ; then cd ${S}/include mv config.h config.h.orig sed -e 's:^/\* \(#define QT_GRAPHICS\) .*:\1:' \ config.h.orig >config.h || die "Patching config.h for QT failed" rm config.h.orig # Same as above, except we can only have one tile.o in WINOBJ and # the qt support doesn't compile against qt 3 cd ${S}/src mv Makefile Makefile.orig sed -e 's:^\(WINSRC = .*\):\1 $(WINQTSRC):' \ -e 's:^\(WINOBJ = .*\):\1 $(WINQTOBJ):' \ -e 's:^\(WINLIB = .*\):\1 $(WINQTLIB):' \ -e 's:^#\(LD=.*\):\1:' \ -e 's:^\(WINQTOBJ =.*\) tile.o\(.*\):\1\2:' \ -e 's:$(QTDIR):/usr/qt/2:' \ Makefile.orig >Makefile || die "Patching src/Makefile for QT failed" rm Makefile.orig fi if [ `use gnome` ] ; then cd ${S}/include mv config.h config.h.orig sed -e 's:^/\* \(#define GNOME_GRAPHICS\) .*:\1:' \ config.h.orig >config.h || die "Patching config.h for gnome failed" rm config.h.orig # again, we can only have one tile.o in WINOBJ cd ${S}/src mv Makefile Makefile.orig sed -e 's:^\(WINSRC = .*\):\1 $(WINGNOMESRC):' \ -e 's:^\(WINOBJ = .*\):\1 $(WINGNOMEOBJ):' \ -e 's:^\(WINLIB = .*\):\1 $(WINGNOMELIB):' \ -e 's:\(.*gnyesno.o\) tile.o\(.*\):\1\2:' \ -e "s:^\(GNOMEINC=.*\):\1 `gnome-config --cflags gnomeui`:" \ Makefile.orig >Makefile || die "Patching src/Makefile for gnome failed" rm Makefile.orig cd ${S} mv Makefile Makefile.orig sed -e 's:^\(VARDATND =.*\):\1 mapbg.xpm:' \ Makefile.orig >Makefile || die rm Makefile.orig fi fi } src_compile() { cd ${S}/src # src/Makefile suggests -fomit-frame-pointer for nh on linux make \ CC="gcc" \ CFLAGS="${CFLAGS} -fomit-frame-pointer -I../include" \ LFLAGS="-L/usr/X11R6/lib" || die cd ${S}/util make recover } src_install() { make \ CC="gcc" \ PREFIX=${D}/usr \ GAMEDIR=${D}${HACKDIR} \ SHELLDIR=${D}/${GAMES_BINDIR} \ install || die "make install failed" # The final nethack is a sh script. This fixes the hard-coded # HACKDIR directory so it doesn't point to ${D}/usr/share/nethackdir dosed "s:^\(HACKDIR=\).*:\1${HACKDIR}:" ${GAMES_BINDIR}/nethack cd ${S}/doc doman *.6 dodoc *.txt cd ${S}/util mv recover recover-nethack dogamesbin recover-nethack # Can be copied to ~/.nethackrc to set options cp ${FILESDIR}/dot.nethackrc ${S} if [ `use X` ] ; then # install nethack fonts dodir ${HACKDIR}/fonts cd ${S}/win/X11 bdftopcf -o nh10.pcf nh10.bdf || die "Converting fonts failed" bdftopcf -o ibm.pcf ibm.bdf || die "Converting fonts failed" cp *.pcf ${D}${HACKDIR}/fonts cd ${D}${HACKDIR}/fonts mkfontdir || die "The action mkfontdir ${D}${HACKDIR}/fonts failed" # copy nethack x application defaults cd ${S}/win/X11 cp NetHack.ad NetHack.ad.orig sed -e 's:^!\(NetHack.tile_file.*\):\1:' \ NetHack.ad.orig >NetHack.ad || die "Patching NetHack.ad for X failed" cp NetHack.ad NetHack insinto /etc/X11/app-defaults doins NetHack || die "Failed to install NetHack X app defaults" cd ${S} mv dot.nethackrc dot.nethackrc.orig sed -e 's/^\(# Your windowtype choices are: .*\)/\1 x11/' \ -e 's/^\(OPTIONS=windowtype:\).*/\1x11/' \ dot.nethackrc.orig >dot.nethackrc || die "Patching dot.nethackrc for X failed" if [ `use qt` ] ; then cd ${S} mv dot.nethackrc dot.nethackrc.orig sed -e 's/^\(# Your windowtype choices are: .*\)/\1 qt/' \ -e 's/^\(OPTIONS=windowtype:\).*/\1qt/' \ dot.nethackrc.orig >dot.nethackrc || die "Patching dot.nethackrc for qt failed" fi if [ `use gnome` ] ; then cd ${S} mv dot.nethackrc dot.nethackrc.orig sed -e 's/^\(# Your windowtype choices are: .*\)/\1 gnome/' \ -e 's/^\(OPTIONS=windowtype:\).*/\1gnome/' \ dot.nethackrc.orig >dot.nethackrc || die "Patching dot.nethackrc for gnome failed" fi fi insinto ${HACKDIR} doins ${S}/dot.nethackrc keepdir /usr/share/games/nethack/save ## Add this to /etc/.skel as well, thats the place for default configs cp ${S}/dot.nethackrc ${S}/.nethackrc insinto /etc/skel doins ${S}/.nethackrc einfo "you may want to look at /etc/skel/.nethackrc for interesting options" prepgamesdirs }