/*
 * This file will be included by various Imakefiles in the directories
 * below this.
 * Before compiling, you might need to change some of the default
 * variables.  Read through this file and change what is appropriate
 * for your system.
 */

#define MAKE
#include "../include/version.h"
#undef MAKE

#ifndef Concat
#if __STDC__ && !defined(UnixCpp)
#define Concat(a,b)a##b
#else
#define Concat(a,b)a/**/b
#endif
#endif

/* Openwindows 3.0 seems to be missing this */
#ifndef NullParameter
#define NullParameter
#endif


/* if [ -d ] or [ ! -d ] causes make to fail, define this as - */
#ifndef DirFailPrefix
#define DirFailPrefix
#endif


#ifndef MakeDir
#define MakeDir(dir) DirFailPrefix@if [ -d dir ]; then set +x; \        @@\
                else (set -x; $(MKDIRHIER) dir); fi
#endif /* MakeDir */



/*
 * package making
 */

VERSION = crossfire-/**/Version/**/PatchLevel
/*VERSION = crossfire-0.90.4*/
#define ArchiveNoArch /* no archetype hierachy to packet */
/* #define ArchiveNoMaps /* no map hierachy to packet (no effect yet,9310) */

/* CrossFire is only defined in sub-directories. Only in subdirectories is
 * the include path right so that ../ has precedence over config/
 * Luckily we don't need ../crosssite.def in the top directory.
 */
#ifdef CrossFire
#ifdef AIXArchitecture
#include "../config/crosssite.def"
#else
#include <crosssite.def>
#endif
#endif

MANSUFFIX = 6
MANPATH = /usr/local/man /* Comment this away if you install as root */

#ifdef CManPath
MANPATH = CManPath
#endif
#ifdef CManSuffix
MANSUFFIX = CManSuffix
#endif

/*
 * Leave CDebug uncommented if you only want to play, not debug.
 */
#ifdef CDebug
#ifdef HasGcc
/* Gcc is nice.  Lets us use both the -g and -O flags
 */
DEBUGFLAGS = -g -DDEBUG -O /* define if you want to get useful corefiles */
#else
DEBUGFLAGS = -g -DDEBUG /* define if you want to get useful corefiles */
#endif
#endif

#ifdef CProf
#ifdef HPArchitecture
DEBUGFLAGS = -g -DDEBUG -p -y	/* For studying performance with prof */
#else
DEBUGFLAGS = -static -g -DDEBUG -pg -O 	/* For studying performance with prof */
#endif
#endif

/* Use this, since CDEBUGFLAGS will be used in both the link
 * and normal compile phase.
 */
CDEBUGFLAGS = $(DEBUGFLAGS) $(EXTRA_FLAGS)

#ifndef NoLongJumps
NOLONGJUMPS = -DLONGJUMP
#endif

#ifdef StupidSunHeaders
STUPIDSUNHEADERS = -DStupidSunHeaders
#endif

#ifdef XPM_PIX
#ifdef Xpm_LibDir
/* Concat(-L,Xpm_LibDir) doesn't work right (At least not on my
 * sun 3).  Instead of replacing Xpm_LibDir with its defined value,
 * it instead becomes -LXpm_LibDir.  I don't know if this is because
 * the preprocessor used is the one that comes with standard sun
 * systems, and thus does not understand something, or if there
 * is some other problem.  In any case, by doing it with
 * the following method, it works, and will hopefully work on
 * other systems  -- master@rahul.net
 */
XPM_LIBDIR = -L/**/Xpm_LibDir
#endif
#ifdef Xpm_Include
XPM_DEFINES = -DXpm_Pix -I/**/Xpm_Include
#else
XPM_DEFINES = -DXpm_Pix
#endif
XPM_LIBS = $(XPM_LIBDIR) -lXpm
#endif

#ifdef DEBUG_MALLOC
#ifdef DEBUG_DMALLOC
MALLOC_DEFINES = -DDMALLOC
MALLOC_LIBS = /usr/local/lib/libdmalloc.a
#else
MALLOC_DEFINES = -DDEBUG_MALLOC_LEVEL=DEBUG_MALLOC_LEVEL
MALLOC_LIBS = /usr/lib/debug/malloc.o
#endif
#endif

#ifdef Extra_Flags
EXTRA_FLAGS = Extra_Flags
#endif

