Commit Graph

115 Commits

Author SHA1 Message Date
PatR
62ba302851 Unix 'make clean' and 'make spotless'
Provide a reasonably straightforward way to leave lua alone when
changing git branches (which I precede with 'make spotless').
 make clean-keep-lib
and
 make spotless-keep-lib
are new alternate forms of top level 'make clean' and 'make spotless'
that won't touch lib/lua/.
2021-01-03 11:27:17 -08:00
nhmall
1d94e65e45 finish mapglyph() removal 2021-01-02 09:22:53 -05:00
Dean Luick
a4e7646f4c Remove src and unix VISION_TABLES
Remove all references to the unused vision tables in the main source
and unix build.  Leave makedefs able to generate the vision tables.
makdefs will be cleaned up in a different commit, once all ports
are clear of dependencies.
2020-12-29 20:38:37 -06:00
nhmall
8c42d306f7 purge trampoli.h 2020-12-13 10:27:49 -05:00
nhmall
6806c30a59 adopt some integration suggestions
sys/lib -> sys/libnh
sys/lib/libnethackmain.c -> sys/libnh/libnhmain.c
libnethack.a -> libnh.a
2020-10-11 13:33:51 -04:00
nhmall
de80dd2437 cross-compile fix-up 2020-10-09 08:52:46 -04:00
PatR
49ef50fc54 Makefile.src: avoid extra feedback while linking
Recently added cross-compile stuff had resulted in an extra line
of feedback when linking:  'true;'.  Suppress that.

Also, I think 'AWK=nawk' was needed for Solaris or maybe even
SunOS.  Switch 'make depend' to use ordinary awk by default since
most systems have Posix-compliant awk these days and OSX doesn't
have nawk.
2020-10-04 16:34:59 -07:00
Adam Powers
dc2d757399 libnethack pr385
roll parts of pr385 into source tree

This does not take the PR as is.

Unlike the PR, this streamlines and minimizes the integration somewhat:

- use hints/include mechanism instead of creating alternative
  Makefile.dat, Makefile.src, Makefile.top, Makefile.utl in sys/lib;
  those would have been a maintenance nightmare.

- don't have alternative mkmkfile.sh and setup.sh in sys/lib.

- sys/lib/libnethackmain.c differed from sys/unix/unixmain.c by
  very little, so just place a small bit of conditional code at the
  top of sys/unix/unixmain.c instead.

- changed the conditional code bits from __EMSCRIPTEN__ to
  CROSS_TO_WASM.

- You should be able to build the wasm result by:
    cd sys/unix ; sh setup.sh hints/linux.2020 ; cd ../..
    make fetch-lua    (<-one time)
    make WANT_LIBNH all

- You should be able to build LIBNBH by:
    cd sys/unix ; sh setup.sh hints/linux.2020 ; cd ../..
    make fetch-lua    (<-one time)
    make CROSS_TO_WASM=1 all

As it is currently coded, winshim.c requires C99.
2020-10-04 14:46:32 -04:00
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
PatR
10d80eb150 Qt's 3.6 status conditions
Replace the blank placeholder icon with individual placeholders
for Stone, Slime, Strngl, Deaf, Lev, Fly, and Ride.  They're just
40x40 tiles showing solid color (different for each) holding white
block letters spelling the condition.  For the first four of those,
the text runs from upper-left to lower-right, for Lev and Fly the
text runs from lower-left towards upper-right, and for Ride it's
horizontal.  Not particularly exciting but better than blank.  We
still need real artwork to make them be similar to the older
conditions.

