A new feature, enabled by default to maximize testing, but one which can
be disabled by commenting it out in config.h
With this, some additional information is added to the glyphmap entries
in a new optional substructure called u with these fields:
ucolor RGB color for use with truecolor terminals/platforms.
A ucolor value of zero means "not set." The actual
rgb value of 0 has the 0x1000000 bit set.
u256coloridx 256 color index value for use with 256 color
terminals, the closest color match to ucolor.
utf8str Custom representation via utf-8 string (can be null).
There is a new symset included in the symbols file, called enhanced1.
Some initial code has been added to parse individual
OPTIONS=glyph:glyphid/R-G-B entries in the config file.
The glyphid can, in theory, either be an individual glyph (G_* glyphid)
for a single glyph, or it can be an existing symbol S_ value
(monster, object, or cmap symbol) to store the custom representation for
all the glyphs that match that symbol.
Examples:
OPTIONS=glyph:G_fountain/U+03A8/0-150-255
(Your platform/terminal font needs to be able to include/display the
character, of course.)
The NetHack core code does parsing and storing the customized
entries, and adding them to the glyphmap data structure.
Any window port can utilize the additional information in the glyphinfo
that is passed to them, once code is added to do so.
Also, consolidate some symbol-related code into symbols.c, and remove it from
files.c and options.c
934 lines
25 KiB
Makefile
934 lines
25 KiB
Makefile
# NetHack 3.7 Makefile.mingw32
|
|
# Copyright (c) 2022 by Feiyun Wang
|
|
#-Copyright (c) 2022 by Michael Allison
|
|
# NetHack may be freely redistributed. See license for details.
|
|
#
|
|
#==============================================================================
|
|
#
|
|
# Win32 Compilers Tested with this Makefile.mingw32:
|
|
# mingw-w64
|
|
# from:
|
|
# https://sourceforge.net/p/mingw-w64/wiki2/GeneralUsageInstructions/
|
|
# Toolchain for 32 and 64 bit Windows target
|
|
#
|
|
#==============================================================================
|
|
# This is used for building two versions of NetHack:
|
|
#
|
|
# A tty port utilizing the Win32 Console I/O subsystem, Console
|
|
# NetHack.
|
|
#
|
|
# A Win32 native port built on the Windows API, Graphical NetHack or
|
|
# NetHackW.
|
|
#
|
|
# If you have any questions read the sys/windows/Install.windows file included
|
|
# with the distribution.
|
|
#
|
|
#==============================================================================
|
|
#
|
|
# The default make target (so just typing 'mingw32-make').
|
|
#
|
|
|
|
default: install
|
|
|
|
#---------------------------------------------------------------
|
|
# Where do you want the game to be built (which folder)?
|
|
# If not present prior to compilation it gets created.
|
|
#
|
|
|
|
GAMEDIR = ../binary
|
|
|
|
#
|
|
#---------------------------------------------------------------
|
|
# Do you want debug information in the executable?
|
|
#
|
|
|
|
DEBUGINFO = N
|
|
|
|
#
|
|
#---------------------------------------------------------------
|
|
# Do you have a connection to the internet available that you want
|
|
# to utilize for obtaining prerequisite Lua source code and pdcurses source code
|
|
#
|
|
|
|
INTERNET_AVAILABLE = N
|
|
|
|
#
|
|
#---------------------------------------------------------------
|
|
# Do you have git commands available and NetHack in a git repository?
|
|
#
|
|
|
|
GIT_AVAILABLE = N
|
|
|
|
#
|
|
#===============================================
|
|
#======= End of Modification Section ===========
|
|
#===============================================
|
|
#
|
|
################################################
|
|
# #
|
|
# Nothing below here should have to be changed.#
|
|
# #
|
|
################################################
|
|
#
|
|
#==============================================================================
|
|
|
|
SKIP_NETHACKW = N
|
|
USE_LUADLL = Y
|
|
WANT_LUAC = N
|
|
|
|
ifndef LUA_VERSION
|
|
LUAVER=5.4.4
|
|
else
|
|
LUAVER=$(LUA_VERSION)
|
|
endif
|
|
|
|
# if GIT=1 is passed on the make command, allow use of git and internet
|
|
ifeq "$(GIT)" "1"
|
|
INTERNET_AVAILABLE=Y
|
|
GIT_AVAILABLE=Y
|
|
endif
|
|
ifeq "$(git)" "1"
|
|
INTERNET_AVAILABLE=Y
|
|
GIT_AVAILABLE=Y
|
|
endif
|
|
|
|
#
|
|
#==============================================================================
|
|
# Sanity checks for prerequisite Lua and pdcurses
|
|
#
|
|
LUA_MAY_PROCEED=N
|
|
ADD_CURSES=N
|
|
PDCURSES_TOP=
|
|
|
|
# First, Lua
|
|
ifeq "$(INTERNET_AVAILABLE)" "Y"
|
|
ifeq "$(GIT_AVAILABLE)" "Y"
|
|
LUATOP=../submodules/lua
|
|
LUASRC=$(LUATOP)
|
|
LUA_MAY_PROCEED=Y
|
|
else # GIT_AVAILABLE
|
|
LUATOP = ../lib/lua-$(LUAVER)
|
|
LUASRC = $(LUATOP)/src
|
|
LUA_MAY_PROCEED=Y
|
|
endif # GIT_AVAILABLE
|
|
else # INTERNET_AVAILABLE not
|
|
# The internet is not available for obtaining Lua using either
|
|
# method (git or download). Check to see if it is available already, with
|
|
# precedence given to ../submodules, then ../lib.
|
|
#
|
|
ifneq ("$(wildcard ../submodules/lua/lua.h)", "")
|
|
LUATOP=../submodules/lua
|
|
LUASRC=$(LUATOP)
|
|
LUA_MAY_PROCEED=Y
|
|
else ifneq ("$(wildcard ../lib/lua-$(LUAVER)/src/lua.h)", "")
|
|
LUATOP = ../lib/lua-$(LUAVER)
|
|
LUASRC = $(LUATOP)/src
|
|
LUA_MAY_PROCEED=Y
|
|
else
|
|
endif # Lua sources
|
|
ifeq "$(LUA_MAY_PROCEED)" "Y"
|
|
$(info No internet connection was authorized in the Makefile,)
|
|
$(info but a copy of lua-$(LUAVER) was found in $(LUASRC), so that will be used.)
|
|
endif # LUA_MAY_PROCEED
|
|
endif # INTERNET_AVAILABLE
|
|
|
|
ifneq "$(LUA_MAY_PROCEED)" "Y"
|
|
ifneq "$(INTERNET_AVAILABLE)" "Y"
|
|
$(info Your Makefile settings do not allow use of the internet to obtain Lua)
|
|
endif # INTERNET_AVAILABLE
|
|
$(info and no copy of Lua was found in either ../submodules/lua or ../lib/lua-$(LUAVER).)
|
|
$(info Change your make command line to include:)
|
|
$(info GIT=1)
|
|
$(info or modify your Makefile to set the following:)
|
|
$(info INTERNET_AVAILABLE=Y)
|
|
$(info GIT_AVAILABLE=Y)
|
|
$(error Stopping because NetHack 3.7 requires Lua for its build.)
|
|
endif # LUA_MAY_PROCEED
|
|
|
|
# Now, pdcurses
|
|
ifeq "$(INTERNET_AVAILABLE)" "Y"
|
|
ifeq "$(GIT_AVAILABLE)" "Y"
|
|
PDCURSES_TOP=../submodules/pdcurses
|
|
ADD_CURSES=Y
|
|
else # GIT_AVAILABLE
|
|
PDCURSES_TOP=../lib/pdcurses
|
|
ADD_CURSES=Y
|
|
endif # GIT_AVAILABLE
|
|
else # INTERNET_AVAILABLE is not Y below
|
|
# Your Makefile settings to not allow pdcurses to be obtained by
|
|
# git or by download). Check to see if it is available at one of
|
|
# the expected locations already, with precedence given to ../submodules,
|
|
# then ../lib.
|
|
#
|
|
ifneq ("$(wildcard ../submodules/pdcurses/curses.h)", "")
|
|
PDCURSES_TOP=../submodules/pdcurses
|
|
ADD_CURSES=Y
|
|
else ifneq ("$(wildcard ../lib/pdcurses/curses.h)", "")
|
|
PDCURSES_TOP=../lib/pdcurses
|
|
ADD_CURSES=Y
|
|
endif # pdcurses sources available somewhere
|
|
|
|
ifeq "$(ADD_CURSES)" "Y"
|
|
$(info Your Makefile settings do not allow pdcurses to be obtained by)
|
|
$(info git or by download, but a copy of pdcurses was found in $(PDCURSES_TOP),)
|
|
$(info so that will be used.)
|
|
endif # ADD_CURSES == Y
|
|
endif # INTERNET_AVAILABLE
|
|
|
|
ifneq "$(ADD_CURSES)" "Y"
|
|
$(info NetHack 3.7 will be built without support for the curses window-port.)
|
|
endif
|
|
|
|
ifeq "$(INTERNET_AVAILABLE)" "Y"
|
|
ifeq "$(GIT_AVAILABLE)" "Y"
|
|
GIT_HASH := $(shell echo `git rev-parse --verify HEAD` 2>&1)
|
|
GIT_BRANCH := $(shell echo `git rev-parse --abbrev-ref HEAD` 2>&1)
|
|
ifdef GIT_HASH
|
|
GITHASH = -DNETHACK_GIT_SHA=\"$(GIT_HASH)\"
|
|
endif
|
|
ifdef GIT_BRANCH
|
|
GITBRANCH = -DNETHACK_GIT_BRANCH=\"$(GIT_BRANCH)\"
|
|
endif
|
|
endif
|
|
endif
|
|
|
|
#==============================================================================
|
|
|
|
# The version of the game this Makefile was designed for
|
|
NETHACK_VERSION="3.7.0"
|
|
|
|
# A brief version for use in macros
|
|
NHV1=$(subst .,,$(NETHACK_VERSION))
|
|
NHV=$(subst ",,$(NHV1))
|
|
|
|
#
|
|
# Source directories. Makedefs hardcodes these, don't change them.
|
|
#
|
|
|
|
# INCL - NetHack include files
|
|
# DAT - NetHack data files
|
|
# DOC - NetHack documentation files
|
|
# UTIL - Utility source
|
|
# SRC - Main source
|
|
# SSYS - Shared system files
|
|
# MSWSYS - mswin specific files
|
|
# TTY - window port files (tty)
|
|
# MSWIN - window port files (win32)
|
|
# WCURSES - window port files (curses)
|
|
# WSHR - Tile support files
|
|
# QT - QT window support files
|
|
|
|
INCL =../include
|
|
DAT =../dat
|
|
DOC =../doc
|
|
UTIL =../util
|
|
SRC =../src
|
|
SSYS =../sys/share
|
|
MSWSYS =../sys/windows
|
|
TTY =../win/tty
|
|
MSWIN =../win/win32
|
|
WCURSES =../win/curses
|
|
WSHR =../win/share
|
|
QT =../win/Qt
|
|
|
|
#
|
|
# Object directory.
|
|
#
|
|
|
|
OBJ = o
|
|
|
|
#
|
|
# Shorten up the location for some files
|
|
#
|
|
|
|
O = $(OBJ)/
|
|
|
|
U = $(UTIL)/
|
|
|
|
# To store all the level files,
|
|
# help files, etc. in a single library file.
|
|
# USE_DLB = Y is left uncommented
|
|
|
|
USE_DLB = Y
|
|
|
|
#==========================================
|
|
#==========================================
|
|
# Setting up the compiler and linker
|
|
# macros. All builds include the base ones.
|
|
#==========================================
|
|
#==========================================
|
|
|
|
ifdef CI_COMPILER
|
|
cc = gcc -c
|
|
ld = gcc
|
|
else
|
|
cc = gcc -c
|
|
ld = gcc
|
|
endif
|
|
ifeq "$(MSYSTEM)" "MINGW32"
|
|
rc = windres --target=pe-i386
|
|
else # MINGW64
|
|
rc = windres --target=pe-x86-64
|
|
endif
|
|
|
|
#
|
|
# Handle user settings
|
|
#
|
|
CFLAGS = -mms-bitfields -I../include -I../sys/windows
|
|
LDFLAGS =
|
|
ifeq "$(DEBUGINFO)" "Y"
|
|
CFLAGS += -g -D_DEBUG
|
|
else
|
|
CFLAGS += -DNDEBUG
|
|
LDFLAGS += -s
|
|
endif
|
|
|
|
ifeq "$(USE_DLB)" "Y"
|
|
DLBFLG = -DDLB
|
|
else
|
|
DLBFLG =
|
|
endif
|
|
|
|
COMMONDEF = -DWIN32 -DWINVER=0x0601 -D_WIN32_WINNT=0x0601
|
|
DLLDEF = $(COMMONDEF) -DWIN32CON -D_WINDOWS -D_USRDLL -D_WINDLL
|
|
CONSOLEDEF = $(COMMONDEF) -D_CONSOLE
|
|
|
|
# To build util targets
|
|
CFLAGSU = $(CFLAGS) $(CONSOLEDEF) $(DLBFLG) -DWIN32CON -DMSWIN_GRAPHICS
|
|
|
|
LIBS = -lcomctl32 -lgdi32 -lole32 -lshell32 -luuid -lwinmm -lbcrypt
|
|
|
|
$(GAMEDIR):
|
|
@mkdir -p $@
|
|
|
|
$(OBJ):
|
|
@mkdir -p $@
|
|
|
|
CLEAN_DIR = $(GAMEDIR) $(OBJ)
|
|
|
|
#===============-=================================================
|
|
# LUA library
|
|
# Source from http://www.lua.org/ftp/lua-5.4.4.tar.gz
|
|
#=================================================================
|
|
|
|
OLUA = $(O)lua
|
|
LUAOBJS = $(addprefix $(OLUA)/, $(addsuffix .o, lapi lauxlib lbaselib lcode lcorolib lctype \
|
|
ldblib ldebug ldo ldump lfunc lgc linit liolib llex lmathlib lmem \
|
|
loadlib lobject lopcodes loslib lparser lstate lstring lstrlib ltable ltablib ltm \
|
|
lundump lutf8lib lvm lzio))
|
|
LUADLL = $(GAMEDIR)/lua-$(LUAVER).dll
|
|
LUAIMP = $(OLUA)/lua-$(LUAVER).dll.a
|
|
ULUADLL = $(U)$(notdir $(LUADLL))
|
|
LUASTATIC = $(OLUA)/lua-$(LUAVER).a
|
|
LUATARGETS = $(U)lua.exe
|
|
|
|
ifeq "$(USE_LUADLL)" "Y"
|
|
LUALIB = $(LUAIMP)
|
|
LUATARGETS += $(LUADLL) $(ULUADLL) $(LUAIMP)
|
|
else
|
|
LUALIB = $(LUASTATIC)
|
|
LUATARGETS += $(LUASTATIC)
|
|
endif
|
|
|
|
ifeq "$(WANT_LUAC)" "Y"
|
|
LUATARGETS += $(U)luac.exe
|
|
endif
|
|
|
|
lua: $(LUATARGETS)
|
|
|
|
$(U)lua.exe: $(OLUA)/lua.o $(LUALIB)
|
|
$(ld) $(LDFLAGS) $^ -o$@
|
|
|
|
$(LUADLL): $(ULUADLL)
|
|
cp $< $@
|
|
|
|
$(ULUADLL) $(LUAIMP): $(LUAOBJS) | $(OLUA)
|
|
$(ld) $(LDFLAGS) -fPIC -shared -Wl,--export-all-symbols -Wl,--add-stdcall-alias \
|
|
-Wl,--out-implib=$(LUAIMP) $^ -o$(ULUADLL)
|
|
|
|
$(LUASTATIC): $(LUAOBJS) | $(OLUA)
|
|
ar rcs $@ $^
|
|
|
|
$(OLUA)/%.o: $(LUASRC)/%.c | $(OLUA)
|
|
$(cc) $(CFLAGS) $< -o$@
|
|
|
|
$(U)luac.exe: $(OLUA)/luac.o $(LUALIB)
|
|
$(ld) $(LDFLAGS) $^ -o$@
|
|
|
|
$(OLUA):
|
|
@mkdir -p $@
|
|
|
|
CLEAN_DIR += $(OLUA)
|
|
CLEAN_FILE += $(LUATARGETS) $(LUAOBJS) $(OLUA)/lua.o $(OLUA)/luac.o
|
|
|
|
#==========================================
|
|
# nhlua.h
|
|
#==========================================
|
|
NHLUAH = $(INCL)/nhlua.h
|
|
|
|
$(NHLUAH):
|
|
echo "/* nhlua.h - generated by Makefile.mingw32 */" > $@
|
|
@echo "#include \"$(LUASRC)/lua.h\"" >> $@
|
|
@echo "LUA_API int (lua_error) (lua_State *L) NORETURN;" >>$@
|
|
@echo "#include \"$(LUASRC)/lualib.h\"" >> $@
|
|
@echo "#include \"$(LUASRC)/lauxlib.h\"" >> $@
|
|
@echo "/*nhlua.h*/" >> $@
|
|
|
|
CLEAN_FILE += $(NHLUAH)
|
|
|
|
#==========================================
|
|
# Makedefs
|
|
#==========================================
|
|
OM = $(O)makedefs
|
|
MOBJS = $(addprefix $(OM)/, alloc.o date.o makedefs.o monst.o objects.o panic.o)
|
|
MTARGETS = $(U)makedefs.exe
|
|
|
|
makedefs: $(MTARGETS)
|
|
|
|
$(U)makedefs.exe: $(MOBJS)
|
|
$(ld) $(LDFLAGS) $^ -o$@
|
|
|
|
$(OM)/%.o: $(SRC)/%.c $(NHLUAH) | $(OM)
|
|
$(cc) $(CFLAGSU) -DENUM_PM $< -o$@
|
|
|
|
$(OM)/%.o: $(U)%.c $(NHLUAH) | $(OM)
|
|
$(cc) $(CFLAGSU) -DENUM_PM $< -o$@
|
|
|
|
$(OM):
|
|
@mkdir -p $@
|
|
|
|
CLEAN_DIR += $(OM)
|
|
CLEAN_FILE += $(MTARGETS) $(MOBJS)
|
|
|
|
#==========================================
|
|
# Recover
|
|
#==========================================
|
|
OR = $(OBJ)
|
|
ROBJS = $(OR)/recover.o
|
|
RTARGETS = $(GAMEDIR)/recover.txt $(GAMEDIR)/recover.exe
|
|
|
|
recover: $(RTARGETS)
|
|
|
|
$(GAMEDIR)/recover.txt: $(DOC)/recover.txt | $(GAMEDIR)
|
|
cp $< $@
|
|
|
|
$(GAMEDIR)/recover.exe: $(ROBJS) | $(GAMEDIR)
|
|
$(ld) $(LDFLAGS) $^ -o$@
|
|
|
|
$(OR)/recover.o: $(U)recover.c | $(OR)
|
|
$(cc) $(CFLAGSU) $< -o$@
|
|
|
|
# $(OR):
|
|
# @mkdir -p $@
|
|
|
|
CLEAN_FILE += $(RTARGETS) $(ROBJS)
|
|
|
|
#==========================================
|
|
# PDCurses
|
|
#==========================================
|
|
ifeq "$(ADD_CURSES)" "Y"
|
|
OP = $(O)pdcurses
|
|
PDCOBJS = $(addprefix $(OP)/, addch.o addchstr.o addstr.o attr.o beep.o bkgd.o border.o \
|
|
clear.o color.o debug.o delch.o deleteln.o getch.o getstr.o getyx.o \
|
|
inch.o inchstr.o initscr.o inopts.o insch.o insstr.o \
|
|
kernel.o keyname.o mouse.o move.o outopts.o overlay.o \
|
|
pad.o panel.o pdcclip.o pdcdisp.o pdcgetsc.o pdckbd.o pdcscrn.o pdcsetsc.o pdcutil.o printw.o \
|
|
refresh.o scanw.o scr_dump.o scroll.o slk.o termattr.o touch.o util.o window.o)
|
|
PDCSRC = $(PDCURSES_TOP)/pdcurses
|
|
PDCWINCON = $(PDCURSES_TOP)/wincon
|
|
PDCINCL = -I$(PDCURSES_TOP) -I$(PDCSRC) -I$(PDCWINCON)
|
|
PDCLIB = $(O)pdcurses.a
|
|
PDCDEP = $(PDCURSES_TOP)/curses.h
|
|
|
|
pdcurses: $(PDCLIB)
|
|
|
|
$(PDCLIB): $(PDCOBJS)
|
|
ar rcs $@ $^
|
|
|
|
$(OP)/%.o: $(PDCSRC)/%.c | $(OP)
|
|
$(cc) $(CFLAGS) $(PDCINCL) -D_LIB $< -o$@
|
|
|
|
$(OP)/%.o: $(PDCWINCON)/%.c | $(OP)
|
|
$(cc) $(CFLAGS) $(PDCINCL) -D_LIB $< -o$@
|
|
|
|
$(OP):
|
|
@mkdir -p $@
|
|
|
|
CLEAN_DIR += $(OP)
|
|
CLEAN_FILE += $(PDCLIB) $(PDCOBJS)
|
|
endif
|
|
|
|
#==========================================
|
|
# tile2bmp
|
|
#==========================================
|
|
OT = $(O)tile2bmp
|
|
TOBJS = $(addprefix $(OT)/, drawing.o monst.o objects.o tile2bmp.o tiletext.o tiletxt.o)
|
|
TTARGETS = $(U)tile2bmp.exe
|
|
|
|
tile2bmp: $(TTARGETS)
|
|
|
|
$(U)tile2bmp.exe: $(TOBJS)
|
|
$(ld) $(LDFLAGS) $^ -o$@
|
|
|
|
$(OT)/tiletxt.o: $(WSHR)/tilemap.c $(NHLUAH) | $(OT)
|
|
$(cc) $(CFLAGSU) -DTILETEXT $< -o$@
|
|
|
|
$(OT)/%.o: $(WSHR)/%.c $(NHLUAH) | $(OT)
|
|
$(cc) $(CFLAGSU) $< -o$@
|
|
|
|
$(OT)/%.o: $(SRC)/%.c $(NHLUAH) | $(OT)
|
|
$(cc) $(CFLAGSU) $< -o$@
|
|
|
|
$(OT):
|
|
@mkdir -p $@
|
|
|
|
CLEAN_DIR += $(OT)
|
|
CLEAN_FILE += $(TTARGETS) $(TOBJS)
|
|
|
|
#==========================================
|
|
# Optional Tile Utilities
|
|
#==========================================
|
|
TEXT_IO = $(addprefix $(OT)/, drawing.o monst.o objects.o tiletext.o tiletxt.o)
|
|
TUCOMMON = $(OT)/alloc.o $(OT)/panic.o
|
|
TUOBJS = $(TUCOMMON) $(TEXT_IO)
|
|
|
|
T32OBJS = $(OT)/tilete32.o $(OT)/tiletx32.o
|
|
TEXT_IO32 = $(addprefix $(OT)/, drawing.o monst.o objects.o) $(T32OBJS)
|
|
TU32OBJS = $(TUCOMMON) $(TEXT_IO32)
|
|
|
|
GIFOBJ = $(OT)/gifread.o
|
|
GIF32OBJ = $(OT)/gifrd32.o
|
|
PPMOBJ = $(OT)/ppmwrite.o
|
|
BMP32OBJ = $(OT)/til2bm32.o
|
|
TILEFILES32 = $(addprefix $(WSHR)/, mon32.txt obj32.txt oth32.txt)
|
|
TUTARGETS = $(U)gif2txt.exe $(U)gif2tx32.exe $(U)txt2ppm.exe $(U)til2bm32.exe
|
|
|
|
tileutil: $(TUTARGETS)
|
|
|
|
$(U)gif2txt.exe: $(GIFOBJ) $(TUOBJS)
|
|
$(ld) $(LDFLAGS) $^ -o$@
|
|
|
|
$(U)gif2tx32.exe: $(GIF32OBJ) $(TU32OBJS)
|
|
$(ld) $(LDFLAGS) $^ -o$@
|
|
|
|
$(U)txt2ppm.exe: $(PPMOBJ) $(TUOBJS)
|
|
$(ld) $(LDFLAGS) $^ -o$@
|
|
|
|
$(U)til2bm32.exe: $(BMP32OBJ) $(TEXT_IO32)
|
|
$(ld) $(LDFLAGS) $^ -o$@
|
|
|
|
$(OT)/tilete32.o: $(WSHR)/tiletext.c $(NHLUAH) | $(OT)
|
|
$(cc) $(CFLAGSU) -DTILE_X=32 -DTILE_Y=32 $< -o$@
|
|
|
|
$(OT)/tiletx32.o: $(WSHR)/tilemap.c $(NHLUAH) | $(OT)
|
|
$(cc) $(CFLAGSU) -DTILETEXT -DTILE_X=32 -DTILE_Y=32 $< -o$@
|
|
|
|
$(GIF32OBJ): $(WSHR)/gifread.c $(NHLUAH) | $(OT)
|
|
$(cc) $(CFLAGSU) -DTILE_X=32 -DTILE_Y=32 $< -o$@
|
|
|
|
$(BMP32OBJ): $(WSHR)/tile2bmp.c $(NHLUAH) | $(OT)
|
|
$(cc) $(CFLAGSU) -DTILE_X=32 -DTILE_Y=32 $< -o$@
|
|
|
|
$(OT)/panic.o: $(UTIL)/panic.c $(NHLUAH) | $(OT)
|
|
$(cc) $(CFLAGSU) $< -o$@
|
|
|
|
$(MSWIN)/tiles32.bmp: $(U)til2bm32.exe $(TILEFILES32)
|
|
$< $@
|
|
|
|
CLEAN_FILE += $(TUTARGETS) $(GIFOBJ) $(GIF32OBJ) $(PPMOBJ) $(BMP32OBJ) \
|
|
$(T32OBJS) $(TUCOMMON)
|
|
|
|
#==========================================
|
|
# tilemap
|
|
#==========================================
|
|
OTM = $(OBJ)/tilemap
|
|
TMOBJS = $(addprefix $(OTM)/, drawing.o monst.o objects.o tilemap.o)
|
|
TMTARGETS = $(SRC)/tile.c $(U)tilemap.exe
|
|
|
|
tilemap: $(SRC)/tile.c
|
|
|
|
$(SRC)/tile.c: $(U)tilemap.exe
|
|
$<
|
|
|
|
$(U)tilemap.exe: $(TMOBJS)
|
|
$(ld) $(LDFLAGS) $^ -o$@
|
|
|
|
$(OTM)/tilemap.o: $(WSHR)/tilemap.c $(NHLUAH) | $(OTM)
|
|
$(cc) $(CFLAGSU) $< -o$@
|
|
|
|
$(OTM)/%.o: $(SRC)/%.c $(NHLUAH) | $(OTM)
|
|
$(cc) $(CFLAGSU) $< -o$@
|
|
|
|
$(OTM):
|
|
@mkdir -p $@
|
|
|
|
CLEAN_DIR += $(OTM)
|
|
# tilemap.exe will create tilemappings.lst
|
|
CLEAN_FILE += $(TMTARGETS) $(TMOBJS) $(SRC)/tilemappings.lst
|
|
|
|
#==========================================
|
|
# uudecode
|
|
#==========================================
|
|
OU = $(OBJ)
|
|
UOBJS = $(OU)/uudecode.o
|
|
UTARGETS = $(U)uudecode.exe $(MSWIN)/NetHack.ico
|
|
|
|
uudecode: $(UTARGETS)
|
|
|
|
$(U)uudecode.exe: $(UOBJS)
|
|
$(ld) $(LDFLAGS) $^ -o$@
|
|
|
|
$(OU)/uudecode.o: $(SSYS)/uudecode.c | $(OU)
|
|
$(cc) $(CFLAGS) $(CONSOLEDEF) $< -o$@
|
|
|
|
# $(OU):
|
|
# @mkdir -p $@
|
|
|
|
$(MSWIN)/NetHack.ico: $(U)uudecode.exe $(MSWSYS)/nhico.uu
|
|
$^
|
|
mv nethack.ico $@
|
|
|
|
CLEAN_FILE += $(UTARGETS) $(UOBJS)
|
|
|
|
#==========================================
|
|
# Data librarian
|
|
#==========================================
|
|
ODLB = $(O)dlb
|
|
DLBOBJS = $(addprefix $(ODLB)/, alloc.o dlb.o dlb_main.o panic.o)
|
|
DAT_CLEAN = $(addprefix $(DAT)/, data oracles options porthelp rumors engrave epitaph bogusmon)
|
|
DAT_NOCLEAN = $(addprefix $(DAT)/, help hh cmdhelp keyhelp history opthelp optmenu \
|
|
wizhelp license engrave epitaph bogusmon tribute)
|
|
DLBLST = $(DAT)/dlb.lst
|
|
DLB = $(GAMEDIR)/nhdat$(NHV)
|
|
DTARGETS = $(U)dlb.exe $(DAT_CLEAN) $(DLBLST) $(DLB)
|
|
|
|
dlb: $(DTARGETS)
|
|
|
|
$(U)dlb.exe: $(DLBOBJS)
|
|
$(ld) $(LDFLAGS) $^ -o$@
|
|
|
|
$(ODLB)/%.o: $(SRC)/%.c $(NHLUAH) | $(ODLB)
|
|
$(cc) $(CFLAGSU) $< -o$@
|
|
|
|
$(ODLB)/%.o: $(U)%.c $(NHLUAH) | $(ODLB)
|
|
$(cc) $(CFLAGSU) $< -o$@
|
|
|
|
$(ODLB):
|
|
@mkdir -p $@
|
|
|
|
$(DAT)/data: $(U)makedefs.exe $(DAT)/data.base
|
|
$< -d
|
|
|
|
$(DAT)/oracles: $(U)makedefs.exe $(DAT)/oracles.txt
|
|
$< -h
|
|
|
|
$(DAT)/options $(INCL)/date.h: $(U)makedefs.exe
|
|
$< -v
|
|
|
|
$(DAT)/porthelp: $(MSWSYS)/porthelp
|
|
cp $< $@
|
|
|
|
$(DAT)/rumors: $(U)makedefs.exe $(DAT)/rumors.tru $(DAT)/rumors.fal
|
|
$< -r
|
|
|
|
$(DAT)/engrave: $(DAT)/bogusmon
|
|
|
|
$(DAT)/epitaph: $(DAT)/bogusmon
|
|
|
|
$(DAT)/bogusmon: $(U)makedefs.exe $(DAT)/bogusmon.txt $(DAT)/engrave.txt $(DAT)/epitaph.txt
|
|
$< -s
|
|
|
|
$(DLBLST): | $(DAT_CLEAN) $(DAT_NOCLEAN)
|
|
echo data > $(DLBLST)
|
|
echo oracles >> $(DLBLST)
|
|
echo options >> $(DLBLST)
|
|
if [ -f $(DAT)/ttyoptions ] ; then echo ttyoptions >> $(DLBLST) ; fi
|
|
if [ -f $(DAT)/guioptions ] ; then echo guioptions >> $(DLBLST) ; fi
|
|
echo porthelp >> $(DLBLST)
|
|
echo rumors >> $(DLBLST)
|
|
echo help >> $(DLBLST)
|
|
echo hh >> $(DLBLST)
|
|
echo cmdhelp >> $(DLBLST)
|
|
echo keyhelp >> $(DLBLST)
|
|
echo history >> $(DLBLST)
|
|
echo opthelp >> $(DLBLST)
|
|
echo optmenu >> $(DLBLST)
|
|
echo wizhelp >> $(DLBLST)
|
|
echo license >> $(DLBLST)
|
|
echo engrave >> $(DLBLST)
|
|
echo epitaph >> $(DLBLST)
|
|
echo bogusmon >> $(DLBLST)
|
|
echo tribute >> $(DLBLST)
|
|
cd $(DAT) ; ls -1 *.lua >> $(DLBLST)
|
|
|
|
$(DLB): $(U)dlb.exe $(DLBLST) | $(GAMEDIR)
|
|
$(U)dlb.exe CcIf $(dir $(DLBLST)) $(notdir $(DLBLST)) $(SRC)/nhdat
|
|
mv $(SRC)/nhdat$(NHV) $@
|
|
|
|
CLEAN_DIR += $(ODLB)
|
|
CLEAN_FILE += $(DTARGETS) $(DLBOBJS) $(INCL)/date.h
|
|
|
|
#============================================
|
|
# Fetching other source files that are needed
|
|
#============================================
|
|
|
|
ifeq "$(INTERNET_AVAILABLE)" "Y"
|
|
ifeq "$(GIT_AVAILABLE)" "Y"
|
|
|
|
fetchlua:
|
|
@if [ ! -f $(LUASRC)/lua.h ] ; then \
|
|
git submodule init ../submodules/lua && \
|
|
git submodule update --remote ../submodules/lua ; fi
|
|
fetchpdcurses:
|
|
@if [ ! -f $(PDCURSES_TOP)/curses.h ] ; then \
|
|
git submodule init ../submodules/pdcurses && \
|
|
git submodule update --remote ../submodules/pdcurses ; fi
|
|
else # GIT_AVAILABLE no
|
|
CURLLUASRC=http://www.lua.org/ftp/lua-5.4.4.tar.gz
|
|
CURLLUADST=lua-5.4.4.tar.gz
|
|
|
|
CURLPDCSRC=https://github.com/wmcbrine/PDCurses/archive/refs/tags/3.9.zip
|
|
CURLPDCDST=pdcurses.zip
|
|
|
|
fetchlua:
|
|
@if [ ! -f $(LUASRC)/lua.h ] ; then \
|
|
mkdir -p ../lib ; \
|
|
cd ../lib ; \
|
|
curl -L $(CURLLUASRC) -o $(CURLLUADST) ; \
|
|
/c/Windows/System32/tar -xvf $(CURLLUADST) ; \
|
|
cd ../src ; \
|
|
fi
|
|
fetchpdcurses:
|
|
mkdir -p ../lib
|
|
@if [ ! -f $(PDCURSES_TOP)/curses.h ] ; then \
|
|
cd ../lib ; \
|
|
curl -L $(CURLPDCSRC) -o $(CURLPDCDST) ; \
|
|
mkdir -p pdcurses ; \
|
|
/c/Windows/System32/tar -C pdcurses --strip-components=1 -xvf $(CURLPDCDST) ; \
|
|
cd ../src ; \
|
|
fi
|
|
endif # GIT_AVAILABLE
|
|
endif # INTERNET_AVAILABLE
|
|
|
|
#==========================================
|
|
# nethackw
|
|
#==========================================
|
|
COREOBJS = $(addsuffix .o, allmain alloc apply artifact attrib ball bones botl cmd cppregex \
|
|
dbridge decl detect dig display dlb do do_name do_wear \
|
|
dog dogmove dokick dothrow drawing dungeon \
|
|
eat end engrave exper explode extralev files fountain \
|
|
hack hacklib insight invent isaac64 light lock \
|
|
mail makemon mcastu mdlib mhitm mhitu minion mklev mkmap mkmaze mkobj mkroom \
|
|
mon mondata monmove monst mplayer mthrowu muse music \
|
|
nhlobj nhlsel nhlua ntsound o_init objects objnam options \
|
|
pager pickup pline polyself potion pray priest quest questpgr \
|
|
random read rect region restore rip rnd role rumors \
|
|
safeproc save sfstruct shk shknam sit sounds sp_lev spell steal steed stubs symbols sys \
|
|
teleport timeout topten track trap u_init uhitm utf8map vault version vision \
|
|
weapon were wield windmain windows windsys wizard worm worn write zap)
|
|
|
|
CFLAGSW = $(CFLAGS) $(COMMONDEF) $(DLBFLG) -DTILES -D_WINDOWS -DMSWIN_GRAPHICS -DSAFEPROCS -DNOTTYGRPHICS
|
|
|
|
ONHW = $(O)nethackw
|
|
NHWONLY = $(addsuffix .o, mhaskyn mhdlg mhfont mhinput mhmain mhmap mhmenu \
|
|
mhmsgwnd mhrip mhsplash mhstatus mhtext mswproc tile NetHackW win10)
|
|
NHWOBJS = $(addprefix $(ONHW)/, $(COREOBJS) $(NHWONLY))
|
|
DATEW_O = $(addsuffix .o, $(addprefix $(ONHW)/, date))
|
|
TILEFILES = $(addprefix $(WSHR)/, monsters.txt objects.txt other.txt)
|
|
BMPS = $(addprefix $(MSWIN)/, $(addsuffix .bmp, mnsel mnselcnt mnunsel petmark pilemark rip splash tiles))
|
|
NHWRES = $(ONHW)/winres.o
|
|
NHWTARGETS = $(GAMEDIR)/NetHackW.exe
|
|
|
|
nethackw: $(NHWTARGETS)
|
|
|
|
$(GAMEDIR)/NetHackW.exe: $(NHWOBJS) $(NHWRES) $(DATEW_O) $(LUALIB) | $(GAMEDIR)
|
|
$(ld) $(LDFLAGS) -mwindows $^ $(LIBS) -static -lstdc++ -o$@
|
|
|
|
$(ONHW)/%.o: $(SRC)/%.c $(NHLUAH) | $(ONHW)
|
|
$(cc) $(CFLAGSW) $< -o$@
|
|
|
|
# In NetHack 3.7, date.c must be recompiled after any other file is compiled,
|
|
# otherwise the game internal build timestamp (and potentially git hash)
|
|
# will not be accurate.
|
|
# Therefore, date must not be included in COREOBJS (and by extension
|
|
# NHWOBJS, NHWONLY). That allows those to be listed as explicit dependencies
|
|
# to ensure that date.c is always recompiled again after anything else that
|
|
# was just recompiled. date.h is not used in the build of NetHack 3.7.
|
|
#
|
|
$(ONHW)/date.o: $(SRC)/date.c $(NHWOBJS) | $(ONHW)
|
|
$(cc) $(CFLAGSW) $(GITHASH) $(GITBRANCH) $< -o$@
|
|
|
|
$(ONHW)/cppregex.o: $(SSYS)/cppregex.cpp $(NHLUAH) | $(ONHW)
|
|
$(cc) $(CFLAGSW) $< -o$@
|
|
|
|
$(ONHW)/%.o: $(SSYS)/%.c $(NHLUAH) | $(ONHW)
|
|
$(cc) $(CFLAGSW) $< -o$@
|
|
|
|
$(ONHW)/stubs.o: $(MSWSYS)/stubs.c $(NHLUAH) | $(ONHW)
|
|
$(cc) $(CFLAGSW) -DTTYSTUB $< -o$@
|
|
|
|
$(ONHW)/%.o: $(MSWSYS)/%.c $(NHLUAH) | $(ONHW)
|
|
$(cc) $(CFLAGSW) $< -o$@
|
|
|
|
$(ONHW)/%.o: $(MSWIN)/%.c $(NHLUAH) | $(ONHW)
|
|
$(cc) $(CFLAGSW) $< -o$@
|
|
|
|
$(ONHW)/%.o: $(WSHR)/%.c $(NHLUAH) | $(ONHW)
|
|
$(cc) $(CFLAGSW) $< -o$@
|
|
|
|
$(NHWRES): $(MSWIN)/NetHackW.rc $(BMPS) $(MSWIN)/NetHack.ico | $(ONHW)
|
|
$(rc) --include-dir=$(MSWIN) --input=$< -o$@
|
|
|
|
$(MSWIN)/tiles.bmp: $(U)tile2bmp.exe $(TILEFILES)
|
|
$< $@
|
|
|
|
$(MSWIN)/%.bmp: $(U)uudecode.exe $(MSWIN)/%.uu
|
|
$^
|
|
mv $(notdir $@) $@
|
|
|
|
$(ONHW):
|
|
@mkdir -p $@
|
|
|
|
CLEAN_DIR += $(ONHW)
|
|
CLEAN_FILE += $(NHWTARGETS) $(NHWOBJS) $(NHWRES) $(BMPS)
|
|
|
|
#==========================================
|
|
# nethack
|
|
#==========================================
|
|
CFLAGSNH = $(CFLAGSU) -DNO_TILE_C -DSAFEPROCS -D_LIB
|
|
|
|
ONH = $(O)nethack
|
|
|
|
NHONLY = consoletty.o getline.o topl.o wintty.o
|
|
ifeq "$(ADD_CURSES)" "Y"
|
|
CFLAGSNH += -DCURSES_GRAPHICS -DCHTYPE_32 -DPDC_NCMOUSE
|
|
NHONLY += $(addsuffix .o, cursdial cursinit cursinvt cursmain cursmesg cursmisc cursstat curswins)
|
|
endif
|
|
DATE_O = $(addsuffix .o, $(addprefix $(ONH)/, date))
|
|
|
|
NHOBJS = $(addprefix $(ONH)/, $(COREOBJS) $(NHONLY))
|
|
NHRES = $(ONH)/conres.o
|
|
NHTARGET = $(GAMEDIR)/NetHack.exe
|
|
|
|
nethack: $(NHTARGET)
|
|
|
|
$(GAMEDIR)/NetHack.exe: $(NHOBJS) $(NHRES) $(DATE_O) $(LUALIB) $(PDCLIB) | $(GAMEDIR)
|
|
$(ld) $(LDFLAGS) -mconsole $^ $(LIBS) -static -lstdc++ -o$@
|
|
|
|
$(ONH)/%.o: $(SRC)/%.c $(NHLUAH) | $(ONH)
|
|
$(cc) $(CFLAGSNH) $< -o$@
|
|
|
|
# In NetHack 3.7, date.c must be recompiled after any other file is compiled,
|
|
# otherwise the game internal build timestamp (and potentially git hash)
|
|
# will not be accurate.
|
|
# Therefore, date must not be included in COREOBJS (and by extension
|
|
# NHOBJS). That allows those to be listed as explicit dependencies of date.o
|
|
# to ensure that date.c is always recompiled again after anything else that
|
|
# was just recompiled. date.h is not used in the build of NetHack 3.7.
|
|
#
|
|
$(ONH)/date.o: $(SRC)/date.c $(NHOBJS) $(NHRES) | $(ONH)
|
|
$(cc) $(CFLAGSNH) $(GITHASH) $(GITBRANCH) $< -o$@
|
|
|
|
$(ONH)/cppregex.o: $(SSYS)/cppregex.cpp $(NHLUAH) | $(ONH)
|
|
$(cc) $(CFLAGSNH) $< -o$@
|
|
|
|
$(ONH)/%.o: $(SSYS)/%.c $(NHLUAH) | $(ONH)
|
|
$(cc) $(CFLAGSNH) $< -o$@
|
|
|
|
$(ONH)/stubs.o: $(MSWSYS)/stubs.c $(NHLUAH) | $(ONH)
|
|
$(cc) $(CFLAGSNH) -DGUISTUB $< -o$@
|
|
|
|
$(ONH)/%.o: $(MSWSYS)/%.c $(NHLUAH) | $(ONH)
|
|
$(cc) $(CFLAGSNH) $< -o$@
|
|
|
|
$(ONH)/%.o: $(MSWIN)/%.c $(NHLUAH) | $(ONH)
|
|
$(cc) $(CFLAGSNH) $< -o$@
|
|
|
|
$(ONH)/%.o: $(WSHR)/%.c $(NHLUAH) | $(ONH)
|
|
$(cc) $(CFLAGSNH) $< -o$@
|
|
|
|
$(ONH)/%.o: $(TTY)/%.c $(NHLUAH) | $(ONH)
|
|
$(cc) $(CFLAGSNH) $< -o$@
|
|
|
|
$(ONH)/%.o: $(WCURSES)/%.c $(NHLUAH) | $(ONH)
|
|
$(cc) $(CFLAGSNH) $(PDCINCL) $< -o$@
|
|
|
|
$(NHRES): $(MSWIN)/NetHack.rc $(MSWIN)/NetHack.ico | $(ONH)
|
|
$(rc) --include-dir=$(MSWIN) --input=$< -o$@
|
|
|
|
$(ONH):
|
|
@mkdir -p $@
|
|
|
|
CLEAN_DIR += $(ONH)
|
|
CLEAN_FILE += $(NHTARGET) $(NHOBJS) $(NHRES)
|
|
|
|
#==========================================
|
|
#=============== TARGETS ==================
|
|
#==========================================
|
|
|
|
.PHONY: all clean default install lua makedefs recover pdcurses \
|
|
tile2bmp tilemap uudecode dlb nethackw nethack tileutil \
|
|
fetchlua fetchpdcurses
|
|
|
|
#
|
|
# Everything
|
|
#
|
|
|
|
all: install
|
|
|
|
TO_INSTALL = $(GAMEDIR)/NetHack.exe $(RTARGETS) \
|
|
$(addprefix $(GAMEDIR)/, $(addsuffix .template, sysconf .nethackrc) \
|
|
Guidebook.txt NetHack.txt license opthelp record symbols)
|
|
|
|
ifeq "$(USE_LUADLL)" "Y"
|
|
TO_INSTALL += $(LUADLL)
|
|
endif
|
|
|
|
ifneq "$(SKIP_NETHACKW)" "Y"
|
|
TO_INSTALL += $(GAMEDIR)/NetHackW.exe
|
|
endif
|
|
|
|
ifeq "$(USE_DLB)" "Y"
|
|
TO_INSTALL += $(DLB)
|
|
endif
|
|
|
|
install: fetchlua fetchpdcurses $(TO_INSTALL)
|
|
ifdef CI_COMPILER
|
|
ls -l $(SRC)
|
|
ls -l $(DAT)
|
|
ls -l $(UTIL)
|
|
endif
|
|
ifneq "$(USE_DLB)" "Y"
|
|
cp $(DAT)/*.dat $(GAMEDIR)/
|
|
endif
|
|
@echo NetHack is up to date.
|
|
|
|
$(GAMEDIR)/symbols: $(DAT)/symbols
|
|
cp $< $@
|
|
|
|
$(GAMEDIR)/NetHack.txt: $(DOC)/nethack.txt
|
|
cp $< $@
|
|
|
|
$(GAMEDIR)/record:
|
|
touch $@
|
|
|
|
$(GAMEDIR)/%: $(DAT)/%
|
|
cp $< $@
|
|
|
|
$(GAMEDIR)/%: $(DOC)/%
|
|
cp $< $@
|
|
|
|
$(GAMEDIR)/%: $(MSWSYS)/%
|
|
cp $< $@
|
|
|
|
CLEAN_FILE += $(TO_INSTALL)
|
|
|
|
clean:
|
|
@-rm -f $(CLEAN_FILE)
|
|
@$(foreach dir, $(CLEAN_DIR), \
|
|
if [ -d $(dir) ] ; then rmdir -p --ignore $(dir) ; fi ; )
|
|
|
|
-include Makefile.mingw32.depend
|
|
-include .depend
|
|
# end of file
|