Files
nethack/sys/unix/hints/linux.2020
nhmall b9b4755fe3 expand sys/unix Makefiles scope
Expand the use of the sys/unix Makefiles to be used for both normal
local builds and installs, as well as cross-compiles for other
platforms/targets.

Up until now, the primary unix Makefiles have treated util/host-side
component compiles, links and target object files just the same as
the game component compiles, links, and target object files.

Unfortunately, that meant that cross-compile effort typically had
to re-invent Makefiles specific to the cross-compile, creating a
maintenance burden and deviation from the typical local unix build
and providing a daunting obstacle to those that want to establish
build for a target environment/platform.

This change distinguishes between util/host-side component builds,
links, and component builds and targets object files destined for
the game (and other target platforms) in the Makefiles.

In theory, this will ease the effort for people that want to try to
resurrect NetHack perhaps on an old platform where it is no longer
viable to build NetHack-3.7 on the platform itself using old, outdated
compile tools, possibly with an old, outdated C dialect.

Some details:

-  Game-related targets in the Makefiles (as opposed to util/host-side
   targets that will be executed on the host), which could be destined
   for another platform in a cross-compile scenario are prefixed with
   $(TARGETPFX) so that they are distinguished.

   The default scenario where no cross-compiler is involved, is to
   define TARGETPFX to nothing, and therefore meant to have no effect.

-  Game-related compile and link commands in the Makefiles and their
   associated command line flags are distinguished from util/host-side
   compile and link commands in the Makefiles by using $(TARGET_CC),
   $(TARGET_CFLAGS), $(TARGET_LINK), $(TARGET_LFLAGS), $(TARGET_CXX),
   $(TARGET_CXXFLAGS), $(TARGET_LIBS).

   Those are used in the Makefile in place of $(CC), $(CFLAGS), $(LINK),
   $(LFLAGS), $(CXX), $(CXXFLAGS), $(LIBS).

   The default scenario where no cross-compiler is involved, defines
   the TARGET_ version of those Makefile variables to match their
   typical non-TARGET_ ounterparts.

-  The dependency lists in the Makefiles includes the $(TARGETPFX)
   prefix for stuff that would potentially be produced from a
   cross-compile build.

-  It adds pregame targets and $(PREGAME) variable, so that hints files
   can add some additional stuff if required for a cross-compile
   scenario.

   The default scenario where no cross-compiler is involved doesn't
   do anything for $(PREGAME).

-  It adds $(BUILDMORE) target and variable, so that hints files
   can add some additional things to be built for a cross-compile
   scenario.

-  It adds a "package" target and $(PACKAGE) variable, so that hints files
   can add steps for the target platform in a cross-compile
   scenario.

   The "install" target assumes local build and placement and
   isn't really applicable to a cross-compile scenario where the results
   really just need to be bundled up for transport to the target platform.

-  Also, this adds a pair of include files that can be updated with some
   cross-compile recipes as they evolve. They are named "cross-pre.2020"
   (for stuff to be included in the PRE section) and "cross-post.2020"
   for stuff to be included in the POST section via sys/unix/setup.sh.

   Those are included in sys/unix/hints/linux.2020 and
   sys/unix/hints/macOS.2020 hints files.
2020-09-28 16:25:31 -04:00

214 lines
6.2 KiB
Plaintext
Executable File