Also moves the two petmarks and the pilemark from qt_xpms.h to
qt_map.cpp.  The marks and the assorted status icons are all
static arrays, and including that header in two source files
meant that they were all duplicated unless the compiler or linker
was smart enough to discard the unused ones.
2020-09-23 16:40:26 -07:00
PatR
276477e953 win/Qt/* dependencies update
A couple of qt_*.h headers now include other qt_*.h headers,
adding a bunch of new dependencies for the qt_*.cpp sources.
This is from 'make depend'.
2020-08-17 15:44:16 -07:00
nhmall
ac9ba38449 file header bump from "NetHack 3.6" to "NetHack 3.7" 2020-08-03 22:07:36 -04:00
PatR
7f1420558a lua on Unix tinkering
The base Makefile hasn't been using the '+=' construct, so take
out the one used for lua (post 3.6.6).

Only the 'Sysunix' target has been tested.
2020-07-30 06:25:43 -07:00
PatR
79275629fc Qt tinkering
After installing qt511-qtbase and qt511-qtmultimedia from macports
on my OSX 10.11 system (there is a qt513 but it requires OSX 10.12),
I can build the Qt interface with hints/macosx10.10-qt by overriding
QTDIR.  It doesn't actually need the extra CFLAGS, and without those
I wonder whether the multimedia package is needed either, but I've
left them in.  I have changed them to not be passed to the C sources
though, just the C++ ones.

I haven't tried combining with X11 or adding curses.
2020-07-28 19:31:14 -07:00
nhmall
9b58010880 turn off clang -Wshadow when processing some qt headers
removes recently added win/Qt/qt_undef.h and win/Qt/qt_redef.h
adds win/Qt/qt_pre.h win/Qt/qt_post.h
2020-07-18 08:31:51 -04:00
PatR
c9ea607e46 bring Unix 'make depend' up to date
and run it.

We need to do some about preserving the Makefiles as they were before
the obsolete code went away, because many of the bits that that
obsolete code depended on are now going away too.
2020-07-18 01:36:21 -07:00
nhmall
1443ceecc5 more patchlevel consolidation 2020-07-07 08:55:11 -04:00
nhmall
68638d7103 outdated move follow-up 2020-07-05 15:25:37 -04:00
nhmall
6c0d522b1a relocate some more outdated code 2020-07-05 09:27:59 -04:00
nhmall
c2fa3c36d8 dependency bit 2020-05-09 18:19:56 -04:00
nhmall
cdf280628c split symbols bits from drawing.c; new file src/symbols.c 2020-05-06 10:55:54 -04:00
PatR
6b2fcd7d73 X11 missing prototypes
Add some prototypes and add a new include to a couple of files that
use config.h instead of hack.h.  So sys/unix/Makefile.src has been
changed slightly.
2020-04-24 02:40:22 -07:00
nhmall
68fdc3bbcb February 2020 options.c overhaul
combine boolean and compound options into a single allopt[] array for
processing in options.c.

move the definitions of the options into new include/optlist.h file which
uses a set of macros to define them appropriately.

during compile of options.c each option described in include/optlist.h:
   1. automatically results in a function prototype for an optfn called
      optfn_xxxx (xxxx is the option name).
   2. automatically results in an opt_xxxx enum value for referencing
      its index throughout options.c (xxxx is the option name).
   3. is used to initialize an element of the allopt[] array at index
      opt_xxxx (xxxx is the option name) based on the settings in the
      NHOPTB, NHOPTC, NHOPTP macros. Those macros only live during the
      compilation of include/optlist.h.

each optfn_xxxx() function can be called with a req id of: do_init, do_set,
get_val or do_handler.

req do_init is called from options_init, and if initialization or memory
allocation or other initialization for that particular option is needed,
it can be done in response to the init req.

req do_set is called from parseoptions() for each option it encounters
and the optfn_xxxx() function is expected to react and set the option
based on the string values that parseoptions() passes to it.

req get_val expects each optfn_xxxx() function to write the current
option value into the buffer it is passed.

req do_handler is called during doset() operations in response to player
selections most likely from the 'O' option-setting menu, but only if the
option is identified as having do_handler support in the allopts[]
'has_handler' boolean flag. Not every optfn_xxxx() does.

function special_handling() is eliminated. It's code has been redistributed
to individual handler functions for the option or purpose that they serve.

moved reglyph_darkroom() function from options.c to display.c
2020-02-26 00:24:37 -05:00
PatR
70611afc48 splitting cmd.c, phase I
Preparation for moving enlightenment and conduct into new source
file insight.c.  Right now it's a stub that shouldn't break anything
whether included or omitted.  Once makefiles and project files have
been updated to compile and link it, the actual code will be moved.

unix/Makefile.src has been updated;
vms/Makefile.src and vmsbuild.com have been updated but not tested.
2020-02-01 08:59:19 -08:00
PatR
a219eed6eb 'make depend' for unix/Makefile.src
Add the new header file to HACKINCL which only matters to HSOURCES
which only matters for the 'tags' target.

'make depend' reordered some stuff that could have stayed as-is but
also found a missing dependency for nhlobj.{c,o}.
2020-01-29 12:16:24 -08:00
nhmall
e39ec5ce3e rename new header file to fnamesiz.h
Changes to be committed:
renamed:    include/filesize.h -> include/fnamesiz.h
2020-01-29 09:56:43 -05:00
nhmall
209fab138b recover fix
recover had deviated somewhat from NetHack in its
file expectations:
1) A couple of 3.7 fields needed to be accommodated.
2) hard-coded file size values had deviated.

The file sizes are now in an added header file named "filesize.h",
which is included at the bottom of config.h.

There will likely be another commit to write the filename size ahead
of the file name so that the precise number of characters can be read,
but since that will break existing saves, it can go in along with another
save-breaking commit.

This commit doesn't not alter savefiles written by nethack so does not
require an editlevel bump. It does alter the read-in expectation in
recover to match the game and this get recover working again.
2020-01-29 09:15:55 -05:00
nhmall
480c3eb6e0 include/lev.h is an empty header file so just get rid of it 2019-12-14 17:18:48 -05:00
nhmall
f4720edfbf include/qtext.h is an empty header so just get rid of it 2019-12-14 12:31:29 -05:00
Pasi Kallinen
7043e2134a Lua NetHack obj bindings 2019-12-11 20:10:59 +02:00
PatR
1c30c437c3 'make' => 'make all'
In sys/unix/Makefile.{top,src}, move the 'all' target first so that
it's the default if no target is specified.  Recent lua handling
unintentionally broke that for Makefile.top by putting 'lua_support'
target in front of 'all'.
2019-12-09 15:02:30 -08:00
PatR
2fe31eec46 more Qt rename
In order for 'make depend' to be able to handle both Qt4/5 and Qt3,
they need to operate on different object file names.

renames qt*.o to qt3*.o for Qt3
renames qt*.cpp to qt3*.cpp for Qt3 (not essential but seems worthwhile)
moves Qt3's headers from include/qt*.h to win/Qt3/qt3*.h
copies include/qt_xpms.h (before rename) or win/Qt3/qt3_xpms.h (after)
    to win/Qt/qt_xpms.h so that Qt4/5 no longer shares one header file
modifies win/Qt3/*.cpp and win/Qt3/qt3_win.h to reflect new header names
modifies Makefile.src to have Qt3 'moc' commands use new names
updates Makefile.src via re-running 'make depend'

'make depend' was only looking at include/*.h to find nested inclusion.
Now it will also look at win/*/*.h.  That found a bunch of missing
dependencies for the old gnome sources and a few for Qt3.

