Files
nethack/include/config1.h
nhmall b9b4755fe3 expand sys/unix Makefiles scope
Expand the use of the sys/unix Makefiles to be used for both normal
local builds and installs, as well as cross-compiles for other
platforms/targets.

Up until now, the primary unix Makefiles have treated util/host-side
component compiles, links and target object files just the same as
the game component compiles, links, and target object files.

Unfortunately, that meant that cross-compile effort typically had
to re-invent Makefiles specific to the cross-compile, creating a
maintenance burden and deviation from the typical local unix build
and providing a daunting obstacle to those that want to establish
build for a target environment/platform.

This change distinguishes between util/host-side component builds,
links, and component builds and targets object files destined for
the game (and other target platforms) in the Makefiles.

In theory, this will ease the effort for people that want to try to
resurrect NetHack perhaps on an old platform where it is no longer
viable to build NetHack-3.7 on the platform itself using old, outdated
compile tools, possibly with an old, outdated C dialect.

Some details:

-  Game-related targets in the Makefiles (as opposed to util/host-side
   targets that will be executed on the host), which could be destined
   for another platform in a cross-compile scenario are prefixed with
   $(TARGETPFX) so that they are distinguished.

   The default scenario where no cross-compiler is involved, is to
   define TARGETPFX to nothing, and therefore meant to have no effect.

-  Game-related compile and link commands in the Makefiles and their
   associated command line flags are distinguished from util/host-side
   compile and link commands in the Makefiles by using $(TARGET_CC),
   $(TARGET_CFLAGS), $(TARGET_LINK), $(TARGET_LFLAGS), $(TARGET_CXX),
   $(TARGET_CXXFLAGS), $(TARGET_LIBS).

   Those are used in the Makefile in place of $(CC), $(CFLAGS), $(LINK),
   $(LFLAGS), $(CXX), $(CXXFLAGS), $(LIBS).

   The default scenario where no cross-compiler is involved, defines
   the TARGET_ version of those Makefile variables to match their
   typical non-TARGET_ ounterparts.

-  The dependency lists in the Makefiles includes the $(TARGETPFX)
   prefix for stuff that would potentially be produced from a
   cross-compile build.

-  It adds pregame targets and $(PREGAME) variable, so that hints files
   can add some additional stuff if required for a cross-compile
   scenario.

   The default scenario where no cross-compiler is involved doesn't
   do anything for $(PREGAME).

-  It adds $(BUILDMORE) target and variable, so that hints files
   can add some additional things to be built for a cross-compile
   scenario.

-  It adds a "package" target and $(PACKAGE) variable, so that hints files
   can add steps for the target platform in a cross-compile
   scenario.

   The "install" target assumes local build and placement and
   isn't really applicable to a cross-compile scenario where the results
   really just need to be bundled up for transport to the target platform.

-  Also, this adds a pair of include files that can be updated with some
   cross-compile recipes as they evolve. They are named "cross-pre.2020"
   (for stuff to be included in the PRE section) and "cross-post.2020"
   for stuff to be included in the POST section via sys/unix/setup.sh.

   Those are included in sys/unix/hints/linux.2020 and
   sys/unix/hints/macOS.2020 hints files.
2020-09-28 16:25:31 -04:00

222 lines
5.0 KiB
C

