NetHack; the official development repository
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

273 lines
11 KiB

2 years ago
2 years ago
2 years ago
2 years ago
17 years ago
2 years ago
compile NetHack-3.7 without makedefs-generated .h files This evolves and hopefully eases the game-build requirements by removing game-compile dependencies on any header files generated by the makedefs utility, including: date.h dependency and its inclusion is removed and comparable functionality is produced at runtime via new file src/date.c. pm.h dependency and its inclusion is removed and comparable functionality is produced by moving the monster definitions from monst.c into new header file called monsters.h and altering them slightly. The former pm.h header file #define PM_ values are now replaced with appropriate emitted enum entries during the compiler preprocessing. onames.h dependency and its inclusion is removed and comparable functionality is produced by moving the object definitions from objects.c into new header file called objects.h and altering them slightly. The former onames.h header file #define values are now replaced with appropriate emitted enum entries during the compiler preprocessing. artilist.h has been slightly altered, and the former onames.h artifact-related header file #define ART_ values are now replaced with appropriate emitted enum entries during the compiler preprocessing. makedefs can still produce date.h (makedefs -v), pm.h (makedefs -p), and onames.h (makedefs -o) for reference purposes. They won't be used during the compiler. The other uses for makedefs remain. They are used to prepare external file content that the game utilizes, not prerequisite code for the compile: makedefs -d (database) makedefs -r (rumors) makedefs -h (oracles) makedefs -s (epitaphs, engravings, bogusmons) date.c Pull the code for date/time stamping from mdlib.c into date.c. Set date.o to be dependent on source files, header files, and .o files so that date.o is rebuilt from date.c when any of those changes, thus ensuring an accurate date/time stamp. It also includes git sha functionality formerly done by makedefs writing #define directives into include/date.h. For unix it passes the git info on the compile line for date.c (via sys/unix/hints/linux.2020, macOS.2020) nethack --dumpenums (optional, but on by default) Allow developer to obtain some internal enum values from NetHack without having to resort to an external utility such as makedefs. Uncomment #define NODUMPENUMS in config.h to disable this. The updates to sys/windows/Makefile.gcc have not been tested yet.
2 months ago
2 years ago
compile NetHack-3.7 without makedefs-generated .h files This evolves and hopefully eases the game-build requirements by removing game-compile dependencies on any header files generated by the makedefs utility, including: date.h dependency and its inclusion is removed and comparable functionality is produced at runtime via new file src/date.c. pm.h dependency and its inclusion is removed and comparable functionality is produced by moving the monster definitions from monst.c into new header file called monsters.h and altering them slightly. The former pm.h header file #define PM_ values are now replaced with appropriate emitted enum entries during the compiler preprocessing. onames.h dependency and its inclusion is removed and comparable functionality is produced by moving the object definitions from objects.c into new header file called objects.h and altering them slightly. The former onames.h header file #define values are now replaced with appropriate emitted enum entries during the compiler preprocessing. artilist.h has been slightly altered, and the former onames.h artifact-related header file #define ART_ values are now replaced with appropriate emitted enum entries during the compiler preprocessing. makedefs can still produce date.h (makedefs -v), pm.h (makedefs -p), and onames.h (makedefs -o) for reference purposes. They won't be used during the compiler. The other uses for makedefs remain. They are used to prepare external file content that the game utilizes, not prerequisite code for the compile: makedefs -d (database) makedefs -r (rumors) makedefs -h (oracles) makedefs -s (epitaphs, engravings, bogusmons) date.c Pull the code for date/time stamping from mdlib.c into date.c. Set date.o to be dependent on source files, header files, and .o files so that date.o is rebuilt from date.c when any of those changes, thus ensuring an accurate date/time stamp. It also includes git sha functionality formerly done by makedefs writing #define directives into include/date.h. For unix it passes the git info on the compile line for date.c (via sys/unix/hints/linux.2020, macOS.2020) nethack --dumpenums (optional, but on by default) Allow developer to obtain some internal enum values from NetHack without having to resort to an external utility such as makedefs. Uncomment #define NODUMPENUMS in config.h to disable this. The updates to sys/windows/Makefile.gcc have not been tested yet.
2 months ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. NetHack Porting Guidelines v 3.7 2019-12-05
  2. 1.0 Introduction
  3. This document goes through the steps required to port NetHack to a
  4. new machine. The basic steps in porting the program are:
  5. 1. Get the code onto your build machine. The parts of the current
  6. directory setup you definitely need include src (NetHack code
  7. shared by all systems), include (include files), util (code
  8. for utility programs), and dat (various data files). The
  9. documentation in doc is strongly recommended. You already
  10. have the files in the top directory since you're reading this
  11. one. :-)
  12. If you will be cross-compiling for your target platform on
  13. a different platform, you may want to read Cross-compiling
  14. in the Top folder as well.
  15. A full list of the distribution files and their associated
  16. OSes may be found in the top-level file "Files".
  17. If your machine uses an OS already supported, you need the sys
  18. subdirectory for that OS and possibly sys/share. Otherwise,
  19. get the closest match (say sys/msdos for single-tasking OSes
  20. and sys/unix for multi-user OSes, along with sys/share, if
  21. nothing else comes to mind). You may want others for
  22. comparison.
  23. If your machine uses a windowing system already supported,
  24. you need the win subdirectory for that system (or the
  25. appropriate sys subdirectory if the windowing system was
  26. previously considered restricted to one OS) and possibly
  27. win/share.
  28. 2. Modify the appropriate include files to customize NetHack to
  29. your system. You may need to add a new OS-specific "*conf.h"
  30. file (see unixconf.h, pcconf.h, tosconf.h, etc. as examples).
  31. 3. If your machine uses a new OS instead of a variant of existing
  32. OSes, add a new sys subdirectory. Add, if required, a OS-
  33. specific copy of "main.c", "tty.c" and "unix.c". Possibly
  34. add an OS-specific library (see "msdos.c" and "tos.c" as
  35. examples) to provide functions NetHack wants and your OS lacks.
  36. 4. If your machine uses a new windowing system, follow doc/window.doc
  37. carefully. Put files implementing these routines in a win or
  38. sys subdirectory as appropriate.
  39. 5. If your compilation environment isn't close to one already
  40. supported, try starting from the UNIX makefiles. Modify the
  41. top level makefile and the src makefile as required. Then run
  42. an initial compile. You are bound to get some errors. You
  43. should be able to fix them in a fairly simple fashion. If
  44. things seem to be getting too complex, take a step back, and
  45. possibly send us some mail. We might be able to help.
  46. 6. Mail all of your fixes to us in a contextual form so that we can
  47. easily integrate them into the code, or fork the NetHack
  48. repository on GitHub and issue a pull-request for your changes.
  49. One general rule of thumb exists. Always add code. Don't delete
  50. somebody else's code for yours -- it won't work on their machine if you do.
  51. Always add your OS specific code inside #ifdef / #else / #endif constructs
  52. so that it will be able to be folded back into the original code easily.
  53. 2.0 Include Files
  54. 2.1 config.h
  55. The file "config.h" is a master configuration file that determines
  56. the basic features of the game, as well as many of the security options.
  57. It is intended that end users configure the game by editing "config.h" and
  58. an appropriate "*conf.h" file, so any #defines for individual preferences
  59. should be added to those files. OS-specific #defines that are not intended
  60. to be changed should also go in "*conf.h"; try to find the most appropriate
  61. place for other #defines.
  62. The following sections may require modification:
  63. - Section 1: OS and window system selection.
  64. You may have to put a #define for your OS here.
  65. If your OS is yet another UNIX variant, put the
  66. #define in unixconf.h instead.
  67. An unfortunately large amount of stuff shares
  68. this section because the #definitions have to
  69. be seen before *conf.h is reached. Don't add
  70. to this unless necessary.
  71. - Section 2: Global parameters and filenames.
  72. These will have to be customized to your system.
  73. - Section 3: Type definitions and other compiler behavior.
  74. These will have to be matched to your compiler.
  75. 2.2 global.h
  76. This file defines things specific to NetHack that should not
  77. require modification by an end user. For a new port, you may have to add
  78. automatic inclusion of another auxiliary config file (*conf.h) which you
  79. wrote for your system.
  80. 2.3 extern.h
  81. If you create any new source modules or new functions in old modules,
  82. you must enter the names of the new external references (the functions defined
  83. there for external use) in this file.
  84. 2.4 system.h
  85. This file contains references for all hooks into the OS (via the
  86. standard "C" libraries). Depending on what your standard library looks like,
  87. you may have to put new entries into this file.
  88. 3.0 Source files
  89. The first step in getting the game up is to get the "makedefs"
  90. program running. This program is used to create configuration-specific
  91. files for the game.
  92. Once "makedefs" has been built, the rest of the game can be compiled.
  93. You may have to create an OS-specific module to handle things you want to
  94. use, like a mouse or a ram-disk.
  95. 3.1 Makefiles
  96. This distribution provides makefiles for several kinds of systems.
  97. There are joint makefiles for the various varieties of UNIX, makefiles for
  98. MSDOS, a makefile for NT, and so on. You may have to create a new
  99. makefile for your specific machine. You may even have to translate some
  100. makefiles into a form more congenial to your system. If possible, however,
  101. add to one of those provided.
  102. 3.2 termcap.c
  103. If your system wants to use tty windowing and it doesn't run off
  104. of a termcap or terminfo database, you may have to put the appropriate
  105. terminal control strings into termcap.c. This has already been done for
  106. MSDOS, and these mods can be used as an example. You can also consider
  107. using the termcap code from sys/share/tclib.c or sys/share/termcap.uu,
  108. especially if your system supports multiple kinds of terminals.
  109. 3.3 main.c
  110. You may need to create a new "main.c" module. If you do, call it
  111. [OS]main.c where the [OS] is replaced with the name of the OS you are porting
  112. to. This file contains the mainline module, which reads options from the
  113. command line (or wherever) and processes them. It also contains various
  114. functions associated with game startup.
  115. 3.4 tty.c
  116. You may need to create a new "tty.c" module. If you do, call it
  117. [OS]tty.c where the [OS] is replaced with the name of the OS you are porting
  118. to. This file contains the routines that configure the terminal/console
  119. for raw I/O, etc.
  120. 3.5 unix.c
  121. You may need to create a new "unix.c" module. If you do, call it
  122. [OS]unix.c where the [OS] is replaced with the name of the OS you are porting
  123. to. This file contains some OS dependencies concerning time and filename
  124. creation.
  125. An object of the NetHack development project is to get the game
  126. working on as many different types of hardware and under as many different
  127. operating systems as is practical. Any assistance will be appreciated.
  128. Cross-compiling may allow porting of NetHack to a machine where there may
  129. be challenges building on the platform directly, and may help maintain a
  130. working version of NetHack on that platform. See the file Cross-compiling
  131. for more information.
  132. 4.0 Build Process
  133. NetHack requires the following steps to be carried out:
  134. 4.1. makedefs
  135. Compile and link util/makedefs. Run makedefs repeatedly with different command
  136. line options to produce several output files that are required for:
  137. (a) creation of files, containing information required by,
  138. or about the game during its execution, that are stored in a
  139. portable, platform-independent way, that need to be inserted
  140. into the final game package.
  141. Required for complete packaging of the game, but not the C source
  142. game compile:
  143. util/makedefs -d
  144. util/makedefs -r
  145. util/makedefs -h
  146. util/makedefs -s
  147. For reference purposes, but no longer a required prerequisite for the
  148. game compile process:
  149. util/makedefs -v
  150. util/makedefs -o
  151. util/makedefs -p
  152. 4.2. Other utilities
  153. Compile and link other utilities such as uudecode, tile-generation
  154. utilities, and so forth. Those produce output files for use during the game and
  155. need to be included in the packaging of the game.
  156. 4.3. Lua
  157. Compile and link into a library, or obtain a prebuilt Lua library for
  158. your platform. Place the Lua source into lib/lua-5.4.3 (or other folder
  159. representing an appropriate Lua version); place the compiled Lua library into
  160. lib.
  161. 4.4 Compile NetHack sources
  162. Compile the source code of the game, including a suitable
  163. regular-expression choice from several options available in sys/share. Pick one
  164. that is supported by your OS or that you have obtained a 3rd party library for.
  165. 4.5 Compile optional window port components into a library
  166. If your platform requires 3rd party sources in order to support the
  167. window port options that you have chosen, such as curses sources for the curses
  168. window port, you may store the sources for that library in a subfolder under
  169. lib.
  170. 4.6. Link the game
  171. Link the game to the Lua library, and to any window port support
  172. libraries.
  173. 4.7 Package the game
  174. 5.0 Design Updates
  175. The following design updates were introduced in NetHack 3.7.
  176. 5.1 Quest text files
  177. The quest text files that were formerly converted from their source
  178. text by makedefs during the build process, have been replaced by Lua versions
  179. and are inserted into the game package for processing by the embedded Lua
  180. interpreter during game execution.
  181. 5.2 Level Compiler
  182. There is no longer a build-time level compiler. Instead, the level
  183. descriptions have been converted to Lua and are inserted into the game package
  184. for processing by the embeded Lua interpreter during game execution.
  185. 5.3 Dungeon Compiler
  186. There is no longer a build-time dungeon compiler. Instead, the dungeon
  187. description has been converted to Lua and is inserted into the game package for
  188. processing by the embeded Lua interpreter during game execution.
  189. 5.4 Run-time Options
  190. Some of the build and option information that was formerly produced at
  191. build-time by makedefs, and contained information about the game platform and
  192. options selected during the build of the game can now be produced at run-time
  193. by code within the game itself. That was done to facilitate cross-compiling of
  194. NetHack on one platform for game execution on another.
  195. # NetHack 3.7 Porting $NHDT-Date: 1596498144 2020/08/03 23:42:24 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.9 $
  196. # Copyright (c) 2005 by Michael Allison
  197. # NetHack may be freely redistributed. See license for details.