# NetHack 3.7 linux.2020 $NHDT-Date: 1599687610 2020/09/09 21:40:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.11 $
# Copyright (c) Kenneth Lorber, Kensington, Maryland, 2007.
# NetHack may be freely redistributed. See license for details.
#
#---------------------------------------------------------------------
# Linux hints file with support for multiple window ports (interfaces)
# Tested on:
# - Ubuntu focal
#
# If this doesn't work for your distribution, consider making a new
# hints file for it, rather than changing this one.
# And let us know about it.
#
#-PRE
# linux.2020 hints file provides a single-user build for Linux (such
# as Ubuntu focal).
# compiler flags: CCFLAGS is used to construct a value for CFLAGS with
# various -I, -D, and -W settings appended below;
# these are the settings of most interest for an end-user build
# (clang doesn't support '-Og', gcc needs 4.x or later)
CCFLAGS = -g
#CCFLAGS = -g -Og
#CCFLAGS = -O2
# Note: this is not the usual 'CFLAGS' which is used in default
# rules for compiling C code; specifying a value for that on the
# 'make' command line should be avoided.
# note: '#-INCLUDE' is not just a comment; multiw-1 contains sections 1 to 3
#-INCLUDE multiw-1.2020
# 4. If you set WANT_WIN_QT, you need to
# A) set QTDIR either here or in the environment to point to the Qt5
# Library installation root.
# B) set XPMLIB to point to the Xpm library
ifndef WANT_WIN_QT
ifdef WANT_WIN_ALL
WANT_WIN_QT=1
endif
endif
ifdef WANT_WIN_QT
QTDIR=/usr
endif # WANT_WIN_QT
ifndef LIBXPM
LIBXPM= -L/opt/X11/lib -lXpm
endif
#5. Other
GAMEUID = $(USER)
GAMEGRP = games
#-----------------------------------------------------------------------------
# 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).
#
#-INCLUDE multiw-2.2020
CFLAGS=$(CCFLAGS) -I../include -DNOTPARMDECL
ifeq "$(CCISCLANG)" ""
# get the version of gcc
GCCGTEQ9 := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 9)
ifeq "$(GCCGTEQ9)" "1"
CFLAGS+=-Wno-format-overflow
endif #gcc version greater than or equal to 9
endif #not clang
# As of LLVM build 2336.1.00, this gives dozens of spurious messages, so
# leave it out by default.
#CFLAGS+=-Wunreachable-code
#CFLAGS+=-Wall -Wextra -Wno-missing-field-initializers -Wimplicit \
# -Wreturn-type -Wunused -Wformat -Wswitch -Wshadow -Wwrite-strings
#CFLAGS+=-DGCC_WARN
# NetHack sources control
CFLAGS+=-DDLB
CFLAGS+=-DHACKDIR=\"$(HACKDIR)\"
CFLAGS+=-DDEFAULT_WINDOW_SYS=\"$(WANT_DEFAULT)\"
CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE
CFLAGS+=-DTIMED_DELAY
CFLAGS+=-DDUMPLOG
CFLAGS+=-DCONFIG_ERROR_SECURE=FALSE
#CFLAGS+=-DGREPPATH=\"/usr/bin/grep\"
CFLAGS+=-DCOMPRESS=\"/bin/gzip\" -DCOMPRESS_EXTENSION=\".gz\"
#CFLAGS+=-DNOMAIL
#CFLAGS+=-DEXTRA_SANITY_CHECKS
#CFLAGS+=-DEDIT_GETLIN
#CFLAGS+=-DSCORE_ON_BOTL
#CFLAGS+=-DMSGHANDLER
#CFLAGS+=-DTTY_TILES_ESCCODES
#CFLAGS+=-DTTY_SOUND_ESCCODES
CFLAGS+= $(WINCFLAGS) #WINCFLAGS set from multiw-2.2020
VARDATND =
VARDATND0 =
CURSESLIB =
#ifdef WANT_WIN_CHAIN
#HINTSRC=$(CHAINSRC)
#HINTOBJ=$(CHAINOBJ)
#endif # WANT_WIN_CHAIN
ifdef WANT_WIN_TTY
CURSESLIB = -lncurses -ltinfo
endif
ifdef WANT_WIN_CURSES
CURSESLIB = -lncurses -ltinfo
endif
ifdef CURSESLIB
WINLIB += $(CURSESLIB)
endif
ifdef WANT_WIN_X11
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
WINLIB += $(WINX11LIB)
LFLAGS=-L/opt/X11/lib
endif # WANT_WIN_X11
ifdef WANT_WIN_QT
# Qt5 requires C++11
LINK = $(CXX)
QTCXXFLAGS += -Wno-deprecated-declarations
ifeq "$(CCISCLANG)" ""
# get the version of g++
GPPGTEQ9 := $(shell expr `$(CXX) -dumpversion | cut -f1 -d.` \>= 9)
ifeq "$(GPPGTEQ9)" "1"
QTCXXFLAGS+= -Wno-format-truncation
endif #g++ version greater than or equal to 9
endif #not clang
QTCXXFLAGS += $(sort $(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)
VARDATND0 += nhtiles.bmp rip.xpm nhsplash.xpm
# 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+= bdftopcf win/X11/nh10.bdf > $(INSTDIR)/nh10.pcf; \
( cd $(INSTDIR); mkfontdir -x .lev );
else
LINK = $(CC)
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;
ifneq "$(CCISCLANG)" ""
# 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;
endif
# 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
# endif
CHOWN=true
CHGRP=true
VARDIRPERM = 0755
VARFILEPERM = 0600
GAMEPERM = 0755
#
#-INCLUDE cross-pre.2020
#
#-POST
#
#-INCLUDE cross-post.2020
#