XCOMM platform:  $Xorg: FreeBSD.cf,v 1.3 2000/08/17 19:41:45 cpqbld Exp $
XCOMM
XCOMM
XCOMM
XCOMM platform:  $XFree86: xc/config/cf/FreeBSD.cf,v 3.112 2002/01/03 16:33:49 tsi Exp $

#ifndef UseElfFormat
#define UseElfFormat		DefaultToElfFormat
#endif

#if UseElfFormat
#define OSBinaryFormat		[ELF]
#else
#define OSBinaryFormat		[a.out]
#endif

#ifndef OSName
#define OSName			DefaultOSName OSBinaryFormat
#endif
#ifndef OSVendor
#define OSVendor		/**/
#endif
#ifndef OSMajorVersion
#define OSMajorVersion		DefaultOSMajorVersion
#endif
#ifndef OSMinorVersion
#define OSMinorVersion		DefaultOSMinorVersion
#endif
#ifndef OSTeenyVersion
#define OSTeenyVersion		DefaultOSTeenyVersion
#endif

#ifndef OSRelVersion
/* Include this to get finer-grained information about the OS version */
#include "/usr/include/osreldate.h"
#define OSRelVersion __FreeBSD_version
#endif

XCOMM operating system:  OSName (OSMajorVersion./**/OSMinorVersion./**/OSTeenyVersion) (OSRelVersion)


#define HasCplusplus		YES
#define GccUsesGas		YES
#define UseGas			YES
#define GnuCpp			YES
#define HasNdbm			YES
#define HasPutenv		YES
#define HasSnprintf		YES
#define HasBSD44Sockets 	YES
#define HasDlopen		YES
#ifndef HasLibCrypt
# define HasLibCrypt		YES
#endif
#ifndef HasShm
# define HasShm			YES
#endif
#define HasWChar32		YES
#define HasUsableFileMmap	YES
#define HasNCurses		YES
#define HasVarRun		YES
#define HasVarDb		YES

#if (OSMajorVersion > 1)
#define InstallXloadSetGID	NO
#else
#define InstallXloadSetGID	YES
#endif

/*
 * Multi-thread safe libs 
 */	
/* 2.2.7 and later has libc_r (POSIX threads) */
#if OSMajorVersion == 2 && OSMinorVersion == 2 && OSTeenyVersion >= 7 || \
    OSMajorVersion >= 3
# ifndef HasLibPthread
#  define HasLibPthread		NO
# endif
# define HasPosixThreads	YES
# define ThreadedX		YES
/*
 * math.h uses _REENTRANT and stdio.h uses _THREAD_SAFE, so define both.
 */
# define SystemMTDefines	-D_REENTRANT -D_THREAD_SAFE
/*
 * FreeBSD has tread-safe api but no getpwnam_r yet.
 */
# define HasThreadSafeAPI	YES
# define MTSafeAPIDefines	-DXUSE_MTSAFE_API -DXNO_MTSAFE_PWDAPI
# if HasLibPthread
#  define ThreadsLibraries	-lpthread
# else
#  define BuildThreadStubLibrary  YES 
#  define NeedUIThrStubs          YES 
#  define ThreadsCompileFlags	-pthread
#  define ThreadsLibraries 	-pthread
#  define SharedX11Reqs		$(LDPRELIB) $(XTHRSTUBLIB)
#  define SharedXtReqs		$(LDPRELIB) $(XLIBONLY) $(SMLIB) $(ICELIB) $(XTHRSTUBLIB)
# endif
#endif

#define AvoidNullMakeCommand	YES
#define StripInstalledPrograms	YES
#define CompressAllFonts	YES
#define Malloc0ReturnsNull	YES
#define NeedConstPrototypes	YES
#define NeedFunctionPrototypes	YES
#define NeedNestedPrototypes	YES
#define NeedVarargsPrototypes	YES
#define NeedWidePrototypes	NO

#define HasPlugin		YES
#define VendorHasX11R6_3libXext	YES	/* XC or XFree86 >= 3.3.1 */

#define MkdirHierCmd		mkdir -p

#ifndef LexCmd
#define LexCmd			flex -l
#endif
#ifndef HasFlex
#define HasFlex			YES
#endif

#ifndef HasMktemp
#if (OSMajorVersion >= 4) || (OSMajorVersion == 3 && OSMinorVersion >= 1) || \
	(OSMajorVersion == 2 && OSMinorVersion == 2 && OSTeenyVersion >= 7)
#define HasMktemp		YES
#else
#define HasMktemp		NO
#endif
#endif

/*
 * 2.2.x has perl 4 by default, not perl 5.
 */
#if (OSMajorVersion <= 2)
#ifndef HasPerl5
#define HasPerl5		NO
#endif
#endif