Building without Qt still works.  Building with it (any version) has
not been tested.
2019-12-09 11:15:49 -08:00
Patric Mueller
b9f3a33ec9 Update depend.awk for the new Qt location and lua headers 2019-12-08 14:41:54 +01:00
nhmall
bc8c1f8f56 remove field-level savefile code 2019-12-08 07:27:01 -05:00
PatR
9318bb816b 'make depend' update for sys/unix/Makefile.src
I deleted three lines
  ../include/../lib/lua-5.3.5/src/lua.h \
  ../include/../lib/lua-5.3.5/src/lualib.h \
  ../include/../lib/lua-5.3.5/src/lauxlib.h \
from $(CONFIG_H) but other than that, this is as-is with unmodified
'make depend'.  depend.awk will need to be taught about suppressing
those lua headers.
2019-12-07 17:06:07 -08:00
nhmall
f2dd00f86b more Qt follow-up 2019-12-07 15:27:57 -05:00
nhmall
17867059b5 Qt follow-up bit
name collision with 2 existing files
adjust Makefile.src to falter on the obsolete version, if at all, not the current
2019-12-07 15:18:44 -05:00
nhmall
3073a588eb Rename Qt4 directory to Qt 2019-12-07 17:07:50 +01:00
PatR
5226726c99 more lua notice from makedefs.c to mdlib.c
Add missing dependency of makedefs needing src/mdlib.c to unix
Makefile.src.
2019-11-29 17:19:37 -08:00
PatR
10359c7bee build fix for unix
Add src/mdlib.[co] to Makefile.src.  Dependencies for mklib.o have
been added manually rather than via 'make depend'.
2019-11-29 15:58:03 -08:00
PatR
865607a392 3.7 Unix Makefiles
Copy lib/lua-$(VERSION)/src/liblua.h to lib/lua/ rather than lib/.

Instead of copying any of the header files or telling the compiler
where to find the lua ones, generate include/nhlua.h on the fly and
restrict the knowledge of where they are to it (paths are relative
to include/).

|/* nhlua.h - generated by top Makefile */
|#include "../lib/lua-5.3.5/src/lua.h"
|LUA_API int   (lua_error) (lua_State *L) NORETURN;
|#include "../lib/lua-5.3.5/src/lualib.h"
|#include "../lib/lua-5.3.5/src/lauxlib.h"
|/*nhlua.h*/

This might need to be redone (or augmented by having CFLAGS add back
'-I path-to-lua') if some compiler can't find '#include "luaconf.h"'
issued by lua.h.
2019-11-26 19:27:00 -08:00
PatR
1b2b330e9f lua reorganization
Reduce the implied reliance of a specific version of lua.

Instead of copying liblua.a to src/, copy it to lib/.  Instead of
telling the compiler to look for headers in lib/lua-5.3.5/src/ as
well as in include/, copy the relevant ones to lib/ and tell the
compiler to look for them there.  'make spotless' in src/ will
remove both the object library and the header files from lib/ but
there really should be a new Makefile.lib to take care of that
directory.

