]> granicus.if.org Git - nethack/commitdiff
This sys/unix/hints/linux.2020 file can support tty, curses, x11, and Qt in the same...
authornhmall <nhmall@nethack.org>
Sun, 9 Aug 2020 23:02:50 +0000 (19:02 -0400)
committernhmall <nhmall@nethack.org>
Sun, 9 Aug 2020 23:02:50 +0000 (19:02 -0400)
any subset of those.

- For x11 support, you'll need to obtain and install x11 development libraries.
    For example, on Ubuntu 20.04 (as of August 2020):
        sudo apt-get install libx11-dev
        sudo apt-get install libmotif-dev
        sudo apt-get install libxaw7-dev
        sudo apt install xfonts-utils
       (That last one is for bdftopcf and mkfontdir utils)

- For Qt support, you'll need to obtain and install Qt.
    For example, on Ubuntu 20.04 (as of August 2020):
        sudo apt-get install qtbase5-dev
        sudo apt-get install qtmultimedia5-dev

    Another odd note about Qt on Linux is that if you find you are getting
    the following error trying to run NetHack after you build it:
         "error while loading shared libraries: libQt5Core.so.5:
          cannot open shared object file: No such file or directory"
    you may have to fix that (one-time only) by the following command:
     sudo strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so.5

- For curses support, you may need to obtain and install the
    ncurses development libraries if they aren't already installed
    with your distribution. They seem to be there already with Ubuntu 20.04, but
    for example, if you needed to install ncurses:
        sudo apt-get install libncurses-dev

- tty support shouldn't require any prerequisite additional packages.
---
Assuming you have the prerequisite packages mentioned above, you can
specify, right on the make command line, which window ports (or interfaces)
to include in your build. Doing it via the make command line means that you
don't have to edit the Makefile.

The make command line example below will build one binary that has
support for tty, curses, x11, and Qt. You can select between them via
your .nethackrc file (OPTIONS=windowtype:curses, OPTIONS=windowtype:tty,
OPTIONS=windowtype:x11, or OPTIONS=windowtype:Qt).

  make WANT_WIN_QT=1 WANT_WIN_X11=1 WANT_WIN_CURSES=1 WANT_WIN_TTY=1 install

sys/unix/hints/linux.2020 [new file with mode: 0755]