/*
 * Add an LD_LIBRARY_PATH environment variable, defined by $(CLIENTENVSETUP),
 * when building X to avoid that for each client ld give the message
 *
 *    ld: warning: libXThrStub.so.6, needed by libX11.so, not found
 */
#if BuildThreadStubLibrary && !UseInstalled
# define CcCmd			$(CLIENTENVSETUP) cc
# define CplusplusCmd		$(CLIENTENVSETUP) c++
#else
# define CcCmd			cc
# define CplusplusCmd		c++
#endif

#define CppCmd			/usr/bin/cpp
#define PreProcessCmd		CppCmd
#define StandardCppOptions	-traditional
#define StandardCppDefines	/**/
#ifndef DefaultCCOptions
#if defined(UseInstalled)
#define DefaultCCOptions	/**/
#else
#define DefaultCCOptions	-ansi -pedantic -Dasm=__asm GccWarningOptions
#endif
#endif
#ifndef ExtraLibraries
/* support for multi-byte locales is in libxpg4 rather than libc */
#if (OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion >= 2)) && \
    !(OSMajorVersion == 4 && OSRelVersion >= 400020) && \
    !(OSRelVersion >= 500005)
#define ExtraLibraries		-lxpg4
#else
#define ExtraLibraries		/**/
#endif
#endif
#ifndef UseGnuMalloc
/* 2.2 doesn't really have GnuMalloc */
#if OSMajorVersion < 2 || (OSMajorVersion == 2 && OSMinorVersion < 2)
#define UseGnuMalloc		YES
#else
#define UseGnuMalloc		NO
#endif
#endif
/* 2.2.2 and later has setusercontext() */
#if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion > 2) || \
     (OSMajorVersion == 2 && OSMinorVersion == 2 && OSTeenyVersion >= 2)
#define HasSetUserContext	YES
#endif

/* 3.3(?) and later has support for setting MTRRs */
#ifndef HasMTRRSupport
#if OSMajorVersion > 3 || (OSMajorVersion == 3 && OSMinorVersion >= 3)
#define HasMTRRSupport		YES
#else
#define HasMTRRSupport		NO
#endif
#endif

/*
 * Drivers that don't need AGP can work with 4.0, but we don't have a
 * mechanism for specifying a subset of drivers in the OS.cf files yet.
 */
#ifndef BuildXF86DRI
#if OSMajorVersion >= 5 || (OSMajorVersion == 4 && OSMinorVersion >= 1)
#define BuildXF86DRI		YES
#endif
#endif

/*
 * 4.1/i386 and 5.0/i386 have the AGP driver.
 */
#ifndef HasAgpGart
#if defined(i386Architecture) && \
	(OSMajorVersion >= 5 || (OSMajorVersion == 4 && OSMinorVersion >= 1))
#define HasAgpGart		YES
#endif
#endif

/* 
 * This doesn't work the way it does on every other system. On FreeBSD it's
 * only a "hint, not a demand", whatever that means. Note that this is not 
 * what it says in the ld and ld.so man pages, which are rather vague on the
 * matter.
 *
 * But we do know that if a) you do what the X Project team does and set your 
 * ProjectRoot to something like "/X11", and b) you have other X libraries, 
 * e.g. in /usr/X11R6/lib, and you have added /usr/X11R6/lib to your 
 * ld.so.cache with ldconfig, then any programs linked with this "hint" will
 * find that ld.so ignores the "hint" at runtime and loads the libraries in 
 * the ld.so.cache, i.e.the wrong ones, instead! Empirically we find that
 * the run-path is only used as a last resort to find the libraries, after
 * the LD_LIBRARY_PATH and ld.so.cache.
 *
 * N. B. to FreeBSD users who are not familiar with the semantics of the run-
 * path on other systems. The run-path is akin to a per-program ld.so.cache. 
 * If a program is linked with a run-path, that run-path should take 
 * precedence over _everything_ else! In my opinion ldconfig and the 
 * ld.so.cache should be deprecated immediately now that FreeBSD has run-
 * paths. Any program that needs libraries that are outside the "well known" 
 * locations should be linked with a run-path.
 *
 * All of which begs the question: If this option doesn't work in any useful
 * way, why did they (FreeBSD) bother to add it? It would be nice if FreeBSD
 * would fix ld.so so that run-paths are truly useful.
 *
 * Using run-paths is added with the intent that vendors who ship X for 
 * FreeBSD should use it too. Once everyone uses it then there will be no 
 * reason for FreeBSD to assume that it knows where X libraries are installed 
 * and they can remove it from the list of directories they add to ld.so.cache 
 * in their /etc/rc file.
 */
#if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion >= 2)
#ifndef ExtraLoadFlags
#if UseElfFormat
#define ExtraLoadFlags		-Wl,-rpath,$(USRLIBDIRPATH)
#else
#define ExtraLoadFlags		-Wl,-R,$(USRLIBDIRPATH)
#endif
#endif
#endif