Update Makefile.src to be able to build lua in case someone starts
with 'make all' there instead of in the top Makefile.  It doesn't
duplicate the option to fetch the lua source package though.

NHinternal/../genFiles.c has been updated to mention lib/liblua.a
and lib/lua*.h as 'generated at compile time' in Files and to skip
lib/lua-* entirely if it comes across that (so not operating on a
completely clean tree).  But it won't be accurate unless/until
other ports stage their lua files there instead of in src/ and
lib/lua-$(VERSION)/src/.

I haven't tried 'make depend' to see what it makes of the numerous
changes....
2019-11-25 12:20:42 -08:00
Pasi Kallinen
9cd9280276 Lua: remove dgn_comp, use lua instead 2019-11-06 18:45:10 +02:00
Pasi Kallinen
fd55d9118e Use lua for special level files
Game is playable, and should compile on linux and Windows.
Assumes you have a lua 5.3 library available.

Removes level compiler and associated files.
Replaces special level des-files with lua scripts.
Exposes some NetHack internals to lua:
 - des-table with commands to create special levels
 - nh-table with NetHack core commands
 - nhc-table with some constants
 - u-table with some player-specific data (u-struct)
 - selection userdata

Adds some rudimentary tests.

Adds new extended command #wizloadlua to run a specific script,
and #wizloaddes to run a specific level-creation script.

nhlib.lua is loaded for every lua script.

Download and untar lua:
  mkdir lib
  cd lib
  curl -R -O http://www.lua.org/ftp/lua-5.3.5.tar.gz
  tar zxf lua-5.3.5.tar.gz

Then make nethack normally.
2019-11-06 18:43:20 +02:00
nhmall
ba0f6ed47f updated files 2019-06-23 00:57:38 -04:00
nhmall
7054e06e42 NetHack minor release checklist items - savefiles
Make some progress on a couple of next minor release checklist
items, hopefully without introducing too many new bugs. This
is just the initial commit, and work continues.

Checklist items:

Savefiles compatible between Windows versions, whether 64-bit
or 32-bit in little-endian field format.

Selection of file formats:
 historical (structlevel saves),
 lendian (little-endian, fieldlevel saves),
 and just for proof-of-concept, ascii fieldlevel saves
 (the ascii is huge! 10x bigger than little-endian).

For the fieldlevel save, all complex data structures recursively
get broken down until until it is one of the simple types that
can't be broken down any further, and that gets when it gets
written to the output file.

New files needed for this build:

hand-coded:
include/sfprocs.h
src/sfbase.c      - really a dispatcher to one of the
                    output/input format routines.
src/sflendian.c   - little-endian output writer/reader.
src/sfascii.c     - ascii text output writer/reader.

auto-coded (generated):
include/sfproto.h
src/sfdata.c

This is just one approach. I'm sure there are countless others
and they have different pros and cons.

For producing the auto-coded files a utility called
universal-ctags, that is actively maintained and evolving,
was used to do all the heavy-lifting of parsing the
NetHack C sources to tabulate the data fields, and store
them in an intermediate file called util/nethack.tags
(not required for building NetHack if you already have a
generated include/sfproto.h and src/sfdata.c)

util/readtags (also not required for building NetHack
itself) will decipher the nethack.tags file and produce
the functions that can deal with the NetHack struct data
fields.

You can obtain the source for universal-ctags by cloning it
from here:
https://github.com/universal-ctags/ctags.git

The combination universal-ctags + util/readtags has been
tried and tested under both Windows and Linux, so it is
not tied to a particular platform.

Note: util/readtags will work only with universal-ctags
output, so other ctags are unlikely to work as-is.
Universal-ctags can be build from source very easily
under Linux, or under Windows using visual studio.
2019-06-23 00:11:46 -04:00
PatR
17a00b5032 unix/Makefile.src - wincurs.h
I don't know whether anyone uses 'make tags' any more, but it was
missing include/wincurs.h (and win/curses/*.h, but I'm ingoring those).
2019-02-22 14:55:29 -08:00
PatR
f067a3e9ff compiling isaac64.c
Revise isaac64.c so that it can be compiled unconditionally and
yield nothing if USE_ISAAC64 isn't defined.  Necessary for building
via vmsbuild.com.
2019-02-10 13:41:45 -08:00
Patric Mueller
f9433b2a87 integrate isaac64 into nethack
Also removed the float code from isaac64 as they are not used in
NetHack.
2019-01-28 10:02:08 +01:00
PatR
3cc4db7950 Unix Makefile
Separate the compiler flags used for compiling X11 code from the rest
of CFLAGS.  Affects hints/macosx10.8 and later.

Add an explicit output argument to the generated compile rules.
2018-12-30 17:39:56 -08:00