diff --git a/sys/unix/hints/linux.2020 b/sys/unix/hints/linux.2020
new file mode 100755 (executable)
index 0000000..0472d13
--- /dev/null
@@ -0,0 +1,258 @@
+#
+# NetHack 3.7  linux.2020 $NHDT-Date: 1596498415 2020/08/03 23:46:55 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.32 $
+# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2007.
+# NetHack may be freely redistributed.  See license for details. 
+#
+#-PRE
+# Linux hints file with support for multiple window ports (interfaces)
+#
+# This hints file supports tty, curses, x11, and Qt in the same binary,
+# but:
+#
+#  - For x11 support, you'll need to obtain and install x11 development libraries.
+#    For example, on Ubuntu 20.04 (as of August 2020):
+#        sudo apt-get install libx11-dev
+#        sudo apt-get install libmotif-dev
+#        sudo apt-get install libxaw7-dev
+#       sudo apt install xfonts-utils
+#       (That last one is for bdftopcf and mkfontdir utils)
+#
+#  - For Qt support, you'll need to obtain and install Qt.
+#    For example, on Ubuntu 20.04 (as of August 2020):
+#        sudo apt-get install qtbase5-dev
+#        sudo apt-get install qtmultimedia5-dev
+#
+#    Another odd note about Qt on Linux is that if you find you are getting
+#    the following error trying to run NetHack after you build it:
+#         "error while loading shared libraries: libQt5Core.so.5:
+#          cannot open shared object file: No such file or directory"
+#    you may have to fix that (one-time only) by the following command:
+#     sudo strip --remove-section=.note.ABI-tag /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
+#
+#  - For curses support, you may need to obtain and install the
+#    ncurses development libraries if they aren't already installed
+#    with your distribution. They seem to be there already with Ubuntu 20.04, but
+#    for example, if you needed to install ncurses:
+#        sudo apt-get install libncurses-dev
+#
+#  - tty support shouldn't require any prerequisite additional packages.
+#
+# Assuming you have the prerequisite packages mentioned above, you can
+# specify, right on the make command line, which window ports (or interfaces)
+# to include in your build. Doing it via the make command line means that won't
+# have to edit the Makefile.
+#
+# make WANT_WIN_QT=1 WANT_WIN_X11=1 WANT_WIN_CURSES=1 WANT_WIN_TTY=1 install
+#
+# Add WANT_DEFAULT=Qt (or other interface) if you want nethack to use
+# something other than tty as the default interface.
+#
+# 1. Which windowing interface(s) should be included in this binary?
+# One or more of these can be manually uncommented and/or can be specified
+# on the 'make' command line.  If none are enabled, tty will be used.
+#WANT_WIN_TTY=1
+#WANT_WIN_CURSES=1
+#WANT_WIN_X11=1
+#WANT_WIN_QT=1
+
+# 1a. What is the default window system?
+# Exactly one of these can be manually uncommented and/or can be specified
+# on the 'make' command line.  If none is enabled, the first among
+# WANT_WIN_{tty,curses,X11,Qt} that is enabled will become default.
+#WANT_DEFAULT=tty
+#WANT_DEFAULT=curses
+#WANT_DEFAULT=Qt
+#WANT_DEFAULT=X11
+
+ifdef WANT_WIN_QT
+QTDIR=/usr
+endif  # WANT_WIN_QT
+ifndef LIBXPM
+LIBXPM= -L/opt/X11/lib -lXpm
+endif
+
+# 2. Not customizable in this linux.2020 hints file, which provides
+#    a single-user build for Linux (such as Ubuntu focal).
+GAMEUID  = $(USER)
+GAMEGRP  = games
+
+# 3. miscellaneous:  compiler selection; Qt5 requires C++11
+ifdef WANT_WIN_QT
+CC=clang
+CXX=clang++ -std=gnu++11
+#CC=gcc
+#CXX=g++ -std=gnu++11
+LINK= $(CXX)
+else
+# compiling C code only; CC and CXX defaults can be used
+#CC=
+#CXX=
+LINK = $(CC)
+endif
+#MOC = moc
+
+#
+# You shouldn't need to change anything below here (in the hints file; if
+# you're reading this in Makefile augmented by hints, that may not be true).
+#
+
+# Make sure that at least one interface is enabled.
+ifndef WANT_WIN_TTY
+ifndef  WANT_WIN_CURSES
+ifndef   WANT_WIN_X11
+ifndef    WANT_WIN_QT
+WANT_WIN_TTY=1
+endif
+endif
+endif
+endif
+
+# Make sure that a default interface is specified; this doesn't guarantee
+# sanity for something like 'make WANT_WIN_CURSES=1 WANT_DEFAULT=X11' but
+# 'makedefs -v' would notice, complain, and quit causing 'make' to quit.
+ifndef WANT_DEFAULT
+# pick the first one enabled among { tty, curses, X11, Qt }
+ifdef WANT_WIN_TTY
+WANT_DEFAULT=tty
+else
+ifdef  WANT_WIN_CURSES
+WANT_DEFAULT=curses
+else
+ifdef   WANT_WIN_X11
+WANT_DEFAULT=X11
+else
+ifdef    WANT_WIN_QT
+WANT_DEFAULT=Qt
+else
+# ? shouldn't be able to get here...
+endif
+endif
+endif
+endif
+endif
+
+CFLAGS=-g -O -I../include -DNOTPARMDECL
+CFLAGS+=-DDLB
+CFLAGS+=-DCOMPRESS=\"/bin/gzip\" -DCOMPRESS_EXTENSION=\".gz\"
+CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE
+CFLAGS+=-DTIMED_DELAY
+CFLAGS+=-DHACKDIR=\"$(HACKDIR)\"
+CFLAGS+=-DDUMPLOG
+CFLAGS+=-DCONFIG_ERROR_SECURE=FALSE
+#CFLAGS+=-DEXTRA_SANITY_CHECKS
+#CFLAGS+=-DEDIT_GETLIN
+#CFLAGS+=-DSCORE_ON_BOTL
+#CFLAGS+=-DMSGHANDLER
+#CFLAGS+=-DTTY_TILES_ESCCODES
+#CFLAGS+=-DTTY_SOUND_ESCCODES
+
+WINSRC =
+WINOBJ0 =
+WINLIB =
+VARDATND =
+VARDATND0 =
+CURSESLIB =
+
+ifdef WANT_WIN_TTY
+WINSRC += $(WINTTYSRC)
+WINOBJ0 += $(WINTTYOBJ)
+CURSESLIB = -lncurses -ltinfo
+else   # !WANT_WIN_TTY
+CFLAGS += -DNOTTYGRAPHICS
+endif  # !WANT_WIN_TTY
+
+ifdef WANT_WIN_CURSES
+CFLAGS += -DCURSES_GRAPHICS
+WINSRC += $(WINCURSESSRC)
+WINOBJ0 += $(WINCURSESOBJ)
+CURSESLIB = -lncurses -ltinfo
+endif
+
+ifdef CURSESLIB
+WINLIB += $(CURSESLIB)
+endif
+
+ifdef WANT_WIN_X11
+CFLAGS += -DX11_GRAPHICS
+USE_XPM=1
+WINX11LIB = -lXaw -lXmu -lXext -lXt -lX11
+VARDATND0 += x11tiles NetHack.ad pet_mark.xbm pilemark.xbm
+# -x: if built without dlb, some versions of mkfontdir think *.lev are fonts
+POSTINSTALL += bdftopcf win/X11/nh10.bdf > $(HACKDIR)/nh10.pcf; ( cd $(HACKDIR); mkfontdir -x .lev );
+# separate from CFLAGS so that we don't pass it to every file
+X11CFLAGS = -I/opt/X11/include
+# avoid repeated complaints about _X_NONNULL(args...) in <X11/Xfuncproto.h>
+X11CFLAGS += -Wno-variadic-macros
+ifdef USE_XPM
+CFLAGS += -DUSE_XPM
+WINX11LIB += -lXpm
+VARDATND0 += rip.xpm
+endif
+WINSRC += $(WINX11SRC)
+WINOBJ0 += $(WINX11OBJ)
+WINLIB += $(WINX11LIB)
+LFLAGS=-L/opt/X11/lib
+endif  # WANT_WIN_X11
+
+ifdef WANT_WIN_QT
+CFLAGS += -DQT_GRAPHICS
+QTCXXFLAGS += -Wno-deprecated-declarations
+QTCXXFLAGS += $(shell PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig pkg-config Qt5Gui Qt5Widgets Qt5Multimedia --cflags)
+QTCXXFLAGS += -fPIC
+WINLIB += $(shell PKG_CONFIG_PATH=$(QTDIR)/lib/pkgconfig pkg-config Qt5Gui Qt5Widgets Qt5Multimedia --libs)
+WINSRC += $(WINQTSRC)
+WINOBJ0 += $(WINQTOBJ)
+VARDATND0 += nhtiles.bmp rip.xpm nhsplash.xpm pet_mark.xbm pilemark.xbm
+# XXX if /Developer/qt exists and QTDIR not set, use that
+ifndef QTDIR
+$(error QTDIR not defined in the environment or Makefile)
+endif  # QTDIR
+# XXX make sure QTDIR points to something reasonable
+POSTINSTALL+= cp -n sys/unix/sysconf $(INSTDIR)/sysconf; \
+               $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf; \
+               $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf; \
+               chmod $(VARFILEPERM) $(INSTDIR)/sysconf;
+POSTINSTALL+= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; \
+               ( cd $(INSTDIR); mkfontdir -x .lev );
+endif  # !WANT_WIN_QT
+
+# prevent duplicate tile.o in WINOBJ
+WINOBJ = $(sort $(WINOBJ0))
+# prevent duplicates in VARDATND if both X11 and Qt are being supported
+VARDATND += $(sort $(VARDATND0))
+
+#PREFIX=/usr
+PREFIX=$(wildcard ~)/nh/install
+HACKDIR=$(PREFIX)/games/lib/$(GAME)dir
+SHELLDIR = $(PREFIX)/games
+INSTDIR=$(HACKDIR)
+VARDIR = $(HACKDIR)
+
+POSTINSTALL+= cp -n sys/unix/sysconf $(INSTDIR)/sysconf; \
+       $(CHOWN) $(GAMEUID) $(INSTDIR)/sysconf; \
+       $(CHGRP) $(GAMEGRP) $(INSTDIR)/sysconf; \
+       chmod $(VARFILEPERM) $(INSTDIR)/sysconf;
+# gdb may not be installed if clang is chosen compiler so the game 
+# won't start in that case due to a sysconf error. Comment out
+# relevant lines in sysconf.
+POSTINSTALL+= sed -i -e 's;^GDBPATH=/usr/bin/gdb;\#GDBPATH=/usr/bin/gdb;' \
+               -e 's;PANICTRACE_GDB=1;PANICTRACE_GDB=0;' $(INSTDIR)/sysconf;
+
+# when building liblua.a, avoid warning that use of tmpnam() should be
+# replaced by mkstemp(); the lua code doesn't use nethack's config.h so
+# this needs to be passed via make rather than defined in unixconf.h
+SYSCFLAGS=-DLUA_USE_POSIX
+
+# Only needed for GLIBC stack trace:
+LFLAGS=-rdynamic
+
+# if TTY_TILES_ESCCODES
+#WINSRC += tile.c
+#WINOBJ += tile.o
+
+CHOWN=true
+CHGRP=true
+
+VARDIRPERM = 0755
+VARFILEPERM = 0600
+GAMEPERM = 0755