#ifndef SharedLibraryLoadFlags
#if UseElfFormat
#define SharedLibraryLoadFlags	-shared -rpath $(USRLIBDIRPATH)
#else
#define SharedLibraryLoadFlags	-Bshareable -R $(USRLIBDIRPATH)
#endif
#endif

#ifndef GnuMallocLibrary
#define GnuMallocLibrary	-lgnumalloc
#endif

#if (OSMajorVersion > 2) || (OSMajorVersion == 2 && OSMinorVersion >= 2) \
	|| (OSMajorVersion == 2 && OSMinorVersion == 1 && OSTeenyVersion >= 6)
/* 2.1.6 and 2.2 have libz */
#ifndef HasZlib
#define HasZlib		YES
#endif
#endif

/* PAM appeared in FreeBSD 3.1 */
#if (OSMajorVersion > 3) || (OSMajorVersion == 3 && OSMinorVersion >=1 )
#ifndef HasPam
#define HasPam		YES
#endif
#endif

/*
 * For FreeBSD 2.2.5 and later don't make any assumptions about the version
 * of Tcl in the base OS.
 *
 * Note the static libs in some versions of the FreeBSD packages are
 * broken.  The symptom of this is unresolved symbols when linking
 * XF86Setup.  If you run into this problem, either build your own
 * static libs from the standard Tcl and Tk source, or change the
 * definitions of XF86SetupUsesStatic{Tcl,Tk}.  The latter is not
 * recommended for binaries that are going to be redistributed.
 */

#if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion > 2) || \
    (OSMajorVersion == 2 && OSMinorVersion == 2 && OSTeenyVersion > 5)
/*
 * For 2.2.6, 3.0 and later the defaults assume that the tcl-8.0 and tk-8.0
 * packages have been installed.  XF86Setup is much faster with 8.x than
 * with earlier versions.
 *
 */

#ifndef TkLibName
#define TkLibName		tk80
#endif
#ifndef TkIncDir
#define TkIncDir		/usr/local/include/tk8.0
#endif
#ifndef TclLibName
#define TclLibName		tcl80
#endif
#ifndef TclIncDir
#define TclIncDir		/usr/local/include/tcl8.0
#endif

#elif OSMajorVersion == 2 && OSMinorVersion == 2 && OSTeenyVersion > 2
/*
 * For 2.2.5, the defaults assume that the tcl-7.6 and tk-4.2
 * packages have been installed.
 */

#ifndef TkLibName
#define TkLibName		tk42
#endif
#ifndef TkIncDir
#define TkIncDir		/usr/local/include/tk4.2
#endif
#ifndef TclLibName
#define TclLibName		tcl76
#endif
#ifndef TclIncDir
#define TclIncDir		/usr/local/include/tcl7.6
#endif

#elif OSMajorVersion == 2 && OSMinorVersion == 2
/*
 * FreeBSD 2.2 prior to 2.2.5
 *
 * tcl is part of the base OS.
 *
 * Note: the tk-4.1 package for FreeBSD doesn't have the static lib, so
 * you'll have to build it yourself, or change the definition of
 * XF86SetupUsesStaticTk.
 */
#ifndef TkLibName
#define TkLibName		tk41
#endif
#ifndef TclLibName
#define TclLibName		tcl
#endif
#ifndef TclLibDir
#define TclLibDir		/usr/lib
#endif
#ifndef TclIncDir
#define TclIncDir		/usr/include
#endif
/* FreeBSD 2.2 has libtcl in the base system */
#ifndef XF86SetupUsesStaticTcl
#define XF86SetupUsesStaticTcl	NO
#endif

#else /* ! 2.2 or later */

#if OSMajorVersion == 2 && OSMinorVersion == 1 && OSTeenyVersion >= 6

/*
 * 2.1.x with x >=6 has tk 4.1 and tcl 7.5 in the packages collection.
 * Neither packages include the static libs, so you either need to build
 * them yourself or set XF86SetupUsesStaticTcl and XF86SetupUsesStaticTk
 * to NO.  This isn't the default because we don't want the XFree86
 * binaries to have these packages as a dependency.
 */

#ifndef TkLibName
#define TkLibName		tk41
#endif
#ifndef TclLibName
#define TclLibName		tcl75
#endif

#else /* ! 2.1.6 or later */

#ifndef TkLibName
#define TkLibName		tk40
#endif
#ifndef TclLibName
#define TclLibName		tcl74
#endif

#endif
#endif

#undef  InstallCmd
#define InstallCmd		/usr/bin/install

#if UseElfFormat
# define AsmElfDefines		-D__ELF__
#else
# define AsmElfDefines /**/
#endif

