incremental improvements to cross-compiling support in NetHack 3.7
Some support of new code #defines to faciliate cross-compiling:
OPTIONS_AT_RUNTIME If this is defined, code to support obtaining
the compile time options and features is
included. If you define this, you'll also have
to compile sys/mdlib.c and link the resulting
object file into your game binary/executable.
CROSSCOMPILE Flags that this is a cross-compiled NetHack build,
where there are two stages:
1. makedefs and some other utilities are compiled
on the host platform and executed there to generate
some output files and header files needed by the
game.
2. the NetHack game files are compiled by a
cross-compiler to generate binary/executables for
a different platform than the one the build is
being run on. The executables produced for the
target platform may not be able to execute on the
build platform, except perhaps via a software
emulator.
The 2-stage process (1. host, 2.target) can be done
on the same platform to test the cross-compile
process. In that case, the host and target platforms
would be the same.
CROSSCOMPILE_HOST Separates/identifies code paths that should only be
be included in the compile on the host side, for
utilities that will be run on the host as part of
stage 1 to produce output files needed to build the
game. Examples are the code for makedefs, tile
conversion utilities, uudecode, dlb, etc.
CROSSCOMPILE_TARGET Separates/identifies code paths that should be
included on the build for the target platform
during stage 2, the cross-compiler stage. That
includes most of the pieces of the game itself
but the code is only flagged as such if it must
not execute on the host.
If you don't define any of those, things should build as before.
One follow-on change that is likely required is setting the new dependency
makedefs has on src/mdlib.c in Makefiles etc.
More information about the changes:
makedefs
- splinter off some of makedefs functionality into a separate file
called src/mdlib.c.
- src/mdlib.c, while included during the compile of makedefs.c
for producing the makedefs utility, can also be compiled
as a stand-alone object file for inclusion in the link step
of your NetHack game build. The src/mdlib.c code can then
deliver the same functionality that it provided to makedefs
right to your NetHack game code at run-time.
For example, do_runtime_info() will provide the caller with
the features and options that were built into the game.
Previously, that information was produced at build time on the
host and stored in a dat file. Under a cross-compile situation,
those values are highly suspect and might not even reflect the
correct options and setting for the cross-compiled target
platform's binary/executable. The compile of those values and
the functionality to obtain them needs to move to the target
cross-compiler stage of the build (stage 2).
- date information on the target-side binary is produced from
the cross-compiler preprocessor pre-defined macros __DATE__
and __TIME__, as they reflect the actual compile time of the
cross-compiled target and not host-side execution of a utility
to produce them. The cross-compiler itself, through those
pre-defined preprocessor macros, provides them to the target
platform binary/executable. They reflect the actual build
time of the target binary/executable (not values produced
at the time the makefiles utility was built and the
appropriate option selected to store them in a text file.)
- most Makefiles should not require adding the new file
src/mdlib.c because util/makedefs.c has a preprocessor
include "../src/mdlib.c" to draw in its contents. As previously
stated though, the Makefile dependency may be required:
makedefs.o: ../util/makedefs.c ../src/mdlib.c
^^^^^^^^^^^^^^^
This commit is contained in:
642
util/makedefs.c
642
util/makedefs.c
@@ -53,7 +53,7 @@
|
||||
#endif
|
||||
|
||||
#if defined(UNIX) && !defined(LINT) && !defined(GCC_WARN)
|
||||
static const char SCCS_Id[] UNUSED = "@(#)makedefs.c\t3.6\t2019/05/07";
|
||||
static const char SCCS_Id[] UNUSED = "@(#)makedefs.c\t3.7\t2019/11/19";
|
||||
#endif
|
||||
|
||||
/* names of files to be generated */
|
||||
@@ -156,7 +156,6 @@ void FDECL(do_makedefs, (char *));
|
||||
void NDECL(do_objs);
|
||||
void NDECL(do_data);
|
||||
void NDECL(do_dungeon);
|
||||
void NDECL(do_date);
|
||||
void NDECL(do_options);
|
||||
void NDECL(do_monstr);
|
||||
void NDECL(do_permonst);
|
||||
@@ -164,6 +163,7 @@ void NDECL(do_questtxt);
|
||||
void NDECL(do_rumors);
|
||||
void NDECL(do_oracles);
|
||||
void NDECL(do_vision);
|
||||
void NDECL(do_date);
|
||||
|
||||
extern void NDECL(monst_globals_init); /* monst.c */
|
||||
extern void NDECL(objects_globals_init); /* objects.c */
|
||||
@@ -172,22 +172,13 @@ static char *FDECL(name_file, (const char *, const char *));
|
||||
static void FDECL(delete_file, (const char *template, const char *));
|
||||
static FILE *FDECL(getfp, (const char *, const char *, const char *));
|
||||
static void FDECL(do_ext_makedefs, (int, char **));
|
||||
|
||||
static void NDECL(make_version);
|
||||
static char *FDECL(version_string, (char *, const char *));
|
||||
static char *FDECL(version_id_string, (char *, const char *));
|
||||
static char *FDECL(bannerc_string, (char *, const char *));
|
||||
static char *FDECL(xcrypt, (const char *));
|
||||
static unsigned long FDECL(read_rumors_file,
|
||||
(const char *, int *, long *, unsigned long));
|
||||
static boolean FDECL(get_gitinfo, (char *, char *));
|
||||
static void FDECL(do_rnd_access_file, (const char *));
|
||||
static boolean FDECL(d_filter, (char *));
|
||||
static boolean FDECL(h_filter, (char *));
|
||||
static void NDECL(build_savebones_compat_string);
|
||||
static void NDECL(windowing_sanity);
|
||||
static void FDECL(opt_out_words, (char *, int *));
|
||||
|
||||
static boolean FDECL(qt_comment, (char *));
|
||||
static boolean FDECL(qt_control, (char *));
|
||||
static int FDECL(get_hdr, (char *));
|
||||
@@ -211,8 +202,8 @@ static int FDECL(clear_path, (int, int, int, int));
|
||||
static char *FDECL(fgetline, (FILE*));
|
||||
static char *FDECL(tmpdup, (const char *));
|
||||
static char *FDECL(limit, (char *, int));
|
||||
static char *FDECL(eos, (char *));
|
||||
static int FDECL(case_insensitive_comp, (const char *, const char *));
|
||||
static void NDECL(windowing_sanity);
|
||||
static boolean FDECL(get_gitinfo, (char *, char *));
|
||||
|
||||
/* input, output, tmp */
|
||||
static FILE *ifp, *ofp, *tfp;
|
||||
@@ -228,6 +219,22 @@ static boolean use_enum =
|
||||
extern unsigned _stklen = STKSIZ;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Some of the routines in this source file were moved into .../src/mdlib
|
||||
* to facilitate the use of a cross-compiler generation of some of the
|
||||
* information for the target environment during the game compile portion
|
||||
* under the cross-compiler and/or at runtime in some cases.
|
||||
*/
|
||||
/* These actually reside in src/mdlib.c */
|
||||
static int FDECL(case_insensitive_comp, (const char *, const char *));
|
||||
static void NDECL(make_version);
|
||||
static char *FDECL(version_id_string, (char *, const char *));
|
||||
static char *FDECL(version_string, (char *, const char *));
|
||||
static char *FDECL(eos, (char *));
|
||||
/* REPRODUCIBLE_BUILD will change this to TRUE */
|
||||
static boolean date_via_env = FALSE;
|
||||
#include "../src/mdlib.c"
|
||||
|
||||
#ifdef MACsansMPWTOOL
|
||||
int
|
||||
main(void)
|
||||
@@ -295,7 +302,6 @@ char *argv[];
|
||||
/*NOTREACHED*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void
|
||||
@@ -1069,180 +1075,6 @@ rumors_failure:
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Use this to explicitly mask out features during version checks.
|
||||
*
|
||||
* ZEROCOMP, RLECOMP, and ZLIB_COMP describe compression features
|
||||
* that the port/plaform which wrote the savefile was capable of
|
||||
* dealing with. Don't reject a savefile just because the port
|
||||
* reading the savefile doesn't match on all/some of them.
|
||||
* The actual compression features used to produce the savefile are
|
||||
* recorded in the savefile_info structure immediately following the
|
||||
* version_info, and that is what needs to be checked against the
|
||||
* feature set of the port that is reading the savefile back in.
|
||||
* That check is done in src/restore.c now.
|
||||
*
|
||||
*/
|
||||
#define IGNORED_FEATURES \
|
||||
(0L | (1L << 19) /* SCORE_ON_BOTL */ \
|
||||
| (1L << 27) /* ZEROCOMP */ \
|
||||
| (1L << 28) /* RLECOMP */ \
|
||||
)
|
||||
|
||||
static void
|
||||
make_version()
|
||||
{
|
||||
register int i;
|
||||
|
||||
/*
|
||||
* integer version number
|
||||
*/
|
||||
version.incarnation = ((unsigned long) VERSION_MAJOR << 24)
|
||||
| ((unsigned long) VERSION_MINOR << 16)
|
||||
| ((unsigned long) PATCHLEVEL << 8)
|
||||
| ((unsigned long) EDITLEVEL);
|
||||
/*
|
||||
* encoded feature list
|
||||
* Note: if any of these magic numbers are changed or reassigned,
|
||||
* EDITLEVEL in patchlevel.h should be incremented at the same time.
|
||||
* The actual values have no special meaning, and the category
|
||||
* groupings are just for convenience.
|
||||
*/
|
||||
version.feature_set = (unsigned long) (0L
|
||||
/* levels and/or topology (0..4) */
|
||||
/* monsters (5..9) */
|
||||
#ifdef MAIL_STRUCTURES
|
||||
| (1L << 6)
|
||||
#endif
|
||||
/* objects (10..14) */
|
||||
/* flag bits and/or other global variables (15..26) */
|
||||
#ifdef TEXTCOLOR
|
||||
| (1L << 17)
|
||||
#endif
|
||||
#ifdef INSURANCE
|
||||
| (1L << 18)
|
||||
#endif
|
||||
#ifdef SCORE_ON_BOTL
|
||||
| (1L << 19)
|
||||
#endif
|
||||
/* data format (27..31)
|
||||
* External compression methods such as COMPRESS and ZLIB_COMP
|
||||
* do not affect the contents and are thus excluded from here */
|
||||
#ifdef ZEROCOMP
|
||||
| (1L << 27)
|
||||
#endif
|
||||
#ifdef RLECOMP
|
||||
| (1L << 28)
|
||||
#endif
|
||||
);
|
||||
/*
|
||||
* Value used for object & monster sanity check.
|
||||
* (NROFARTIFACTS<<24) | (NUM_OBJECTS<<12) | (NUMMONS<<0)
|
||||
*/
|
||||
for (i = 1; artifact_names[i]; i++)
|
||||
continue;
|
||||
version.entity_count = (unsigned long) (i - 1);
|
||||
for (i = 1; objects[i].oc_class != ILLOBJ_CLASS; i++)
|
||||
continue;
|
||||
version.entity_count = (version.entity_count << 12) | (unsigned long) i;
|
||||
for (i = 0; mons[i].mlet; i++)
|
||||
continue;
|
||||
version.entity_count = (version.entity_count << 12) | (unsigned long) i;
|
||||
/*
|
||||
* Value used for compiler (word size/field alignment/padding) check.
|
||||
*/
|
||||
version.struct_sizes1 =
|
||||
(((unsigned long) sizeof(struct context_info) << 24)
|
||||
| ((unsigned long) sizeof(struct obj) << 17)
|
||||
| ((unsigned long) sizeof(struct monst) << 10)
|
||||
| ((unsigned long) sizeof(struct you)));
|
||||
version.struct_sizes2 = (((unsigned long) sizeof(struct flag) << 10) |
|
||||
/* free bits in here */
|
||||
#ifdef SYSFLAGS
|
||||
((unsigned long) sizeof(struct sysflag)));
|
||||
#else
|
||||
((unsigned long) 0L));
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
/* REPRODUCIBLE_BUILD will change this to TRUE */
|
||||
static boolean date_via_env = FALSE;
|
||||
|
||||
static char *
|
||||
version_string(outbuf, delim)
|
||||
char *outbuf;
|
||||
const char *delim;
|
||||
{
|
||||
Sprintf(outbuf, "%d%s%d%s%d", VERSION_MAJOR, delim, VERSION_MINOR, delim,
|
||||
PATCHLEVEL);
|
||||
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED)
|
||||
Sprintf(eos(outbuf), "-%d", EDITLEVEL);
|
||||
#endif
|
||||
return outbuf;
|
||||
}
|
||||
|
||||
static char *
|
||||
version_id_string(outbuf, build_date)
|
||||
char *outbuf;
|
||||
const char *build_date;
|
||||
{
|
||||
char subbuf[64], versbuf[64];
|
||||
char betabuf[64];
|
||||
|
||||
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED)
|
||||
#if (NH_DEVEL_STATUS == NH_STATUS_BETA)
|
||||
Strcpy(betabuf, " Beta");
|
||||
#else
|
||||
Strcpy(betabuf, " Work-in-progress");
|
||||
#endif
|
||||
#else
|
||||
betabuf[0] = '\0';
|
||||
#endif
|
||||
|
||||
subbuf[0] = '\0';
|
||||
#ifdef PORT_SUB_ID
|
||||
subbuf[0] = ' ';
|
||||
Strcpy(&subbuf[1], PORT_SUB_ID);
|
||||
#endif
|
||||
|
||||
Sprintf(outbuf, "%s NetHack%s Version %s%s - last %s %s.", PORT_ID,
|
||||
subbuf, version_string(versbuf, "."), betabuf,
|
||||
date_via_env ? "revision" : "build", build_date);
|
||||
return outbuf;
|
||||
}
|
||||
|
||||
static char *
|
||||
bannerc_string(outbuf, build_date)
|
||||
char *outbuf;
|
||||
const char *build_date;
|
||||
{
|
||||
char subbuf[64], versbuf[64];
|
||||
|
||||
subbuf[0] = '\0';
|
||||
#ifdef PORT_SUB_ID
|
||||
subbuf[0] = ' ';
|
||||
Strcpy(&subbuf[1], PORT_SUB_ID);
|
||||
#endif
|
||||
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED)
|
||||
#if (NH_DEVEL_STATUS == NH_STATUS_BETA)
|
||||
Strcat(subbuf, " Beta");
|
||||
#else
|
||||
Strcat(subbuf, " Work-in-progress");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Sprintf(outbuf, " Version %s %s%s, %s %s.",
|
||||
version_string(versbuf, "."), PORT_ID, subbuf,
|
||||
date_via_env ? "revised" : "built", &build_date[4]);
|
||||
#if 0
|
||||
Sprintf(outbuf, "%s NetHack%s %s Copyright 1985-%s (built %s)",
|
||||
PORT_ID, subbuf, version_string(versbuf,"."), RELEASE_YEAR,
|
||||
&build_date[4]);
|
||||
#endif
|
||||
return outbuf;
|
||||
}
|
||||
|
||||
void
|
||||
do_date()
|
||||
{
|
||||
@@ -1254,6 +1086,13 @@ do_date()
|
||||
char githash[BUFSZ], gitbranch[BUFSZ];
|
||||
char *c, cbuf[60], buf[BUFSZ];
|
||||
const char *ul_sfx;
|
||||
#if defined(CROSSCOMPILE) && defined(CROSSCOMPILE_HOST)
|
||||
int steps = 0;
|
||||
const char ind[] = " ";
|
||||
const char *xpref = "HOST_";
|
||||
#else
|
||||
const char *xpref = (const char *) 0;
|
||||
#endif /* CROSSCOMPILE && CROSSCOMPILE_HOST */
|
||||
|
||||
/* before creating date.h, make sure that xxx_GRAPHICS and
|
||||
DEFAULT_WINDOW_SYS have been set up in a viable fashion */
|
||||
@@ -1345,7 +1184,7 @@ do_date()
|
||||
#else
|
||||
/* ordinary build: use current date+time */
|
||||
Strcpy(cbuf, ctime(&clocktim));
|
||||
#endif
|
||||
#endif /* REPRODUCIBLE_BUILD */
|
||||
|
||||
if ((c = index(cbuf, '\n')) != 0)
|
||||
*c = '\0'; /* strip off the '\n' */
|
||||
@@ -1354,6 +1193,20 @@ do_date()
|
||||
#else
|
||||
ul_sfx = "L";
|
||||
#endif
|
||||
|
||||
#if !defined(CROSSCOMPILE) || defined(CROSSCOMPILE_HOST)
|
||||
Fprintf(ofp, "\n#if !defined(CROSSCOMPILE) || defined(CROSSCOMPILE_HOST)\n");
|
||||
#if 0
|
||||
Fprintf(ofp, "/* On a CROSSCOMPILE build, NetHack is built in two steps:\n");
|
||||
Fprintf(ofp, " *%s%d. %s\n",
|
||||
ind, ++steps, "Build makedefs and its prerequisites, and");
|
||||
Fprintf(ofp, " *%s %s\n",
|
||||
ind, "execute makedefs to generate date.h, onames.h, and pm.h.");
|
||||
Fprintf(ofp, " *%s%d. %s\n *%s %s\n */\n\n", ind, ++steps,
|
||||
"Build the rest of NetHack using the cross-compiler",
|
||||
ind, "to generate the game code for target platform.");
|
||||
#endif
|
||||
#endif /* CROSSCOMPILE || CROSSCOMPILE_HOST */
|
||||
if (date_via_env)
|
||||
Fprintf(ofp, "#define SOURCE_DATE_EPOCH (%lu%s) /* via getenv() */\n",
|
||||
(unsigned long) clocktim, ul_sfx);
|
||||
@@ -1368,9 +1221,9 @@ do_date()
|
||||
ul_sfx);
|
||||
Fprintf(ofp, "#define VERSION_FEATURES 0x%08lx%s\n", version.feature_set,
|
||||
ul_sfx);
|
||||
#ifdef IGNORED_FEATURES
|
||||
#ifdef MD_IGNORED_FEATURES
|
||||
Fprintf(ofp, "#define IGNORED_FEATURES 0x%08lx%s\n",
|
||||
(unsigned long) IGNORED_FEATURES, ul_sfx);
|
||||
(unsigned long) MD_IGNORED_FEATURES, ul_sfx);
|
||||
#endif
|
||||
Fprintf(ofp, "#define VERSION_SANITY1 0x%08lx%s\n", version.entity_count,
|
||||
ul_sfx);
|
||||
@@ -1384,11 +1237,19 @@ do_date()
|
||||
version_id_string(buf, cbuf));
|
||||
Fprintf(ofp, "#define COPYRIGHT_BANNER_C \\\n \"%s\"\n",
|
||||
bannerc_string(buf, cbuf));
|
||||
Fprintf(ofp, "\n");
|
||||
if (get_gitinfo(githash, gitbranch)) {
|
||||
Fprintf(ofp, "#define NETHACK_GIT_SHA \"%s\"\n", githash);
|
||||
Fprintf(ofp, "#define NETHACK_GIT_BRANCH \"%s\"\n", gitbranch);
|
||||
}
|
||||
if (xpref && get_gitinfo(githash, gitbranch)) {
|
||||
Fprintf(ofp, "#else /* !CROSSCOMPILE || CROSSCOMPILE_HOST */\n");
|
||||
Fprintf(ofp, "#define NETHACK_%sGIT_SHA \"%s\"\n",
|
||||
xpref, githash);
|
||||
Fprintf(ofp, "#define NETHACK_%sGIT_BRANCH \"%s\"\n",
|
||||
xpref, gitbranch);
|
||||
}
|
||||
Fprintf(ofp, "#endif /* !CROSSCOMPILE || CROSSCOMPILE_HOST */\n");
|
||||
Fprintf(ofp, "\n");
|
||||
#ifdef AMIGA
|
||||
{
|
||||
struct tm *tm = localtime((time_t *) &clocktim);
|
||||
@@ -1462,281 +1323,28 @@ char *githash, *gitbranch;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
case_insensitive_comp(s1, s2)
|
||||
const char *s1;
|
||||
const char *s2;
|
||||
void
|
||||
do_options()
|
||||
{
|
||||
uchar u1, u2;
|
||||
const char *optline;
|
||||
int infocontext = 0;
|
||||
|
||||
for (;; s1++, s2++) {
|
||||
u1 = (uchar) *s1;
|
||||
if (isupper(u1))
|
||||
u1 = tolower(u1);
|
||||
u2 = (uchar) *s2;
|
||||
if (isupper(u2))
|
||||
u2 = tolower(u2);
|
||||
if (u1 == '\0' || u1 != u2)
|
||||
break;
|
||||
windowing_sanity();
|
||||
filename[0] = '\0';
|
||||
#ifdef FILE_PREFIX
|
||||
Strcat(filename, file_prefix);
|
||||
#endif
|
||||
Sprintf(eos(filename), DATA_TEMPLATE, OPTIONS_FILE);
|
||||
if (!(ofp = fopen(filename, WRTMODE))) {
|
||||
perror(filename);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
return u1 - u2;
|
||||
while ((optline = do_runtime_info(&infocontext)))
|
||||
Fprintf(ofp, "%s\n", optline);
|
||||
Fclose(ofp);
|
||||
return;
|
||||
}
|
||||
|
||||
static char save_bones_compat_buf[BUFSZ];
|
||||
|
||||
static void
|
||||
build_savebones_compat_string()
|
||||
{
|
||||
#ifdef VERSION_COMPATIBILITY
|
||||
unsigned long uver = VERSION_COMPATIBILITY;
|
||||
#endif
|
||||
Strcpy(save_bones_compat_buf,
|
||||
"save and bones files accepted from version");
|
||||
#ifdef VERSION_COMPATIBILITY
|
||||
Sprintf(eos(save_bones_compat_buf), "s %lu.%lu.%lu through %d.%d.%d",
|
||||
((uver & 0xFF000000L) >> 24), ((uver & 0x00FF0000L) >> 16),
|
||||
((uver & 0x0000FF00L) >> 8), VERSION_MAJOR, VERSION_MINOR,
|
||||
PATCHLEVEL);
|
||||
#else
|
||||
Sprintf(eos(save_bones_compat_buf), " %d.%d.%d only", VERSION_MAJOR,
|
||||
VERSION_MINOR, PATCHLEVEL);
|
||||
#endif
|
||||
}
|
||||
|
||||
static const char *build_opts[] = {
|
||||
#ifdef AMIGA_WBENCH
|
||||
"Amiga WorkBench support",
|
||||
#endif
|
||||
#ifdef ANSI_DEFAULT
|
||||
"ANSI default terminal",
|
||||
#endif
|
||||
#ifdef TEXTCOLOR
|
||||
"color",
|
||||
#endif
|
||||
#ifdef TTY_GRAPHICS
|
||||
#ifdef TTY_TILES_ESCCODES
|
||||
"console escape codes for tile hinting",
|
||||
#endif
|
||||
#endif
|
||||
#ifdef COM_COMPL
|
||||
"command line completion",
|
||||
#endif
|
||||
#ifdef LIFE
|
||||
"Conway's Game of Life",
|
||||
#endif
|
||||
#ifdef COMPRESS
|
||||
"data file compression",
|
||||
#endif
|
||||
#ifdef ZLIB_COMP
|
||||
"ZLIB data file compression",
|
||||
#endif
|
||||
#ifdef DLB
|
||||
#ifndef VERSION_IN_DLB_FILENAME
|
||||
"data librarian",
|
||||
#else
|
||||
"data librarian with a version-dependent name",
|
||||
#endif
|
||||
#endif
|
||||
#ifdef DUMPLOG
|
||||
"end-of-game dumplogs",
|
||||
#endif
|
||||
#ifdef HOLD_LOCKFILE_OPEN
|
||||
"exclusive lock on level 0 file",
|
||||
#endif
|
||||
#if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__))
|
||||
"external program as a message handler",
|
||||
#endif
|
||||
#ifdef MFLOPPY
|
||||
"floppy drive support",
|
||||
#endif
|
||||
#ifdef INSURANCE
|
||||
"insurance files for recovering from crashes",
|
||||
#endif
|
||||
#ifdef LOGFILE
|
||||
"log file",
|
||||
#endif
|
||||
#ifdef XLOGFILE
|
||||
"extended log file",
|
||||
#endif
|
||||
#ifdef PANICLOG
|
||||
"errors and warnings log file",
|
||||
#endif
|
||||
#ifdef MAIL_STRUCTURES
|
||||
"mail daemon",
|
||||
#endif
|
||||
#ifdef GNUDOS
|
||||
"MSDOS protected mode",
|
||||
#endif
|
||||
#ifdef NEWS
|
||||
"news file",
|
||||
#endif
|
||||
#ifdef OVERLAY
|
||||
#ifdef MOVERLAY
|
||||
"MOVE overlays",
|
||||
#else
|
||||
#ifdef VROOMM
|
||||
"VROOMM overlays",
|
||||
#else
|
||||
"overlays",
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
/* pattern matching method will be substituted by nethack at run time */
|
||||
"pattern matching via :PATMATCH:",
|
||||
#ifdef USE_ISAAC64
|
||||
"pseudo random numbers generated by ISAAC64",
|
||||
#ifdef DEV_RANDOM
|
||||
#ifdef NHSTDC
|
||||
/* include which specific one */
|
||||
"strong PRNG seed available from " DEV_RANDOM,
|
||||
#else
|
||||
"strong PRNG seed available from DEV_RANDOM",
|
||||
#endif
|
||||
#else
|
||||
#ifdef WIN32
|
||||
"strong PRNG seed available from CNG BCryptGenRandom()",
|
||||
#endif
|
||||
#endif /* DEV_RANDOM */
|
||||
#else /* ISAAC64 */
|
||||
#ifdef RANDOM
|
||||
"pseudo random numbers generated by random()",
|
||||
#else
|
||||
"pseudo random numbers generated by C rand()",
|
||||
#endif
|
||||
#endif
|
||||
#ifdef SELECTSAVED
|
||||
"restore saved games via menu",
|
||||
#endif
|
||||
#ifdef SCORE_ON_BOTL
|
||||
"score on status line",
|
||||
#endif
|
||||
#ifdef CLIPPING
|
||||
"screen clipping",
|
||||
#endif
|
||||
#ifdef NO_TERMS
|
||||
#ifdef MAC
|
||||
"screen control via mactty",
|
||||
#endif
|
||||
#ifdef SCREEN_BIOS
|
||||
"screen control via BIOS",
|
||||
#endif
|
||||
#ifdef SCREEN_DJGPPFAST
|
||||
"screen control via DJGPP fast",
|
||||
#endif
|
||||
#ifdef SCREEN_VGA
|
||||
"screen control via VGA graphics",
|
||||
#endif
|
||||
#ifdef WIN32CON
|
||||
"screen control via WIN32 console I/O",
|
||||
#endif
|
||||
#endif
|
||||
#ifdef SHELL
|
||||
"shell command",
|
||||
#endif
|
||||
"traditional status display",
|
||||
#ifdef STATUS_HILITES
|
||||
"status via windowport with highlighting",
|
||||
#else
|
||||
"status via windowport without highlighting",
|
||||
#endif
|
||||
#ifdef SUSPEND
|
||||
"suspend command",
|
||||
#endif
|
||||
#ifdef TTY_GRAPHICS
|
||||
#ifdef TERMINFO
|
||||
"terminal info library",
|
||||
#else
|
||||
#if defined(TERMLIB) || (!defined(MICRO) && !defined(WIN32))
|
||||
"terminal capability library",
|
||||
#endif
|
||||
#endif
|
||||
#endif /*TTY_GRAPHICS*/
|
||||
/*#ifdef X11_GRAPHICS*/
|
||||
#ifdef USE_XPM
|
||||
"tiles file in XPM format",
|
||||
#endif
|
||||
/*#endif*/
|
||||
/*#if (defined(QT_GRAPHICS) || defined(X11_GRAPHICS)*/
|
||||
#ifdef GRAPHIC_TOMBSTONE
|
||||
"graphical RIP screen",
|
||||
#endif
|
||||
/*#endif*/
|
||||
#ifdef TIMED_DELAY
|
||||
"timed wait for display effects",
|
||||
#endif
|
||||
#ifdef USER_SOUNDS
|
||||
"user sounds",
|
||||
#endif
|
||||
#ifdef PREFIXES_IN_USE
|
||||
"variable playground",
|
||||
#endif
|
||||
#ifdef VISION_TABLES
|
||||
"vision tables",
|
||||
#endif
|
||||
#ifdef ZEROCOMP
|
||||
"zero-compressed save files",
|
||||
#endif
|
||||
#ifdef RLECOMP
|
||||
"run-length compression of map in save files",
|
||||
#endif
|
||||
#ifdef SYSCF
|
||||
"system configuration at run-time",
|
||||
#endif
|
||||
save_bones_compat_buf,
|
||||
"and basic NetHack features"
|
||||
};
|
||||
|
||||
struct win_info {
|
||||
const char *id, /* DEFAULT_WINDOW_SYS string */
|
||||
*name; /* description, often same as id */
|
||||
};
|
||||
static struct win_info window_opts[] = {
|
||||
#ifdef TTY_GRAPHICS
|
||||
{ "tty",
|
||||
/* testing 'USE_TILES' here would bring confusion because it could
|
||||
apply to another interface such as X11, so check MSDOS explicitly
|
||||
instead; even checking TTY_TILES_ESCCODES would probably be
|
||||
confusing to most users (and it will already be listed separately
|
||||
in the compiled options section so users aware of it can find it) */
|
||||
#ifdef MSDOS
|
||||
"traditional text with optional 'tiles' graphics"
|
||||
#else
|
||||
/* assume that one or more of IBMgraphics, DECgraphics, or MACgraphics
|
||||
can be enabled; we can't tell from here whether that is accurate */
|
||||
"traditional text with optional line-drawing"
|
||||
#endif
|
||||
},
|
||||
#endif
|
||||
#ifdef CURSES_GRAPHICS
|
||||
{ "curses", "terminal-based graphics" },
|
||||
#endif
|
||||
#ifdef X11_GRAPHICS
|
||||
{ "X11", "X11" },
|
||||
#endif
|
||||
#ifdef QT_GRAPHICS /* too vague; there are multiple incompatible versions */
|
||||
{ "Qt", "Qt" },
|
||||
#endif
|
||||
#ifdef GNOME_GRAPHICS /* unmaintained/defunct */
|
||||
{ "Gnome", "Gnome" },
|
||||
#endif
|
||||
#ifdef MAC /* defunct OS 9 interface */
|
||||
{ "mac", "Mac" },
|
||||
#endif
|
||||
#ifdef AMIGA_INTUITION /* unmaintained/defunct */
|
||||
{ "amii", "Amiga Intuition" },
|
||||
#endif
|
||||
#ifdef GEM_GRAPHICS /* defunct Atari interface */
|
||||
{ "Gem", "Gem" },
|
||||
#endif
|
||||
#ifdef MSWIN_GRAPHICS /* win32 */
|
||||
{ "mswin", "mswin" },
|
||||
#endif
|
||||
#ifdef BEOS_GRAPHICS /* unmaintained/defunct */
|
||||
{ "BeOS", "BeOS InterfaceKit" },
|
||||
#endif
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
static void
|
||||
windowing_sanity()
|
||||
{
|
||||
@@ -1776,107 +1384,6 @@ windowing_sanity()
|
||||
#endif /*DEFAULT_WINDOW_SYS*/
|
||||
}
|
||||
|
||||
static const char opt_indent[] = " ";
|
||||
|
||||
static void
|
||||
opt_out_words(str, length_p)
|
||||
char *str; /* input, but modified during processing */
|
||||
int *length_p; /* in/out */
|
||||
{
|
||||
char *word;
|
||||
|
||||
while (*str) {
|
||||
word = index(str, ' ');
|
||||
#if 0
|
||||
/* treat " (" as unbreakable space */
|
||||
if (word && *(word + 1) == '(')
|
||||
word = index(word + 1, ' ');
|
||||
#endif
|
||||
if (word)
|
||||
*word = '\0';
|
||||
if (*length_p + (int) strlen(str) > COLNO - 5)
|
||||
Fprintf(ofp, "\n%s", opt_indent),
|
||||
*length_p = (int) strlen(opt_indent);
|
||||
else
|
||||
Fprintf(ofp, " "), (*length_p)++;
|
||||
Fprintf(ofp, "%s", str), *length_p += (int) strlen(str);
|
||||
str += strlen(str) + (word ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
do_options()
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
int i, length, winsyscnt;
|
||||
|
||||
windowing_sanity();
|
||||
|
||||
filename[0] = '\0';
|
||||
#ifdef FILE_PREFIX
|
||||
Strcat(filename, file_prefix);
|
||||
#endif
|
||||
Sprintf(eos(filename), DATA_TEMPLATE, OPTIONS_FILE);
|
||||
if (!(ofp = fopen(filename, WRTMODE))) {
|
||||
perror(filename);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
build_savebones_compat_string();
|
||||
Fprintf(ofp, "\n%sNetHack version %d.%d.%d%s\n",
|
||||
opt_indent,
|
||||
VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL,
|
||||
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED)
|
||||
#if (NH_DEVEL_STATUS == NH_STATUS_BETA)
|
||||
" [beta]"
|
||||
#else
|
||||
" [work-in-progress]"
|
||||
#endif
|
||||
#else
|
||||
""
|
||||
#endif
|
||||
);
|
||||
|
||||
Fprintf(ofp, "\nOptions compiled into this edition:\n");
|
||||
length = COLNO + 1; /* force 1st item onto new line */
|
||||
for (i = 0; i < SIZE(build_opts); i++) {
|
||||
opt_out_words(strcat(strcpy(buf, build_opts[i]),
|
||||
(i < SIZE(build_opts) - 1) ? "," : "."),
|
||||
&length);
|
||||
}
|
||||
Fprintf(ofp, "\n"); /* terminate last line of words */
|
||||
|
||||
winsyscnt = SIZE(window_opts) - 1;
|
||||
Fprintf(ofp, "\nSupported windowing system%s:\n",
|
||||
(winsyscnt > 1) ? "s" : "");
|
||||
length = COLNO + 1; /* force 1st item onto new line */
|
||||
for (i = 0; i < winsyscnt; i++) {
|
||||
Sprintf(buf, "\"%s\"", window_opts[i].id);
|
||||
if (strcmp(window_opts[i].name, window_opts[i].id))
|
||||
Sprintf(eos(buf), " (%s)", window_opts[i].name);
|
||||
/*
|
||||
* 1 : foo.
|
||||
* 2 : foo and bar (note no period; comes from 'with default' below)
|
||||
* 3+: for, bar, and quux
|
||||
*/
|
||||
opt_out_words(strcat(buf, (winsyscnt == 1) ? "." /* no 'default' */
|
||||
: (winsyscnt == 2 && i == 0) ? " and"
|
||||
: (i == winsyscnt - 2) ? ", and"
|
||||
: ","),
|
||||
&length);
|
||||
}
|
||||
if (winsyscnt > 1) {
|
||||
Sprintf(buf, "with a default of \"%s\".", DEFAULT_WINDOW_SYS);
|
||||
opt_out_words(buf, &length);
|
||||
}
|
||||
Fprintf(ofp, "\n"); /* terminate last line of words */
|
||||
|
||||
/* end with a blank line */
|
||||
Fprintf(ofp, "\n");
|
||||
Fclose(ofp);
|
||||
return;
|
||||
}
|
||||
|
||||
/* routine to decide whether to discard something from data.base */
|
||||
static boolean
|
||||
d_filter(line)
|
||||
@@ -2904,15 +2411,6 @@ const char *str;
|
||||
return buf;
|
||||
}
|
||||
|
||||
static char *
|
||||
eos(str)
|
||||
char *str;
|
||||
{
|
||||
while (*str)
|
||||
str++;
|
||||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
* macro used to control vision algorithms:
|
||||
* VISION_TABLES => generate tables
|
||||
|
||||
@@ -68,6 +68,8 @@ struct needs_array_handling {
|
||||
#define SFI_PROTO c_sfiproto
|
||||
#define SFDATA c_sfdata
|
||||
#define SFPROTO c_sfproto
|
||||
#define SFPROTO_NAME "../include/sfproto.h"
|
||||
#define SFDATA_NAME "../src/sfdata.c"
|
||||
|
||||
static char *fgetline(FILE*);
|
||||
static void quit(void);
|
||||
@@ -287,6 +289,8 @@ char *argv[];
|
||||
showthem();
|
||||
#endif
|
||||
generate_c_files();
|
||||
printf("Created %s\n", SFDATA_NAME);
|
||||
printf("Created %s\n", SFPROTO_NAME);
|
||||
exit(EXIT_SUCCESS);
|
||||
/*NOTREACHED*/
|
||||
return 0;
|
||||
@@ -783,19 +787,50 @@ struct tagstruct *t;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* TIME_type: type of the argument to time(); we actually use &(time_t) */
|
||||
#if defined(BSD) && !defined(POSIX_TYPES)
|
||||
#define TIME_type long *
|
||||
#else
|
||||
#define TIME_type time_t *
|
||||
#endif
|
||||
/* LOCALTIME_type: type of the argument to localtime() */
|
||||
#if (defined(ULTRIX) && !(defined(ULTRIX_PROTO) || defined(NHSTDC))) \
|
||||
|| (defined(BSD) && !defined(POSIX_TYPES))
|
||||
#define LOCALTIME_type long *
|
||||
#else
|
||||
#define LOCALTIME_type time_t *
|
||||
#endif
|
||||
|
||||
char *preamble[] = {
|
||||
"/* Copyright (c) NetHack Development Team 2018. */\n",
|
||||
const char *preamble[] = {
|
||||
"/* Copyright (c) NetHack Development Team %d. */\n",
|
||||
"/* NetHack may be freely redistributed. See license for details. */\n\n",
|
||||
"/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE! */\n\n",
|
||||
"#include \"hack.h\"\n",
|
||||
"#include \"artifact.h\"\n",
|
||||
"#include \"func_tab.h\"\n",
|
||||
"#include \"lev.h\"\n",
|
||||
"#include \"integer.h\"\n",
|
||||
"#include \"wintype.h\"\n",
|
||||
"#include \"integer.h\"\n",
|
||||
"#include \"wintype.h\"\n",
|
||||
(char *)0
|
||||
};
|
||||
char crbuf[BUFSZ];
|
||||
|
||||
static const char *get_preamble(n)
|
||||
int n;
|
||||
{
|
||||
const char *r = preamble[n];
|
||||
|
||||
if (!n) {
|
||||
time_t datetime = 0;
|
||||
struct tm *lt;
|
||||
|
||||
(void) time((TIME_type) &datetime);
|
||||
lt = localtime((LOCALTIME_type) &datetime);
|
||||
Sprintf(crbuf, preamble[0], (1900 + lt->tm_year));
|
||||
r = crbuf;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
static void output_types(fp1)
|
||||
FILE *fp1;
|
||||
@@ -862,10 +897,10 @@ static void generate_c_files()
|
||||
int okeydokey, x, a;
|
||||
boolean did_i;
|
||||
|
||||
SFDATA = fopen("../src/sfdata.c", "w");
|
||||
SFDATA = fopen(SFDATA_NAME, "w");
|
||||
if (!SFDATA) return;
|
||||
|
||||
SFPROTO = fopen("../include/sfproto.h", "w");
|
||||
SFPROTO = fopen(SFPROTO_NAME, "w");
|
||||
if (!SFPROTO) return;
|
||||
|
||||
SFO_DATA = fopen("../src/sfo_data.tmp", "w");
|
||||
@@ -892,10 +927,10 @@ static void generate_c_files()
|
||||
*c = '\0'; /* strip off the '\n' */
|
||||
|
||||
/* begin sfproto.h */
|
||||
Fprintf(SFPROTO,"/* NetHack %d.%d sfproto.h\t%s */\n",
|
||||
VERSION_MAJOR, VERSION_MINOR, cbuf);
|
||||
Fprintf(SFPROTO,"/* NetHack %d.%d sfproto.h */\n",
|
||||
VERSION_MAJOR, VERSION_MINOR);
|
||||
for (j = 0; j < 3; ++j)
|
||||
Fprintf(SFPROTO, "%s", preamble[j]);
|
||||
Fprintf(SFPROTO, "%s", get_preamble(j));
|
||||
Fprintf(SFPROTO, "#ifndef SFPROTO_H\n#define SFPROTO_H\n\n");
|
||||
Fprintf(SFPROTO, "#include \"hack.h\"\n#include \"integer.h\"\n#include \"wintype.h\"\n\n"
|
||||
"#define E extern\n\n");
|
||||
@@ -950,13 +985,11 @@ static void generate_c_files()
|
||||
Fprintf(SFI_PROTO, "/* generated input functions */\n");
|
||||
|
||||
/* begin sfdata.c */
|
||||
Fprintf(SFDATA,"/* NetHack %d.%d sfdata.c\t$Date$ $Revision$ */\n",
|
||||
Fprintf(SFDATA,"/* NetHack %d.%d sfdata.c */\n",
|
||||
VERSION_MAJOR, VERSION_MINOR);
|
||||
for (j = 0; preamble[j]; ++j)
|
||||
Fprintf(SFDATA, "%s", preamble[j]);
|
||||
Fprintf(SFDATA, "%s", get_preamble(j));
|
||||
Fprintf(SFDATA, "#include \"sfproto.h\"\n\n");
|
||||
Fprintf(SFDATA, "#define BUILD_DATE \"%s\"\n", cbuf);
|
||||
Fprintf(SFDATA, "#define BUILD_TIME (%ldL)\n\n", (long) clocktim);
|
||||
Fprintf(SFDATA, "#define NHTYPE_SIMPLE 1\n");
|
||||
Fprintf(SFDATA, "#define NHTYPE_COMPLEX 2\n");
|
||||
Fprintf(SFDATA, "struct nhdatatypes_t {\n");
|
||||
|
||||
Reference in New Issue
Block a user