EXTRA_DEFINES = $(NOLONGJUMPS) $(STUPIDSUNHEADERS) $(XPM_DEFINES) \
	$(MALLOC_DEFINES)  $(SOUND_DEF) $(EUTL_DEFINES)

#ifdef ForceCCOPTIONS
CCOPTIONS = ForceCCOPTIONS /* Some compilers don't like the default -pipe */
#endif

/*
 * Which compiler to use.  It must be able to handle ANSI-C.  gcc -ansi is OK.
 * On anything except sun and hp, the lines should ideally stay commented out.
 */
#ifndef ForceCC
#if defined(SunArchitecture)
#ifdef SunHasAcc
CC = acc
CCOPTIONS = -Xc
#else
CC = gcc -ansi -Wall		/* Suns or other systems without ANSI-C */
#endif
#endif

#ifdef HPArchitecture
CC = cc 			       /* cc on HP-UX, use xmkmf.ansi  */
#if defined (CProf) || defined (CDebug)
CCOPTIONS = -Aa -D_HPUX_SOURCE /* cpp.ansi barfs on -Wp,200000 */
#else
CCOPTIONS = -Aa -D_HPUX_SOURCE +O3 +OS /* cpp.ansi barfs on -Wp,200000 */
#endif
#endif

#ifdef MipsArchitecture
/* CC = cc -Olimit 1000		/* Decstations:  -Olimit 1000 is useful */
CC = gcc -ansi -Wall -Dmips -DMIPS	/* const usage in X11R5 xtoolkits.         */
#endif				/* This only affects crossedit, so if you  */
				/* use /bin/cc you will be able to compile */
				/* crossfire itself. */

#ifdef AlphaArchitecture
CC = cc -std1 -Olimit 1000    /* Alpha */
#endif

#ifdef NeXTArchitecture
CC = cc -DNeXT -DBSD
#endif

/*
 * #ifdef RsArchitecture
 * CC = cc -D__STDC___
 * #endif
 */

#ifdef AIXArchitecture
CC = cc -I../include/
#endif

#ifdef SGIArchitecture
CC = cc -ansi
#endif

#ifdef __pyrsoft
CC = /usr/ccs/bin/cc
CCOPTIONS = -Xa -g
#endif

#else
CC = ForceCC
#endif

#ifdef HPArchitecture
TARGET = -Dhpux
#endif
#ifdef SGIArchitecture
TARGET = -Dsgi
#endif
#ifdef pyrSVR4
SYS_LIBRARIES=-lsocket
#endif

#if defined(__FreeBSD__)
SYS_LIBRARIES=-lcrypt
#endif

/*
 * Where to put the executable files
 */
#ifdef CBinDir
C_BINDIR = CBinDir
#else
C_BINDIR = $(BINDIR)
#endif

/*
 * Define this to affect all directories needed for building Crossfire.
 * This will affect the LIBDIR define in config.h
 */
#ifdef CLibDir
C_LIBDIR = CLibDir
#else
C_LIBDIR = $(LIBDIR)/crossfire
#endif

/*
 * Change this to where you want to put the maintainance scripts
 */
ADMDIR = $(C_LIBDIR)/adm

/*
 * Change FONTDIR to where you've put the font file.  Remember "mkfontdir".
 */
#ifdef CFontDir
FONTDIR = CFontDir
#else
FONTDIR = FontDir/misc
#endif

FONTNAME=crossfire

/*
 * If you are using Openwindows, remove the comments around OWIN:
 */
/* #define OWIN */

/*
 * pcf or snf, choose one of these.  DECstations use pcf, most others use snf.
 * SGI are also using pcf fonts, so are all R5 servers. :)
 */
#ifdef ForceFont
FONTTYPE=ForceFont
#else
#ifdef UltrixArchitecture
FONTTYPE=pcf
#else
#if ProjectX >= 5
FONTTYPE=pcf
#else
FONTTYPE=snf
#endif
#endif
#endif

#ifdef SoundEffects

#ifdef RPlayLibDir
RPLAY_LIBDIR = RPlayLibDir
SOUND_LIBS = -L$(RPLAY_LIBDIR) -lrplay
#else
SOUNDS_LIBS = -lrplay
#endif

#ifdef RPlayIncDir
RPLAY_INCDIR = -I/**/RPlayIncDir
#endif

SOUND_DEF = -DSOUND_EFFECTS
#endif

#ifdef Extra_Libraries
EXTRA_LIBRARIES = Extra_Libraries
#endif
