From: nhmall Date: Sat, 23 Nov 2019 03:35:48 +0000 (-0500) Subject: incremental improvements to cross-compiling support in NetHack 3.7 X-Git-Tag: NetHack-3.7.0_WIP~254 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1e0c03b3f6f2e7b67df7098d13de95f5ba5fcc78;p=nethack 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 ^^^^^^^^^^^^^^^ --- diff --git a/include/artilist.h b/include/artilist.h index 4a8b40554..d7b8f250c 100644 --- a/include/artilist.h +++ b/include/artilist.h @@ -3,7 +3,7 @@ /*-Copyright (c) Robert Patrick Rankin, 2017. */ /* NetHack may be freely redistributed. See license for details. */ -#ifdef MAKEDEFS_C +#if defined(MAKEDEFS_C) || defined (MDLIB_C) /* in makedefs.c, all we care about is the list of names */ #define A(nam, typ, s1, s2, mt, atk, dfn, cry, inv, al, cl, rac, cost, clr) nam @@ -32,7 +32,7 @@ static const char *artifact_names[] = { /* clang-format on */ static NEARDATA struct artifact artilist[] = { -#endif /* MAKEDEFS_C */ +#endif /* MAKEDEFS_C || MDLIB_C */ /* Artifact cost rationale: * 1. The more useful the artifact, the better its cost. @@ -256,7 +256,7 @@ A("The Palantir of Westernesse", CRYSTAL_BALL, #undef A -#ifndef MAKEDEFS_C +#if !defined(MAKEDEFS_C) && !defined(MDLIB_C) #undef NO_ATTK #undef NO_DFNS #undef DFNS diff --git a/include/extern.h b/include/extern.h index aba2bdcfd..08ca0b29a 100644 --- a/include/extern.h +++ b/include/extern.h @@ -16,7 +16,7 @@ E char *FDECL(fmt_ptr, (const genericptr)); /* This next pre-processor directive covers almost the entire file, * interrupted only occasionally to pick up specific functions as needed. */ -#if !defined(MAKEDEFS_C) && !defined(LEV_LEX_C) +#if !defined(MAKEDEFS_C) && !defined(MDLIB_C) && !defined(LEV_LEX_C) /* ### allmain.c ### */ @@ -583,10 +583,10 @@ E boolean FDECL(hurtle_jump, (genericptr_t, int, int)); E boolean FDECL(hurtle_step, (genericptr_t, int, int)); /* ### drawing.c ### */ -#endif /* !MAKEDEFS_C && !LEV_LEX_C */ +#endif /* !MAKEDEFS_C && !MDLIB_C && !LEV_LEX_C */ E int FDECL(def_char_to_objclass, (CHAR_P)); E int FDECL(def_char_to_monclass, (CHAR_P)); -#if !defined(MAKEDEFS_C) && !defined(LEV_LEX_C) +#if !defined(MAKEDEFS_C) && !defined(MDLIB_C) && !defined(LEV_LEX_C) E void FDECL(switch_symbols, (int)); E void FDECL(assign_graphics, (int)); E void NDECL(init_symbols); @@ -713,9 +713,9 @@ E int NDECL(done2); E void FDECL(done_intr, (int)); #endif E void FDECL(done_in_by, (struct monst *, int)); -#endif /* !MAKEDEFS_C && !LEV_LEX_C */ +#endif /* !MAKEDEFS_C && MDLIB_C && !LEV_LEX_C */ E void VDECL(panic, (const char *, ...)) PRINTF_F(1, 2) NORETURN; -#if !defined(MAKEDEFS_C) && !defined(LEV_LEX_C) +#if !defined(MAKEDEFS_C) && !defined(MDLIB_C) && !defined(LEV_LEX_C) E void FDECL(done, (int)); E void FDECL(container_contents, (struct obj *, BOOLEAN_P, BOOLEAN_P, BOOLEAN_P)); @@ -1663,10 +1663,14 @@ E char *NDECL(lan_username); #endif /* ### nhlsel.c ### */ +#if !defined(CROSSCOMPILE) || defined(CROSSCOMPILE_TARGET) E struct selectionvar *FDECL(l_selection_check, (lua_State *, int)); E int FDECL(l_selection_register, (lua_State *)); +#endif /* ### nhlua.c ### */ + +#if !defined(CROSSCOMPILE) || defined(CROSSCOMPILE_TARGET) E lua_State * NDECL(nhl_init); E boolean FDECL(nhl_loadlua, (lua_State *, const char *)); E boolean FDECL(load_lua, (const char *)); @@ -1685,14 +1689,21 @@ E int FDECL(get_table_boolean_opt, (lua_State *, const char *, int)); E int FDECL(get_table_option, (lua_State *, const char *, const char *, const char *const *)); E int FDECL(str_lines_max_width, (const char *)); E char *FDECL(stripdigits, (char *)); +#endif /* !CROSSCOMPILE || CROSSCOMPILE_TARGET */ /* ### nhregex.c ### */ + E struct nhregex *NDECL(regex_init); E boolean FDECL(regex_compile, (const char *, struct nhregex *)); E const char *FDECL(regex_error_desc, (struct nhregex *)); E boolean FDECL(regex_match, (const char *, struct nhregex *)); E void FDECL(regex_free, (struct nhregex *)); +/* ### mdlib.c ### */ + +E void NDECL(runtime_info_init); +E const char *FDECL(do_runtime_info, (int *)); + /* ### nttty.c ### */ #ifdef WIN32 @@ -2405,7 +2416,7 @@ E void NDECL(sysopt_release); E void FDECL(sysopt_seduce_set, (int)); /* ### sp_lev.c ### */ - +#if !defined(CROSSCOMPILE) || defined(CROSSCOMPILE_TARGET) E boolean FDECL(check_room, (xchar *, xchar *, xchar *, xchar *, BOOLEAN_P)); E boolean FDECL(create_room, (XCHAR_P, XCHAR_P, XCHAR_P, XCHAR_P, XCHAR_P, XCHAR_P, XCHAR_P, XCHAR_P)); @@ -2434,6 +2445,7 @@ E void FDECL(set_floodfillchk_match_under, (XCHAR_P)); E void FDECL(selection_do_ellipse, (struct selectionvar *, int, int, int, int, int)); E void NDECL(update_croom); E void FDECL(l_register_des, (lua_State *)); +#endif /* !CROSSCOMPILE || CROSSCOMPILE_TARGET */ /* ### spell.c ### */ @@ -3069,7 +3081,7 @@ E int FDECL(destroy_mitem, (struct monst *, int, int)); E int FDECL(resist, (struct monst *, CHAR_P, int, int)); E void NDECL(makewish); -#endif /* !MAKEDEFS_C && !LEV_LEX_C */ +#endif /* !MAKEDEFS_C && !MDLIB_C && !LEV_LEX_C */ #undef E diff --git a/include/global.h b/include/global.h index e98cdf84d..7bc33dcd8 100644 --- a/include/global.h +++ b/include/global.h @@ -124,6 +124,41 @@ typedef uchar nhsym; #define LARGEST_INT 32767 #include "coord.h" + +#if defined(CROSSCOMPILE) +struct cross_target_s { + const char *build_date; + const char *copyright_banner_c; + const char *git_sha; + const char *git_branch; + const char *version_string; + const char *version_id; + unsigned long version_number; + unsigned long version_features; + unsigned long ignored_features; + unsigned long version_sanity1; + unsigned long version_sanity2; + unsigned long version_sanity3; + unsigned long build_time; +}; +extern struct cross_target_s cross_target; +#if defined(CROSSCOMPILE_TARGET) && !defined(MAKEDEFS_C) +#define BUILD_DATE cross_target.build_date /* "Wed Apr 1 00:00:01 2020" */ +#define COPYRIGHT_BANNER_C cross_target.copyright_banner_c +#define NETHACK_GIT_SHA cross_target.git_sha +#define NETHACK_GIT_BRANCH cross_target.git_branch +#define VERSION_ID cross_target.version_id +#define IGNORED_FEATURES cross_target.ignored_features +#define VERSION_FEATURES cross_target.version_features +#define VERSION_NUMBER cross_target.version_number +#define VERSION_SANITY1 cross_target.version_sanity1 +#define VERSION_SANITY2 cross_target.version_sanity2 +#define VERSION_SANITY3 cross_target.version_sanity3 +#define VERSION_STRING cross_target.version_string +#define BUILD_TIME cross_target.build_time /* (1574157640UL) */ +#endif /* CROSSCOMPILE_TARGET && !MAKEDEFS_C */ +#endif /* CROSSCOMPILE */ + /* * Automatic inclusions for the subsidiary files. * Please don't change the order. It does matter. diff --git a/include/qtext.h b/include/qtext.h index 752938423..29993d29a 100644 --- a/include/qtext.h +++ b/include/qtext.h @@ -15,7 +15,7 @@ struct qtmsg { long offset, size, summary_size; }; -#ifdef MAKEDEFS_C /***** MAKEDEFS *****/ +#if defined(MAKEDEFS_C) || defined(MDLIB_C) /***** MAKEDEFS *****/ #define N_MSG 100 /* arbitrary */ @@ -47,7 +47,7 @@ struct qthdr { "Too many messages in class (line %d)\nAdjust N_MSG in qtext.h and " \ "recompile.\n" -#else /***** !MAKEDEFS *****/ +#else /***** !MAKEDEFS && !MDLIB_C *****/ struct qtlists { struct qtmsg *common, @@ -113,6 +113,6 @@ struct qtlists { #define QTN_DEMONIC 20 #define QT_BANISHED 60 -#endif /***** !MAKEDEFS *****/ +#endif /***** !MAKEDEFS && !MDLIB_C *****/ #endif /* QTEXT_H */ diff --git a/include/sfproto.h b/include/sfproto.h index 7655f328a..bb30ac4f2 100644 --- a/include/sfproto.h +++ b/include/sfproto.h @@ -1,5 +1,5 @@ -/* NetHack 3.7 sfproto.h Tue Jun 25 09:57:33 2019 */ -/* Copyright (c) NetHack Development Team 2018. */ +/* NetHack 3.7 sfproto.h */ +/* Copyright (c) NetHack Development Team 2019. */ /* NetHack may be freely redistributed. See license for details. */ /* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE! */ diff --git a/include/system.h b/include/system.h index fe29cbf4c..265f46f98 100644 --- a/include/system.h +++ b/include/system.h @@ -527,7 +527,7 @@ E char *FDECL(tgetstr, (const char *, char **)); E char *FDECL(tgoto, (const char *, int, int)); #endif -#if defined(ALLOC_C) || defined(MAKEDEFS_C) +#if defined(ALLOC_C) || defined(MAKEDEFS_C) || defined(MDLIB_C) E genericptr_t FDECL(malloc, (size_t)); E genericptr_t FDECL(realloc, (genericptr_t, size_t)); #endif @@ -569,6 +569,7 @@ E int FDECL(atoi, (const char *)); #endif /* !__cplusplus && !__GO32__ */ #endif /* WIN32 */ +#if !defined(CROSSCOMPILE) || defined(CROSSCOMPILE_TARGET) #include "lua.h" #include "lualib.h" #include "lauxlib.h" @@ -578,5 +579,5 @@ E int FDECL(atoi, (const char *)); #else #define LUA_INTCAST(i) (i) #endif - +#endif /* !CROSSCOMPILE || CROSSCOMPILE_TARGET */ #endif /* SYSTEM_H */ diff --git a/src/allmain.c b/src/allmain.c index 0c50a07df..96bd35c35 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -25,6 +25,9 @@ early_init() decl_globals_init(); objects_globals_init(); monst_globals_init(); +#if defined(OPTIONS_AT_RUNTIME) || defined(CROSSCOMPILE_TARGET) + runtime_info_init(); +#endif sys_early_init(); } diff --git a/src/mdlib.c b/src/mdlib.c new file mode 100644 index 000000000..6d3dcdd5d --- /dev/null +++ b/src/mdlib.c @@ -0,0 +1,761 @@ +/* NetHack 3.7 mdlib.c $NHDT-Date: 1562180226 2019/07/03 18:57:06 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.149 $ */ +/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ +/*-Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015. */ +/* Copyright (c) M. Stephenson, 1990, 1991. */ +/* Copyright (c) Dean Luick, 1990. */ +/* NetHack may be freely redistributed. See license for details. */ + +/* + * This can be linked into a binary to provide the functionality + * via the contained functions, or it can be #included directly + * into util/makedefs.c to provide it there. + */ + +#ifndef MAKEDEFS_C +#define MDLIB_C +#include "config.h" +#ifdef MONITOR_HEAP +#undef free /* makedefs, mdlib don't use the alloc and free in src/alloc.c */ +#endif +#include "permonst.h" +#include "objclass.h" +#include "monsym.h" +#include "artilist.h" +#include "dungeon.h" +#include "obj.h" +#include "monst.h" +#include "you.h" +#include "context.h" +#include "flag.h" +#include "dlb.h" +#include +/* version information */ +#ifdef SHORT_FILENAMES +#include "patchlev.h" +#else +#include "patchlevel.h" +#endif +#define Fprintf (void) fprintf +#define Fclose (void) fclose +#define Unlink (void) unlink +#if !defined(AMIGA) || defined(AZTEC_C) +#define rewind(fp) fseek((fp), 0L, SEEK_SET) /* guarantee a return value */ +#endif /* AMIGA || AZTEC_C */ + +#endif /* !MAKEDEFS_C */ + +void NDECL(build_options); +static char *FDECL(bannerc_string, (char *, const char *)); +static void FDECL(opt_out_words, (char *, int *)); +static void NDECL(build_savebones_compat_string); +static int idxopttext, done_runtime_opt_init_once = 0; +#define MAXOPT 30 +static char rttimebuf[MAXOPT]; +static char *opttext[ROWNO] = {0}; +char optbuf[BUFSZ]; +static struct version_info version; +static const char opt_indent[] = " "; + +#ifndef MAKEDEFS_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; +#endif /* !MAKEDEFS_C */ + +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 /*TTY_GRAPHICS */ +#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 } +}; + +/* + * 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. + * + */ +#ifndef MD_IGNORED_FEATURES +#define MD_IGNORED_FEATURES \ + (0L | (1L << 19) /* SCORE_ON_BOTL */ \ + | (1L << 27) /* ZEROCOMP */ \ + | (1L << 28) /* RLECOMP */ \ + ) +#endif /* MD_IGNORED_FEATUES */ + +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; +} + +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; +} + +static int +case_insensitive_comp(s1, s2) +const char *s1; +const char *s2; +{ + uchar u1, u2; + + 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; + } + return u1 - u2; +} + +static char * +eos(str) +char *str; +{ + while (*str) + str++; + return str; +} + +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 +#if defined(GNUDOS) || defined(__DJGPP__) + "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 /* ISAAC64 */ +#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 /* NO_TERMS */ +#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 USE_XPM + "tiles file in XPM format", +#endif +#ifdef GRAPHIC_TOMBSTONE + "graphical RIP screen", +#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" +}; + +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) { + opttext[idxopttext] = strdup(optbuf); + if (idxopttext < (MAXOPT - 1)) + idxopttext++; + Sprintf(optbuf, "%s", opt_indent), + *length_p = (int) strlen(opt_indent); + } else { + Sprintf(eos(optbuf), " "), (*length_p)++; + } + Sprintf(eos(optbuf), + "%s", str), *length_p += (int) strlen(str); + str += strlen(str) + (word ? 1 : 0); + } +} + +void +build_options() +{ + char buf[BUFSZ]; + int i, length, winsyscnt; + + build_savebones_compat_string(); + opttext[idxopttext] = strdup(optbuf); + if (idxopttext < (MAXOPT - 1)) + idxopttext++; + Sprintf(optbuf, + "%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 /* NH_DEVEL_STATUS == NH_STATUS_RELEASED */ + ); + opttext[idxopttext] = strdup(optbuf); + if (idxopttext < (MAXOPT - 1)) + idxopttext++; + Sprintf(optbuf, + "Options compiled into this edition:"); + opttext[idxopttext] = strdup(optbuf); + if (idxopttext < (MAXOPT - 1)) + idxopttext++; + optbuf[0] = '\0'; + 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); + } + opttext[idxopttext] = strdup(optbuf); + if (idxopttext < (MAXOPT - 1)) + idxopttext++; + optbuf[0] = '\0'; + winsyscnt = SIZE(window_opts) - 1; + opttext[idxopttext] = strdup(optbuf); + if (idxopttext < (MAXOPT - 1)) + idxopttext++; + Sprintf(optbuf, "Supported windowing system%s:", + (winsyscnt > 1) ? "s" : ""); + opttext[idxopttext] = strdup(optbuf); + if (idxopttext < (MAXOPT - 1)) + idxopttext++; + optbuf[0] = '\0'; + 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); + } + opttext[idxopttext] = strdup(optbuf); + if (idxopttext < (MAXOPT - 1)) + idxopttext++; + optbuf[0] = '\0'; + + /* end with a blank line */ + opttext[idxopttext] = strdup(optbuf); + if (idxopttext < (MAXOPT - 1)) + idxopttext++; + optbuf[0] = '\0'; + return; +} + +#if defined(__DATE__) && defined(__TIME__) +#define extract_field(t,s,n,z) \ + do { \ + for (i = 0; i < n; ++i) \ + t[i] = s[i + z]; \ + t[i] = '\0'; \ + } while (0) +#endif + +void +runtime_info_init() +{ + int i; + char tmpbuf[BUFSZ], *strp; + const char *mth[] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + struct tm t = {0}; + time_t timeresult; + + if (!done_runtime_opt_init_once) { + done_runtime_opt_init_once = 1; + build_savebones_compat_string(); + /* construct the current version number */ + make_version(); + /* + * In a cross-compiled environment, you can't execute + * the target binaries during the build, so we can't + * use makedefs to write the values of the build + * date and time to a file for retrieval. Not for + * information meaningful to the target execution + * environment. + * + * How can we capture the build date/time of the target + * binaries in such a situation? We need to rely on the + * cross-compiler itself to do it for us during the + * cross-compile. + * + * To that end, we are going to make use of the + * following pre-defined preprocessor macros for this: + * gcc, msvc, clang __DATE__ "Feb 12 1996" + * gcc, msvc, clang __TIME__ "23:59:01" + * + */ + +#if defined(__DATE__) && defined(__TIME__) + if (sizeof __DATE__ + sizeof __TIME__ + sizeof "123" < + sizeof rttimebuf) + Sprintf(rttimebuf, "%s %s", __DATE__, __TIME__); + /* "Feb 12 1996 23:59:01" + 01234567890123456789 */ + if ((int) strlen(rttimebuf) == 20) { + extract_field(tmpbuf, rttimebuf, 4, 7); /* year */ + t.tm_year = atoi(tmpbuf) - 1900; + extract_field(tmpbuf, rttimebuf, 3, 0); /* mon */ + for (i = 0; i < SIZE(mth); ++i) + if (!case_insensitive_comp(tmpbuf, mth[i])) { + t.tm_mon = i; + break; + } + extract_field(tmpbuf, rttimebuf, 2, 4); /* mday */ + strp = tmpbuf; + if (*strp == ' ') + strp++; + t.tm_mday = atoi(strp); + extract_field(tmpbuf, rttimebuf, 2, 12); /* hour */ + t.tm_hour = atoi(tmpbuf); + extract_field(tmpbuf, rttimebuf, 2, 15); /* min */ + t.tm_min = atoi(tmpbuf); + extract_field(tmpbuf, rttimebuf, 2, 18); /* sec */ + t.tm_sec = atoi(tmpbuf); + timeresult = mktime(&t); +#if defined(CROSSCOMPILE_TARGET) && !defined(MAKEDEFS_C) + BUILD_TIME = (unsigned long) timeresult; + BUILD_DATE = rttimebuf; +#endif +#else /* __DATE__ && __TIME__ */ + nhUse(strp); +#endif /* __DATE__ && __TIME__ */ + +#if defined(CROSSCOMPILE_TARGET) && !defined(MAKEDEFS_C) + VERSION_NUMBER = version.incarnation; + VERSION_FEATURES = version.feature_set; +#ifdef MD_IGNORED_FEATURES + IGNORED_FEATURES = MD_IGNORED_FEATURES; +#endif + VERSION_SANITY1 = version.entity_count; + VERSION_SANITY2 = version.struct_sizes1; + VERSION_SANITY3 = version.struct_sizes2; + + VERSION_STRING = strdup(version_string(tmpbuf, ".")); + VERSION_ID = strdup(version_id_string(tmpbuf, BUILD_DATE)); + COPYRIGHT_BANNER_C = strdup(bannerc_string(tmpbuf, BUILD_DATE)); +#ifdef HOST_NETHACK_GIT_SHA + NETHACK_GIT_SHA = strdup(HOST_NETHACK_GIT_SHA); +#endif +#ifdef HOST_NETHACK_GIT_BRANCH + NETHACK_GIT_BRANCH = strdup(HOST_NETHACK_GIT_BRANCH); +#endif +#endif /* CROSSCOMPILE_TARGET && !MAKEDEFS_C */ + } + idxopttext = 0; + build_options(); + } +} + +const char * +do_runtime_info(rtcontext) +int *rtcontext; +{ + const char *retval = (const char *) 0; + + if (!done_runtime_opt_init_once) + runtime_info_init(); + if (idxopttext && rtcontext) + if (*rtcontext >= 0 && *rtcontext < (MAXOPT - 1)) { + retval = opttext[*rtcontext]; + *rtcontext += 1; + } + return retval; +} + +/*mdlib.c*/ diff --git a/src/sfdata.c b/src/sfdata.c index 4ebf3d9c0..ac6fe5fc5 100644 --- a/src/sfdata.c +++ b/src/sfdata.c @@ -1,5 +1,5 @@ -/* NetHack 3.7 sfdata.c $Date$ $Revision$ */ -/* Copyright (c) NetHack Development Team 2018. */ +/* NetHack 3.7 sfdata.c */ +/* Copyright (c) NetHack Development Team 2019. */ /* NetHack may be freely redistributed. See license for details. */ /* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE! */ @@ -12,9 +12,6 @@ #include "wintype.h" #include "sfproto.h" -#define BUILD_DATE "Tue Jun 25 09:57:33 2019" -#define BUILD_TIME (1561471053L) - #define NHTYPE_SIMPLE 1 #define NHTYPE_COMPLEX 2 struct nhdatatypes_t { diff --git a/src/version.c b/src/version.c index 3eedd3ac9..0ab1d8249 100644 --- a/src/version.c +++ b/src/version.c @@ -19,11 +19,44 @@ #include "patchlevel.h" #endif +#if defined(CROSSCOMPILE) +struct cross_target_s cross_target = { + /* https://groups.google.com/forum/#!original/ + comp.sources.games/91SfKYg_xzI/dGnR3JnspFkJ */ + "Tue, 28-Jul-87 13:18:57 EDT", + "Version 1.0, built Jul 28 13:18:57 1987.", + "0000000000000000000000000000000000000000", + "master", + "1.0.0-0", + "NetHack Version 1.0.0-0 - last build Tue Jul 28 13:18:57 1987.", + 0x01010000UL, + 0x00000000UL, + 0x00000000UL, + 0x00000000UL, + 0x00000000UL, + 0x00000000UL, + 554476737UL, +}; +#endif /* CROSSCOMPILE */ + #if defined(NETHACK_GIT_SHA) -const char *NetHack_git_sha = NETHACK_GIT_SHA; +const char *NetHack_git_sha +#if !defined(CROSSCOMPILE) || (defined(CROSSCOMPILE) && defined(CROSSCOMPILE_HOST)) + = NETHACK_GIT_SHA +#else + = NETHACK_HOST_GIT_SHA #endif +; +#endif + #if defined(NETHACK_GIT_BRANCH) -const char *NetHack_git_branch = NETHACK_GIT_BRANCH; +const char *NetHack_git_branch +#if !defined(CROSSCOMPILE) || (defined(CROSSCOMPILE) && defined(CROSSCOMPILE_HOST)) + = NETHACK_GIT_BRANCH +#else + = NETHACK_HOST_GIT_BRANCH +#endif +; #endif static void FDECL(insert_rtoption, (char *)); @@ -98,7 +131,12 @@ doversion() int doextversion() { +#if defined(OPTIONS_AT_RUNTIME) || defined(CROSSCOMPILE_TARGET) + const char *rtbuf; + int rtcontext = 0; +#else dlb *f; +#endif char buf[BUFSZ], *p = 0; winid win = create_nhwindow(NHW_TEXT); @@ -119,12 +157,15 @@ doextversion() putstr(win, 0, p); } +#if defined(OPTIONS_AT_RUNTIME) || defined(CROSSCOMPILE_TARGET) +#else f = dlb_fopen(OPTIONS_USED, "r"); if (!f) { putstr(win, 0, ""); Sprintf(buf, "[Configuration '%s' not available?]", OPTIONS_USED); putstr(win, 0, buf); } else { +#endif /* * already inserted above: * + outdented program name and version plus build date and time @@ -146,8 +187,15 @@ doextversion() */ boolean prolog = TRUE; /* to skip indented program name */ +#if defined(OPTIONS_AT_RUNTIME) || defined(CROSSCOMPILE_TARGET) + while ((rtbuf = do_runtime_info(&rtcontext))) { + if ((int) strlen(rtbuf) >= (BUFSZ - 1)) + continue; + Strcpy(buf, rtbuf); +#else while (dlb_fgets(buf, BUFSZ, f)) { (void) strip_newline(buf); +#endif if (index(buf, '\t') != 0) (void) tabexpand(buf); @@ -167,10 +215,16 @@ doextversion() if (*buf) putstr(win, 0, buf); } +#if defined(OPTIONS_AT_RUNTIME) || defined(CROSSCOMPILE_TARGET) +#else (void) dlb_fclose(f); +#endif display_nhwindow(win, FALSE); destroy_nhwindow(win); +#if defined(OPTIONS_AT_RUNTIME) || defined(CROSSCOMPILE_TARGET) +#else } +#endif return 0; } @@ -370,11 +424,23 @@ void store_version(nhfp) NHFILE *nhfp; { +#if !defined(CROSSCOMPILE) || (defined(CROSSCOMPILE) && defined(CROSSCOMPILE_HOST)) static const struct version_info version_data = { VERSION_NUMBER, VERSION_FEATURES, VERSION_SANITY1, VERSION_SANITY2, VERSION_SANITY3 +#else + struct version_info version_data = { + 0UL,0UL,0UL,0UL,0Ul +#endif }; +#if defined(CROSSCOMPILE) && !defined(CROSSCOMPILE_HOST) + version_data.incarnation = VERSION_NUMBER; /* actual version number */ + version_data.feature_set = VERSION_FEATURES; /* bitmask of config settings */ + version_data.entity_count = VERSION_SANITY1; /* # of monsters and objects */ + version_data.struct_sizes1 = VERSION_SANITY2; /* size of key structs */ + version_data.struct_sizes2 = VERSION_SANITY3; /* size of more key structs */ +#endif if (nhfp->structlevel) { bufoff(nhfp->fd); /* bwrite() before bufon() uses plain write() */ diff --git a/sys/msdos/Makefile1.cross b/sys/msdos/Makefile1.cross index e24bbab3f..1e692237c 100644 --- a/sys/msdos/Makefile1.cross +++ b/sys/msdos/Makefile1.cross @@ -16,7 +16,7 @@ # for testing the msdos port build of the evolving NetHack code.0 # # The GNU Make has a problem if you include a drive spec below. -GAMEDIR =../binary +GAMEDIR =../msdos-binary # #============================================================================== @@ -143,9 +143,11 @@ TEXTIO = $(HOST_O)tiletext.o $(HOST_O)tiletxt.o $(HOST_O)drawing.o $(HOST_O TEXTIO2 = $(HOST_O)tiletex2.o $(HOST_O)tiletxt2.o $(HOST_O)drawing.o $(HOST_O)decl.o $(HOST_O)monst.o \ $(HOST_O)objects.o -TILE_BMP = $(DAT)/nhtiles.bmp +PLANAR_TIB = $(DAT)/NETHACK1.TIB +OVERVIEW_TIB = $(DAT)/NETHACKO.TIB +TILE_BMP = $(DAT)/NHTILES.BMP -TILEUTIL = $(TILOBJ) $(U)tile2bin $(U)til2bin2 $(TILE_BMP) +TILEUTIL = $(TILOBJ) $(U)tile2bin $(U)til2bin2 $(TILE_BMP) $(PLANAR_TIB) $(OVERVIEW_TIB) TILEFILES = $(WSHR)/monsters.txt $(WSHR)/objects.txt $(WSHR)/other.txt @@ -226,18 +228,18 @@ CURSESDEF= CURSESLIB= INCLDIR=-I../include -I../sys/msdos # Debugging -#cflags = -pg -c $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DSUPPRESS_GRAPHICS +#cflags = -pg -c $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DSUPPRESS_GRAPHICS -DCROSSCOMPILE -CROSSCOMPILE_HOST #LFLAGS = -pg # -cflags = -c -O $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DSUPPRESS_GRAPHICS -LFLAGS = +#cflags = -c -O $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DSUPPRESS_GRAPHICS -DCROSSCOMPILE -DCROSSCOMPILE_HOST +#LFLAGS = # # Debugging -#cflags = -g -c $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DUSE_TILES +#cflags = -g -c $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DUSE_TILES -DCROSSCOMPILE -DCROSSCOMPILE_HOST #LFLAGS = -g # # Normal -cflags = -c -O $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DUSE_TILES +cflags = -c -O $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DUSE_TILES -DCROSSCOMPILE -DCROSSCOMPILE_HOST LFLAGS = #========================================== @@ -318,6 +320,7 @@ $(DAT)/nhdat: $(U)dlb_main $(DAT)/data $(DAT)/rumors \ ls -1 data oracles options quest.dat rumors help hh >dlb.lst; \ ls -1 cmdhelp history opthelp wizhelp license >>dlb.lst; \ ls -1 bogusmon engrave epitaph tribute msdoshlp.txt >>dlb.lst; \ + ls -1 *.lua >>dlb.lst; \ $(U)dlb_main cvIf dlb.lst nhdat cd $(SRC) @@ -480,7 +483,19 @@ $(HOST_O)tilemap.o: $(WSHR)/tilemap.c $(HACK_H) $(TILE_H) # Required for tile support #========================================== -$(DAT)/nhtiles.bmp: $(TILEFILES) $(U)tile2bmp +$(DAT)/NetHack1.tib: $(TILEFILES) $(U)tile2bin + @echo Creating binary tile files + cd $(DAT) + $(U)tile2bin + cd $(SRC) + +$(DAT)/NetHacko.tib: $(HOST_O)thintile.tag $(TILEFILES2) $(U)til2bin2 + @echo Creating overview binary tile files + cd $(DAT) + $(U)til2bin2 + cd $(SRC) + +$(DAT)/NHTILES.BMP: $(TILEFILES) $(U)tile2bmp @echo Creating binary tile files which may take some time @cd $(DAT) @$(U)tile2bmp $@ diff --git a/sys/msdos/Makefile2.cross b/sys/msdos/Makefile2.cross index 2d25a3d6b..3cc926015 100644 --- a/sys/msdos/Makefile2.cross +++ b/sys/msdos/Makefile2.cross @@ -1,4 +1,4 @@ -# NetHack 3.6 Makefile2.cross +# NetHack 3.7 Makefile2.cross # Cross-compile msdos version of NetHack using a # linux-hosted djgpp cross-compiler. # @@ -11,17 +11,17 @@ # Makefile2 utilizes the djgpp cross-compiler from Andrew Wu: # https://github.com/andrewwutw/build-djgpp # -# Currently, in NetHack 3.6, the cross-compile for msdos cannot be -# used to build the entire game to a playable point but it is useful -# for testing the msdos port build of the evolving NetHack code. +# In NetHack 3.7, the cross-compile for msdos can be used to +# build the entire game to a complete ms-dos package and +# result (in theory). # # Game Installation Variables # NOTE: Make sure GAMEDIR exists before make is started. -GAME = nethack +GAME = NETHACK # The GNU Make has a problem if you include a drive spec below (unfortunately). -GAMEDIR =../binary +GAMEDIR =../msdos-binary # Optional PDCurses support # Uncomment these and set them appropriately if you want to @@ -39,6 +39,20 @@ PDCURSES_TOP=../../pdcurses # Set top of djgpp if not specified through ENV variables prior to make: #DJGPP_TOP = $(HOME)/djgpp +#--------------------------------------------------------------- +# Location of LUA +# +# Original source needs to be obtained from: +# http://www.lua.org/ftp/lua-5.3.5.tar.gz +# +# This build assumes that the LUA sources are located +# at the specified location. If they are actually elsewhere +# you'll need to specify the correct spot below in order to +# successfully build NetHack-3.7. +# +ADD_LUA=Y +LUATOP=../lib/lua-5.3.5 +# # #============================================================================== # This marks the end of the BUILD DECISIONS section. @@ -47,7 +61,8 @@ PDCURSES_TOP=../../pdcurses # Directories, gcc likes unix style directory specs # -OBJ = o +TARGET = msdos +OBJ = $(TARGET)_o HOBJ = host_o DAT = ../dat DOC = ../doc @@ -73,6 +88,7 @@ endif TARGET_CC = $(DJGPP_TOP)/i586-pc-msdosdjgpp/bin/gcc TARGET_LINK = $(DJGPP_TOP)/i586-pc-msdosdjgpp/bin/gcc TARGET_STUBEDIT = $(DJGPP_TOP)/i586-pc-msdosdjgpp/bin/stubedit +TARGET_AR = $(DJGPP_TOP)/i586-pc-msdosdjgpp/bin/ar MAKEBIN = make # @@ -164,7 +180,7 @@ SUPPRESS_GRAPHICS = # # ################################################ -GAMEFILE = $(GAMEDIR)/$(GAME).exe +GAMEFILE = $(GAMEDIR)/$(GAME).EXE # Changing this conditional block is not recommended ifeq "$(USE_DLB)" "Y" @@ -208,82 +224,60 @@ O = $(OBJ)/ HOST_O = $(HOBJ)/ U = $(UTIL)/ -#========================================== -# Utility Objects. -#========================================== - -VGAOBJ = $(O)vidvga.o $(O)vidvesa.o - -MAKESRC = makedefs.c - -#SPLEVSRC = lev_yacc.c lev_$(LEX).c lev_main.c panic.c - -#DGNCOMPSRC = dgn_yacc.c dgn_$(LEX).c dgn_main.c - -MAKEDEFSOBJS = $(HOST_O)makedefs.o $(HOST_O)monst.o $(HOST_O)objects.o - -#SPLEVOBJS = $(HOST_O)lev_yacc.o $(HOST_O)lev_$(LEX).o $(HOST_O)lev_main.o $(HOST_O)alloc.o \ -# $(HOST_O)monst.o $(HOST_O)objects.o $(HOST_O)panic.o \ -# $(HOST_O)drawing.o $(HOST_O)decl.o $(O)stubvid.o - -#DGNCOMPOBJS = $(HOST_O)dgn_yacc.o $(HOST_O)dgn_$(LEX).o $(HOST_O)dgn_main.o $(HOST_O)alloc.o \ -# $(HOST_O)panic.o - -RECOVOBJS = $(O)recover.o - - #========================================== # Tile related object files. #========================================== -ifeq ($(SUPPRESS_GRAPHICS),Y) -TILOBJ = -TILOBJ2 = -TEXTIO = -TEXTIO2 = -TILE_BMP = -TILEUTIL = -TILEFILES = -TILEFILES2 = -GIFREADERS = -GIFREAD2 = -PPMWRITERS = -PPMWRIT2 = - -else - -TILOBJ = $(O)tile.o $(VGAOBJ) - -TILOBJ2 = $(O)tileset.o $(O)bmptiles.o $(O)giftiles.o - -TEXTIO = $(HOST_O)tiletext.o $(HOST_O)tiletxt.o $(HOST_O)drawing.o $(HOST_O)decl.o $(HOST_O)monst.o \ - $(HOST_O)objects.o $(HOST_O)stubvid.o - -TEXTIO2 = $(HOST_O)tiletex2.o $(HOST_O)tiletxt2.o $(HOST_O)drawing.o $(HOST_O)decl.o $(HOST_O)monst.o \ - $(HOST_O)objects.o $(HOST_O)stubvid.o - -TILE_BMP = $(DAT)/nhtiles.bmp - -TILEUTIL = $(TILOBJ) $(U)tile2bin $(U)til2bin2 $(TILE_BMP) - -TILEFILES = $(WSHR)/monsters.txt $(WSHR)/objects.txt $(WSHR)/other.txt - -TILEFILES2 = $(WSHR)/monthin.txt $(WSHR)/objthin.txt $(WSHR)/oththin.txt - -GIFREADERS = $(HOST_O)gifread.o $(HOST_O)alloc.o $(HOST_O)panic.o - -GIFREAD2 = $(HOST_O)gifread2.o $(HOST_O)alloc.o $(HOST_O)panic.o - -PPMWRITERS = $(HOST_O)ppmwrite.o $(HOST_O)alloc.o $(HOST_O)panic.o - -PPMWRIT2 = $(HOST_O)ppmwrit2.o $(HOST_O)alloc.o $(HOST_O)panic.o -endif +#ifeq ($(SUPPRESS_GRAPHICS),Y) +#TILOBJ = +#TILOBJ2 = +#TEXTIO = +#TEXTIO2 = +#TILE_BMP = +#TILEUTIL = +#TILEFILES = +#TILEFILES2 = +#GIFREADERS = +#GIFREAD2 = +#PPMWRITERS = +#PPMWRIT2 = +# +#else +# +#TILOBJ = $(O)tile.o $(VIDEO_OBJ) +# +#TILOBJ2 = $(O)tileset.o $(O)bmptiles.o $(O)giftiles.o +# +#TEXTIO = $(HOST_O)tiletext.o $(HOST_O)tiletxt.o $(HOST_O)drawing.o $(HOST_O)decl.o $(HOST_O)monst.o \ +# $(HOST_O)objects.o $(HOST_O)stubvid.o +# +#TEXTIO2 = $(HOST_O)tiletex2.o $(HOST_O)tiletxt2.o $(HOST_O)drawing.o $(HOST_O)decl.o $(HOST_O)monst.o \ +# $(HOST_O)objects.o $(HOST_O)stubvid.o +#TILEUTIL = $(TILOBJ) $(U)tile2bin $(U)til2bin2 $(TILE_BMP) $(PLANAR_TIB) $(OVERVIEW_TIB) +# +#TILEFILES = $(WSHR)/monsters.txt $(WSHR)/objects.txt $(WSHR)/other.txt +# +#TILEFILES2 = $(WSHR)/monthin.txt $(WSHR)/objthin.txt $(WSHR)/oththin.txt +# +#GIFREADERS = $(HOST_O)gifread.o $(HOST_O)alloc.o $(HOST_O)panic.o +# +#GIFREAD2 = $(HOST_O)gifread2.o $(HOST_O)alloc.o $(HOST_O)panic.o +# +#PPMWRITERS = $(HOST_O)ppmwrite.o $(HOST_O)alloc.o $(HOST_O)panic.o +# +#PPMWRIT2 = $(HOST_O)ppmwrit2.o $(HOST_O)alloc.o $(HOST_O)panic.o +#endif -#REGEX = $(O)pmatchregex.o -#REGEX = $(O)cppregex.o -REGEX = $(O)posixreg.o +PLANAR_TIB = $(DAT)/NETHACK1.tib +OVERVIEW_TIB = $(DAT)/NETHACKO.tib +TILE_BMP = $(DAT)/NHTILES.BMP -DLBOBJ = $(O)dlb.o +##REGEX = $(O)pmatchregex.o +##REGEX = $(O)cppregex.o +REGEX = $(O)posixreg.o +DLBOBJ = $(O)dlb.o +VIDEO_OBJ = $(O)vidvga.o $(O)vidvesa.o $(O)tile.o $(O)tileset.o $(O)bmptiles.o $(O)giftiles.o +RECOVOBJS = $(O)recover.o # Object files for the game itself. @@ -310,13 +304,19 @@ VOBJ19 = $(O)trap.o $(O)u_init.o $(O)uhitm.o $(O)vault.o $(O)vision.o VOBJ20 = $(O)vis_tab.o $(O)weapon.o $(O)were.o $(O)wield.o $(O)windows.o VOBJ21 = $(O)wintty.o $(O)wizard.o $(O)worm.o $(O)worn.o $(O)write.o VOBJ22 = $(O)zap.o $(O)light.o $(O)dlb.o $(O)dig.o $(O)teleport.o -VOBJ23 = $(O)region.o $(O)sys.o $(REGEX) $(O)isaac64.o +VOBJ23 = $(O)region.o $(O)sys.o $(REGEX) $(O)isaac64.o $(VIDEO_OBJ) +VOBJ24 = $(O)sfbase.o $(O)sfdata.o +VOBJ25 = $(O)sfstruct.o $(O)sfascii.o $(O)sflendian.o -SOBJ = $(O)msdos.o $(O)sound.o $(O)pcsys.o $(O)tty.o $(O)unix.o \ +SOBJ = $(O)msdos.o $(O)pcsys.o $(O)tty.o $(O)unix.o \ $(O)video.o $(O)vidtxt.o $(O)pckeys.o VVOBJ = $(O)version.o +ifeq "$(ADD_LUA)" "Y" +LUAOBJ = $(O)nhlua.o $(O)nhlsel.o +endif + ifeq "$(ADD_CURSES)" "Y" CURSESOBJ= $(O)cursdial.o $(O)cursinit.o $(O)cursinvt.o $(O)cursmain.o \ $(O)cursmesg.o $(O)cursmisc.o $(O)cursstat.o $(O)curswins.o @@ -328,11 +328,54 @@ VOBJ = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \ $(VOBJ06) $(VOBJ07) $(VOBJ08) $(VOBJ09) $(VOBJ10) \ $(VOBJ11) $(VOBJ12) $(VOBJ13) $(VOBJ14) $(VOBJ15) \ $(VOBJ16) $(VOBJ17) $(VOBJ18) $(VOBJ19) $(VOBJ20) \ - $(VOBJ21) $(VOBJ22) $(VOBJ23) \ - $(CURSESOBJ) + $(VOBJ21) $(VOBJ22) $(VOBJ23) $(VOBJ24) $(VOBJ25) \ + $(LUAOBJ) $(CURSESOBJ) ALLOBJ = $(VOBJ) $(SOBJ) $(TILOBJ) $(TILOBJ2) $(VVOBJ) +ifeq "$(ADD_LUA)" "Y" +#===============-================================================= +# LUA library +# Source from http://www.lua.org/ftp/lua-5.3.5.tar.gz +#================================================================= + +LUASRC = $(LUATOP)/src +LUALIB = $(O)lua535s.a +#LUADLL = $(O)lua535.a +LUAINCL = -I$(LUASRC) +#LUAFLAGS = unix added -lm here? +LUATARGETS = lua.exe luac.exe $(LUALIB) +#LUATARGETS = $(LUADLL) $(LUALIB) + +LUASRCFILES = lapi.c lauxlib.c lbaselib.c lbitlib.c lcode.c \ + lcorolib.c lctype.c ldblib.c ldebug.c ldo.c \ + ldump.c lfunc.c lgc.c linit.c liolib.c llex.c \ + lmathlib.c lmem.c loadlib.c lobject.c lopcodes.c \ + loslib.c lparser.c lstate.c lstring.c lstrlib.c \ + ltable.c ltablib.c ltm.c lundump.c lutf8lib.c \ + lvm.c lzio.c + +LUAOBJFILES1 = $(O)lapi.o $(O)lauxlib.o $(O)lbaselib.o $(O)lbitlib.o \ + $(O)lcode.o $(O)lcorolib.o $(O)lctype.o $(O)ldblib.o +LUAOBJFILES2 = $(O)ldebug.o $(O)ldo.o $(O)ldump.o $(O)lfunc.o \ + $(O)lgc.o $(O)linit.o $(O)liolib.o $(O)llex.o +LUAOBJFILES3 = $(O)lmathlib.o $(O)lmem.o $(O)loadlib.o $(O)lobject.o \ + $(O)lopcodes.o $(O)loslib.o $(O)lparser.o $(O)lstate.o +LUAOBJFILES3 = $(O)lstring.o $(O)lstrlib.o $(O)ltable.o $(O)ltablib.o \ + $(O)ltm.o $(O)lundump.o $(O)lutf8lib.o $(O)lvm.o $(O)lzio.o + +#LUAOBJFILES = $(O)lapi.o $(O)lauxlib.o $(O)lbaselib.o $(O)lbitlib.o \ +# $(O)lcode.o $(O)lcorolib.o $(O)lctype.o $(O)ldblib.o \ +# $(O)ldebug.o $(O)ldo.o $(O)ldump.o $(O)lfunc.o \ +# $(O)lgc.o $(O)linit.o $(O)liolib.o $(O)llex.o \ +# $(O)lmathlib.o $(O)lmem.o $(O)loadlib.o $(O)lobject.o \ +# $(O)lopcodes.o $(O)loslib.o $(O)lparser.o $(O)lstate.o \ +# $(O)lstring.o $(O)lstrlib.o $(O)ltable.o $(O)ltablib.o \ +# $(O)ltm.o $(O)lundump.o $(O)lutf8lib.o $(O)lvm.o $(O)lzio.o + +LUALIBOBJS = $(LUAOBJFILES1) $(LUAOBJFILES2) $(LUAOBJFILES3) $(LUAOBJFILES4) +endif + ifeq "$(ADD_CURSES)" "Y" #========================================== # PDCurses build macros @@ -419,11 +462,6 @@ DLB = DLBOBJS = endif -ifdef DJGPP -DJ1 = $(dir $(DJGPP)) -CWSDPMI = $(subst /,\,$(DJ1))bin\CWSDPMI.* -endif - #========================================== # More compiler setup macros #========================================== @@ -435,21 +473,21 @@ CURSESDEF= CURSESLIB= endif -INCLDIR=-I../include -I../sys/msdos +INCLDIR=-I../include -I../sys/msdos $(LUAINCL) # Debugging -#cflags = -pg -c $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DSUPPRESS_GRAPHICS +#cflags = -pg -c $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DSUPPRESS_GRAPHICS -DCROSSCOMPILE -DCROSSCOMPILE_TARGET #LFLAGS = -pg -cflags = -c -O $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DSUPPRESS_GRAPHICS -LFLAGS = +#cflags = -c -O $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DSUPPRESS_GRAPHICS -DCROSSCOMPILE-DCROSSCOMPILE_TARGET +#LFLAGS = # Debugging -#cflags = -g -c $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DUSE_TILES +#cflags = -g -c $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DUSE_TILES -DCROSSCOMPILE -DCROSSCOMPILE_TARGET #LFLAGS = -g # Normal -cflags = -c -O $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DUSE_TILES +cflags = -c -O $(INCLDIR) $(DLBFLG) $(CURSESDEF) -DUSE_TILES -DCROSSCOMPILE -DCROSSCOMPILE_TARGET LFLAGS = #========================================== @@ -523,6 +561,15 @@ $(OBJ)/%.o : $(PDCSRC)/%.c $(OBJ)/%.o : $(PDCDOS)/%.c $(TARGET_CC) $(PDCINCL) $(cflags) -o$@ $< +ifeq "$(ADD_LUA)" "Y" +#========================================== +# Rules for LUA files +#========================================== + +$(OBJ)/%.o : $(LUASRC)/%.c + $(TARGET_CC) $(cflags) -o$@ $< +endif + #========================================== # Primary Targets. #========================================== @@ -538,8 +585,6 @@ default: $(GAMEFILE) util: $(O)utility.tag -#LEVCOMPEXE = $(U)lev_comp - $(O)utility.tag: $(INCL)/date.h $(INCL)/trap.h $(INCL)/onames.h \ $(INCL)/pm.h vis_tab.c $(TILEUTIL) echo utilities made > $@ @@ -553,201 +598,119 @@ recover.exe: $(U)recover $(O)install.tag: $(DAT)/nhdat $(GAMEFILE) ifeq ($(USE_DLB),Y) - cp $(DAT)/nhdat $(GAMEDIR) - cp $(DAT)/license $(GAMEDIR) + cp $(DAT)/nhdat $(GAMEDIR)/NHDAT + cp $(DAT)/license $(GAMEDIR)/LICENSE else cp $(DAT)/*. $(GAMEDIR) cp $(DAT)/*.dat $(GAMEDIR) - cp $(DAT)/*.lev $(GAMEDIR) cp $(MSYS)/msdoshlp.txt $(GAMEDIR)) +ifeq "$(ADD_LUA)" "Y" + cp $(DAT)/*.lua $(GAMEDIR) +endif endif ifdef TERMLIB - cp $(SSHR)/termcap $(GAMEDIR)) + cp $(SSHR)/termcap $(GAMEDIR)/TERMCAP) endif # if [ -f $(TILE_BMP) ]; then rm $(TILE_BMP); fi; - if [ -f $(TILE_BMP) ]; then cp $(TILE_BMP) $(GAMEDIR); fi; - if [ -f $(DAT)/symbols ]; then cp $(DAT)/symbols $(GAMEDIR); fi; - if [ -f $(SSHR)/NetHack.cnf ]; then cp $(SSHR)/NetHack.cnf $(GAMEDIR); fi; - -touch $(GAMEDIR)/record - if [ -f ../sys/winnt/sysconf ]; then cp ../sys/winnt/sysconf $(GAMEDIR); fi; - if [ -f $(DOC)/nethack.txt ]; then cp $(DOC)/nethack.txt $(GAMEDIR); fi; -ifdef CWSDPMI - if [ -f $(CWSDPMI) ]; then cp $(CWSDPMI) $(GAMEDIR); fi; -else - @echo Could not find a copy of CWSDPMI.EXE to put into $(GAMEDIR) -endif + if [ -f $(TILE_BMP) ]; then cp $(TILE_BMP) $(GAMEDIR)/NHTILES.BMP; fi; + if [ -f $(DAT)/symbols ]; then cp $(DAT)/symbols $(GAMEDIR)/SYMBOLS; fi; + if [ -f $(SSHR)/NetHack.cnf ]; then cp $(SSHR)/NetHack.cnf $(GAMEDIR)/NETHACK.CNF; fi; + -touch $(GAMEDIR)/RECORD + if [ -f ../sys/winnt/sysconf ]; then cp ../sys/winnt/sysconf $(GAMEDIR)/SYSCONF; fi; + if [ -f $(DOC)/nethack.txt ]; then cp $(DOC)/nethack.txt $(GAMEDIR)/NETHACK.TXT; fi; +# if [ -f $(PLANAR_TIB) ]; then cp $(PLANAR_TIB) $(GAMEDIR)/$(PLANAR_TIB^^); fi; +# if [ -f $(OVERVIEW_TIB ]; then cp $(OVERVIEW_TIB) $(GAMEDIR)/$(OVERVIEW_TIB^^); fi; @echo install done > $@ #========================================== # The main target. #========================================== -$(GAMEFILE): $(O)obj.tag $(PATCHLEV_H) $(PDCLIB) \ +$(GAMEFILE): $(O)obj.tag $(PDCLIB) $(LUALIB) \ $(O)utility.tag $(ALLOBJ) $(O)$(GAME).lnk if [ -f temp.a ]; then rm temp.a; fi; - @ar r temp.a $(VOBJ01) - @ar r temp.a $(VOBJ02) - @ar r temp.a $(VOBJ03) - @ar r temp.a $(VOBJ04) - @ar r temp.a $(VOBJ05) - @ar r temp.a $(VOBJ06) - @ar r temp.a $(VOBJ07) - @ar r temp.a $(VOBJ08) - @ar r temp.a $(VOBJ09) - @ar r temp.a $(VOBJ10) - @ar r temp.a $(VOBJ11) - @ar r temp.a $(VOBJ12) - @ar r temp.a $(VOBJ13) - @ar r temp.a $(VOBJ14) - @ar r temp.a $(VOBJ15) - @ar r temp.a $(VOBJ16) - @ar r temp.a $(VOBJ17) - @ar r temp.a $(VOBJ18) - @ar r temp.a $(VOBJ19) - @ar r temp.a $(VOBJ20) - @ar r temp.a $(VOBJ21) - @ar r temp.a $(VOBJ22) - @ar r temp.a $(VOBJ23) - @ar r temp.a $(VOBJ24) - @ar r temp.a $(VOBJ25) - @ar r temp.a $(SOBJ) - @ar r temp.a $(TILOBJ) - @ar r temp.a $(TILOBJ2) - @ar r temp.a $(VVOBJ) + @$(TARGET_AR) r temp.a $(VOBJ01) + @$(TARGET_AR) r temp.a $(VOBJ02) + @$(TARGET_AR) r temp.a $(VOBJ03) + @$(TARGET_AR) r temp.a $(VOBJ04) + @$(TARGET_AR) r temp.a $(VOBJ05) + @$(TARGET_AR) r temp.a $(VOBJ06) + @$(TARGET_AR) r temp.a $(VOBJ07) + @$(TARGET_AR) r temp.a $(VOBJ08) + @$(TARGET_AR) r temp.a $(VOBJ09) + @$(TARGET_AR) r temp.a $(VOBJ10) + @$(TARGET_AR) r temp.a $(VOBJ11) + @$(TARGET_AR) r temp.a $(VOBJ12) + @$(TARGET_AR) r temp.a $(VOBJ13) + @$(TARGET_AR) r temp.a $(VOBJ14) + @$(TARGET_AR) r temp.a $(VOBJ15) + @$(TARGET_AR) r temp.a $(VOBJ16) + @$(TARGET_AR) r temp.a $(VOBJ17) + @$(TARGET_AR) r temp.a $(VOBJ18) + @$(TARGET_AR) r temp.a $(VOBJ19) + @$(TARGET_AR) r temp.a $(VOBJ20) + @$(TARGET_AR) r temp.a $(VOBJ21) + @$(TARGET_AR) r temp.a $(VOBJ22) + @$(TARGET_AR) r temp.a $(VOBJ23) + @$(TARGET_AR) r temp.a $(VOBJ24) + @$(TARGET_AR) r temp.a $(VOBJ25) + @$(TARGET_AR) r temp.a $(VIDEO_OBJ) + @$(TARGET_AR) r temp.a $(SOBJ) + @$(TARGET_AR) r temp.a $(TILOBJ) + @$(TARGET_AR) r temp.a $(TILOBJ2) +ifeq "$(ADD_LUA)" "Y" + @$(TARGET_AR) r temp.a $(LUAOBJ) +endif + @$(TARGET_AR) r temp.a $(VVOBJ) ifeq "$(ADD_CURSES)" "Y" - @ar r temp.a $(CURSESOBJ) + @$(TARGET_AR) r temp.a $(CURSESOBJ) endif - $(TARGET_LINK) $(LFLAGS) -o$(GAME).exe temp.a $(PDCLIB) $(LIBRARIES) $(ZLIB) + $(TARGET_LINK) $(LFLAGS) -o$(GAME).exe temp.a $(PDCLIB) $(LUALIB) $(LIBRARIES) $(ZLIB) $(TARGET_STUBEDIT) $(GAME).exe minstack=2048K cp $(GAME).exe $(GAMEFILE) rm $(GAME).exe $(O)$(GAME).lnk: $(ALLOBJ) - echo $(VOBJ01) > $(subst /,\,$@) - echo $(VOBJ02) >> $(subst /,\,$@) - echo $(VOBJ03) >> $(subst /,\,$@) - echo $(VOBJ04) >> $(subst /,\,$@) - echo $(VOBJ05) >> $(subst /,\,$@) - echo $(VOBJ06) >> $(subst /,\,$@) - echo $(VOBJ07) >> $(subst /,\,$@) - echo $(VOBJ08) >> $(subst /,\,$@) - echo $(VOBJ09) >> $(subst /,\,$@) - echo $(VOBJ10) >> $(subst /,\,$@) - echo $(VOBJ11) >> $(subst /,\,$@) - echo $(VOBJ12) >> $(subst /,\,$@) - echo $(VOBJ13) >> $(subst /,\,$@) - echo $(VOBJ14) >> $(subst /,\,$@) - echo $(VOBJ15) >> $(subst /,\,$@) - echo $(VOBJ16) >> $(subst /,\,$@) - echo $(VOBJ17) >> $(subst /,\,$@) - echo $(VOBJ18) >> $(subst /,\,$@) - echo $(VOBJ19) >> $(subst /,\,$@) - echo $(VOBJ20) >> $(subst /,\,$@) - echo $(VOBJ21) >> $(subst /,\,$@) - echo $(VOBJ22) >> $(subst /,\,$@) - echo $(VOBJ23) >> $(subst /,\,$@) - echo $(VOBJ24) >> $(subst /,\,$@) - echo $(VOBJ25) >> $(subst /,\,$@) - echo $(SOBJ) >> $(subst /,\,$@) - echo $(TILOBJ) >> $(subst /,\,$@) - echo $(TILOBJ2) >> $(subst /,\,$@) - echo $(VVOBJ) >> $(subst /,\,$@) + echo $(VOBJ01) > $@ + echo $(VOBJ02) >> $@ + echo $(VOBJ03) >> $@ + echo $(VOBJ04) >> $@ + echo $(VOBJ05) >> $@ + echo $(VOBJ06) >> $@ + echo $(VOBJ07) >> $@ + echo $(VOBJ08) >> $@ + echo $(VOBJ09) >> $@ + echo $(VOBJ10) >> $@ + echo $(VOBJ11) >> $@ + echo $(VOBJ12) >> $@ + echo $(VOBJ13) >> $@ + echo $(VOBJ14) >> $@ + echo $(VOBJ15) >> $@ + echo $(VOBJ16) >> $@ + echo $(VOBJ17) >> $@ + echo $(VOBJ18) >> $@ + echo $(VOBJ19) >> $@ + echo $(VOBJ20) >> $@ + echo $(VOBJ21) >> $@ + echo $(VOBJ22) >> $@ + echo $(VOBJ23) >> $@ + echo $(VOBJ24) >> $@ + echo $(VOBJ25) >> $@ + echo $(SOBJ) >> $@ + echo $(TILOBJ) >> $@ + echo $(TILOBJ2) >> $@ +ifeq "$(ADD_LUA)" "Y" + echo $(LUAOBJ) >> $@ +endif + echo $(VVOBJ) >> $@ ifeq "$(ADD_CURSES)" "Y" - echo $(CURSESOBJ) >> $(subst /,\,$@) + echo $(CURSESOBJ) >> $@ endif #========================================== #=========== SECONDARY TARGETS ============ #========================================== # -# The following include files depend on makedefs to be created. -# -# date.h should be remade every time any of the source or include -# files is modified. -# -# -#$(INCL)/date.h : $(U)makedefs -# -$(U)makedefs -v -# -#$(INCL)/onames.h: $(U)makedefs -# -$(U)makedefs -o -# -#$(INCL)/pm.h: $(U)makedefs -# -$(U)makedefs -p -# -#monstr.c: $(U)makedefs -# -$(U)makedefs -m -# -#$(INCL)/vis_tab.h: $(U)makedefs -# -$(U)makedefs -z -# -#vis_tab.c: $(U)makedefs -# -$(U)makedefs -z -# -#========================================== -# Level Compiler Dependencies -#========================================== -# -#$(U)lev_comp: $(SPLEVOBJS) -# -rm -f temp.a -# @ar ru temp.a $(SPLEVOBJS) -# $(HOST_LINK) $(LFLAGS) -o$@ temp.a -# -#$(HOST_O)lev_yacc.o: $(HACK_H) $(SP_LEV_H) $(INCL)/lev_comp.h $(U)lev_yacc.c -# $(HOST_CC) $(cflags) -o$@ $(U)lev_yacc.c -# -#$(HOST_O)lev_$(LEX).o: $(HACK_H) $(SP_LEV_H) $(INCL)/lev_comp.h \ -# $(U)lev_$(LEX).c -# $(HOST_CC) $(cflags) -o$@ $(U)lev_$(LEX).c -# -#$(HOST_O)lev_main.o: $(HACK_H) $(INCL)/sp_lev.h $(INCL)/date.h $(U)lev_main.c -# -#$(U)lev_yacc.c: $(SSHR)/lev_yacc.c -# @echo --- -# @echo For now, we will copy the prebuilt -# @echo lev_comp.c from $(SSHR) into $(U) and use that. -# @cp $(SSHR)/lev_yacc.c $(U)lev_yacc.c -# @echo.>>$(U)lev_yacc.c -# -#$(INCL)/lev_comp.h : $(SSHR)/lev_comp.h -# @echo For now, we will copy the prebuilt lev_comp.h -# @echo from $(SSHR) into $(INCL) and use that. -# @cp $(SSHR)/lev_comp.h $@ -#$(U)lev_lex.c: $(SSHR)/lev_lex.c -# @echo.>>$(INCL)/lev_comp.h -# @echo For now, we will copy the prebuilt lev_lex.c -# @echo from $(SSHR) into $(U) and use it. -# @cp $(SSHR)/lev_lex.c $@ -# @echo.>>$@ -# -#========================================== -# Dungeon Dependencies -#========================================== -# -#$(U)dgn_comp: $(DGNCOMPOBJS) -# $(HOST_LINK) $(LFLAGS) -o$@ $(DGNCOMPOBJS) -# -#$(U)dgn_yacc.c: $(SSHR)/dgn_yacc.c -# @echo --- -# @echo For now, we will copy the prebuilt $(U)dgn_yacc.c and -# @echo dgn_comp.h from $(SSHR) into $(U) and use that. -# @cp $(SSHR)/dgn_yacc.c $(U)dgn_yacc.c -# @echo.>>$(U)dgn_yacc.c -# -#$(INCL)/dgn_comp.h: $(SSHR)/dgn_comp.h -# @echo --- -# @echo For now, we will copy the prebuilt dgn_comp.h -# @echo from $(SSHR) into $(INCL) and use that. -# @cp $(SSHR)/dgn_comp.h $@ -# @echo.>>$(INCL)/dgn_comp.h -# -#$(U)dgn_$(LEX).c: $(SSHR)/dgn_lex.c $(INCL)/dgn_comp.h -# @echo --- -# @echo For now, we will copy the prebuilt dgn_lex.c -# @echo from $(SSHR) into $(U) and use it. -# @cp $(SSHR)/dgn_lex.c $@ -# @echo.>>$@ - #========================================== # Recover Utility #========================================== @@ -810,109 +773,32 @@ $(O)objects.o: $(CONFIG_H) $(INCL)/obj.h $(INCL)/objclass.h \ $(O)dat.tag: $(DAT)/nhdat @echo dat done >$@ -#$(HOST_O)monst.o: $(CONFIG_H) $(PERMONST_H) $(INCL)/monsym.h \ -# $(INCL)/color.h monst.c -# $(HOST_CC) $(cflags) -o$@ monst.c +#============================================================= +# Lua +#============================================================= -#$(HOST_O)objects.o: $(CONFIG_H) $(INCL)/obj.h $(INCL)/objclass.h \ -# $(INCL)/prop.h $(INCL)/color.h objects.c -# $(HOST_CC) $(cflags) -o$@ objects.c +lua.exe: $(O)lua.o $(LUALIB) + $(TARGET_LINK) $(LFLAGS) -o$@ $(O)lua.o $(LUALIB) -#$(O)panic.o: $(CONFIG_H) $(U)panic.c +luac.exe: $(O)luac.o $(LUALIB) + $(TARGET_LINK) $(LFLAGSU) -o$@ $(O)luac.o $(LUALIB) -# make data.base an 8.3 filename to prevent an make warning -#DATABASE = $(DAT)/data.bas -# -# -# -#$(DAT)/data: $(O)utility.tag $(DATABASE) -# $(U)makedefs -d -# -#$(DAT)/rumors: $(O)utility.tag $(DAT)/rumors.tru $(DAT)/rumors.fal -# $(U)makedefs -r -# -#$(DAT)/quest.dat: $(O)utility.tag $(DAT)/quest.txt -# $(U)makedefs -q -# -#$(DAT)/oracles: $(O)utility.tag $(DAT)/oracles.txt -# $(U)makedefs -h -# -#$(DAT)/bogusmon: $(O)utility.tag $(DAT)/bogusmon.txt -# $(U)makedefs -s -# -#$(DAT)/engrave: $(O)utility.tag $(DAT)/engrave.txt -# $(U)makedefs -s -# -#$(DAT)/epitaph: $(O)utility.tag $(DAT)/epitaph.txt -# $(U)makedefs -s -# -#$(O)sp_lev.tag: $(O)utility.tag \ -# $(DAT)/bigroom.des $(DAT)/castle.des \ -# $(DAT)/endgame.des $(DAT)/gehennom.des $(DAT)/knox.des \ -# $(DAT)/medusa.des $(DAT)/oracle.des $(DAT)/tower.des \ -# $(DAT)/yendor.des $(DAT)/arch.des $(DAT)/barb.des \ -# $(DAT)/caveman.des $(DAT)/healer.des $(DAT)/knight.des \ -# $(DAT)/monk.des $(DAT)/priest.des $(DAT)/ranger.des \ -# $(DAT)/rogue.des $(DAT)/samurai.des $(DAT)/tourist.des \ -# $(DAT)/valkyrie.des $(DAT)/wizard.des -# cd $(DAT) -# $(U)lev_comp bigroom.des -# $(U)lev_comp castle.des -# $(U)lev_comp endgame.des -# $(U)lev_comp gehennom.des -# $(U)lev_comp knox.des -# $(U)lev_comp mines.des -# $(U)lev_comp medusa.des -# $(U)lev_comp oracle.des -# $(U)lev_comp sokoban.des -# $(U)lev_comp tower.des -# $(U)lev_comp yendor.des -# $(U)lev_comp arch.des -# $(U)lev_comp barb.des -# $(U)lev_comp caveman.des -# $(U)lev_comp healer.des -# $(U)lev_comp knight.des -# $(U)lev_comp monk.des -# $(U)lev_comp priest.des -# $(U)lev_comp ranger.des -# $(U)lev_comp rogue.des -# $(U)lev_comp samurai.des -# $(U)lev_comp tourist.des -# $(U)lev_comp valkyrie.des -# $(U)lev_comp wizard.des -# cd $(SRC) -# echo sp_levs done > $@ -# -#$(DAT)/dungeon: $(O)utility.tag $(DAT)/dungeon.def -# $(U)makedefs -e -# cd $(DAT) -# $(U)dgn_comp dungeon.pdf -# cd $(SRC) +$(O)lua.o: $(LUASRC)/lua.c +$(O)luac.o: $(LUASRC)/luac.c #========================================== -# DLB stuff +# Lua lib #========================================== -#note that dir below assumes bin/dir from djgpp distribution -# -#$(DAT)/nhdat: $(U)dlb_main $(DAT)/data $(DAT)/rumors $(DAT)/dungeon \ -# $(DAT)/oracles $(DAT)/quest.dat $(O)sp_lev.tag \ -# $(DAT)/bogusmon $(DAT)/engrave $(DAT)/epitaph $(DAT)/tribute -# echo dat done >$(O)dat.tag -# cd $(DAT) -# copy $(MSYS)/msdoshlp.txt . -# @$(LS) data dungeon oracles options quest.dat rumors help hh >dlb.lst -# @$(LS) cmdhelp history opthelp wizhelp license msdoshlp.txt >>dlb.lst -# @$(LS) bogusmon engrave epitaph tribute >>dlb.lst -# $(LS) $(subst /,\,*.lev) >>dlb.lst -# $(U)dlb_main cvIf dlb.lst nhdat -# cd $(SRC) -# -#$(U)dlb_main: $(DLBOBJS) -# $(HOST_LINK) $(LFLAGS) -o$@ $(DLBOBJS) -# -#$(HOST_O)dlb_main.o: $(U)dlb_main.c $(INCL)/config.h $(DLB_H) -# $(HOST_CC) $(cflags) -o$@ $(U)dlb_main.c +$(LUALIB): $(LUALIBOBJS) + $(TARGET_AR) rcS $@ $(LUAOBJFILES1) + $(TARGET_AR) rcS $@ $(LUAOBJFILES2) + $(TARGET_AR) rcS $@ $(LUAOBJFILES3) + $(TARGET_AR) rcS $@ $(LUAOBJFILES4) + +#$(LUADLL): $(LUALIBOBJS) +# $(TARGET_CC) -shared -Wl,--export-all-symbols \ +# -Wl,--add-stdcall-alias -o $@ $< #========================================== # Housekeeping. @@ -927,24 +813,17 @@ clean: spotless: clean - if [ -f dgn_flex.c ]; then rm dgn_flex.c; fi; - if [ -f dgn_lex.c ]; then rm dgn_lex.c; fi; - if [ -f $(U)dgn_comp.exe ]; then rm $(U)dgn_comp.exe; fi; if [ -f $(U)recover.exe ]; then rm $(U)recover.exe; fi; if [ -f $(INCL)/vis_tab.h ]; then rm $(INCL)/vis_tab.h; fi; if [ -f $(INCL)/onames.h ]; then rm $(INCL)/onames.h; fi; if [ -f $(INCL)/pm.h ]; then rm $(INCL)/pm.h; fi; if [ -f $(INCL)/date.h ]; then rm $(INCL)/date.h; fi; - if [ -f $(INCL)/dgn_comp.h ]; then rm $(INCL)/dgn_comp.h; fi; - if [ -f $(INCL)/lev_comp.h ]; then rm $(INCL)/lev_comp.h; fi; # if [ -f $(SRC)/monstr.c ]; then rm $(SRC)/monstr.c; fi; if [ -f $(SRC)/vis_tab.c ]; then rm $(SRC)/vis_tab.c; fi; if [ -f $(SRC)/tile.c ]; then rm $(SRC)/tile.c; fi; if [ -f $(DAT)/options ]; then rm $(DAT)/options; fi; if [ -f $(DAT)/data ]; then rm $(DAT)/data; fi; if [ -f $(DAT)/rumors ]; then rm $(DAT)/rumors; fi; - if [ -f $(DAT)/dungeon.pdf ]; then rm $(DAT)/dungeon.pdf; fi; - if [ -f $(DAT)/dungeon ]; then rm $(DAT)/dungeon; fi; if [ -f $(DAT)/oracles ]; then rm $(DAT)/oracles; fi; if [ -f $(DAT)/quest.dat ]; then rm $(DAT)/quest.dat; fi; if [ -f $(DAT)/bogusmon ]; then rm $(DAT)/bogusmon; fi; @@ -952,10 +831,11 @@ spotless: clean if [ -f $(DAT)/epitaph ]; then rm $(DAT)/epitaph; fi; if [ -f $(DAT)/dlb.lst ]; then rm $(DAT)/dlb.lst; fi; if [ -f $(TILE_BMP) ]; then rm $(TILE_BMP); fi; + if [ -f $(PLANAR_TIB) ]; then rm $(PLANAR_TIB); fi; + if [ -f $(OVERVIEW_TIB) ]; then rm $(OVERVIEW_TIB); fi; if [ -f $(WSHR)/monthin.txt ]; then rm $(WSHR)/monthin.txt; fi; if [ -f $(WSHR)/objthin.txt ]; then rm $(WSHR)/objthin.txt; fi; if [ -f $(WSHR)/oththin.txt ]; then rm $(WSHR)/oththin.txt; fi; - -rm $(DAT)/*.lev #========================================== # Create directory for holding object files @@ -1077,8 +957,8 @@ $(O)wintext.o: ../win/X11/wintext.c $(HACK_H) $(INCL)/winX.h $(INCL)/xwindow.h $(TARGET_CC) $(cflags) -o$@ ../win/X11/wintext.c $(O)winval.o: ../win/X11/winval.c $(HACK_H) $(INCL)/winX.h $(TARGET_CC) $(cflags) -o$@ ../win/X11/winval.c -$(O)tile.o: tile.c $(HACK_H) -$(HOST_O)tile.o: tile.c $(HACK_H) +#$(O)tile.o: tile.c $(HACK_H) +#$(HOST_O)tile.o: tile.c $(HACK_H) $(O)gnaskstr.o: ../win/gnome/gnaskstr.c ../win/gnome/gnaskstr.h \ ../win/gnome/gnmain.h $(TARGET_CC) $(cflags) $(GNOMEINC) -o$@ ../win/gnome/gnaskstr.c @@ -1130,7 +1010,6 @@ $(O)load_img.o: ../win/gem/load_img.c $(INCL)/load_img.h $(TARGET_CC) $(cflags) -o$@ ../win/gem/load_img.c $(O)gr_rect.o: ../win/gem/gr_rect.c $(INCL)/gr_rect.h $(TARGET_CC) $(cflags) -o$@ ../win/gem/gr_rect.c -$(O)tile.o: tile.c $(HACK_H) $(O)qt_win.o: ../win/Qt/qt_win.cpp $(HACK_H) $(INCL)/func_tab.h \ $(INCL)/dlb.h $(PATCHLEV_H) $(INCL)/tile2x11.h \ $(INCL)/qt_win.h $(INCL)/qt_clust.h $(INCL)/qt_kde0.h \ diff --git a/sys/msdos/msdos-cross-compile.sh b/sys/msdos/msdos-cross-compile.sh new file mode 100644 index 000000000..c5de2b97f --- /dev/null +++ b/sys/msdos/msdos-cross-compile.sh @@ -0,0 +1,60 @@ +#!/bin/sh +if [ -z "$TRAVIS_BUIILD_DIR" ]; then + export DJGPP_TOP=$(pwd)/djgpp +else + export DJGPP_TOP="$TRAVIS_BUILD_DIR/djgpp" +fi +export +cd util +if [ ! -d ../djgpp/i586-pc-msdosdjgpp ]; then + if [ "$(uname)" = "Darwin" ]; then + #Mac + wget --no-hsts https://github.com/andrewwutw/build-djgpp/releases/download/v2.9/djgpp-osx-gcc550.tar.bz2 + elif [ "$(expr substr $(uname -s) 1 5)" = "Linux" ]; then + #Linux + wget --no-hsts https://github.com/andrewwutw/build-djgpp/releases/download/v2.9/djgpp-linux64-gcc550.tar.bz2 + elif [ "$(expr substr $(uname -s) 1 10)" = "MINGW32_NT" ]; then + #mingw + wget --no-hsts https://github.com/andrewwutw/build-djgpp/releases/download/v2.9/djgpp-mingw-gcc550-standalone.zip + fi + if [ ! -d djgpp/i586-pc-msdosdjgpp ]; then + tar xjf util/djgpp-linux64-gcc550.tar.bz2 + fi +fi +cd ../ +# PDCurses +if [ ! -d "../pdcurses" ]; then + echo "Getting ../pdcurses from https://github.com/wmcbrine/PDCurses.git" + git clone --depth 1 https://github.com/wmcbrine/PDCurses.git ../pdcurses +fi +cd djgpp +# DOS-extender for use with djgpp +if [ ! -d cwsdpmi ]; then + wget --no-hsts http://sandmann.dotster.com/cwsdpmi/csdpmi7b.zip + mkdir -p cwsdpmi + cd cwsdpmi + unzip ../csdpmi7b.zip + cd ../ + rm csdpmi7b.zip +fi +cd ../src +pwd +mkdir -p ../binary +cp ../dat/data.base ../dat/data.bas +cp ../include/patchlevel.h ../include/patchlev.h +cp ../doc/Guidebook.txt ../doc/guidebk.txt +cp ../sys/share/posixregex.c ../sys/share/posixreg.c +cp ../sys/msdos/Makefile1.cross ../src/Makefile1 +cp ../sys/msdos/Makefile2.cross ../src/Makefile2 +make -f Makefile1 +cat ../include/date.h +export GCC_EXEC_PREFIX=$DJGPP_TOP/lib/gcc/ +export +pwd +make -f Makefile2 +unset GCC_EXEC_PREFIX +if [ -f $TRAVIS_BUILD_DIR/djgpp/cwsdpmi/bin/cwsdpmi.exe ]; then + cp $TRAVIS_BUILD_DIR/djgpp/cwsdpmi/bin/cwsdpmi.exe ../binary/CWSDPMI.EXE; +fi +ls -l ../binary + diff --git a/sys/winnt/Makefile.msc b/sys/winnt/Makefile.msc index 484f5576e..8455cd075 100644 --- a/sys/winnt/Makefile.msc +++ b/sys/winnt/Makefile.msc @@ -145,6 +145,12 @@ DEBUGINFO = Y # LUATOP=..\..\lua-5.3.5 # +# +#============================================================================== +# +#TEST_CROSSCOMPILE=Y +#OPTIONS_AT_RUNTIME=Y +# #============================================================================== #======================== End of Modification Section ========================= #============================================================================== @@ -314,6 +320,28 @@ REGEX = $(O)cppregex.o TTYOBJ = $(O)topl.o $(O)getline.o $(O)wintty.o +!IFDEF TEST_CROSSCOMPILE +CROSSDEFINE_TARGET = -DCROSSCOMPILE_TARGET +CROSSDEFINE_HOST = -DCROSSCOMPILE_HOST +CROSSCOMPILE = -DCROSSCOMPILE +CROSSDEFINES = $(CROSSCOMPILE) $(CROSSDEFINE_HOST) $(CROSSDEFINE_TARGET) +OPTIONS_AT_RUNTIME=Y +!ELSE +CROSSDEFINE_TARGET = +CROSSDEFINE_HOST = +CROSSCOMPILE = +CROSSDEFINES = +CROSSDEFINES = +!ENDIF + +!IF "$(OPTIONS_AT_RUNTIME)" == "Y" +MDLIB = $(O)mdlib.o +RUNTIMEOPTDEF=-DOPTIONS_AT_RUNTIME +!ELSE +MDLIB = +RUNTIMEOPTDEF= +!ENDIF + !IFNDEF ADD_CURSES CURSESOBJ= !ELSE @@ -330,7 +358,7 @@ OBJS = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \ $(VOBJ16) $(VOBJ17) $(VOBJ18) $(VOBJ19) $(VOBJ20) \ $(VOBJ21) $(VOBJ22) $(VOBJ23) $(VOBJ24) $(VOBJ25) \ $(VOBJ26) $(VOBJ27) $(VOBJ28) $(VOBJ29) $(VOBJ30) \ - $(REGEX) $(CURSESOBJ) + $(REGEX) $(CURSESOBJ) $(MDLIB) GUIOBJ = $(O)mhaskyn.o $(O)mhdlg.o \ $(O)mhfont.o $(O)mhinput.o $(O)mhmain.o $(O)mhmap.o \ @@ -608,7 +636,7 @@ CURSESLIB= ccommon= -c -nologo -D"_CONSOLE" -D"_CRT_NONSTDC_NO_DEPRECATE" -D"_CRT_SECURE_NO_DEPRECATE" \ -D"_LIB" -D"_SCL_SECURE_NO_DEPRECATE" -D"_VC80_UPGRADE=0x0600" -D"DLB" -D"_MBCS" \ -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -D"NDEBUG" -D"YY_NO_UNISTD_H" \ - -DHAS_STDINT_H -DHAS_INLINE $(CURSESDEF) \ + -DHAS_STDINT_H -DHAS_INLINE $(CURSESDEF) $(RUNTIMEOPTDEF) \ -EHsc -fp:precise -Gd -GF -GS -Gy \ $(CL_RECENT) -WX- -Zc:forScope -Zc:wchar_t -Zi cdebug= -analyze- -D"_DEBUG" -MTd -RTC1 -Od @@ -708,20 +736,20 @@ DLB = #========================================== .c{$(OBJ)}.o: - @$(cc) $(cflagsBuild) -Fo$@ $< + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $< {$(SRC)}.c{$(OBJ)}.o: - @$(cc) $(cflagsBuild) -Fo$@ $< + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $< #========================================== # Rules for files in sys\share #========================================== {$(SSYS)}.c{$(OBJ)}.o: - @$(cc) $(cflagsBuild) -Fo$@ $< + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $< {$(SSYS)}.cpp{$(OBJ)}.o: - @$(cc) $(cflagsBuild) /EHsc -Fo$@ $< + @$(cc) $(cflagsBuild) $(CROSSDEFINES) /EHsc -Fo$@ $< #========================================== # Rules for files in sys\winnt @@ -738,14 +766,14 @@ DLB = #========================================== {$(UTIL)}.c{$(OBJ)}.o: - @$(cc) $(cflagsBuild) -Fo$@ $< + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $< #========================================== # Rules for files in win\share #========================================== {$(WSHR)}.c{$(OBJ)}.o: - @$(cc) $(cflagsBuild) -Fo$@ $< + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $< {$(WSHR)}.h{$(INCL)}.h: @copy $< $@ @@ -758,7 +786,7 @@ DLB = #========================================== {$(TTY)}.c{$(OBJ)}.o: - $(cc) $(cflagsBuild) -Fo$@ $< + $(cc) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $< #========================================== @@ -766,14 +794,14 @@ DLB = #========================================== {$(MSWIN)}.c{$(OBJ)}.o: - @$(cc) $(cflagsBuild) -Fo$@ $< + $(cc) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $< #========================================== # Rules for files in win\curses #========================================== {$(WCURSES)}.c{$(OBJ)}.o: - @$(cc) -DPDC_NCMOUSE $(PDCINCL) $(cflagsBuild) -Fo$@ $< + @$(cc) -DPDC_NCMOUSE $(PDCINCL) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $< #{$(WCURSES)}.txt{$(DAT)}.txt: # @copy $< $@ @@ -783,20 +811,20 @@ DLB = #========================================== {$(PDCURSES_TOP)}.c{$(OBJ)}.o: - @$(cc) $(PDCINCL) $(cflagsBuild) -Fo$@ $< + @$(cc) $(PDCINCL) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $< {$(PDCSRC)}.c{$(OBJ)}.o: - @$(cc) $(PDCINCL) $(cflagsBuild) -Fo$@ $< + @$(cc) $(PDCINCL) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $< {$(PDCWINCON)}.c{$(OBJ)}.o: - @$(cc) $(PDCINCL) $(cflagsBuild) -Fo$@ $< + @$(cc) $(PDCINCL) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $< #========================================== # Rules for LUA files #========================================== {$(LUASRC)}.c{$(OBJ)}.o: - @$(cc) $(cflagsBuild) -Fo$@ $< + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $< #========================================== #=============== TARGETS ================== @@ -1063,7 +1091,7 @@ $(U)nhsizes.exe: $(O)nhsizes.o $(link) $(lflagsBuild) -out:$@ $(O)nhsizes.o $(O)panic.o $(O)alloc.o $(O)nhsizes.o: $(CONFIG_H) nhsizes.c - @$(cc) $(cflagsBuild) -Fo$@ nhsizes.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ nhsizes.c $(U)makedefs.exe: $(MAKEOBJS) @echo Linking $(@:\=/) @@ -1074,7 +1102,8 @@ $(O)makedefs.o: $(CONFIG_H) $(INCL)\monattk.h $(INCL)\monflag.h $(INCL)\objcla $(U)makedefs.c @if not exist $(OBJ)\*.* echo creating directory $(OBJ:\=/) @if not exist $(OBJ)\*.* mkdir $(OBJ) - @$(cc) -DENUM_PM $(cflagsBuild) -Fo$@ $(U)makedefs.c + $(cc) -DENUM_PM $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $(U)makedefs.c +# $(cc) -DENUM_PM $(cflagsBuild) $(CROSSDEFINES) /EP -Fo$@ $(U)makedefs.c >makedefs.c.preprocessed # # date.h should be remade every time any of the source or include @@ -1105,7 +1134,7 @@ $(U)uudecode.exe: $(O)uudecode.o @$(link) $(lflagsBuild) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ $(O)uudecode.o $(O)uudecode.o: $(SSYS)\uudecode.c - @$(cc) $(cflagsBuild) /D_CRT_SECURE_NO_DEPRECATE -Fo$@ $(SSYS)\uudecode.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) /D_CRT_SECURE_NO_DEPRECATE -Fo$@ $(SSYS)\uudecode.c $(MSWSYS)\NetHack.ico : $(U)uudecode.exe $(MSWSYS)\nhico.uu chdir $(MSWSYS) @@ -1271,10 +1300,10 @@ $(U)dlb_main.exe: $(DLBOBJ) $(O)dlb.o << $(O)dlb.o: $(O)dlb_main.o $(O)alloc.o $(O)panic.o $(INCL)\dlb.h - @$(cc) $(cflagsBuild) /Fo$@ $(SRC)\dlb.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) /Fo$@ $(SRC)\dlb.c $(O)dlb_main.o: $(UTIL)\dlb_main.c $(INCL)\config.h $(INCL)\dlb.h - @$(cc) $(cflagsBuild) /Fo$@ $(UTIL)\dlb_main.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) /Fo$@ $(UTIL)\dlb_main.c $(DAT)\porthelp: $(MSWSYS)\porthelp @copy $(MSWSYS)\porthelp $@ >nul @@ -1320,7 +1349,7 @@ $(U)recover.exe: $(RECOVOBJS) $(link) $(lflagsBuild) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ $(RECOVOBJS) $(O)recover.o: $(CONFIG_H) $(U)recover.c $(MSWSYS)\win32api.h - @$(cc) $(cflagsBuild) -Fo$@ $(U)recover.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $(U)recover.c #========================================== # Tile Mapping @@ -1335,28 +1364,28 @@ $(U)tilemap.exe: $(O)tilemap.o @$(link) $(lflagsBuild) /PDB:"$(O)$(@B).PDB" /MAP:"$(O)$(@B).MAP" -out:$@ $(O)tilemap.o $(O)tilemap.o: $(WSHR)\tilemap.c $(HACK_H) - @$(cc) $(cflagsBuild) -Fo$@ $(WSHR)\tilemap.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $(WSHR)\tilemap.c $(O)tiletx32.o: $(WSHR)\tilemap.c $(HACK_H) - @$(cc) $(cflagsBuild) /DTILETEXT /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\tilemap.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) /DTILETEXT /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\tilemap.c $(O)tiletxt.o: $(WSHR)\tilemap.c $(HACK_H) - @$(cc) $(cflagsBuild) /DTILETEXT -Fo$@ $(WSHR)\tilemap.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) /DTILETEXT -Fo$@ $(WSHR)\tilemap.c $(O)gifread.o: $(WSHR)\gifread.c $(CONFIG_H) $(TILE_H) - @$(cc) $(cflagsBuild) -I$(WSHR) -Fo$@ $(WSHR)\gifread.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -I$(WSHR) -Fo$@ $(WSHR)\gifread.c $(O)gifrd32.o: $(WSHR)\gifread.c $(CONFIG_H) $(TILE_H) - @$(cc) $(cflagsBuild) -I$(WSHR) /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\gifread.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -I$(WSHR) /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\gifread.c $(O)ppmwrite.o: $(WSHR)\ppmwrite.c $(CONFIG_H) $(TILE_H) - @$(cc) $(cflagsBuild) -I$(WSHR) -Fo$@ $(WSHR)\ppmwrite.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -I$(WSHR) -Fo$@ $(WSHR)\ppmwrite.c $(O)tiletext.o: $(WSHR)\tiletext.c $(CONFIG_H) $(TILE_H) - @$(cc) $(cflagsBuild) -I$(WSHR) -Fo$@ $(WSHR)\tiletext.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -I$(WSHR) -Fo$@ $(WSHR)\tiletext.c $(O)tilete32.o: $(WSHR)\tiletext.c $(CONFIG_H) $(TILE_H) - @$(cc) $(cflagsBuild) -I$(WSHR) /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\tiletext.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -I$(WSHR) /DTILE_X=32 /DTILE_Y=32 -Fo$@ $(WSHR)\tiletext.c #========================================== # Optional Tile Utilities @@ -1414,10 +1443,10 @@ $(U)til2bm32.exe: $(O)til2bm32.o $(TEXT_IO32) << $(O)tile2bmp.o: $(WSHR)\tile2bmp.c $(HACK_H) $(TILE_H) $(MSWSYS)\win32api.h - @$(cc) $(cflagsBuild) -I$(WSHR) /DPACKED_FILE /Fo$@ $(WSHR)\tile2bmp.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -I$(WSHR) /DPACKED_FILE /Fo$@ $(WSHR)\tile2bmp.c $(O)til2bm32.o: $(WSHR)\tile2bmp.c $(HACK_H) $(TILE_H) $(MSWSYS)\win32api.h - @$(cc) $(cflagsBuild) -I$(WSHR) /DPACKED_FILE /DTILE_X=32 /DTILE_Y=32 /Fo$@ $(WSHR)\tile2bmp.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -I$(WSHR) /DPACKED_FILE /DTILE_X=32 /DTILE_Y=32 /Fo$@ $(WSHR)\tile2bmp.c #=============================================================================== # PDCurses @@ -1427,7 +1456,7 @@ $(O)pdcurses.lib : $(PDCLIBOBJS) $(PDCOBJS) lib -nologo /out:$@ $(PDCLIBOBJS) $(PDCOBJS) $(O)pdcscrn.o : $(PDCURSES_HEADERS) $(PDCWINCON)\pdcscrn.c $(MSWSYS)\stub-pdcscrn.c - $(cc) $(PDCINCL) $(cflagsBuild) -Fo$@ $(MSWSYS)\stub-pdcscrn.c + $(cc) $(PDCINCL) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $(MSWSYS)\stub-pdcscrn.c #=============================================================================== # LUA @@ -1448,7 +1477,25 @@ $(O)lua$(LUAVER)-static.lib: $(LUAOBJFILES) $(O)lua.o: $(LUASRC)\lua.c $(O)luac.o: $(LUASRC)\luac.c $(O)lapi.o: $(LUASRC)\lapi.c - @$(cc) $(cflagsBuild) -wd4244 -Fo$@ $(LUASRC)\lapi.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -wd4244 -Fo$@ $(LUASRC)\lapi.c + +#=============================================================================== +# CROSSCOMPILE +#=============================================================================== + +# Under a cross-compile, some of the values stored statically into +# text files cannot be trusted as being representative of the +# settings and features used on the build of the target binaries. +# +# We move some of that stuff into the game run-time by separating +# out the functions into src\mdlib.c to get some of the required +# functionality at game runtime instead of from a previously written +# data file. +# + +$(O)mdlib.o: $(SRC)\mdlib.c + $(cc) $(cflagsBuild) $(CROSSCOMPILE) $(CROSSDEFINE_TARGET) -DMAKEDEFS_MDOBJ -Fo$@ $(SRC)\mdlib.c +# $(cc) $(cflagsBuild) $(CROSSCOMPILE) $(CROSSDEFINE_TARGET) -DMAKEDEFS_MDOBJ /EP -Fo$@ $(SRC)\mdlib.c >mdlib.c.preprocessed #=============================================================================== # Housekeeping @@ -1642,31 +1689,32 @@ $(DAT)\dungeon: $(O)utility.tag $(DAT)\dungeon.def # $(O)nttty.o: $(HACK_H) $(TILE_H) $(MSWSYS)\win32api.h $(MSWSYS)\nttty.c - @$(cc) $(cflagsBuild) -I$(WSHR) -Fo$@ $(MSWSYS)\nttty.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -I$(WSHR) -Fo$@ $(MSWSYS)\nttty.c $(O)winnt.o: $(HACK_H) $(MSWSYS)\win32api.h $(MSWSYS)\winnt.c - @$(cc) $(cflagsBuild) -I$(MSWSYS) -I$(MSWIN) -Fo$@ $(MSWSYS)\win10.c - @$(cc) $(cflagsBuild) -Fo$@ $(MSWSYS)\winnt.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -I$(MSWSYS) -I$(MSWIN) -Fo$@ $(MSWSYS)\win10.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $(MSWSYS)\winnt.c $(O)ntsound.o: $(HACK_H) $(MSWSYS)\ntsound.c - @$(cc) $(cflagsBuild) -Fo$@ $(MSWSYS)\ntsound.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $(MSWSYS)\ntsound.c +$(O)windmain.o: $(MSWSYS)\windmain.c $(HACK_H) #if you aren't linking in the full gui then #include the following stub for proper linkage. $(O)guistub.o: $(HACK_H) $(MSWSYS)\stubs.c - @$(cc) $(cflagsBuild) -DGUISTUB -Fo$@ $(MSWSYS)\stubs.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -DGUISTUB -Fo$@ $(MSWSYS)\stubs.c # # WIN32 dependencies # $(O)NetHackW.o: $(HACK_H) $(MSWIN)\NetHackW.c - @$(cc) $(cflagsBuild) -I$(MSWSYS) -I$(MSWIN) -Fo$@ $(MSWIN)\NetHackW.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -I$(MSWSYS) -I$(MSWIN) -Fo$@ $(MSWIN)\NetHackW.c #if you aren't linking in the full tty then #include the following stub for proper linkage. $(O)ttystub.o: $(HACK_H) $(MSWSYS)\stubs.c - @$(cc) $(cflagsBuild) -DTTYSTUB -Fo$@ $(MSWSYS)\stubs.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -DTTYSTUB -Fo$@ $(MSWSYS)\stubs.c # #============================================ @@ -1675,19 +1723,19 @@ $(O)ttystub.o: $(HACK_H) $(MSWSYS)\stubs.c $(O)sfbase.o: $(HACK_H) $(INCL)\sfproto.h $(INCL)\sfprocs.h \ $(SRC)\sfbase.c - @$(cc) $(cflagsBuild) -Fo$@ $(SRC)\sfbase.c +# @$(cc) $(cflagsBuild) -Fo$@ $(SRC)\sfbase.c $(O)sfdata.o: $(HACK_H) $(INCL)\sfprocs.h $(SRC)\sfdata.c - @$(cc) $(cflagsBuild) -Fo$@ $(SRC)\sfdata.c +# @$(cc) $(cflagsBuild) -Fo$@ $(SRC)\sfdata.c $(O)sfstruct.o: $(HACK_H) $(SRC)\sfstruct.c - @$(cc) $(cflagsBuild) -Fo$@ $(SRC)\sfstruct.c +# @$(cc) $(cflagsBuild) -Fo$@ $(SRC)\sfstruct.c $(O)sfascii.o: $(HACK_H) $(INCL)\sfprocs.h $(SRC)\sfascii.c - @$(cc) $(cflagsBuild) -Fo$@ $(SRC)\sfascii.c +# @$(cc) $(cflagsBuild) -Fo$@ $(SRC)\sfascii.c $(O)sflendian.o: $(HACK_H) $(INCL)\sfprocs.h $(SRC)\sflendian.c - @$(cc) $(cflagsBuild) -Fo$@ $(SRC)\sflendian.c +# @$(cc) $(cflagsBuild) -Fo$@ $(SRC)\sflendian.c $(SRC)\sfdata.c: $(U)readtags.exe $(U)nethack.tags $(U)readtags.exe @@ -1699,7 +1747,7 @@ $(U)readtags.exe: $(O)readtags.o @$(link) $(lflagsBuild) -out:$@ $(O)readtags.o $(O)readtags.o: $(U)readtags.c $(U)nethack.tags $(CONFIG_H) $(PATCHLEVEL_H) - @$(cc) $(cflagsBuild) $(TEMPL) -Fo$@ $(U)readtags.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) $(TEMPL) -Fo$@ $(U)readtags.c # #tested only with exuberant ctags from http://ctags.sourceforge.net @@ -1763,14 +1811,14 @@ $(U)nethack.tags: $(CTAGDEP) # $(O)panic.o: $(U)panic.c $(CONFIG_H) - @$(cc) $(cflagsBuild) -Fo$@ $(U)panic.c + @$(cc) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ $(U)panic.c # # sys/share dependencies # (O)cppregex.o: $(O)cppregex.cpp $(HACK_H) - @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\cppregex.cpp + @$(CC) $(cflagsBuild) $(CROSSDEFINES) -Fo$@ ..\sys\share\cppregex.cpp # # curses window port dependencies @@ -1798,126 +1846,126 @@ $(O)curswins.o: $(WCURSES)\curswins.c $(WCURSES)\curswins.h $(INCL)\wincurs.h # $(O)tos.o: ..\sys\atari\tos.c $(HACK_H) $(INCL)\tcap.h - @$(CC) $(cflagsBuild) -Fo$@ ..\sys\atari\tos.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\sys\atari\tos.c $(O)pctty.o: ..\sys\share\pctty.c $(HACK_H) - @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\pctty.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\pctty.c $(O)isaac64.o: ..\src\isaac64.c $(HACK_H) $(INCL)\isaac64.h $(INCL)\integer.h - @$(CC) $(cflagsBuild) -Fo$@ ..\src\isaac64.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\src\isaac64.c $(O)random.o: ..\sys\share\random.c $(HACK_H) - @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\random.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\random.c $(O)ioctl.o: ..\sys\share\ioctl.c $(HACK_H) $(INCL)\tcap.h - @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\ioctl.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\ioctl.c $(O)unixtty.o: ..\sys\share\unixtty.c $(HACK_H) - @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\unixtty.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\sys\share\unixtty.c $(O)unixmain.o: ..\sys\unix\unixmain.c $(HACK_H) $(INCL)\dlb.h - @$(CC) $(cflagsBuild) -Fo$@ ..\sys\unix\unixmain.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\sys\unix\unixmain.c $(O)unixunix.o: ..\sys\unix\unixunix.c $(HACK_H) - @$(CC) $(cflagsBuild) -Fo$@ ..\sys\unix\unixunix.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\sys\unix\unixunix.c $(O)unixres.o: ..\sys\unix\unixres.c $(CONFIG_H) - @$(CC) $(cflagsBuild) -Fo$@ ..\sys\unix\unixres.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\sys\unix\unixres.c $(O)bemain.o: ..\sys\be\bemain.c $(HACK_H) $(INCL)\dlb.h - @$(CC) $(cflagsBuild) -Fo$@ ..\sys\be\bemain.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\sys\be\bemain.c $(O)getline.o: ..\win\tty\getline.c $(HACK_H) $(INCL)\func_tab.h - @$(CC) $(cflagsBuild) -Fo$@ ..\win\tty\getline.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\win\tty\getline.c $(O)termcap.o: ..\win\tty\termcap.c $(HACK_H) $(INCL)\tcap.h - @$(CC) $(cflagsBuild) -Fo$@ ..\win\tty\termcap.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\win\tty\termcap.c $(O)topl.o: ..\win\tty\topl.c $(HACK_H) $(INCL)\tcap.h - @$(CC) $(cflagsBuild) -Fo$@ ..\win\tty\topl.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\win\tty\topl.c $(O)wintty.o: ..\win\tty\wintty.c $(HACK_H) $(INCL)\dlb.h $(INCL)\tcap.h - @$(CC) $(cflagsBuild) -Fo$@ ..\win\tty\wintty.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\win\tty\wintty.c #$(O)Window.o: ..\win\X11\Window.c $(INCL)\xwindowp.h $(INCL)\xwindow.h \ # $(CONFIG_H) # @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\Window.c $(O)dialogs.o: ..\win\X11\dialogs.c $(CONFIG_H) - @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\dialogs.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\dialogs.c $(O)winX.o: ..\win\X11\winX.c $(HACK_H) $(INCL)\winX.h $(INCL)\dlb.h \ ..\win\X11\nh72icon ..\win\X11\nh56icon ..\win\X11\nh32icon - @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winX.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winX.c $(O)winmap.o: ..\win\X11\winmap.c $(INCL)\xwindow.h $(HACK_H) $(INCL)\dlb.h \ $(INCL)\winX.h $(INCL)\tile2x11.h - @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winmap.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winmap.c $(O)winmenu.o: ..\win\X11\winmenu.c $(HACK_H) $(INCL)\winX.h - @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winmenu.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winmenu.c $(O)winmesg.o: ..\win\X11\winmesg.c $(INCL)\xwindow.h $(HACK_H) $(INCL)\winX.h - @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winmesg.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winmesg.c $(O)winmisc.o: ..\win\X11\winmisc.c $(HACK_H) $(INCL)\func_tab.h \ $(INCL)\winX.h - @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winmisc.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winmisc.c $(O)winstat.o: ..\win\X11\winstat.c $(HACK_H) $(INCL)\winX.h - @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winstat.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winstat.c $(O)wintext.o: ..\win\X11\wintext.c $(HACK_H) $(INCL)\winX.h $(INCL)\xwindow.h - @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\wintext.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\wintext.c $(O)winval.o: ..\win\X11\winval.c $(HACK_H) $(INCL)\winX.h - @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winval.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\win\X11\winval.c $(O)tile.o: $(SRC)\tile.c $(HACK_H) $(O)gnaskstr.o: ..\win\gnome\gnaskstr.c ..\win\gnome\gnaskstr.h \ ..\win\gnome\gnmain.h - @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnaskstr.c +# @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnaskstr.c $(O)gnbind.o: ..\win\gnome\gnbind.c ..\win\gnome\gnbind.h ..\win\gnome\gnmain.h \ ..\win\gnome\gnmenu.h ..\win\gnome\gnaskstr.h \ ..\win\gnome\gnyesno.h - @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnbind.c +# @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnbind.c $(O)gnglyph.o: ..\win\gnome\gnglyph.c ..\win\gnome\gnglyph.h $(INCL)\tile2x11.h - @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnglyph.c +# @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnglyph.c $(O)gnmain.o: ..\win\gnome\gnmain.c ..\win\gnome\gnmain.h ..\win\gnome\gnsignal.h \ ..\win\gnome\gnbind.h ..\win\gnome\gnopts.h $(HACK_H) \ $(INCL)\date.h - @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnmain.c +# @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnmain.c $(O)gnmap.o: ..\win\gnome\gnmap.c ..\win\gnome\gnmap.h ..\win\gnome\gnglyph.h \ ..\win\gnome\gnsignal.h $(HACK_H) - @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnmap.c +# @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnmap.c $(O)gnmenu.o: ..\win\gnome\gnmenu.c ..\win\gnome\gnmenu.h ..\win\gnome\gnmain.h \ ..\win\gnome\gnbind.h $(INCL)\func_tab.h - @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnmenu.c +# @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnmenu.c $(O)gnmesg.o: ..\win\gnome\gnmesg.c ..\win\gnome\gnmesg.h ..\win\gnome\gnsignal.h - @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnmesg.c +# @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnmesg.c $(O)gnopts.o: ..\win\gnome\gnopts.c ..\win\gnome\gnopts.h ..\win\gnome\gnglyph.h \ ..\win\gnome\gnmain.h ..\win\gnome\gnmap.h $(HACK_H) - @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnopts.c +# @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnopts.c $(O)gnplayer.o: ..\win\gnome\gnplayer.c ..\win\gnome\gnplayer.h \ ..\win\gnome\gnmain.h $(HACK_H) - @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnplayer.c +# @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnplayer.c $(O)gnsignal.o: ..\win\gnome\gnsignal.c ..\win\gnome\gnsignal.h \ ..\win\gnome\gnmain.h - @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnsignal.c +# @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnsignal.c $(O)gnstatus.o: ..\win\gnome\gnstatus.c ..\win\gnome\gnstatus.h \ ..\win\gnome\gnsignal.h ..\win\gnome\gn_xpms.h \ ..\win\gnome\gnomeprv.h - @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnstatus.c +# @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnstatus.c $(O)gntext.o: ..\win\gnome\gntext.c ..\win\gnome\gntext.h ..\win\gnome\gnmain.h \ ..\win\gnome\gn_rip.h - @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gntext.c +# @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gntext.c $(O)gnyesno.o: ..\win\gnome\gnyesno.c ..\win\gnome\gnbind.h ..\win\gnome\gnyesno.h - @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnyesno.c +# @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnyesno.c $(O)gnworn.o: ..\win\gnome\gnworn.c ..\win\gnome\gnworn.h ..\win\gnome\gnglyph.h \ ..\win\gnome\gnsignal.h ..\win\gnome\gnomeprv.h - @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnworn.c +# @$(CC) $(cflagsBuild) $(GNOMEINC) -Fo$@ ..\win\gnome\gnworn.c $(O)wingem.o: ..\win\gem\wingem.c $(HACK_H) $(INCL)\func_tab.h $(INCL)\dlb.h \ $(INCL)\patchlevel.h $(INCL)\wingem.h - @$(CC) $(cflagsBuild) -Fo$@ ..\win\gem\wingem.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\win\gem\wingem.c $(O)wingem1.o: ..\win\gem\wingem1.c $(INCL)\gem_rsc.h $(INCL)\load_img.h \ $(INCL)\gr_rect.h $(INCL)\wintype.h $(INCL)\wingem.h - @$(CC) $(cflagsBuild) -Fo$@ ..\win\gem\wingem1.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\win\gem\wingem1.c $(O)load_img.o: ..\win\gem\load_img.c $(INCL)\load_img.h @$(CC) $(cflagsBuild) -Fo$@ ..\win\gem\load_img.c $(O)gr_rect.o: ..\win\gem\gr_rect.c $(INCL)\gr_rect.h - @$(CC) $(cflagsBuild) -Fo$@ ..\win\gem\gr_rect.c +# @$(CC) $(cflagsBuild) -Fo$@ ..\win\gem\gr_rect.c $(O)tile.o: $(SRC)\tile.c $(HACK_H) $(O)qt_win.o: ..\win\Qt\qt_win.cpp $(HACK_H) $(INCL)\func_tab.h \ $(INCL)\dlb.h $(INCL)\patchlevel.h $(INCL)\tile2x11.h \ $(INCL)\qt_win.h $(INCL)\qt_clust.h $(INCL)\qt_kde0.h \ $(INCL)\qt_xpms.h qt_win.moc qt_kde0.moc qttableview.moc - $(CXX) $(CXXFLAGS) -Fo$@ ..\win\Qt\qt_win.cpp +# $(CXX) $(CXXFLAGS) -Fo$@ ..\win\Qt\qt_win.cpp $(O)qt_clust.o: ..\win\Qt\qt_clust.cpp $(INCL)\qt_clust.h - $(CXX) $(CXXFLAGS) -Fo$@ ..\win\Qt\qt_clust.cpp +# $(CXX) $(CXXFLAGS) -Fo$@ ..\win\Qt\qt_clust.cpp $(O)qttableview.o: ..\win\Qt\qttableview.cpp $(INCL)\qttableview.h - $(CXX) $(CXXFLAGS) -Fo$@ ..\win\Qt\qttableview.cpp +# $(CXX) $(CXXFLAGS) -Fo$@ ..\win\Qt\qttableview.cpp $(O)wc_chainin.o: ..\win\chain\wc_chainin.c $(HACK_H) - @$(cc) $(cflagsBuild) -Fo$@ ..\win\chain\wc_chainin.c +# @$(cc) $(cflagsBuild) -Fo$@ ..\win\chain\wc_chainin.c $(O)wc_chainout.o: ..\win\chain\wc_chainout.c $(HACK_H) - @$(cc) $(cflagsBuild) -Fo$@ ..\win\chain\wc_chainout.c +# @$(cc) $(cflagsBuild) -Fo$@ ..\win\chain\wc_chainout.c $(O)wc_trace.o: ..\win\chain\wc_trace.c $(HACK_H) $(INCL)\func_tab.h - @$(cc) $(cflagsBuild) -Fo$@ ..\win\chain\wc_trace.c +# @$(cc) $(cflagsBuild) -Fo$@ ..\win\chain\wc_trace.c $(O)vis_tab.o: vis_tab.c $(CONFIG_H) $(INCL)\vis_tab.h $(O)allmain.o: allmain.c $(HACK_H) $(O)alloc.o: alloc.c $(CONFIG_H) @@ -2023,11 +2071,11 @@ $(O)uhitm.o: uhitm.c $(HACK_H) $(O)vault.o: vault.c $(HACK_H) $(O)version.o: version.c $(HACK_H) $(INCL)\dlb.h $(INCL)\date.h \ $(INCL)\patchlevel.h + @$(cc) $(cflagsBuild) $(CROSSCOMPILE) $(CROSSDEFINE_TARGET) -Fo$@ version.c $(O)vision.o: vision.c $(HACK_H) $(INCL)\vis_tab.h $(O)weapon.o: weapon.c $(HACK_H) $(O)were.o: were.c $(HACK_H) $(O)wield.o: wield.c $(HACK_H) -$(O)windmain.o: $(MSWSYS)\windmain.c $(HACK_H) #$(O)windows.o: windows.c $(HACK_H) $(INCL)\wingem.h $(INCL)\winGnome.h $(O)wizard.o: wizard.c $(HACK_H) $(INCL)\qtext.h $(O)worm.o: worm.c $(HACK_H) $(INCL)\lev.h diff --git a/util/makedefs.c b/util/makedefs.c index 608491894..c6a7a8cb4 100644 --- a/util/makedefs.c +++ b/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; - - 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; - } - return u1 - u2; -} - -static char save_bones_compat_buf[BUFSZ]; + const char *optline; + int infocontext = 0; -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); + 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); + } + while ((optline = do_runtime_info(&infocontext))) + Fprintf(ofp, "%s\n", optline); + Fclose(ofp); + return; } -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 diff --git a/util/readtags.c b/util/readtags.c index 4f730b43d..d9225ae48 100644 --- a/util/readtags.c +++ b/util/readtags.c @@ -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"); diff --git a/win/win32/mhmain.c b/win/win32/mhmain.c index 15da747ce..19f04114e 100644 --- a/win/win32/mhmain.c +++ b/win/win32/mhmain.c @@ -4,7 +4,11 @@ #include "winMS.h" #include +#if !defined(CROSSCOMPILE) #include "date.h" +#else +#include "config.h" +#endif #include "patchlevel.h" #include "resource.h" #include "mhmsg.h" @@ -1063,11 +1067,11 @@ About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SetDlgItemText(hDlg, IDC_ABOUT_VERSION, NH_A2W(buf, wbuf, sizeof(wbuf))); + Sprintf(buf, "%s\n%s\n%s\n%s", + COPYRIGHT_BANNER_A, COPYRIGHT_BANNER_B, + COPYRIGHT_BANNER_C, COPYRIGHT_BANNER_D); SetDlgItemText(hDlg, IDC_ABOUT_COPYRIGHT, - NH_A2W(COPYRIGHT_BANNER_A "\n" COPYRIGHT_BANNER_B - "\n" COPYRIGHT_BANNER_C - "\n" COPYRIGHT_BANNER_D, - wbuf, BUFSZ)); + NH_A2W(buf, wbuf, sizeof(wbuf))); /* center dialog in the main window */ GetWindowRect(GetNHApp()->hMainWnd, &main_rt); diff --git a/win/win32/mhsplash.c b/win/win32/mhsplash.c index dcb698450..c5600177d 100644 --- a/win/win32/mhsplash.c +++ b/win/win32/mhsplash.c @@ -8,7 +8,11 @@ #include "mhsplash.h" #include "mhmsg.h" #include "mhfont.h" +#if !defined(CROSSCOMPILE) #include "date.h" +#else +#include "config.h" +#endif #include "patchlevel.h" #include "dlb.h"