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.
326 lines
9.9 KiB
Makefile
326 lines
9.9 KiB
Makefile
# NetHack Top-level Makefile.
|
|
# NetHack 3.7 Makefile.top $NHDT-Date: 1597031649 2020/08/10 03:54:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.52 $
|
|
# Copyright (c) 2015 by Kenneth Lorber, Kensington, Maryland
|
|
# NetHack may be freely redistributed. See license for details.
|
|
|
|
# Root of source tree:
|
|
NHSROOT=.
|
|
|
|
# newer makes predefine $(MAKE) to 'make' and do smarter processing of
|
|
# recursive make calls if $(MAKE) is used
|
|
# these makes allow $(MAKE) to be overridden by the environment if someone
|
|
# wants to (or has to) use something other than the standard make, so we do
|
|
# not want to unconditionally set $(MAKE) here
|
|
#
|
|
# unfortunately, some older makes do not predefine $(MAKE); if you have one of
|
|
# these, uncomment the following line
|
|
# (you will know that you have one if you get complaints about unable to
|
|
# execute things like 'data' and 'rumors')
|
|
# MAKE = make
|
|
|
|
# make NetHack
|
|
#PREFIX = /usr
|
|
GAME = nethack
|
|
# GAME = nethack.prg
|
|
#GAMEUID = games
|
|
#GAMEGRP = bin
|
|
|
|
# Permissions - some places use setgid instead of setuid, for instance
|
|
# See also the option "SECURE" in include/config.h
|
|
#GAMEPERM = 04755
|
|
FILEPERM = 0644
|
|
# VARFILEPERM = 0644
|
|
EXEPERM = 0755
|
|
DIRPERM = 0755
|
|
# VARDIRPERM = 0755
|
|
|
|
# VARDIR may also appear in unixconf.h as "VAR_PLAYGROUND" else HACKDIR
|
|
#
|
|
# note that 'make install' believes in creating a nice tidy HACKDIR for
|
|
# installation, free of debris from previous NetHack versions --
|
|
# therefore there should not be anything in HACKDIR that you want to keep
|
|
# (if there is, you'll have to do the installation by hand or modify the
|
|
# instructions)
|
|
#HACKDIR = $(PREFIX)/games/lib/$(GAME)dir
|
|
#VARDIR = $(HACKDIR)
|
|
# Where nethack.sh in installed. If this is not defined, the wrapper is not used.
|
|
#SHELLDIR = $(PREFIX)/games
|
|
|
|
# per discussion in Install.X11 and Install.Qt
|
|
#VARDATND =
|
|
# VARDATND = x11tiles NetHack.ad pet_mark.xbm pilemark.xbm
|
|
# VARDATND = x11tiles NetHack.ad pet_mark.xbm pilemark.xbm rip.xpm
|
|
# for Atari/Gem
|
|
# VARDATND = nh16.img title.img GEM_RSC.RSC rip.img
|
|
# for BeOS
|
|
# VARDATND = beostiles
|
|
# for Gnome
|
|
# VARDATND = x11tiles pet_mark.xbm pilemark.xbm rip.xpm mapbg.xpm
|
|
|
|
VARDATD = bogusmon data engrave epitaph oracles options quest.lua rumors
|
|
VARDAT = $(VARDATD) $(VARDATND)
|
|
|
|
# Some versions of make use the SHELL environment variable as the shell
|
|
# for running commands. We need this to be a Bourne shell.
|
|
# SHELL = /bin/sh
|
|
# for Atari
|
|
# SHELL=E:/GEMINI2/MUPFEL.TTP
|
|
|
|
# Commands for setting the owner and group on files during installation.
|
|
# Some systems fail with one or the other when installing over NFS or for
|
|
# other permission-related reasons. If that happens, you may want to set the
|
|
# command to "true", which is a no-op. Note that disabling chown or chgrp
|
|
# will only work if setuid (or setgid) behavior is not desired or required.
|
|
#CHOWN = chown
|
|
#CHGRP = chgrp
|
|
|
|
# Lua version
|
|
LUA_VERSION = 5.4.0
|
|
|
|
#
|
|
# end of configuration
|
|
#
|
|
|
|
DATHELP = help hh cmdhelp keyhelp history opthelp wizhelp
|
|
|
|
SPEC_LEVS = asmodeus.lua baalz.lua bigrm-*.lua castle.lua fakewiz?.lua \
|
|
juiblex.lua knox.lua medusa-?.lua minend-?.lua minefill.lua \
|
|
minetn-?.lua oracle.lua orcus.lua sanctum.lua soko?-?.lua \
|
|
tower?.lua valley.lua wizard?.lua nhlib.lua themerms.lua \
|
|
astral.lua air.lua earth.lua fire.lua water.lua
|
|
QUEST_LEVS = ???-goal.lua ???-fil?.lua ???-loca.lua ???-strt.lua
|
|
|
|
DATNODLB = $(VARDATND) license symbols
|
|
DATDLB = $(DATHELP) dungeon.lua tribute $(SPEC_LEVS) $(QUEST_LEVS) $(VARDATD)
|
|
DAT = $(DATNODLB) $(DATDLB)
|
|
|
|
# first target is also the default target for 'make' without any arguments
|
|
all: $(GAME) recover Guidebook $(VARDAT) spec_levs check-dlb
|
|
true; $(MOREALL)
|
|
@echo "Done."
|
|
|
|
$(GAME): lua_support
|
|
( cd src ; $(MAKE) $(GAME) )
|
|
|
|
lua_support: lib/lua/liblua.a include/nhlua.h
|
|
@true
|
|
lib/lua-$(LUA_VERSION)/src/liblua.a: lib/lua-$(LUA_VERSION)/src/lua.h
|
|
( cd lib/lua-$(LUA_VERSION)/src \
|
|
&& make CC='$(CC)' SYSCFLAGS='$(SYSCFLAGS)' a && cd ../../.. )
|
|
lib/lua/liblua.a: lib/lua-$(LUA_VERSION)/src/liblua.a
|
|
@( if [ ! -d lib/lua ] ; then mkdir -p lib/lua ; fi )
|
|
cp lib/lua-$(LUA_VERSION)/src/liblua.a $@
|
|
include/nhlua.h: lib/lua/liblua.a
|
|
echo '/* nhlua.h - generated by top Makefile */' > $@
|
|
@echo '#include "../lib/lua-$(LUA_VERSION)/src/lua.h"' >> $@
|
|
@sed -e '/(lua_error)/!d' -e '/(lua_error)/s/;/ NORETURN;/1' \
|
|
< lib/lua-$(LUA_VERSION)/src/lua.h >> $@
|
|
@echo '#include "../lib/lua-$(LUA_VERSION)/src/lualib.h"' >> $@
|
|
@echo '#include "../lib/lua-$(LUA_VERSION)/src/lauxlib.h"' >> $@
|
|
@echo '/*nhlua.h*/' >> $@
|
|
|
|
# Note: many of the dependencies below are here to allow parallel make
|
|
# to generate valid output
|
|
|
|
Guidebook:
|
|
( cd doc ; $(MAKE) Guidebook )
|
|
|
|
manpages:
|
|
( cd doc ; $(MAKE) manpages )
|
|
|
|
data: $(GAME)
|
|
( cd dat ; $(MAKE) data )
|
|
|
|
engrave: $(GAME)
|
|
( cd dat ; $(MAKE) engrave )
|
|
|
|
bogusmon: $(GAME)
|
|
( cd dat ; $(MAKE) bogusmon )
|
|
|
|
epitaph: $(GAME)
|
|
( cd dat ; $(MAKE) epitaph )
|
|
|
|
rumors: $(GAME)
|
|
( cd dat ; $(MAKE) rumors )
|
|
|
|
oracles: $(GAME)
|
|
( cd dat ; $(MAKE) oracles )
|
|
|
|
# Note: options should have already been made with make, but...
|
|
options: $(GAME)
|
|
( cd dat ; $(MAKE) options )
|
|
|
|
quest.lua: $(GAME)
|
|
|
|
spec_levs:
|
|
( cd dat ; $(MAKE) spec_levs )
|
|
( cd dat ; $(MAKE) quest_levs )
|
|
|
|
nhtiles.bmp: $(GAME)
|
|
( cd dat ; $(MAKE) nhtiles.bmp )
|
|
|
|
x11tiles: $(GAME)
|
|
( cd util ; $(MAKE) tile2x11 )
|
|
( cd dat ; $(MAKE) x11tiles )
|
|
|
|
beostiles: $(GAME)
|
|
( cd util ; $(MAKE) tile2beos )
|
|
( cd dat ; $(MAKE) beostiles )
|
|
|
|
NetHack.ad: $(GAME)
|
|
( cd dat ; $(MAKE) NetHack.ad )
|
|
|
|
pet_mark.xbm:
|
|
( cd dat ; $(MAKE) pet_mark.xbm )
|
|
|
|
pilemark.xbm:
|
|
( cd dat ; $(MAKE) pilemark.xbm )
|
|
|
|
rip.xpm:
|
|
( cd dat ; $(MAKE) rip.xpm )
|
|
|
|
mapbg.xpm:
|
|
(cd dat ; $(MAKE) mapbg.xpm )
|
|
|
|
nhsplash.xpm:
|
|
( cd dat ; $(MAKE) nhsplash.xpm )
|
|
|
|
nh16.img: $(GAME)
|
|
( cd util ; $(MAKE) tile2img.ttp )
|
|
( cd dat ; $(MAKE) nh16.img )
|
|
|
|
rip.img:
|
|
( cd util ; $(MAKE) xpm2img.ttp )
|
|
( cd dat ; $(MAKE) rip.img )
|
|
GEM_RSC.RSC:
|
|
( cd dat ; $(MAKE) GEM_RSC.RSC )
|
|
|
|
title.img:
|
|
( cd dat ; $(MAKE) title.img )
|
|
|
|
check-dlb: options
|
|
@if egrep -s librarian dat/options ; then $(MAKE) dlb ; else true ; fi
|
|
|
|
dlb:
|
|
( cd util ; $(MAKE) dlb )
|
|
( cd dat ; LC_ALL=C ; ../util/dlb cf nhdat $(DATDLB) )
|
|
|
|
package: $(GAME) recover $(VARDAT) spec_levs
|
|
( cd src ; $(MAKE) $(PACKAGE) )
|
|
|
|
# recover can be used when INSURANCE is defined in include/config.h
|
|
# and the checkpoint option is true
|
|
recover: $(GAME)
|
|
( cd util ; $(MAKE) recover )
|
|
|
|
dofiles:
|
|
target=`sed -n \
|
|
-e '/librarian/{' \
|
|
-e 's/.*/dlb/p' \
|
|
-e 'q' \
|
|
-e '}' \
|
|
-e '$$s/.*/nodlb/p' < dat/options` ; \
|
|
$(MAKE) dofiles-$${target-nodlb}
|
|
cp src/$(GAME) $(INSTDIR)
|
|
cp util/recover $(INSTDIR)
|
|
-if test -n '$(SHELLDIR)'; then rm -f $(SHELLDIR)/$(GAME); fi
|
|
if test -n '$(SHELLDIR)'; then \
|
|
sed -e 's;/usr/games/lib/nethackdir;$(HACKDIR);' \
|
|
-e 's;HACKDIR/nethack;HACKDIR/$(GAME);' \
|
|
< sys/unix/nethack.sh \
|
|
> $(SHELLDIR)/$(GAME) ; fi
|
|
# set up their permissions
|
|
-( cd $(INSTDIR) ; $(CHOWN) $(GAMEUID) $(GAME) recover ; \
|
|
$(CHGRP) $(GAMEGRP) $(GAME) recover )
|
|
chmod $(GAMEPERM) $(INSTDIR)/$(GAME)
|
|
chmod $(EXEPERM) $(INSTDIR)/recover
|
|
-if test -n '$(SHELLDIR)'; then \
|
|
$(CHOWN) $(GAMEUID) $(SHELLDIR)/$(GAME); fi
|
|
if test -n '$(SHELLDIR)'; then \
|
|
$(CHGRP) $(GAMEGRP) $(SHELLDIR)/$(GAME); \
|
|
chmod $(EXEPERM) $(SHELLDIR)/$(GAME); fi
|
|
|
|
dofiles-dlb: check-dlb
|
|
( cd dat ; cp nhdat $(DATNODLB) $(INSTDIR) )
|
|
# set up their permissions
|
|
-( cd $(INSTDIR) ; $(CHOWN) $(GAMEUID) nhdat $(DATNODLB) ; \
|
|
$(CHGRP) $(GAMEGRP) nhdat $(DATNODLB) ; \
|
|
chmod $(FILEPERM) nhdat $(DATNODLB) )
|
|
|
|
dofiles-nodlb:
|
|
# copy over the game files
|
|
( cd dat ; cp $(DAT) $(INSTDIR) )
|
|
# set up their permissions
|
|
-( cd $(INSTDIR) ; $(CHOWN) $(GAMEUID) $(DAT) ; \
|
|
$(CHGRP) $(GAMEGRP) $(DAT) ; \
|
|
chmod $(FILEPERM) $(DAT) )
|
|
#
|
|
# This is not part of the dependency build hierarchy.
|
|
# It requires an explicit "make fetch-Lua".
|
|
fetch-lua: fetch-Lua
|
|
@true
|
|
|
|
fetch-Lua:
|
|
( mkdir -p lib && cd lib && \
|
|
curl -R -O http://www.lua.org/ftp/lua-$(LUA_VERSION).tar.gz && \
|
|
tar zxf lua-$(LUA_VERSION).tar.gz && rm -f lua-$(LUA_VERSION).tar.gz )
|
|
|
|
update: $(GAME) recover $(VARDAT) spec_levs
|
|
# (don't yank the old version out from under people who're playing it)
|
|
-mv $(INSTDIR)/$(GAME) $(INSTDIR)/$(GAME).old
|
|
-mv $(INSTDIR)/nhdat $(INSTDIR)/nhdat.old
|
|
# set up new versions of the game files
|
|
( $(MAKE) dofiles )
|
|
# touch time-sensitive files
|
|
-touch -c $(VARDIR)/bones* $(VARDIR)/?lock* $(VARDIR)/wizard*
|
|
-touch -c $(VARDIR)/save/*
|
|
touch $(VARDIR)/perm $(VARDIR)/record
|
|
# and a reminder
|
|
@echo You may also want to install the man pages via the doc Makefile.
|
|
|
|
rootcheck:
|
|
@true; $(ROOTCHECK)
|
|
|
|
install: rootcheck $(GAME) recover $(VARDAT) spec_levs
|
|
true; $(PREINSTALL)
|
|
# set up the directories
|
|
# not all mkdirs have -p; those that don't will create a -p directory
|
|
-if test -n '$(SHELLDIR)'; then \
|
|
mkdir -p $(SHELLDIR); fi
|
|
rm -rf $(INSTDIR) $(VARDIR)
|
|
-mkdir -p $(INSTDIR) $(VARDIR) $(VARDIR)/save
|
|
if test -d ./-p; then rmdir ./-p; fi
|
|
-$(CHOWN) $(GAMEUID) $(INSTDIR) $(VARDIR) $(VARDIR)/save
|
|
$(CHGRP) $(GAMEGRP) $(INSTDIR) $(VARDIR) $(VARDIR)/save
|
|
# order counts here:
|
|
chmod $(DIRPERM) $(INSTDIR)
|
|
chmod $(VARDIRPERM) $(VARDIR) $(VARDIR)/save
|
|
# set up the game files
|
|
( $(MAKE) dofiles )
|
|
# set up some additional files
|
|
touch $(VARDIR)/perm $(VARDIR)/record $(VARDIR)/logfile $(VARDIR)/xlogfile
|
|
-( cd $(VARDIR) ; $(CHOWN) $(GAMEUID) perm record logfile xlogfile ; \
|
|
$(CHGRP) $(GAMEGRP) perm record logfile xlogfile ; \
|
|
chmod $(VARFILEPERM) perm record logfile xlogfile )
|
|
true; $(POSTINSTALL)
|
|
# and a reminder
|
|
@echo You may also want to reinstall the man pages via the doc Makefile.
|
|
|
|
|
|
# 'make clean' removes all the .o files, but leaves around all the executables
|
|
# and compiled data files
|
|
clean:
|
|
( cd src ; $(MAKE) clean )
|
|
( cd util ; $(MAKE) clean )
|
|
( cd dat ; $(MAKE) clean )
|
|
( cd doc ; $(MAKE) clean )
|
|
( cd lib/lua-$(LUA_VERSION)/src && $(MAKE) clean )
|
|
|
|
# 'make spotless' returns the source tree to near-distribution condition.
|
|
# it removes .o files, executables, and compiled data files
|
|
spotless::
|
|
( cd src ; $(MAKE) spotless )
|
|
( cd util ; $(MAKE) spotless )
|
|
( cd dat ; $(MAKE) spotless )
|
|
( cd doc ; $(MAKE) spotless )
|