#if GccUsesGas
# define GccGasOption		-DGCCUSESGAS
# define AsmDefines		-DUSE_GAS AsmElfDefines
#else
# define GccGasOption /**/
# define AsmDefines		AsmElfDefines
#endif

#ifdef i386Architecture
#define ServerExtraDefines GccGasOption XFree86ServerDefines
#endif
#ifdef AlphaArchitecture
#define ServerExtraDefines GccGasOption XFree86ServerDefines -D_XSERVER64
#endif

#define StandardDefines	-DCSRG_BASED

#if OSMajorVersion > 1
#define ServerOSDefines		XFree86ServerOSDefines -DDDXTIME
#define XawI18nDefines		-DUSE_XWCHAR_STRING
#define HasMakefileSafeInclude	YES
#define IncludeMakefile(file) @@# dependencies are in .depend
#define DependFileName		.depend
#ifndef DoLoadableServer
#define DoLoadableServer	YES
#endif
#ifndef ForceNormalLib
#define ForceNormalLib		YES
#endif
#define HasMkstemp		YES
#else
#define ServerOSDefines		XFree86ServerOSDefines -DDDXTIME -DXNO_SYSCONF
#define XawI18nDefines		-DUSE_XWCHAR_STRING -DUSE_XMBTOWC
#endif

/* The GCC strength-reduce bug is fixed for FreeBSD 2.1.5 and later */
#ifndef DefaultGcc2i386Opt
#if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion > 1) || (OSMajorVersion == 2 && OSMinorVersion == 1 && OSTeenyVersion >= 5)
#define DefaultGcc2i386Opt -O2
#endif
#endif

#ifdef i386Architecture
# define OptimizedCDebugFlags DefaultGcc2i386Opt
#else
# define OptimizedCDebugFlags -O
#endif

#ifndef PreIncDir
# define PreIncDir	/usr/include
#endif

#define HasGroff	YES
#define NroffCmd	groff -Tascii
#define SetTtyGroup	YES

#ifndef ExtraFilesToClean
# define ExtraFilesToClean *.core
#endif

#define DefaultUserPath		/bin:/usr/bin:/sbin:/usr/sbin:$(BINDIR):/usr/gnu/bin:/usr/local/bin
#define DefaultSystemPath	/bin:/usr/bin:/sbin:/usr/sbin:$(BINDIR)
#ifndef SystemManDirectory
#define SystemManDirectory	/usr/share/man
#endif

#define InstKmemFlags	-g kmem -m 2755

/*
 * Compress manual pages
 */
#ifndef CompressManPages
# define CompressManPages	YES
#endif

#if OSMajorVersion > 2 || (OSMajorVersion == 2 && OSMinorVersion >= 1)
#define HasBsdMake	YES
#endif

#ifndef StaticLibrary
#define StaticLibrary(libpath,libname) -Wl,-Bstatic Concat(-L,libpath) Concat(-l,libname) -Wl,-Bdynamic
#endif

#if UseElfFormat
#define DlLibrary		-rdynamic
#else
#define DlLibrary		/**/
#endif

#ifdef AlphaArchitecture
#define IoLibrary		-lio
#else
#define IoLibrary		/**/
#endif

#define ServerExtraSysLibs	IoLibrary
 
#ifndef PamLibraries
#define PamLibraries		-lpam DlLibrary
#endif

/*
 * On FreeBSD, the run-time loader will use the built-in "rpath" before
 * LD_LIBRARY_PATH.  This means that utilities like mkfontdir will load
 * installed libraries (if they exist) in preference to the ones in the
 * build tree, even though LD_LIBRARY_PATH points to the build tree.
 * This can result in the build failing.  One way to avoid this is to
 * pre-load the libraries from the build tree.
 *
 * There should be a better way than this hack...
 */
#if UseElfFormat
#ifndef PreloadFontSetup
#define PreloadFontSetup	LD_PRELOAD="`(cd $(XENVLIBDIR); echo libXfont*.so.?)`"
#endif
#ifndef PreloadSetup
#define PreloadSetup		LD_PRELOAD="`(cd $(XENVLIBDIR); echo lib[A-f]*.so.? | grep -v Xfont)`"
#endif
#endif

#ifndef HasCookieMaker
/* Which versions have /dev/urandom? */
#if OSMajorVersion >= 4
#define HasCookieMaker		YES
#define MkCookieCmd \
	'dd if=/dev/urandom bs=16 count=1 2>/dev/null | hexdump -e \\"%08x\\"'
#else
#define HasCookieMaker		NO
#endif
#endif

/*
 * A hack to work around an optimization problem with gcc 2.95.2
 */
#if OSMajorVersion >= 4
#define GccOptBug295
#endif

#include <bsdLib.rules>

#include <xfree86.cf>