/* NetHack 3.7 config1.h $NHDT-Date: 1596498530 2020/08/03 23:48:50 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.23 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015. */
/* NetHack may be freely redistributed. See license for details. */
#ifndef CONFIG1_H
#define CONFIG1_H
/*
* MS DOS - compilers
*
* Microsoft C auto-defines MSDOS,
* Borland C auto-defines __MSDOS__,
* DJGPP auto-defines MSDOS.
*/
/* #define MSDOS */ /* use if not defined by compiler or cases below */
#ifdef __MSDOS__ /* for Borland C */
#ifndef MSDOS
#define MSDOS
#endif
#endif
#ifdef __TURBOC__
#define __MSC /* increase Borland C compatibility in libraries */
#endif
#ifdef MSDOS
#undef UNIX
#ifndef CROSSCOMPILE
#define SHORT_FILENAMES
#endif
#endif
/*
* Mac Stuff.
*/
#if defined(__APPLE__) && defined(__MACH__)
#define MACOSX
#endif
#ifdef macintosh /* Auto-defined symbol for MPW compilers (sc and mrc) */
#define MAC
#endif
#ifdef THINK_C /* Think C auto-defined symbol */
#define MAC
#define NEED_VARARGS
#endif
#ifdef __MWERKS__ /* defined by Metrowerks' Codewarrior compiler */
#ifndef __BEOS__ /* BeOS */
#define MAC
#endif
#define NEED_VARARGS
#define USE_STDARG
#endif
#if defined(MAC) || defined(__BEOS__)
#define DLB
#undef UNIX
#endif
#ifdef __BEOS__
#define NEED_VARARGS
#endif
/*
* Amiga setup.
*/
#ifdef AZTEC_C /* Manx auto-defines this */
#ifdef MCH_AMIGA /* Manx auto-defines this for AMIGA */
#ifndef AMIGA
#define AMIGA /* define for Commodore-Amiga */
#endif /* (SAS/C auto-defines AMIGA) */
#define AZTEC_50 /* define for version 5.0 of manx */
#endif
#endif
#ifdef __SASC_60
#define NEARDATA __near /* put some data close */
#else
#ifdef _DCC
#define NEARDATA __near /* put some data close */
#else
#define NEARDATA
#endif
#endif
#ifdef AMIGA
#define NEED_VARARGS
#undef UNIX
#define DLB
#define HACKDIR "NetHack:"
#define NO_MACRO_CPATH
#endif
/*
* Atari auto-detection
*/
#ifdef atarist
#undef UNIX
#ifndef TOS
#define TOS
#endif
#else
#ifdef __MINT__
#undef UNIX
#ifndef TOS
#define TOS
#endif
#endif
#endif
/*
* Windows NT Autodetection
*/
#ifdef _WIN32_WCE
#define WIN_CE
#ifndef WIN32
#define WIN32
#endif
#endif
#if defined(_WIN32) && !defined(WIN32)
#define WIN32
#endif
#ifdef WIN32
#undef UNIX
#undef MSDOS
#define NHSTDC
#define USE_STDARG
#define NEED_VARARGS
#ifndef WIN_CE
#define STRNCMPI
#define STRCMPI
#endif
#endif
#if defined(__linux__) && defined(__GNUC__) && !defined(_GNU_SOURCE)
/* ensure _GNU_SOURCE is defined before including any system headers */
#define _GNU_SOURCE
#endif
#ifdef VMS /* really old compilers need special handling, detected here */
#undef UNIX
#ifdef __DECC
#ifndef __DECC_VER /* buggy early versions want widened prototypes */
#define NOTSTDC /* except when typedefs are involved */
/* [25 or so years later... That was probably uchar widening to */
/* 'unsigned int' rather than anything to do with typedefs. pr] */
#define USE_VARARGS
#else
#define NHSTDC
#define USE_STDARG
#define POSIX_TYPES
#ifndef _DECC_V4_SOURCE /* only def here if not already def'd on comd line */
#define _DECC_V4_SOURCE /* avoid some incompatible V5.x (and later) changes */
#endif
#endif /*__DECC_VER*/
#undef __HIDE_FORBIDDEN_NAMES /* need non-ANSI library support functions */
#ifdef VAXC /* DEC C in VAX C compatibility mode; 'signed' works */
#define signed /* but causes diagnostic about VAX C not supporting it */
#endif
#else /*!__DECC*/
#ifdef VAXC /* must use CC/DEFINE=ANCIENT_VAXC for vaxc v2.2 or older */
#define signed
#ifdef ANCIENT_VAXC /* vaxc v2.2 and earlier [lots of warnings to come] */
#define KR1ED /* simulate defined() */
#define USE_VARARGS
#else /* vaxc v2.3,2.4,or 3.x, or decc in vaxc mode */
#if defined(USE_PROTOTYPES) /* this breaks 2.2 (*forces* use of ANCIENT)*/
#define __STDC__ 0 /* vaxc is not yet ANSI compliant, but close enough */
#include <stddef.h>
#define UNWIDENED_PROTOTYPES
#endif
#define USE_STDARG
#endif
#endif /*VAXC*/
#endif /*__DECC*/
#ifdef VERYOLD_VMS /* v4.5 or earlier; no longer available for testing */
#define USE_OLDARGS /* <varargs.h> is there, vprintf & vsprintf aren't */
#ifdef USE_VARARGS
#undef USE_VARARGS
#endif
#ifdef USE_STDARG
#undef USE_STDARG
#endif
#endif
#endif /*VMS*/
#ifdef vax
/* just in case someone thinks a DECstation is a vax. It's not, it's a mips */
#ifdef ULTRIX_PROTO
#undef ULTRIX_PROTO
#endif
#ifdef ULTRIX_CC20
#undef ULTRIX_CC20
#endif
#endif
#ifdef KR1ED /* For compilers which cannot handle defined() */
#define defined(x) (-x - 1 != -1)
/* Because:
* #define FOO => FOO={} => defined( ) => (-1 != - - 1) => 1
* #define FOO 1 or on command-line -DFOO
* => defined(1) => (-1 != - 1 - 1) => 1
* if FOO isn't defined, FOO=0. But some compilers default to 0 instead of 1
* for -DFOO, oh well.
* => defined(0) => (-1 != - 0 - 1) => 0
*
* But:
* defined("") => (-1 != - "" - 1)
* [which is an unavoidable catastrophe.]
*/
#endif
#endif /* CONFIG1_H */