add dirs-perms.500 and a default build change

The directories and permissions portion of the linux.500 and macOS.500
hints files and their included files has been consolidated to
dirs-perms.500.

The builder can edit that one file now, to identify
the folders that will be utilised as part of the build.

Alternatively, you can set those folders and permissions in a
make.perms file in the top of the NetHack folder tree and
they should take precedence over the ones in dirs-perms.500
because dirs-perms.500 uses '?=' variable assignment, which
means "set the value of the variable if no value has been set."

* NOTE: BUILD CHANGE *

This also makes WANT_SOURCE_INSTALL=1 the default over
WANT_SHARED_INSTALL=1, if neither is explicitly set.
The new default is the safer and less-impacting default,
but it will change where things get installed over earlier
Makefile builds. You can be explicit with WANT_SHARED_INSTALL=1
in your make command to get that..

These are the differences between the two:

make WANT_SHARED_INSTALL=1    Place the results of the install/update portion
                              of the build into a shared area on a multiuser
                              system.

make WANT_SOURCE_INSTALL=1    Place the results of the install/update portion
                              of the build into a subfolder of the source
                              tree, rather than in a system-wide shared area.

Also note that the macOS hints file behaves slightly differntly depending
on whether WANT_SOURCE_INSTALL=1 was set versus letting it be the default.
That's not new, it behaved that way before.
This commit is contained in:
nhmall
2026-05-27 19:32:40 -04:00
parent 5d2dc1c85e
commit 0bf0498155
4 changed files with 162 additions and 79 deletions
+3 -1
View File
@@ -73,13 +73,15 @@ make WANT_ASAN=1 Include support for the address sanitizer in the
make WANT_UBSAN=1 Include support for the undefined behaviour
sanitizer in the build.
make WANT_SHARE_INSTALL=1 Place the results of the install/update portion
make WANT_SHARED_INSTALL=1 Place the results of the install/update portion
of the build into a shared area on a multiuser
system.
make WANT_SOURCE_INSTALL=1 Place the results of the install/update portion
of the build into a subfolder of the source
tree, rather than in a system-wide shared area.
(This is now the default if WANT_SHARED_INSTALL=1
wasn't specified)
make WANT_NHUUID=1 Include support for a unique game identifier.
On Linux, libuuid and its headers must be installed
+123
View File
@@ -0,0 +1,123 @@
#------------------------------------------------------------------------------
# NetHack 5.0 directories.500 $NHDT-Date: 1668359835 2022/11/13 17:17:15 $ $NHDT-Branch: NetHack-5.0 $
ifndef WANT_SHARED_INSTALL
PREFIX=$(abspath $(NHSROOT))
SOURCEINSTALL=1
# -----------------------------------------
# This is for the Linux source tree install
# -----------------------------------------
ifeq "$(WHICH_OS)" "Linux"
HACKDIR ?=$(PREFIX)/playground
INSTDIR ?=$(HACKDIR)
VARDIR ?=$(HACKDIR)
GAMEPERM ?= 0700
VARFILEPERM ?= 0600
VARDIRPERM ?= 0700
else # macOS
#
# -----------------------------------------
# This is for the macOS source tree install
# -----------------------------------------
#
# The macOS setup sets things up two different
# ways, depending on whether an explicit
# WANT_SOURCE_INSTALL=1 was given, or not.
ifdef WANT_SOURCE_INSTALL
HACKDIR ?=$(PREFIX)/playground
CHOWN ?=/usr/bin/true
CHGRP ?=/usr/bin/true
GAMEPERM ?= 0700
VARFILEPERM ?= 0600
VARDIRPERM ?= 0700
else # WANT_SOURCE_INSTALL not expressed
PREFIX:=$(wildcard ~)
SHELLDIR ?=$(PREFIX)/bin
HACKDIR ?=$(PREFIX)/nethackdir
CHOWN ?=/usr/bin/true
CHGRP ?=/usr/bin/true
GAMEPERM ?= 0700
VARFILEPERM ?= 0600
VARDIRPERM ?= 0700
endif # WANT_SOURCE_INSTALL
INSTDIR ?=$(HACKDIR)
VARDIR ?=$(HACKDIR)
endif # macOS
endif # not WANT_SHARED_INSTALL
ifneq "$(SOURCEINSTALL)" "1"
ifdef WANT_SHARED_INSTALL
ifeq "$(WHICH_OS)" "Linux"
# -----------------------------------------
# This is for the Linux system-wide install
# -----------------------------------------
PREFIX ?=$(wildcard ~)/nh/install
HACKDIR ?=$(PREFIX)/games/lib/nethackdir
SHELLDIR ?= $(PREFIX)/games
INSTDIR ?=$(HACKDIR)
VARDIR ?=$(HACKDIR)
MANDIR ?=/usr/share/man/man6
VARDIRPERM ?= 0755
VARFILEPERM ?= 0600
GAMEPERM ?= 0755
# ----------------------------------
# End of Linux system-wide install
# ----------------------------------
else # macOS
# ------------------------------------------------
# This is for the macOS system-wide shared install
# ------------------------------------------------
# if $GAMEUID is root, we install into roughly
# proper Mac locations, otherwise we install
# into ~/nethackdir
ifeq ($(GAMEUID),root)
PREFIX:=/Library/NetHack
SHELLDIR ?=/usr/local/bin
HACKDIR ?=$(PREFIX)/nethackdir
MANDIR ?=/usr/local/share/man/man6
CHOWN ?=chown
CHGRP ?=chgrp
# We run sgid so the game has access to both HACKDIR
# and user preferences
GAMEPERM ?=02755
else # ! root
PREFIX:=/Users/$(GAMEUID)
SHELLDIR ?=$(PREFIX)/bin
HACKDIR ?=$(PREFIX)/Library/NetHack/nethackdir
CHOWN ?=/usr/bin/true
CHGRP ?=/usr/bin/true
GAMEPERM ?= 0500
endif # ! root
INSTDIR ?=$(HACKDIR)
VARDIR ?=$(HACKDIR)
VARFILEPERM ?= 0664
VARDIRPERM ?= 0775
# ---------------------------------------
# End of macOS system-wide shared install
# --------------------------------------
endif # WHICH_OS?
endif # WANT_SHARED_INSTALL
endif # SOURCEINSTALL != 1
#end of dirs-perms.500
#--------------------------------------
+18 -27
View File
@@ -12,14 +12,9 @@
# And let us know about it.
#
#-PRE
# linux.500 hints file provides a single-user build for Linux (such
# as Ubuntu focal).
# note: '#-INCLUDE' is not just a comment
# multiw-1.500 contains sections 1 to 2
#-INCLUDE multiw-1.500
#-PRE xxxx
WHICH_OS=Linux
HINTSVERSION := 500
ifdef MAKEFILE_TOP
@@ -28,16 +23,29 @@ ifeq ($(MAKELEVEL),0)
PRECHECK+=checkmakefiles
# all files included from this hints file get listed
# in HINTSINCLNAMES (without suffix and without a path)
HINTSINCLNAMES := compiler cross-pre1 cross-pre2 cross-post \
HINTSINCLNAMES := dirs-perms \
compiler cross-pre1 cross-pre2 cross-post \
gbdates-pre gbdates-post \
linuxdistro \
multiw-1 multiw-2 misc \
multisnd1-pre multisnd2-pre multisnd-post
multisnd1-pre multisnd2-pre multisnd-post \
response
HINTSINCLFILES := $(addsuffix .$(HINTSVERSION), $(HINTSINCLNAMES))
endif
endif
#-INCLUDE linuxdistro.500
# linux.500 hints file provides a single-user build for Linux (such
# as Ubuntu focal).
# note: '#-INCLUDE' is not just a comment
# multiw-1.500 contains sections 1 to 2
#-INCLUDE multiw-1.500
# note: '#-INCLUDE' is not just a comment
# it pulls in the contents of dirs-perms.500
#-INCLUDE dirs-perms.500
#-INCLUDE linuxdistro.500
ifndef LIBXPM
LIBXPM= -L/opt/X11/lib -lXpm
@@ -523,27 +531,10 @@ SYSCONFENSURE = (if ! test -f $(INSTDIR)/sysconf ; then \
chmod $(VARFILEPERM) $(INSTDIR)/sysconf; fi );
ifdef WANT_SOURCE_INSTALL
PREFIX=$(abspath $(NHSROOT))
#SHELLDIR=
HACKDIR=$(PREFIX)/playground
GAMEPERM = 0700
VARFILEPERM = 0600
VARDIRPERM = 0700
CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE
MOREALL=$(MAKE) install
else #!WANT_SOURCE_INSTALL
#PREFIX=/usr
PREFIX=$(wildcard ~)/nh/install
HACKDIR=$(PREFIX)/games/lib/nethackdir
SHELLDIR = $(PREFIX)/games
VARDIRPERM = 0755
VARFILEPERM = 0600
GAMEPERM = 0755
endif #?WANT_SOURCE_INSTALL
INSTDIR=$(HACKDIR)
VARDIR = $(HACKDIR)
ifdef MAKEFILE_TOP
TESTGDBPATH=/usr/bin/gdb
POSTINSTALL+= test -f $(TESTGDBPATH) || \
+18 -51
View File
@@ -17,24 +17,32 @@
# macOS hints file
#
# note: '#-INCLUDE' is not just a comment; multiw-1 contains sections 1 to 2
#-INCLUDE multiw-1.500
WHICH_OS=macOS
HINTSVERSION := 500
ifdef MAKEFILE_TOP
LUA_VERSION=5.4.8
ifeq ($(MAKELEVEL),0)
PRECHECK+=checkmakefiles
# all files included from this hints file get listed
# in HINTSINCLNAMES (without suffix and without a path)
HINTSINCLNAMES := compiler cross-pre1 cross-pre2 cross-post \
HINTSINCLNAMES := dirs-perms \
compiler cross-pre1 cross-pre2 cross-post \
gbdates-pre gbdates-post \
multiw-1 multiw-2 misc \
multisnd1-pre multisnd2-pre multisnd-post
multisnd1-pre multisnd2-pre multisnd-post \
response
HINTSINCLFILES := $(addsuffix .$(HINTSVERSION), $(HINTSINCLNAMES))
endif
endif
# note: '#-INCLUDE' is not just a comment; multiw-1 contains sections 1 to 2
#-INCLUDE multiw-1.500
# note: '#-INCLUDE' is not just a comment
# it pulls in the contents of dirs-perms.500
#-INCLUDE dirs-perms.500
ifneq "$(USEMACPORTS)" "1"
HAVE_HOMEBREW := $(shell expr `which -s brew; echo $$?` = 0)
endif
@@ -368,31 +376,11 @@ override LUA2NHTOP = ../..
override LUAMAKEFLAGS=$(LUAFLAGS)
endif # GITSUBMODULES
ifdef WANT_SHARE_INSTALL
ifdef WANT_SHARED_INSTALL
#ifdef MAKEFILE_SRC
#$(info WANT_SOURCE_INSTALL = $(WANT_SOURCE_INSTALL), WANT_SHARE_INSTALL = $(WANT_SHARE_INSTALL))
#$(info WANT_SOURCE_INSTALL = $(WANT_SOURCE_INSTALL), WANT_SHARED_INSTALL = $(WANT_SHARED_INSTALL))
#endif
# if $GAMEUID is root, we install into roughly proper Mac locations, otherwise
# we install into ~/nethackdir
ifeq ($(GAMEUID),root)
PREFIX:=/Library/NetHack
SHELLDIR=/usr/local/bin
HACKDIR=$(PREFIX)/nethackdir
CHOWN=chown
CHGRP=chgrp
# We run sgid so the game has access to both HACKDIR and user preferences.
GAMEPERM = 02755
else # ! root
PREFIX:=/Users/$(GAMEUID)
SHELLDIR=$(PREFIX)/bin
HACKDIR=$(PREFIX)/Library/NetHack/nethackdir
CHOWN=/usr/bin/true
CHGRP=/usr/bin/true
GAMEPERM = 0500
endif # ! root
VARFILEPERM = 0664
VARDIRPERM = 0775
ROOTCHECK= [[ `id -u` == 0 ]] || ( echo "Must run install with sudo."; exit 1)
# XXX it's nice we don't write over sysconf, but we've already erased it
# make sure we have group GAMEUID and group GAMEGRP
@@ -409,17 +397,8 @@ PREINSTALL= . sys/unix/hints/macosx.sh user2 $(GAMEUID); \
else ifdef WANT_SOURCE_INSTALL
#ifdef MAKEFILE_SRC
#$(info WANT_SOURCE_INSTALL = $(WANT_SOURCE_INSTALL), WANT_SHARE_INSTALL = $(WANT_SHARE_INSTALL))
#$(info WANT_SOURCE_INSTALL = $(WANT_SOURCE_INSTALL), WANT_SHARED_INSTALL = $(WANT_SHARED_INSTALL))
#endif
PREFIX=$(abspath $(NHSROOT))
# suppress nethack.sh
#SHELLDIR=
HACKDIR=$(PREFIX)/playground
CHOWN=/usr/bin/true
CHGRP=/usr/bin/true
GAMEPERM = 0700
VARFILEPERM = 0600
VARDIRPERM = 0700
POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/sysconf;
# We can use "make all" to build the whole thing - but it misses some things:
@@ -429,17 +408,8 @@ CFLAGS+=-DSYSCF -DSYSCF_FILE=\"$(HACKDIR)/sysconf\" -DSECURE
else # !WANT_SOURCE_INSTALL
#ifdef MAKEFILE_SRC
#$(info WANT_SOURCE_INSTALL = $(WANT_SOURCE_INSTALL), WANT_SHARE_INSTALL = $(WANT_SHARE_INSTALL))
#$(info WANT_SOURCE_INSTALL = $(WANT_SOURCE_INSTALL), WANT_SHARED_INSTALL = $(WANT_SHARED_INSTALL))
#endif
PREFIX:=$(wildcard ~)
SHELLDIR=$(PREFIX)/bin
HACKDIR=$(PREFIX)/nethackdir
CHOWN=/usr/bin/true
CHGRP=/usr/bin/true
GAMEPERM = 0700
VARFILEPERM = 0600
VARDIRPERM = 0700
ifdef ($(WANT_DEFAULT),X11)
# install nethack.rc as ~/.nethackrc if no ~/.nethackrc exists
PREINSTALL+= cp -n win/X11/nethack.rc ~/.nethackrc || true;
@@ -451,10 +421,7 @@ POSTINSTALL+= sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/s
$(CHGRP) $(GAMEGRP) $(HACKDIR)/sysconf; \
chmod $(VARFILEPERM) $(HACKDIR)/sysconf;
endif # !WANT_SHARE_INSTALL
INSTDIR=$(HACKDIR)
VARDIR=$(HACKDIR)
endif # !WANT_SHARED_INSTALL
SYSCONFCREATE = sys/unix/hints/macosx.sh editsysconf sys/unix/sysconf $(HACKDIR)/sysconf
SYSCONFINSTALL = $(SYSCONFCREATE) && \