Skip to content


Subversion checkout URL

You can clone with
Download ZIP
100644 173 lines (128 sloc) 7.17 KB
a82d95c @sorear Original NH343 tarball contents
1 NetHack Porting Guidelines v 3.4 1999-11-29
4 1.0 Introduction
6 This document goes through the steps required to port NetHack to a
7 new machine. The basic steps in porting the program are:
9 1. Get the code onto your machine. The parts of the current
10 directory setup you definitely need include src (NetHack code
11 shared by all systems), include (include files), util (code
12 for utility programs), and dat (various data files). The
13 documentation in doc is strongly recommended. You already
14 have the files in the top directory since you're reading this
15 one. :-)
17 A full list of the distribution files and their associated
18 OSes may be found in the top-level file "Files".
20 If your machine uses an OS already supported, you need the sys
21 subdirectory for that OS and possibly sys/share. Otherwise,
22 get the closest match (say sys/msdos for single-tasking OSes
23 and sys/unix for multi-user OSes, along with sys/share, if
24 nothing else comes to mind). You may want others for
25 comparison.
27 If your machine uses a windowing system already supported,
28 you need the win subdirectory for that system (or the
29 appropriate sys subdirectory if the windowing system was
30 previously considered restricted to one OS).
32 2. Modify the appropriate include files to customize NetHack to
33 your system. You may need to add a new OS-specific "*conf.h"
34 file (see unixconf.h, pcconf.h, tosconf.h, etc. as examples).
36 3. If your machine uses a new OS instead of a variant of existing
37 OSes, add a new sys subdirectory. Add, if required, a OS-
38 specific copy of "main.c", "tty.c" and "unix.c". Possibly
39 add an OS-specific library (see "msdos.c" and "tos.c" as
40 examples) to provide functions NetHack wants and your OS lacks.
42 4. If your machine uses a new windowing system, follow doc/window.doc
43 carefully. Put files implementing these routines in a win or
44 sys subdirectory as appropriate.
46 5. If your compilation environment isn't close to one already
47 supported, try starting from the UNIX makefiles. Modify the
48 top level makefile and the src makefile as required. Then run
49 an initial compile. You are bound to get some errors. You
50 should be able to fix them in a fairly simple fashion. If
51 things seem to be getting too complex, take a step back, and
52 possibly send us some mail. We might be able to help.
54 6. Mail all of your fixes to us in a contextual form so that we can
55 easily integrate them into the code.
57 One general rule of thumb exists. Always add code. Don't delete
58 somebody else's code for yours -- it won't work on their machine if you do.
59 Always add your OS specific code inside #ifdef / #else / #endif constructs
60 so that it will be able to be folded back into the original code easily.
63 2.0 Include Files
65 2.1 config.h
67 The file "config.h" is a master configuration file that determines
68 the basic features of the game, as well as many of the security options.
69 It is intended that end users configure the game by editing "config.h" and
70 an appropriate "*conf.h" file, so any #defines for individual preferences
71 should be added to those files. OS-specific #defines that are not intended
72 to be changed should also go in "*conf.h"; try to find the most appropriate
73 place for other #defines.
75 The following sections may require modification:
77 - Section 1: OS and window system selection.
78 You may have to put a #define for your OS here.
79 If your OS is yet another UNIX variant, put the
80 #define in unixconf.h instead.
81 An unfortunately large amount of stuff shares
82 this section because the #definitions have to
83 be seen before *conf.h is reached. Don't add
84 to this unless necessary.
86 - Section 2: Global parameters and filenames.
87 These will have to be customized to your system.
89 - Section 3: Type definitions and other compiler behavior.
90 These will have to be matched to your compiler.
92 2.2 global.h
94 This file defines things specific to NetHack that should not
95 require modification by an end user. For a new port, you may have to add
96 automatic inclusion of another auxiliary config file (*conf.h) which you
97 wrote for your system.
99 2.3 extern.h
101 If you create any new source modules or new functions in old modules,
102 you must enter the names of the new external references (the functions defined
103 there for external use) in this file.
105 2.4 system.h
107 This file contains references for all hooks into the OS (via the
108 standard "C" libraries). Depending on what your standard library looks like,
109 you may have to put new entries into this file.
112 3.0 Source files
114 The first step in getting the game up is to get the "makedefs"
115 program running. This program is used to create configuration-specific
116 files for the game.
118 Once "makedefs" has been built, the rest of the game can be compiled.
119 You may have to create an OS-specific module to handle things you want to
120 use, like a mouse or a ram-disk.
122 The utility compilers "dgn_comp" and "lev_comp" may be a better
123 place to start. They also require "makedefs" but are independent of
124 "nethack". They are usually the last programs made, but since they are
125 much smaller they may be more tractable when first arguing with the include
126 files. These programs create binary data files that "nethack" uses to
127 guide its dungeon creation.
129 3.1 Makefiles
131 This distribution provides makefiles for several kinds of systems.
132 There are joint makefiles for the various varieties of UNIX, makefiles for
133 MSDOS, a makefile for NT, and so on. You may have to create a new
134 makefile for your specific machine. You may even have to translate some
135 makefiles into a form more congenial to your system. If possible, however,
136 add to one of those provided.
138 3.2 termcap.c
140 If your system wants to use tty windowing and it doesn't run off
141 of a termcap or terminfo database, you may have to put the appropriate
142 terminal control strings into termcap.c. This has already been done for
143 MSDOS, and these mods can be used as an example. You can also consider
144 using the termcap code from sys/share/tclib.c or sys/share/termcap.uu,
145 especially if your system supports multiple kinds of terminals.
147 3.3 main.c
149 You may need to create a new "main.c" module. If you do, call it
150 [OS]main.c where the [OS] is replaced with the name of the OS you are porting
151 to. This file contains the mainline module, which reads options from the
152 command line (or wherever) and processes them. It also contains various
153 functions associated with game startup.
155 3.4 tty.c
157 You may need to create a new "tty.c" module. If you do, call it
158 [OS]tty.c where the [OS] is replaced with the name of the OS you are porting
159 to. This file contains the routines that configure the terminal/console
160 for raw I/O, etc.
162 3.5 unix.c
164 You may need to create a new "unix.c" module. If you do, call it
165 [OS]unix.c where the [OS] is replaced with the name of the OS you are porting
166 to. This file contains some OS dependencies concerning time and filename
167 creation.
170 An object of the NetHack development project is to get the game
171 working on as many different types of hardware and under as many different
172 operating systems as is practical. Any assistance will be appreciated.
Something went wrong with that request. Please try again.