configure.ac revision b1d344b3
1dnl Copyright © 2003-2007 Keith Packard, Daniel Stone
2dnl
3dnl Permission is hereby granted, free of charge, to any person obtaining a
4dnl copy of this software and associated documentation files (the "Software"),
5dnl to deal in the Software without restriction, including without limitation
6dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
7dnl and/or sell copies of the Software, and to permit persons to whom the
8dnl Software is furnished to do so, subject to the following conditions:
9dnl
10dnl The above copyright notice and this permission notice (including the next
11dnl paragraph) shall be included in all copies or substantial portions of the
12dnl Software.
13dnl
14dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20dnl DEALINGS IN THE SOFTWARE.
21dnl
22dnl Authors: Keith Packard <keithp@keithp.com>
23dnl          Daniel Stone <daniel@fooishbar.org>
24dnl          an unwitting cast of miscellaneous others
25dnl
26dnl Process this file with autoconf to create configure.
27
28AC_PREREQ(2.57)
29AC_INIT([xorg-server], 1.6.5, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
30AC_CONFIG_SRCDIR([Makefile.am])
31AM_INIT_AUTOMAKE([dist-bzip2 foreign])
32AM_MAINTAINER_MODE
33
34RELEASE_DATE="2009-10-11"
35
36dnl this gets generated by autoheader, and thus contains all the defines.  we
37dnl don't ever actually use it, internally.
38AC_CONFIG_HEADERS(include/do-not-use-config.h)
39dnl xorg-server.h is an external header, designed to be included by loadable
40dnl drivers.
41AC_CONFIG_HEADERS(include/xorg-server.h)
42dnl dix-config.h covers most of the DIX (i.e. everything but the DDX, not just
43dnl dix/).
44AC_CONFIG_HEADERS(include/dix-config.h)
45dnl xorg-config.h covers the Xorg DDX.
46AC_CONFIG_HEADERS(include/xorg-config.h)
47dnl xkb-config.h covers XKB for the Xorg and Xnest DDXs.
48AC_CONFIG_HEADERS(include/xkb-config.h)
49dnl xwin-config.h covers the XWin DDX.
50AC_CONFIG_HEADERS(include/xwin-config.h)
51dnl kdrive-config.h covers the kdrive DDX
52AC_CONFIG_HEADERS(include/kdrive-config.h)
53
54AC_PROG_CC
55AM_PROG_AS
56AC_PROG_INSTALL
57AC_PROG_LN_S
58AC_LIBTOOL_WIN32_DLL
59AC_DISABLE_STATIC
60AC_PROG_LIBTOOL
61DOLT
62AC_PROG_MAKE_SET
63PKG_PROG_PKG_CONFIG
64AC_PROG_LEX
65AC_PROG_YACC
66AC_SYS_LARGEFILE
67XORG_PROG_RAWCPP
68AC_PATH_PROG(SED,sed)
69
70dnl Check for dtrace program (needed to build Xserver dtrace probes)
71dnl Also checks for <sys/sdt.h>, since some Linux distros have an 
72dnl ISDN trace program named dtrace
73AC_ARG_WITH(dtrace, AS_HELP_STRING([--with-dtrace=PATH],
74	     [Enable dtrace probes (default: enabled if dtrace found)]),
75	     [WDTRACE=$withval], [WDTRACE=auto])
76dnl Darwin 9 has dtrace, but it doesn't support compilation into ELF...
77if test "x$WDTRACE" = xauto; then
78	case $host_os in
79		darwin*) WDTRACE="no" ;;
80	esac
81fi
82if test "x$WDTRACE" = "xyes" -o "x$WDTRACE" = "xauto" ; then
83	AC_PATH_PROG(DTRACE, [dtrace], [not_found], [$PATH:/usr/sbin])
84	if test "x$DTRACE" = "xnot_found" ; then
85		if test "x$WDTRACE" = "xyes" ; then
86			AC_MSG_FAILURE([dtrace requested but not found])
87		fi
88		WDTRACE="no"
89	else
90		AC_CHECK_HEADER(sys/sdt.h, [HAS_SDT_H="yes"], [HAS_SDT_H="no"])
91		if test "x$WDTRACE" = "xauto" -a "x$HAS_SDT_H" = "xno" ; then
92			WDTRACE="no"
93		fi
94	fi
95fi
96if test "x$WDTRACE" != "xno" ; then
97  AC_DEFINE(XSERVER_DTRACE, 1, 
98      [Define to 1 if the DTrace Xserver provider probes should be built in.])
99fi
100AM_CONDITIONAL(XSERVER_DTRACE, [test "x$WDTRACE" != "xno"])
101
102AC_HEADER_DIRENT
103AC_HEADER_STDC
104AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
105
106dnl Checks for typedefs, structures, and compiler characteristics.
107AC_C_CONST
108AC_C_BIGENDIAN([ENDIAN="X_BIG_ENDIAN"], [ENDIAN="X_LITTLE_ENDIAN"])
109
110AC_CHECK_SIZEOF([unsigned long])
111if test "$ac_cv_sizeof_unsigned_long" = 8; then
112	AC_DEFINE(_XSERVER64, 1, [Define to 1 if unsigned long is 64 bits.])
113fi
114
115AC_TYPE_PID_T
116
117# Checks for headers/macros for byte swapping
118# Known variants:
119#	<byteswap.h> bswap_16, bswap_32, bswap_64  (glibc)
120#	<sys/endian.h> __swap16, __swap32, __swap64 (OpenBSD)
121#	<sys/endian.h> bswap16, bswap32, bswap64 (other BSD's)
122#	and a fallback to local macros if none of the above are found
123
124# if <byteswap.h> is found, assume it's the correct version
125AC_CHECK_HEADERS([byteswap.h])
126
127# if <sys/endian.h> is found, have to check which version
128AC_CHECK_HEADER([sys/endian.h], [HAVE_SYS_ENDIAN_H="yes"], [HAVE_SYS_ENDIAN_H="no"])
129
130if test "x$HAVE_SYS_ENDIAN_H" = "xyes" ; then
131	AC_MSG_CHECKING([for __swap16 variant of <sys/endian.h> byteswapping macros])
132	AC_LINK_IFELSE([AC_LANG_PROGRAM([
133#include <sys/types.h>
134#include <sys/endian.h>
135 ], [
136int a = 1, b;
137b = __swap16(a);
138 ])
139], [SYS_ENDIAN__SWAP='yes'], [SYS_ENDIAN__SWAP='no'])
140	AC_MSG_RESULT([$SYS_ENDIAN__SWAP])
141
142	AC_MSG_CHECKING([for bswap16 variant of <sys/endian.h> byteswapping macros])
143	AC_LINK_IFELSE([AC_LANG_PROGRAM([
144#include <sys/types.h>
145#include <sys/endian.h>
146 ], [
147int a = 1, b;
148b = bswap16(a);
149 ])
150], [SYS_ENDIAN_BSWAP='yes'], [SYS_ENDIAN_BSWAP='no'])
151	AC_MSG_RESULT([$SYS_ENDIAN_BSWAP])
152
153    	if test "$SYS_ENDIAN_BSWAP" = "yes" ; then
154		USE_SYS_ENDIAN_H=yes
155		BSWAP=bswap
156	else	
157	    	if test "$SYS_ENDIAN__SWAP" = "yes" ; then
158			USE_SYS_ENDIAN_H=yes
159			BSWAP=__swap
160		else
161			USE_SYS_ENDIAN_H=no
162		fi
163	fi
164
165	if test "$USE_SYS_ENDIAN_H" = "yes" ; then
166	    AC_DEFINE([USE_SYS_ENDIAN_H], 1, 
167		[Define to use byteswap macros from <sys/endian.h>])
168	    AC_DEFINE_UNQUOTED([bswap_16], ${BSWAP}16, 
169			[Define to 16-bit byteswap macro])
170	    AC_DEFINE_UNQUOTED([bswap_32], ${BSWAP}32, 
171			[Define to 32-bit byteswap macro])
172	    AC_DEFINE_UNQUOTED([bswap_64], ${BSWAP}64, 
173			[Define to 64-bit byteswap macro])
174	fi
175fi
176
177dnl Check to see if dlopen is in default libraries (like Solaris, which
178dnl has it in libc), or if libdl is needed to get it.
179AC_CHECK_FUNC([dlopen], [],
180	AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))
181
182dnl Checks for library functions.
183AC_FUNC_VPRINTF
184AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr \
185		strtol getopt getopt_long vsnprintf walkcontext backtrace \
186		getisax getzoneid shmctl64 strcasestr ffs])
187AC_FUNC_ALLOCA
188dnl Old HAS_* names used in os/*.c.
189AC_CHECK_FUNC([getdtablesize],
190	AC_DEFINE(HAS_GETDTABLESIZE, 1, [Have the 'getdtablesize' function.]))
191AC_CHECK_FUNC([getifaddrs],
192	AC_DEFINE(HAS_GETIFADDRS, 1, [Have the 'getifaddrs' function.]))
193AC_CHECK_FUNC([getpeereid],
194	AC_DEFINE(HAS_GETPEEREID, 1, [Have the 'getpeereid' function.]))
195AC_CHECK_FUNC([getpeerucred],
196	AC_DEFINE(HAS_GETPEERUCRED, 1, [Have the 'getpeerucred' function.]))
197AC_CHECK_FUNC([strlcat], HAVE_STRLCAT=yes, HAVE_STRLCAT=no)
198AM_CONDITIONAL(NEED_STRLCAT, [test x$HAVE_STRLCAT = xno])	
199AC_CHECK_FUNC([strlcpy], AC_DEFINE(HAS_STRLCPY, 1, [Have the 'strlcpy' function]))
200
201AM_CONDITIONAL(NEED_VSNPRINTF, [test x$HAVE_VSNPRINTF = xno])
202
203dnl Check for mmap support for Xvfb
204AC_CHECK_FUNC([mmap], AC_DEFINE(HAS_MMAP, 1, [Have the 'mmap' function.]))
205
206dnl Find the math libary
207AC_CHECK_LIB(m, sqrt)
208AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT, 1, [Have the 'cbrt' function]))
209
210AC_CHECK_HEADERS([ndbm.h dbm.h rpcsvc/dbm.h])
211
212dnl AGPGART headers
213AC_CHECK_HEADERS([linux/agpgart.h sys/agpio.h], AGP=yes)
214AM_CONDITIONAL(AGP, [test "x$AGP" = xyes])
215
216dnl APM header
217AC_CHECK_HEADERS([linux/apm_bios.h], LNXAPM=yes)
218AM_CONDITIONAL(LNXAPM, [test "x$LNXAPM" = xyes])
219
220dnl fbdev header
221AC_CHECK_HEADERS([linux/fb.h], FBDEV=yes)
222AM_CONDITIONAL(FBDEVHW, [test "x$FBDEV" = xyes])
223
224dnl MTRR header
225AC_CHECK_HEADERS([asm/mtrr.h], ac_cv_asm_mtrr_h=yes)
226if test "x$ac_cv_asm_mtrr_h" = xyes; then
227	HAVE_MTRR=yes
228fi
229
230dnl BSD MTRR header
231AC_CHECK_HEADERS([sys/memrange.h], ac_cv_memrange_h=yes)
232if test "x$ac_cv_memrange_h" = xyes; then
233	HAVE_MTRR=yes
234fi
235
236if test "x$HAVE_MTRR" = xyes; then
237	AC_DEFINE(HAS_MTRR_SUPPORT, 1, [MTRR support available])
238fi
239
240dnl A NetBSD MTRR header
241AC_CHECK_HEADERS([machine/mtrr.h], ac_cv_machine_mtrr_h=yes)
242if test "x$ac_cv_machine_mtrr_h" = xyes; then
243	AC_DEFINE(HAS_MTRR_BUILTIN, 1, [Define to 1 if NetBSD built-in MTRR
244		support is available])
245fi
246
247dnl FreeBSD kldload support (sys/linker.h)
248AC_CHECK_HEADERS([sys/linker.h],
249	[ac_cv_sys_linker_h=yes],
250	[ac_cv_sys_linker_h=no],
251	[#include <sys/param.h>])
252AM_CONDITIONAL(FREEBSD_KLDLOAD, [test "x$ac_cv_sys_linker_h" = xyes])
253
254AC_CACHE_CHECK([for SYSV IPC],
255		ac_cv_sysv_ipc,
256		[AC_TRY_LINK([
257#include <sys/types.h>
258#include <sys/ipc.h>
259#include <sys/shm.h>
260],[
261{ 
262    int id;
263    id = shmget(IPC_PRIVATE, 512, SHM_W | SHM_R);
264    if (id < 0) return -1;
265    return shmctl(id, IPC_RMID, 0);
266}],
267	[ac_cv_sysv_ipc=yes],
268	[ac_cv_sysv_ipc=no])])
269if test "x$ac_cv_sysv_ipc" = xyes; then
270	AC_DEFINE(HAVE_SYSV_IPC, 1, [Define to 1 if SYSV IPC is available])
271fi
272
273dnl OpenBSD /dev/xf86 aperture driver 
274if test -c /dev/xf86 ; then
275	AC_DEFINE(HAS_APERTURE_DRV, 1, [System has /dev/xf86 aperture driver])
276fi
277
278dnl BSD APM support 
279AC_CHECK_HEADER([machine/apmvar.h],[
280	AC_CHECK_HEADER([sys/event.h],
281		ac_cv_BSD_KQUEUE_APM=yes,
282		ac_cv_BSD_APM=yes)])
283
284AM_CONDITIONAL(BSD_APM, [test "x$ac_cv_BSD_APM" = xyes])
285AM_CONDITIONAL(BSD_KQUEUE_APM, [test "x$ac_cv_BSD_KQUEUE_APM" = xyes])
286	
287dnl glibc backtrace support check (hw/xfree86/common/xf86Events.c)
288AC_CHECK_HEADER([execinfo.h],[
289    AC_CHECK_LIB(c, backtrace, [
290        AC_DEFINE(HAVE_BACKTRACE, 1, [Has backtrace support])
291        AC_DEFINE(HAVE_EXECINFO_H, 1, [Have execinfo.h])
292    ])]
293)
294
295dnl ---------------------------------------------------------------------------
296dnl Bus options and CPU capabilities.  Replaces logic in
297dnl hw/xfree86/os-support/bus/Makefile.am, among others.
298dnl ---------------------------------------------------------------------------
299DEFAULT_INT10="x86emu"
300
301dnl Override defaults as needed for specific platforms:
302
303case $host_cpu in
304  alpha*)
305	ALPHA_VIDEO=yes
306	case $host_os in
307	        *freebsd*)	SYS_LIBS=-lio ;;
308		*netbsd*)	AC_DEFINE(USE_ALPHA_PIO, 1, [NetBSD PIO alpha IO]) ;;
309	esac
310	GLX_ARCH_DEFINES="-D__GLX_ALIGN64 -mieee"
311	;;
312  arm*)
313	ARM_VIDEO=yes
314	;;
315  i*86)
316	I386_VIDEO=yes
317	case $host_os in
318		*freebsd*)	AC_DEFINE(USE_DEV_IO) ;;
319		*dragonfly*)	AC_DEFINE(USE_DEV_IO) ;;
320		*netbsd*)	AC_DEFINE(USE_I386_IOPL)
321				SYS_LIBS=-li386
322				;;
323		*openbsd*)	AC_DEFINE(USE_I386_IOPL) 
324				SYS_LIBS=-li386
325				;;
326	esac
327        ;;
328  powerpc*)
329	PPC_VIDEO=yes
330	case $host_os in
331		*freebsd*)	DEFAULT_INT10=stub ;;
332	esac
333	;;
334  sparc*)
335	SPARC64_VIDEO=yes
336	BSD_ARCH_SOURCES="sparc64_video.c ioperm_noop.c"
337	GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
338	;;
339  x86_64*|amd64*)
340	I386_VIDEO=yes
341	case $host_os in
342		*freebsd*)	AC_DEFINE(USE_DEV_IO, 1, [BSD /dev/io]) ;;
343		*dragonfly*)	AC_DEFINE(USE_DEV_IO, 1, [BSD /dev/io]) ;;
344		*netbsd*)	AC_DEFINE(USE_I386_IOPL, 1, [BSD i386 iopl])
345				SYS_LIBS=-lx86_64
346				;;
347		*openbsd*)	AC_DEFINE(USE_AMD64_IOPL, 1, [BSD AMD64 iopl])
348				SYS_LIBS=-lamd64
349				;;
350	esac
351	GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
352	;;
353  ia64*)
354  	GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
355	;;
356  s390*)
357  	GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
358	;;
359esac
360AC_SUBST(GLX_ARCH_DEFINES)
361
362dnl BSD *_video.c selection
363AM_CONDITIONAL(ALPHA_VIDEO, [test "x$ALPHA_VIDEO" = xyes])
364AM_CONDITIONAL(ARM_VIDEO, [test "x$ARM_VIDEO" = xyes])
365AM_CONDITIONAL(I386_VIDEO, [test "x$I386_VIDEO" = xyes])
366AM_CONDITIONAL(PPC_VIDEO, [test "x$PPC_VIDEO" = xyes])
367AM_CONDITIONAL(SPARC64_VIDEO, [test "x$SPARC64_VIDEO" = xyes])
368
369DRI=no
370KDRIVE_HW=no
371dnl it would be nice to autodetect these *CONS_SUPPORTs
372case $host_os in
373  *freebsd* | *dragonfly*)
374	case $host_os in
375		kfreebsd*-gnu) ;;
376		*) AC_DEFINE(CSRG_BASED, 1, [System is BSD-like]) ;;
377	esac
378	AC_DEFINE(PCCONS_SUPPORT, 1, [System has PC console])
379	AC_DEFINE(PCVT_SUPPORT, 1, [System has PCVT console])
380	AC_DEFINE(SYSCONS_SUPPORT, 1, [System has syscons console])
381	DRI=yes
382	;;
383  *netbsd*)
384	AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
385	AC_DEFINE(PCCONS_SUPPORT, 1, [System has PC console])
386	AC_DEFINE(PCVT_SUPPORT, 1, [System has PCVT console])
387	AC_DEFINE(WSCONS_SUPPORT, 1, [System has wscons console])
388	DRI=yes
389	;;
390  *openbsd*)
391	AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
392	AC_DEFINE(PCVT_SUPPORT, 1, [System has PC console])
393	AC_DEFINE(WSCONS_SUPPORT, 1, [System has wscons console])
394	;;
395  *linux*)
396	DRI=yes
397	KDRIVE_HW=yes
398	;;
399  *solaris*)
400	PKG_CHECK_EXISTS(libdrm, DRI=yes, DRI=no)
401	;;
402  darwin*)
403	AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
404	;;
405esac
406AM_CONDITIONAL(KDRIVE_HW, test "x$KDRIVE_HW" = xyes)
407
408XORG_RELEASE_VERSION
409dnl augment XORG_RELEASE_VERSION for our snapshot number and to expose the
410dnl major number
411PVMAJOR=`echo $PACKAGE_VERSION | cut -d . -f 1`
412PVS=`echo $PACKAGE_VERSION | cut -d . -f 4 | cut -d - -f 1`
413if test "x$PVS" = "x"; then
414	PVS="0"
415fi
416
417VENDOR_RELEASE="((($PVMAJOR) * 10000000) + (($PVM) * 100000) + (($PVP) * 1000) + $PVS)"
418VENDOR_MAN_VERSION="Version ${PACKAGE_VERSION}"
419
420VENDOR_NAME="The X.Org Foundation"
421VENDOR_NAME_SHORT="X.Org"
422VENDOR_WEB="http://wiki.x.org"
423
424m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))])
425
426dnl Build options.
427AC_ARG_ENABLE(werror,        AS_HELP_STRING([--enable-werror],
428				  [Treat warnings as errors (default: disabled)]),
429			        [WERROR=$enableval], [WERROR=no])
430AC_ARG_ENABLE(debug,         AS_HELP_STRING([--enable-debug],
431				  [Enable debugging (default: disabled)]),
432			        [DEBUGGING=$enableval], [DEBUGGING=no])
433AC_ARG_WITH(int10,           AS_HELP_STRING([--with-int10=BACKEND], [int10 backend: vm86, x86emu or stub]),
434				[INT10="$withval"],
435				[INT10="$DEFAULT_INT10"])
436AC_ARG_WITH(vendor-name,     AS_HELP_STRING([--with-vendor-name=VENDOR],
437				  [Vendor string reported by the server]),
438				[ VENDOR_NAME="$withval" ], [])
439AC_ARG_WITH(vendor-name-short, AS_HELP_STRING([--with-vendor-name-short=VENDOR],
440				  [Short version of vendor string reported by the server]),
441				[ VENDOR_NAME_SHORT="$withval" ], [])
442AC_ARG_WITH(vendor-web,      AS_HELP_STRING([--with-vendor-web=URL],
443				  [Vendor web address reported by the server]),
444				[ VENDOR_WEB="$withval" ], [])
445AC_ARG_WITH(module-dir,      AS_HELP_STRING([--with-module-dir=DIR],
446				  [Directory where modules are installed (default: $libdir/xorg/modules)]),
447				[ moduledir="$withval" ],
448				[ moduledir="${libdir}/xorg/modules" ])
449AC_ARG_WITH(log-dir,         AS_HELP_STRING([--with-log-dir=DIR],
450				  [Directory where log files are kept (default: $localstatedir/log)]),
451				[ logdir="$withval" ],
452				[ logdir="$localstatedir/log" ])
453AC_ARG_WITH(builder-addr,    AS_HELP_STRING([--with-builder-addr=ADDRESS],
454				  [Builder address (default: xorg@lists.freedesktop.org)]),
455				[ BUILDERADDR="$withval" ],
456				[ BUILDERADDR="xorg@lists.freedesktop.org" ])
457AC_ARG_WITH(os-name,         AS_HELP_STRING([--with-os-name=OSNAME], [Name of OS (default: output of "uname -srm")]),
458				[ OSNAME="$withval" ],
459				[ OSNAME=`uname -srm` ])
460AC_ARG_WITH(os-vendor,       AS_HELP_STRING([--with-os-vendor=OSVENDOR], [Name of OS vendor]),
461				[ OSVENDOR="$withval" ],
462				[ OSVENDOR="" ])
463AC_ARG_WITH(builderstring,   AS_HELP_STRING([--with-builderstring=BUILDERSTRING], [Additional builder string]),
464				[ BUILDERSTRING="$withval" ]
465				[ ])
466AC_ARG_WITH(fontdir,         AS_HELP_STRING([--with-fontdir=FONTDIR], [Path to top level dir where fonts are installed (default: ${libdir}/X11/fonts)]),
467                                [ FONTDIR="$withval" ],
468                                [ FONTDIR="${libdir}/X11/fonts" ])
469DEFAULT_FONT_PATH="${FONTDIR}/misc/,${FONTDIR}/TTF/,${FONTDIR}/OTF,${FONTDIR}/Type1/,${FONTDIR}/100dpi/,${FONTDIR}/75dpi/"
470case $host_os in
471	darwin*)    DEFAULT_FONT_PATH="${DEFAULT_FONT_PATH},/Library/Fonts,/System/Library/Fonts" ;;
472esac
473AC_ARG_WITH(default-font-path, AS_HELP_STRING([--with-default-font-path=PATH], [Comma separated list of font dirs]),
474				[ FONTPATH="$withval" ],
475				[ FONTPATH="${DEFAULT_FONT_PATH}" ])
476AC_ARG_WITH(xkb-path,         AS_HELP_STRING([--with-xkb-path=PATH], [Path to XKB base dir (default: ${datadir}/X11/xkb)]),
477				[ XKBPATH="$withval" ],
478				[ XKBPATH="${datadir}/X11/xkb" ])
479AC_ARG_WITH(xkb-output,       AS_HELP_STRING([--with-xkb-output=PATH], [Path to XKB output dir (default: ${datadir}/X11/xkb/compiled)]),
480				[ XKBOUTPUT="$withval" ],
481				[ XKBOUTPUT="compiled" ])
482AC_ARG_WITH(serverconfig-path, AS_HELP_STRING([--with-serverconfig-path=PATH],
483				   [Directory where ancillary server config files are installed (default: ${libdir}/xorg)]),
484				[ SERVERCONFIG="$withval" ],
485				[ SERVERCONFIG="${libdir}/xorg" ])
486AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir=PATH], [Path to the Applications directory (default: /Applications/Utilities)]),
487				[ APPLE_APPLICATIONS_DIR="${withval}" ],
488				[ APPLE_APPLICATIONS_DIR="/Applications/Utilities" ])
489AC_SUBST([APPLE_APPLICATIONS_DIR])
490AC_ARG_WITH(apple-application-name,AS_HELP_STRING([--with-apple-application-name=NAME], [Name for the .app (default: X11)]),
491				[ APPLE_APPLICATION_NAME="${withval}" ],
492				[ APPLE_APPLICATION_NAME="X11" ])
493AC_SUBST([APPLE_APPLICATION_NAME])
494AC_ARG_WITH(apple-application-id,AS_HELP_STRING([--with-apple-application-id=VALUE], [CFBundleIdentification for the .app (default: org.x.X11)]),
495				[ APPLE_APPLICATION_ID="${withval}" ],
496				[ APPLE_APPLICATION_ID="org.x.X11" ])
497AC_SUBST([APPLE_APPLICATION_ID])
498AC_ARG_ENABLE(builddocs,      AS_HELP_STRING([--enable-builddocs], [Build docs (default: disabled)]),
499                                [BUILDDOCS=$enableval],
500                                [BUILDDOCS=no])
501AC_ARG_ENABLE(install-libxf86config,
502				AS_HELP_STRING([--enable-install-libxf86config],
503				[Install libxf86config (default: disabled)]),
504				[INSTALL_LIBXF86CONFIG=$enableval],
505				[INSTALL_LIBXF86CONFIG=no])
506AC_ARG_ENABLE(null-root-cursor, AS_HELP_STRING([--enable-null-root-cursor], [Use an empty root cursor (default: use core cursor)]),
507                                 [NULL_ROOT_CURSOR=$enableval],
508                                 [NULL_ROOT_CURSOR=no])
509
510dnl GLX build options
511AC_ARG_WITH(mesa-source,     AS_HELP_STRING([--with-mesa-source=MESA_SOURCE], [Path to Mesa source tree]),
512                                [ MESA_SOURCE="$withval" ],
513                                [ MESA_SOURCE="" ])
514AC_ARG_WITH(dri-driver-path,  AS_HELP_STRING([--with-dri-driver-path=PATH], [Path to DRI drivers (default: ${libdir}/dri)]),
515				[ DRI_DRIVER_PATH="$withval" ],
516				[ DRI_DRIVER_PATH="${libdir}/dri" ])
517AC_ARG_ENABLE(aiglx,          AS_HELP_STRING([--enable-aiglx], [Build accelerated indirect GLX (default: enabled)]),
518                                [AIGLX=$enableval],
519                                [AIGLX=yes])
520AC_ARG_ENABLE(glx-tls,        AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: disabled)]),
521                                [GLX_USE_TLS=$enableval],
522                                [GLX_USE_TLS=no])
523
524dnl Extensions.
525AC_ARG_ENABLE(registry,       AS_HELP_STRING([--disable-registry], [Build string registry module (default: enabled)]), [XREGISTRY=$enableval], [XREGISTRY=yes])
526AC_ARG_ENABLE(composite,      AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes])
527AC_ARG_ENABLE(mitshm,         AS_HELP_STRING([--disable-shm], [Build SHM extension (default: enabled)]), [MITSHM=$enableval], [MITSHM=yes])
528AC_ARG_ENABLE(xres,           AS_HELP_STRING([--disable-xres], [Build XRes extension (default: enabled)]), [RES=$enableval], [RES=yes])
529AC_ARG_ENABLE(record,         AS_HELP_STRING([--enable-record], [Build Record extension (default: disabled)]), [RECORD=$enableval], [RECORD=no])
530AC_ARG_ENABLE(xv,             AS_HELP_STRING([--disable-xv], [Build Xv extension (default: enabled)]), [XV=$enableval], [XV=yes])
531AC_ARG_ENABLE(xvmc,           AS_HELP_STRING([--disable-xvmc], [Build XvMC extension (default: enabled)]), [XVMC=$enableval], [XVMC=yes])
532AC_ARG_ENABLE(dga,            AS_HELP_STRING([--disable-dga], [Build DGA extension (default: auto)]), [DGA=$enableval], [DGA=auto])
533AC_ARG_ENABLE(screensaver,    AS_HELP_STRING([--disable-screensaver], [Build ScreenSaver extension (default: enabled)]), [SCREENSAVER=$enableval], [SCREENSAVER=yes])
534AC_ARG_ENABLE(xdmcp,          AS_HELP_STRING([--disable-xdmcp], [Build XDMCP extension (default: auto)]), [XDMCP=$enableval], [XDMCP=auto])
535AC_ARG_ENABLE(xdm-auth-1,     AS_HELP_STRING([--disable-xdm-auth-1], [Build XDM-Auth-1 extension (default: auto)]), [XDMAUTH=$enableval], [XDMAUTH=auto])
536AC_ARG_ENABLE(glx,            AS_HELP_STRING([--disable-glx], [Build GLX extension (default: enabled)]), [GLX=$enableval], [GLX=yes])
537AC_ARG_ENABLE(dri,            AS_HELP_STRING([--enable-dri], [Build DRI extension (default: auto)]), [DRI=$enableval])
538AC_ARG_ENABLE(dri2,           AS_HELP_STRING([--enable-dri2], [Build DRI2 extension (default: auto)]), [DRI2=$enableval], [DRI2=auto])
539AC_ARG_ENABLE(xinerama,	      AS_HELP_STRING([--disable-xinerama], [Build Xinerama extension (default: enabled)]), [XINERAMA=$enableval], [XINERAMA=yes])
540AC_ARG_ENABLE(xf86vidmode,    AS_HELP_STRING([--disable-xf86vidmode], [Build XF86VidMode extension (default: auto)]), [XF86VIDMODE=$enableval], [XF86VIDMODE=auto])
541AC_ARG_ENABLE(xace,           AS_HELP_STRING([--disable-xace], [Build X-ACE extension (default: enabled)]), [XACE=$enableval], [XACE=yes])
542AC_ARG_ENABLE(xselinux,       AS_HELP_STRING([--disable-xselinux], [Build SELinux extension (default: disabled)]), [XSELINUX=$enableval], [XSELINUX=no])
543AC_ARG_ENABLE(xcsecurity,     AS_HELP_STRING([--disable-xcsecurity], [Build Security extension (default: disabled)]), [XCSECURITY=$enableval], [XCSECURITY=no])
544AC_ARG_ENABLE(xcalibrate,     AS_HELP_STRING([--enable-xcalibrate], [Build XCalibrate extension (default: disabled)]), [XCALIBRATE=$enableval], [XCALIBRATE=no])
545AC_ARG_ENABLE(tslib,          AS_HELP_STRING([--enable-tslib], [Build kdrive tslib touchscreen support (default: disabled)]), [TSLIB=$enableval], [TSLIB=no])
546AC_ARG_ENABLE(multibuffer,    AS_HELP_STRING([--enable-multibuffer], [Build Multibuffer extension (default: disabled)]), [MULTIBUFFER=$enableval], [MULTIBUFFER=no])
547AC_ARG_ENABLE(dbe,            AS_HELP_STRING([--disable-dbe], [Build DBE extension (default: enabled)]), [DBE=$enableval], [DBE=yes])
548AC_ARG_ENABLE(xf86bigfont,    AS_HELP_STRING([--disable-xf86bigfont], [Build XF86 Big Font extension (default: disabled)]), [XF86BIGFONT=$enableval], [XF86BIGFONT=no])
549AC_ARG_ENABLE(dpms,           AS_HELP_STRING([--disable-dpms], [Build DPMS extension (default: enabled)]), [DPMSExtension=$enableval], [DPMSExtension=yes])
550AC_ARG_ENABLE(config-dbus,    AS_HELP_STRING([--enable-config-dbus], [Build D-BUS API support (default: no)]), [CONFIG_DBUS_API=$enableval], [CONFIG_DBUS_API=no])
551AC_ARG_ENABLE(config-hal,     AS_HELP_STRING([--disable-config-hal], [Build HAL support (default: auto)]), [CONFIG_HAL=$enableval], [CONFIG_HAL=auto])
552AC_ARG_ENABLE(xfree86-utils,     AS_HELP_STRING([--enable-xfree86-utils], [Build xfree86 DDX utilities (default: enabled)]), [XF86UTILS=$enableval], [XF86UTILS=yes])
553
554dnl DDXes.
555AC_ARG_ENABLE(xorg,    	      AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto])
556AC_ARG_ENABLE(dmx,    	      AS_HELP_STRING([--enable-dmx], [Build DMX server (default: no)]), [DMX=$enableval], [DMX=no])
557AC_ARG_ENABLE(xvfb,    	      AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: yes)]), [XVFB=$enableval], [XVFB=yes])
558AC_ARG_ENABLE(xnest,   	      AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: auto)]), [XNEST=$enableval], [XNEST=auto])
559AC_ARG_ENABLE(xquartz,        AS_HELP_STRING([--enable-xquartz], [Build Xquartz server for OS-X (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
560AC_ARG_ENABLE(standalone-xpbproxy, AS_HELP_STRING([--enable-standalone-xpbproxy], [Build a standalone xpbproxy (in addigion to the one integrated into Xquartz as a separate thread) (default: no)]), [STANDALONE_XPBPROXY=$enableval], [STANDALONE_XPBPROXY=no])
561AC_ARG_ENABLE(xwin,    	      AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
562dnl kdrive and its subsystems
563AC_ARG_ENABLE(kdrive,         AS_HELP_STRING([--enable-kdrive], [Build kdrive servers (default: no)]), [KDRIVE=$enableval], [KDRIVE=no])
564AC_ARG_ENABLE(xephyr,         AS_HELP_STRING([--enable-xephyr], [Build the kdrive Xephyr server (default: auto)]), [XEPHYR=$enableval], [XEPHYR=auto])
565AC_ARG_ENABLE(xsdl,           AS_HELP_STRING([--enable-xsdl], [Build the kdrive Xsdl server (default: auto)]), [XSDL=$enableval], [XSDL=auto])
566AC_ARG_ENABLE(xfake,          AS_HELP_STRING([--enable-xfake], [Build the kdrive 'fake' server (default: auto)]), [XFAKE=$enableval], [XFAKE=auto])
567AC_ARG_ENABLE(xfbdev,         AS_HELP_STRING([--enable-xfbdev], [Build the kdrive framebuffer device server (default: auto)]), [XFBDEV=$enableval], [XFBDEV=auto])
568
569
570dnl chown/chmod to be setuid root as part of build
571dnl Replaces InstallXserverSetUID in imake
572AC_ARG_ENABLE(install-setuid, 
573    AS_HELP_STRING([--enable-install-setuid],
574       [Install Xorg server as owned by root with setuid bit (default: auto)]),
575    [SETUID=$enableval], [SETUID=auto])
576AC_MSG_CHECKING([to see if we can install the Xorg server as root])
577if test "x$SETUID" = "xauto" ; then
578	case $host_os in
579	    darwin*)		SETUID="no"  ;;
580	    *)
581	   	case $host_cpu in
582		    sparc)	SETUID="no"  ;;
583		    *)		SETUID="yes" ;;
584		esac
585	esac
586	if test "x$SETUID" = xyes; then
587		touch testfile
588		chown root testfile > /dev/null 2>&1 || SETUID="no"
589		rm -f testfile
590	fi
591fi
592AC_MSG_RESULT([$SETUID])
593AM_CONDITIONAL(INSTALL_SETUID, [test "x$SETUID" = "xyes"])
594
595dnl Issue an error if xtrans.m4 was not found and XTRANS_CONNECTION_FLAGS macro
596dnl was not expanded, since xorg-server with no transport types is rather useless.
597dnl
598dnl If you're seeing an error here, be sure you installed the lib/xtrans module
599dnl first and if it's not in the default location, that you set the ACLOCAL
600dnl environment variable to find it, such as:
601dnl	ACLOCAL="aclocal -I ${PREFIX}/share/aclocal"
602m4_pattern_forbid(XTRANS_CONNECTION_FLAGS)
603
604# Transport selection macro from xtrans.m4
605XTRANS_CONNECTION_FLAGS
606
607# Secure RPC detection macro from xtrans.m4
608XTRANS_SECURE_RPC_FLAGS
609AM_CONDITIONAL(SECURE_RPC, [test "x$SECURE_RPC" = xyes])
610
611AM_CONDITIONAL(INT10_VM86, [test "x$INT10" = xvm86])
612AM_CONDITIONAL(INT10_X86EMU, [test "x$INT10" = xx86emu])
613AM_CONDITIONAL(INT10_STUB, [test "x$INT10" = xstub])
614if test "x$INT10" = xyes; then
615	dnl VM86 headers
616	AC_CHECK_HEADERS([sys/vm86.h sys/io.h])
617fi
618
619dnl Handle building documentation
620AM_CONDITIONAL(BUILDDOCS, test "x$BUILDDOCS" = xyes)
621
622dnl Only build sgml docs when linuxdoc is available and
623dnl def.ents has been installed
624XORG_CHECK_LINUXDOC
625
626dnl Handle installing libxf86config
627AM_CONDITIONAL(INSTALL_LIBXF86CONFIG, [test "x$INSTALL_LIBXF86CONFIG" = xyes])
628
629dnl XQuartz DDX Detection... Yes, it's ugly to have it here... but we need to handle this early on
630case $host_os in
631	darwin*)
632		DRI2=no
633
634		if test x$XQUARTZ = xauto; then
635			AC_CACHE_CHECK([whether to build Xquartz],xorg_cv_Carbon_framework,[
636		 		save_LDFLAGS=$LDFLAGS
637				LDFLAGS="$LDFLAGS -framework Carbon"
638				AC_LINK_IFELSE([char FSFindFolder(); int main() { FSFindFolder(); return 0;}],
639				[xorg_cv_Carbon_framework=yes],
640				[xorg_cv_Carbon_framework=no])
641			LDFLAGS=$save_LDFLAGS])
642                
643			if test "X$xorg_cv_Carbon_framework" = Xyes; then
644				XQUARTZ=yes
645			else
646				XQUARTZ=no
647			fi
648		fi
649
650		if test "x$XQUARTZ" = xyes ; then
651			XQUARTZ=yes
652			XVFB=no
653			XNEST=no
654
655			COMPOSITE=no
656			DGA=no
657			DPMSExtension=no
658			XF86VIDMODE=no
659		fi
660		;;
661esac
662
663dnl ---------------------------------------------------------------------------
664dnl Extension section
665dnl ---------------------------------------------------------------------------
666XEXT_INC='-I$(top_srcdir)/Xext'
667XEXT_LIB='$(top_builddir)/Xext/libXext.la'
668XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la'
669
670dnl Core modules for most extensions, et al.
671REQUIRED_MODULES="[randrproto >= 1.2.99.1] [renderproto >= 0.9.3] [fixesproto >= 4.0] [damageproto >= 1.1] xcmiscproto [xextproto >= 7.0.3] [xproto >= 7.0.13] [xtrans >= 1.2.2] bigreqsproto resourceproto fontsproto [inputproto >= 1.5] [kbproto >= 1.0.3]"
672REQUIRED_LIBS="xfont xau fontenc [pixman-1 >= 0.13.2]"
673
674dnl HAVE_DBUS is true if we actually have the D-Bus library, whereas
675dnl CONFIG_DBUS_API is true if we want to enable the D-Bus config
676dnl API.
677PKG_CHECK_MODULES(DBUS, dbus-1, [HAVE_DBUS=yes], [HAVE_DBUS=no])
678if test "x$HAVE_DBUS" = xyes; then
679	AC_DEFINE(HAVE_DBUS, 1, [Have D-Bus support])
680fi
681AM_CONDITIONAL(HAVE_DBUS, [test "x$HAVE_DBUS" = xyes])
682
683if test "x$CONFIG_DBUS_API" = xauto; then
684	CONFIG_DBUS_API="$HAVE_DBUS"
685fi
686if test "x$CONFIG_DBUS_API" = xyes; then
687	if ! test "x$HAVE_DBUS" = xyes; then
688		AC_MSG_ERROR([D-Bus configuration API requested, but D-Bus is not installed.])
689	fi
690
691	AC_DEFINE(CONFIG_DBUS_API, 1, [Use the D-Bus input configuration API])
692	CONFIG_NEED_DBUS="yes"
693fi
694AM_CONDITIONAL(CONFIG_DBUS_API, [test "x$CONFIG_DBUS_API" = xyes])
695
696PKG_CHECK_MODULES(HAL, hal, [HAVE_HAL=yes], [HAVE_HAL=no])
697if test "x$CONFIG_HAL" = xauto; then
698	CONFIG_HAL="$HAVE_HAL"
699fi
700if test "x$CONFIG_HAL" = xyes; then
701	if ! test "x$HAVE_HAL" = xyes; then
702		AC_MSG_ERROR([HAL hotplug API requested, but HAL is not installed.])
703	fi
704
705	AC_DEFINE(CONFIG_HAL, 1, [Use the HAL hotplug API])
706        REQUIRED_LIBS="$REQUIRED_LIBS hal"
707	CONFIG_NEED_DBUS="yes"
708fi
709AM_CONDITIONAL(CONFIG_HAL, [test "x$CONFIG_HAL" = xyes])
710
711if test "x$CONFIG_NEED_DBUS" = xyes; then
712	REQUIRED_LIBS="$REQUIRED_LIBS dbus-1"
713        AC_DEFINE(CONFIG_NEED_DBUS, 1, [Use D-Bus for input hotplug])
714fi
715AM_CONDITIONAL(CONFIG_NEED_DBUS, [test "x$CONFIG_NEED_DBUS" = xyes])
716CONFIG_LIB='$(top_builddir)/config/libconfig.a'
717
718AC_MSG_CHECKING([for glibc...])
719AC_PREPROC_IFELSE([
720#include <features.h>
721#ifndef __GLIBC__
722#error
723#endif
724], glibc=yes, glibc=no)
725AC_MSG_RESULT([$glibc])
726
727AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes],
728               [AC_CHECK_LIB([rt], [clock_gettime], [have_clock_gettime=-lrt],
729                             [have_clock_gettime=no])])
730
731AC_MSG_CHECKING([for a useful monotonic clock ...])
732
733if ! test "x$have_clock_gettime" = xno; then
734    if ! test "x$have_clock_gettime" = xyes; then
735        CLOCK_LIBS="$have_clock_gettime"
736    else
737        CLOCK_LIBS=""
738    fi
739
740    LIBS_SAVE="$LIBS"
741    LIBS="$CLOCK_LIBS"
742    CPPFLAGS_SAVE="$CPPFLAGS"
743
744    if test x"$glibc" = xyes; then
745        CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
746    fi
747
748    AC_RUN_IFELSE([
749#include <time.h>
750
751int main(int argc, char *argv[[]]) {
752    struct timespec tp;
753
754    if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
755        return 0;
756    else
757        return 1;
758}
759    ], [MONOTONIC_CLOCK=yes], [MONOTONIC_CLOCK=no],
760       [MONOTONIC_CLOCK="cross compiling"])
761
762    LIBS="$LIBS_SAVE"
763    CPPFLAGS="$CPPFLAGS_SAVE"
764else
765    MONOTONIC_CLOCK=no
766fi
767
768AC_MSG_RESULT([$MONOTONIC_CLOCK])
769
770if test "x$MONOTONIC_CLOCK" = xyes; then
771    AC_DEFINE(MONOTONIC_CLOCK, 1, [Have monotonic clock from clock_gettime()])
772    LIBS="$LIBS $CLOCK_LIBS"
773fi
774
775AM_CONDITIONAL(XV, [test "x$XV" = xyes])
776if test "x$XV" = xyes; then
777	AC_DEFINE(XV, 1, [Support Xv extension])
778	AC_DEFINE(XvExtension, 1, [Build Xv extension])
779	REQUIRED_MODULES="$REQUIRED_MODULES videoproto"
780else
781	XVMC=no
782fi
783
784AM_CONDITIONAL(XVMC, [test "x$XVMC" = xyes])
785if test "x$XVMC" = xyes; then
786	AC_DEFINE(XvMCExtension, 1, [Build XvMC extension])
787fi
788
789AM_CONDITIONAL(XREGISTRY, [test "x$XREGISTRY" = xyes])
790if test "x$XREGISTRY" = xyes; then
791	AC_DEFINE(XREGISTRY, 1, [Build registry module])
792fi
793
794AM_CONDITIONAL(COMPOSITE, [test "x$COMPOSITE" = xyes])
795if test "x$COMPOSITE" = xyes; then
796	AC_DEFINE(COMPOSITE, 1, [Support Composite Extension])
797	REQUIRED_MODULES="$REQUIRED_MODULES [compositeproto >= 0.4]"
798	COMPOSITE_LIB='$(top_builddir)/composite/libcomposite.la'
799	COMPOSITE_INC='-I$(top_srcdir)/composite'
800fi
801
802AM_CONDITIONAL(MITSHM, [test "x$MITSHM" = xyes])
803if test "x$MITSHM" = xyes; then
804	AC_DEFINE(MITSHM, 1, [Support MIT-SHM extension])
805	AC_DEFINE(HAS_SHM, 1, [Support SHM])
806fi
807
808AM_CONDITIONAL(RECORD, [test "x$RECORD" = xyes])
809if test "x$RECORD" = xyes; then
810	AC_DEFINE(XRECORD, 1, [Support Record extension])
811	REQUIRED_MODULES="$REQUIRED_MODULES recordproto"
812	RECORD_LIB='$(top_builddir)/record/librecord.la'
813fi
814
815AM_CONDITIONAL(SCREENSAVER, [test "x$SCREENSAVER" = xyes])
816if test "x$SCREENSAVER" = xyes; then
817	AC_DEFINE(SCREENSAVER, 1, [Support MIT-SCREEN-SAVER extension])
818	REQUIRED_MODULES="$REQUIRED_MODULES [scrnsaverproto >= 1.1]"
819fi
820
821AM_CONDITIONAL(RES, [test "x$RES" = xyes])
822if test "x$RES" = xyes; then
823	AC_DEFINE(RES, 1, [Support X resource extension])
824	REQUIRED_MODULES="$REQUIRED_MODULES resourceproto"
825fi
826
827if test "x$GLX" = xyes; then
828	PKG_CHECK_MODULES([XLIB], [x11])
829	PKG_CHECK_MODULES([GL], [glproto >= 1.4.9 gl >= 7.1.0])
830	AC_SUBST(XLIB_CFLAGS)
831	AC_DEFINE(GLXEXT, 1, [Build GLX extension])
832	GLX_LIBS='$(top_builddir)/glx/libglx.la'
833	GLX_SYS_LIBS="$GLX_SYS_LIBS $DLOPEN_LIBS"
834else
835        GLX=no
836fi
837AM_CONDITIONAL(GLX, test "x$GLX" = xyes)
838AC_SUBST([MESA_SOURCE])
839
840if test "x$AIGLX" = xyes -a "x$GLX" = xyes -a "x$DRI" = xyes; then
841	AC_DEFINE(AIGLX, 1, [Build AIGLX loader])
842else
843	AIGLX=no
844fi
845AM_CONDITIONAL(AIGLX, test "x$AIGLX" = xyes)
846
847if test "x$GLX_USE_TLS" = xyes -a "x$AIGLX" = xyes; then
848	GLX_DEFINES="-DGLX_USE_TLS -DPTHREADS"
849	GLX_SYS_LIBS="$GLX_SYS_LIBS -lpthread"
850fi
851AC_SUBST([GLX_DEFINES])
852
853AM_CONDITIONAL(DRI, test "x$DRI" = xyes)
854if test "x$DRI" = xyes; then
855	AC_DEFINE(XF86DRI, 1, [Build DRI extension])
856	PKG_CHECK_MODULES([DRIPROTO], [xf86driproto])
857	PKG_CHECK_MODULES([GL], [glproto >= 1.4.1 dri >= 7.1.0])
858	AC_SUBST(DRIPROTO_CFLAGS)
859	AC_SUBST(GL_CFLAGS)
860fi
861
862PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= 2.1],
863                  [HAVE_DRI2PROTO=yes], [HAVE_DRI2PROTO=no])
864case "$DRI2,$HAVE_DRI2PROTO" in
865	yes,no)
866		AC_MSG_ERROR([DRI2 requested, but dri2proto not found.])
867		;;
868	yes,yes | auto,yes)
869		AC_DEFINE(DRI2, 1, [Build DRI2 extension])
870		DRI2=yes
871		;;
872esac
873AM_CONDITIONAL(DRI2, test "x$DRI2" = xyes)
874
875if test "x$DRI" = xyes || test "x$DRI2" = xyes; then
876	PKG_CHECK_MODULES([LIBDRM], [libdrm >= 2.3.0])
877	AC_SUBST(LIBDRM_CFLAGS)
878	AC_SUBST(LIBDRM_LIBS)
879fi
880
881if test "x$DRI2" = xyes; then
882	save_CFLAGS=$CFLAGS
883	CFLAGS="$GL_CFLAGS $LIBDRM_CFLAGS"
884	AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <GL/gl.h>
885#include <GL/internal/dri_interface.h>
886#ifndef __DRI_DRI2
887#error DRI2 extension not available.
888#endif]])],
889			  [HAVE_DRI2EXTENSION=yes],
890			  [HAVE_DRI2EXTENSION=no])
891	CFLAGS=$save_CFLAGS
892	if test "x$HAVE_DRI2EXTENSION" = xyes; then
893		AC_DEFINE(DRI2_AIGLX, 1, [Build DRI2 AIGLX loader])
894		DRI2_AIGLX=yes
895	else
896		AC_MSG_NOTICE([DRI2 AIGLX disabled, __DRI_DRI2 not defined in dri_interface.h.])
897		DRI2_AIGLX=no
898	fi
899fi
900AM_CONDITIONAL(DRI2_AIGLX, test "x$DRI2_AIGLX" = xyes)
901
902
903AM_CONDITIONAL(XINERAMA, [test "x$XINERAMA" = xyes])
904if test "x$XINERAMA" = xyes; then
905	AC_DEFINE(XINERAMA, 1, [Support Xinerama extension])
906	AC_DEFINE(PANORAMIX, 1, [Internal define for Xinerama])
907	REQUIRED_MODULES="$REQUIRED_MODULES xineramaproto"
908fi
909
910AM_CONDITIONAL(XACE, [test "x$XACE" = xyes])
911if test "x$XACE" = xyes; then
912	AC_DEFINE(XACE, 1, [Build X-ACE extension])
913fi
914
915AM_CONDITIONAL(XSELINUX, [test "x$XSELINUX" = xyes])
916if test "x$XSELINUX" = xyes; then
917	if test "x$XACE" != xyes; then
918		AC_MSG_ERROR([cannot build SELinux extension without X-ACE])
919	fi
920	AC_CHECK_HEADERS([selinux/selinux.h selinux/avc.h], [], AC_MSG_ERROR([SELinux include files not found]))
921	AC_CHECK_LIB(selinux, avc_init, [], AC_MSG_ERROR([SELinux library not found])) 
922	AC_CHECK_HEADERS([libaudit.h], [], AC_MSG_ERROR([SELinux extension requires audit system headers]))
923	AC_CHECK_LIB(audit, audit_open, [], AC_MSG_ERROR([SELinux extension requires audit system library]))
924        AC_CHECK_DECL(avc_netlink_acquire_fd,
925                      [AC_DEFINE(HAVE_AVC_NETLINK_ACQUIRE_FD, 1, "Have avc_netlink_acquire_fd")],
926                      [],
927                      [#include <selinux/avc.h>])
928	AC_DEFINE(XSELINUX, 1, [Build SELinux extension])
929	SELINUX_LIB="-lselinux -laudit"
930fi
931
932AM_CONDITIONAL(XCSECURITY, [test "x$XCSECURITY" = xyes])
933if test "x$XCSECURITY" = xyes; then
934	if test "x$XACE" != xyes; then
935		AC_MSG_ERROR([cannot build Security extension without X-ACE])
936	fi
937	AC_DEFINE(XCSECURITY, 1, [Build Security extension])
938fi
939
940AM_CONDITIONAL(MULTIBUFFER, [test "x$MULTIBUFFER" = xyes])
941if test "x$MULTIBUFFER" = xyes; then
942	AC_DEFINE(MULTIBUFFER, 1, [Build Multibuffer extension])
943	# Requires xextproto which is always required
944fi
945
946AM_CONDITIONAL(DBE, [test "x$DBE" = xyes])
947if test "x$DBE" = xyes; then
948	AC_DEFINE(DBE, 1, [Support DBE extension])
949	DBE_LIB='$(top_builddir)/dbe/libdbe.la'
950fi
951
952AM_CONDITIONAL(XF86BIGFONT, [test "x$XF86BIGFONT" = xyes])
953if test "x$XF86BIGFONT" = xyes; then
954	AC_DEFINE(XF86BIGFONT, 1, [Support XF86 Big font extension])
955fi
956
957AM_CONDITIONAL(DPMSExtension, [test "x$DPMSExtension" = xyes])
958if test "x$DPMSExtension" = xyes; then
959	AC_DEFINE(DPMSExtension, 1, [Support DPMS extension])
960fi
961
962if test "x$XCALIBRATE" = xyes && test "$KDRIVE" = yes; then
963   AC_DEFINE(XCALIBRATE, 1, [Build XCalibrate extension])
964   REQUIRED_MODULES="$REQUIRED_MODULES xcalibrateproto"
965else
966   XCALIBRATE=no
967fi
968AM_CONDITIONAL(XCALIBRATE, [test "x$XCALIBRATE" = xyes])
969
970AC_DEFINE(RENDER, 1, [Support RENDER extension])
971RENDER_LIB='$(top_builddir)/render/librender.la'
972RENDER_INC='-I$(top_srcdir)/render'
973
974AC_DEFINE(RANDR, 1, [Support RANDR extension])
975RANDR_LIB='$(top_builddir)/randr/librandr.la'
976RANDR_INC='-I$(top_srcdir)/randr'
977
978AC_DEFINE(XFIXES,1,[Support XFixes extension])
979FIXES_LIB='$(top_builddir)/xfixes/libxfixes.la'
980FIXES_INC='-I$(top_srcdir)/xfixes'
981
982AC_DEFINE(DAMAGE,1,[Support Damage extension])
983DAMAGE_LIB='$(top_builddir)/damageext/libdamageext.la'
984DAMAGE_INC='-I$(top_srcdir)/damageext'
985MIEXT_DAMAGE_LIB='$(top_builddir)/miext/damage/libdamage.la'
986MIEXT_DAMAGE_INC='-I$(top_srcdir)/miext/damage'
987
988# XINPUT extension is integral part of the server
989XI_LIB='$(top_builddir)/Xi/libXi.la'
990XI_INC='-I$(top_srcdir)/Xi'
991
992AM_CONDITIONAL(XF86UTILS, test "x$XF86UTILS" = xyes)
993
994AC_DEFINE(SHAPE, 1, [Support SHAPE extension])
995
996AC_DEFINE(XKB, 1, [Build XKB])
997AC_DEFINE(XKB_IN_SERVER, 1, [Build XKB server])
998AC_DEFINE(XKB_DFLT_DISABLED, 0, [Disable XKB per default])
999REQUIRED_MODULES="$REQUIRED_MODULES xkbfile"
1000XKB_LIB='$(top_builddir)/xkb/libxkb.la'
1001XKB_STUB_LIB='$(top_builddir)/xkb/libxkbstubs.la'
1002
1003AC_CHECK_FUNC(strcasecmp, [], AC_DEFINE([NEED_STRCASECMP], 1,
1004                                        [Do not have 'strcasecmp'.]))
1005AC_CHECK_FUNC(strncasecmp, [], AC_DEFINE([NEED_STRNCASECMP], 1,
1006                                        [Do not have 'strncasecmp'.]))
1007AC_CHECK_FUNC(strcasestr, [], AC_DEFINE([NEED_STRCASESTR], 1,
1008                                       [Do not have 'strcasestr'.]))
1009
1010if test "x$NULL_ROOT_CURSOR" = xyes; then
1011        AC_DEFINE(NULL_ROOT_CURSOR, 1, [Use an empty root cursor])
1012fi
1013
1014PKG_CHECK_MODULES([XDMCP], [xdmcp], [have_libxdmcp="yes"], [have_libxdmcp="no"])
1015if test "x$have_libxdmcp" = xyes; then
1016	AC_CHECK_LIB(Xdmcp, XdmcpWrap, [have_xdmcpwrap="yes"], [have_xdmcpwrap="no"], [$XDMCP_LIBS])
1017fi
1018if test "x$XDMCP" = xauto; then
1019	if test "x$have_libxdmcp" = xyes; then
1020		XDMCP=yes
1021	else
1022		XDMCP=no
1023	fi
1024fi
1025if test "x$XDMAUTH" = xauto; then
1026	if test "x$have_libxdmcp" = xyes && test "x$have_xdmcpwrap" = xyes; then
1027		XDMAUTH=yes
1028	else
1029		XDMAUTH=no
1030	fi
1031fi
1032
1033AM_CONDITIONAL(XDMCP, [test "x$XDMCP" = xyes])
1034if test "x$XDMCP" = xyes; then
1035	AC_DEFINE(XDMCP, 1, [Support XDM Control Protocol])
1036	REQUIRED_LIBS="$REQUIRED_LIBS xdmcp"
1037	XDMCP_MODULES="xdmcp"
1038fi
1039
1040AM_CONDITIONAL(XDMAUTH, [test "x$XDMAUTH" = xyes])
1041if test "x$XDMAUTH" = xyes; then
1042	AC_DEFINE(HASXDMAUTH,1,[Support XDM-AUTH*-1])
1043	if ! test "x$XDMCP" = xyes; then
1044		REQUIRED_LIBS="$REQUIRED_LIBS xdmcp"
1045		XDMCP_MODULES="xdmcp"
1046	fi
1047fi
1048
1049AC_DEFINE_DIR(COMPILEDDEFAULTFONTPATH, FONTPATH, [Default font path])
1050AC_DEFINE_DIR(PCI_TXT_IDS_PATH, PCI_TXT_IDS_DIR, [Default PCI text file ID path])
1051AC_DEFINE_DIR(SERVER_MISC_CONFIG_PATH, SERVERCONFIG, [Server miscellaneous config path])
1052AC_DEFINE_DIR(BASE_FONT_PATH, FONTDIR, [Default base font path])
1053AC_DEFINE_DIR(DRI_DRIVER_PATH, DRI_DRIVER_PATH, [Default DRI driver path])
1054AC_DEFINE_UNQUOTED(XVENDORNAME, ["$VENDOR_NAME"], [Vendor name])
1055AC_DEFINE_UNQUOTED(XVENDORNAMESHORT, ["$VENDOR_NAME_SHORT"], [Short vendor name])
1056AC_DEFINE_UNQUOTED(XORG_DATE, ["$RELEASE_DATE"], [Vendor release])
1057AC_DEFINE_UNQUOTED(XORG_MAN_VERSION, ["$VENDOR_MAN_VERSION"], [Vendor man version])
1058AC_DEFINE_UNQUOTED(BUILDERADDR, ["$BUILDERADDR"], [Builder address])
1059
1060if test -z "$OSNAME"; then
1061    OSNAME="UNKNOWN"
1062fi
1063
1064AC_DEFINE_UNQUOTED(OSNAME, ["$OSNAME"], [Operating System Name])
1065AC_DEFINE_UNQUOTED(OSVENDOR, ["$OSVENDOR"], [Operating System Vendor])
1066AC_DEFINE_UNQUOTED(BUILDERSTRING, ["$BUILDERSTRING"], [Builder string])
1067
1068AC_SUBST([VENDOR_NAME])
1069AC_SUBST([VENDOR_NAME_SHORT])
1070AC_SUBST([VENDOR_RELEASE])
1071AC_SUBST([VENDOR_MAN_VERSION])
1072
1073AC_DEFINE(NO_LIBCWRAPPER, 1, [Define to 1 if modules should avoid the libcwrapper])
1074
1075if test "x$DEBUGGING" = xyes; then
1076       AC_DEFINE(DEBUG, 1, [Enable debugging code])
1077fi
1078AM_CONDITIONAL(DEBUG, [test "x$DEBUGGING" = xyes])
1079
1080AC_DEFINE(XTEST, 1, [Support XTest extension])
1081AC_DEFINE(XSYNC, 1, [Support XSync extension])
1082AC_DEFINE(XCMISC, 1, [Support XCMisc extension])
1083AC_DEFINE(BIGREQS, 1, [Support BigRequests extension])
1084
1085if test "x$WDTRACE" != "xno" ; then
1086  DIX_LIB='$(top_builddir)/dix/dix.O'
1087  OS_LIB='$(top_builddir)/os/os.O'
1088else
1089  DIX_LIB='$(top_builddir)/dix/libdix.la'
1090  OS_LIB='$(top_builddir)/os/libos.la'
1091fi
1092MI_LIB='$(top_builddir)/mi/libmi.la'
1093MI_EXT_LIB='$(top_builddir)/mi/libmiext.la'
1094MI_INC='-I$(top_srcdir)/mi'
1095FB_LIB='$(top_builddir)/fb/libfb.la'
1096FB_INC='-I$(top_srcdir)/fb'
1097MIEXT_SHADOW_INC='-I$(top_srcdir)/miext/shadow'
1098MIEXT_SHADOW_LIB='$(top_builddir)/miext/shadow/libshadow.la'
1099CORE_INCS='-I$(top_srcdir)/include -I$(top_builddir)/include'
1100
1101# OpenSSL used for SHA1 hashing in render/glyph.c, but we don't need all of
1102# the OpenSSL libraries, just libcrypto
1103# Some systems have matching functionality in the smaller/simpler libmd
1104# Builders who want to force a choice can set SHA1_LIB and SHA1_CFLAGS
1105if test "x$SHA1_LIB" = "x" ; then
1106  AC_CHECK_LIB([md], [SHA1Init], [SHA1_LIB="-lmd"
1107            AC_DEFINE([HAVE_SHA1_IN_LIBMD], [1],
1108            [Use libmd SHA1 functions instead of OpenSSL libcrypto])])
1109fi
1110
1111if test "x$SHA1_LIB" = "x" ; then
1112  PKG_CHECK_EXISTS([OPENSSL], [openssl], [HAVE_OPENSSL_PKC=yes],
1113                    [HAVE_OPENSSL_PKC=no])
1114  if test "x$HAVE_OPENSSL_PKC" = xyes; then
1115    REQUIRED_LIBS="$REQUIRED_LIBS openssl"
1116  else
1117    AC_CHECK_LIB([crypto], [SHA1_Init], [SHA1_LIB="-lcrypto"],
1118                 [AC_MSG_ERROR([OpenSSL must be installed in order to build the X server.])])
1119  fi
1120fi
1121
1122PKG_CHECK_MODULES([XSERVERCFLAGS], [$REQUIRED_MODULES $REQUIRED_LIBS])
1123PKG_CHECK_MODULES([XSERVERLIBS], [$REQUIRED_LIBS])
1124
1125# Autotools has some unfortunate issues with library handling.  In order to
1126# get a server to rebuild when a dependency in the tree is changed, it must
1127# be listed in SERVERNAME_DEPENDENCIES.  However, no system libraries may be
1128# listed there, or some versions of autotools will break (especially if a -L
1129# is required to find the library).  So, we keep two sets of libraries
1130# detected: NAMESPACE_LIBS for in-tree libraries to be linked against, which
1131# will go into the _DEPENDENCIES and _LDADD of the server, and
1132# NAMESPACE_SYS_LIBS which will go into only the _LDADD.  The
1133# NAMESPACEMODULES_LIBS detected from pkgconfig should always go in
1134# NAMESPACE_SYS_LIBS.
1135#
1136# XSERVER_LIBS is the set of in-tree libraries which all servers require.
1137# XSERVER_SYS_LIBS is the set of out-of-tree libraries which all servers
1138# require.
1139#
1140XSERVER_CFLAGS="${XSERVERCFLAGS_CFLAGS} ${SHA1_CFLAGS}"
1141XSERVER_LIBS="$DIX_LIB $CONFIG_LIB $MI_LIB $OS_LIB"
1142XSERVER_SYS_LIBS="${XSERVERLIBS_LIBS} ${SYS_LIBS} ${LIBS} ${SHA1_LIB}"
1143AC_SUBST([XSERVER_LIBS])
1144AC_SUBST([XSERVER_SYS_LIBS])
1145
1146UTILS_SYS_LIBS="${SYS_LIBS}"
1147AC_SUBST([UTILS_SYS_LIBS])
1148
1149# The Xorg binary needs to export symbols so that they can be used from modules
1150# Some platforms require extra flags to do this.   gcc should set these flags
1151# when -rdynamic is passed to it, other compilers/linkers may need to be added
1152# here.
1153if test "x$GCC" = "xyes"; then
1154       GCC_WARNINGS1="-Wall -Wpointer-arith -Wstrict-prototypes"
1155       GCC_WARNINGS2="-Wmissing-prototypes -Wmissing-declarations"
1156       GCC_WARNINGS3="-Wnested-externs -fno-strict-aliasing"
1157       GCC_WARNINGS="$GCC_WARNINGS1 $GCC_WARNINGS2 $GCC_WARNINGS3"
1158       if test "x$WERROR" = "xyes"; then
1159               GCC_WARNINGS="${GCC_WARNINGS} -Werror"
1160       fi
1161       XSERVER_CFLAGS="$GCC_WARNINGS $XSERVER_CFLAGS"
1162
1163       LD_EXPORT_SYMBOLS_FLAG="-rdynamic"
1164fi
1165case $host_os in
1166       openbsd*)
1167       LD_EXPORT_SYMBOLS_FLAG="-Wl,--export-dynamic"
1168       ;;
1169esac
1170AC_SUBST([LD_EXPORT_SYMBOLS_FLAG])
1171
1172dnl Imake defines SVR4 on SVR4 systems, and many files check for it, so
1173dnl we need to replicate that here until those can all be fixed
1174AC_MSG_CHECKING([if SVR4 needs to be defined])
1175AC_EGREP_CPP([I_AM_SVR4],[
1176#if defined(SVR4) || defined(__svr4__) || defined(__SVR4)
1177 I_AM_SVR4
1178#endif
1179],[
1180AC_DEFINE([SVR4],1,[Define to 1 on systems derived from System V Release 4])
1181AC_MSG_RESULT([yes])], AC_MSG_RESULT([no]))
1182
1183XSERVER_CFLAGS="$XSERVER_CFLAGS $CORE_INCS $XEXT_INC $COMPOSITE_INC $DAMAGE_INC $FIXES_INC $XI_INC $MI_INC $MIEXT_SHADOW_INC $MIEXT_LAYER_INC $MIEXT_DAMAGE_INC $RENDER_INC $RANDR_INC $FB_INC"
1184
1185dnl ---------------------------------------------------------------------------
1186dnl DDX section.
1187dnl ---------------------------------------------------------------------------
1188
1189dnl Xvfb DDX
1190
1191AC_MSG_CHECKING([whether to build Xvfb DDX])
1192AC_MSG_RESULT([$XVFB])
1193AM_CONDITIONAL(XVFB, [test "x$XVFB" = xyes])
1194
1195if test "x$XVFB" = xyes; then
1196	XVFB_LIBS="$FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB"
1197	XVFB_SYS_LIBS="$XVFBMODULES_LIBS $GLX_SYS_LIBS"
1198	AC_SUBST([XVFB_LIBS])
1199	AC_SUBST([XVFB_SYS_LIBS])
1200fi
1201
1202
1203dnl Xnest DDX
1204
1205PKG_CHECK_MODULES(XNESTMODULES, [xfont xext x11 xau $XDMCP_MODULES], [have_xnest=yes], [have_xnest=no])
1206AC_MSG_CHECKING([whether to build Xnest DDX])
1207if test "x$XNEST" = xauto; then
1208	XNEST="$have_xnest"
1209fi
1210AC_MSG_RESULT([$XNEST])
1211AM_CONDITIONAL(XNEST, [test "x$XNEST" = xyes])
1212
1213if test "x$XNEST" = xyes; then
1214	XNEST_LIBS="$FB_LIB $FIXES_LIB $MI_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DIX_LIB $OS_LIB $CONFIG_LIB"
1215	XNEST_SYS_LIBS="$XNESTMODULES_LIBS $GLX_SYS_LIBS"
1216	AC_SUBST([XNEST_LIBS])
1217	AC_SUBST([XNEST_SYS_LIBS])
1218fi
1219
1220
1221dnl Xorg DDX
1222
1223AC_MSG_CHECKING([whether to build Xorg DDX])
1224if test "x$XORG" = xauto; then
1225	XORG="yes"
1226	case $host_os in
1227		cygwin*) XORG="no" ;;
1228		darwin*) XORG="no" ;;
1229	esac
1230fi
1231AC_MSG_RESULT([$XORG])
1232
1233xorg_bus_linuxpci=no
1234xorg_bus_bsdpci=no
1235xorg_bus_sparc=no
1236
1237if test "x$XORG" = xyes; then
1238	XORG_DDXINCS='-I$(top_srcdir)/hw/xfree86 -I$(top_srcdir)/hw/xfree86/include -I$(top_srcdir)/hw/xfree86/common'
1239	XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'
1240	XORG_INCS="$XORG_DDXINCS $XORG_OSINCS"
1241	XORG_CFLAGS="$XORGSERVER_CFLAGS -DHAVE_XORG_CONFIG_H"
1242	XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB"
1243
1244	PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0])
1245	SAVE_LIBS=$LIBS
1246	SAVE_CFLAGS=$CFLAGS
1247	CFLAGS=$PCIACCESS_CFLAGS
1248	LIBS=$PCIACCESS_LIBS
1249	AC_CHECK_FUNCS([pci_system_init_dev_mem])
1250	AC_CHECK_FUNCS([pci_device_enable])
1251	LIBS=$SAVE_LIBS
1252	CFLAGS=$SAVE_CFLAGS
1253	XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $DLOPEN_LIBS $GLX_SYS_LIBS $SELINUX_LIB"
1254	XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"
1255
1256	case $host_os in
1257	  linux*)
1258		if test "x$LNXAPM" = xyes; then
1259			XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
1260		fi
1261	  	XORG_OS="linux"
1262		XORG_OS_SUBDIR="linux"
1263		xorg_bus_linuxpci="yes"
1264		linux_acpi="no"
1265		case $host_cpu in
1266		  ia64*)
1267			linux_ia64=yes
1268			linux_acpi="yes"
1269			;;
1270		  alpha*)
1271		  	linux_alpha=yes
1272			;;
1273		  i*86|amd64*|x86_64*)
1274			linux_acpi="yes"
1275			;;
1276		  *)
1277			;;
1278		esac
1279		;;
1280	  freebsd* | kfreebsd*-gnu | dragonfly*)
1281	  	XORG_OS="freebsd"
1282		XORG_OS_SUBDIR="bsd"
1283		xorg_bus_bsdpci="yes"
1284		;;
1285	  netbsd*)
1286	  	XORG_OS="netbsd"
1287		XORG_OS_SUBDIR="bsd"
1288		xorg_bus_bsdpci="yes"
1289		;;
1290	  openbsd*)
1291		if test "x$ac_cv_BSD_APM" = xyes \
1292			-o "x$ac_cv_BSD_KQUEUE_APM" = xyes; then
1293			XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
1294		fi
1295	  	XORG_OS="openbsd"
1296		XORG_OS_SUBDIR="bsd"
1297		xorg_bus_bsdpci="yes"
1298		;;
1299	  solaris*)
1300	  	XORG_OS="solaris"
1301		XORG_OS_SUBDIR="solaris"
1302		# Use the same stubs as BSD for old functions, since we now
1303		# use libpciaccess for PCI
1304		xorg_bus_bsdpci="yes"
1305		AC_CHECK_HEADERS([sys/kd.h])
1306		# This really should be tests for specific features, but the #ifdef's
1307		# were done as a simple version check in XFree86 4.x and haven't been 
1308		# fixed yet
1309		AC_MSG_CHECKING([Solaris version])
1310	        OS_MINOR=`echo ${host_os}|sed -e 's/^.*solaris2\.//' -e s'/\..*$//'`
1311		if test "${OS_MINOR}" -ge 7 ; then
1312	        	AC_MSG_RESULT(Solaris ${OS_MINOR})
1313		else
1314			AC_MSG_RESULT(Solaris `echo ${host_os}|sed -e 's/^.*solaris//`)
1315		fi
1316		if test "${OS_MINOR}" -ge 8 ; then
1317			AC_DEFINE(__SOL8__,1,[Solaris 8 or later])
1318		fi
1319		AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
1320		if test "x$SUNCC" = "xyes"; then
1321			solaris_asm_inline="yes"
1322		fi
1323		AC_CHECK_DECL([_LP64], [SOLARIS_64="yes"], [SOLARIS_64="no"])
1324			
1325		case $host_cpu in
1326		  sparc*)	
1327			SOLARIS_INOUT_ARCH="sparcv8plus"
1328			;;
1329		  i*86)	
1330			if test x$SOLARIS_64 = xyes ; then
1331				SOLARIS_INOUT_ARCH="amd64"
1332			else
1333				SOLARIS_INOUT_ARCH="ia32"
1334			fi
1335			if test "${OS_MINOR}" -lt 8 ; then
1336				solaris_usl_console="yes"
1337			else
1338				XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
1339			fi
1340			;;
1341		  *)
1342			AC_MSG_ERROR([Unsupported Solaris platform. Only SPARC & x86 \
1343			are supported on Solaris in this release.   If you are \
1344			interested in porting Xorg to your platform, please email \
1345			xorg@lists.freedesktop.org.]) ;;
1346		esac
1347		AC_SUBST([SOLARIS_INOUT_ARCH])
1348		if test x$solaris_asm_inline = xyes ; then
1349			SOLARIS_ASM_CFLAGS='$(top_srcdir)/hw/xfree86/os-support/solaris/solaris-$(SOLARIS_INOUT_ARCH).il'
1350			XORG_CFLAGS="${XORG_CFLAGS} "'$(SOLARIS_ASM_CFLAGS)'
1351		fi
1352		AC_SUBST([SOLARIS_ASM_CFLAGS])
1353		;;
1354	  gnu*)
1355	  	XORG_OS="gnu"
1356		XORG_OS_SUBDIR="hurd"
1357		;;
1358	  *)
1359	  	XORG_OS="unknown"
1360		XORG_OS_SUBDIR="unknown"
1361		AC_MSG_ERROR([Your OS is unknown. Xorg currently only supports Linux, \
1362		Free/Open/NetBSD, Solaris, and OS X. If you are interested in porting \
1363	        Xorg to your platform, please email xorg@lists.freedesktop.org.])
1364		;;
1365	esac
1366
1367	case $host_cpu in
1368	  sparc*)
1369		xorg_bus_sparc="yes"
1370		;;
1371	esac
1372
1373	if test "x$XORG_OS_PCI" = x ; then
1374		XORG_OS_PCI=$XORG_OS
1375	fi
1376	if test "x$DGA" = xauto; then
1377		PKG_CHECK_MODULES(DGA, xf86dgaproto, [DGA=yes], [DGA=no])
1378	fi
1379	if test "x$DGA" = xyes; then
1380		XORG_MODULES="$XORG_MODULES xf86dgaproto"
1381		PKG_CHECK_MODULES(DGA, xf86dgaproto)
1382		AC_DEFINE(DGA, 1, [Support DGA extension])
1383		AC_DEFINE(XFreeXDGA, 1, [Build XDGA support])
1384	fi
1385
1386	if test "x$XF86VIDMODE" = xauto; then
1387		PKG_CHECK_MODULES(XF86VIDMODE, xf86vidmodeproto, [XF86VIDMODE=yes], [XF86VIDMODE=no])
1388	fi
1389	if test "x$XF86VIDMODE" = xyes; then
1390		XORG_MODULES="$XORG_MODULES xf86vidmodeproto"
1391		PKG_CHECK_MODULES(XF86VIDMODE, xf86vidmodeproto)
1392		AC_DEFINE(XF86VIDMODE, 1, [Support XFree86 Video Mode extension])
1393	fi
1394
1395	if test -n "$XORG_MODULES"; then
1396	        PKG_CHECK_MODULES(XORG_MODULES, [$XORG_MODULES])
1397	        XORG_CFLAGS="$XORG_CFLAGS $XORG_MODULES_CFLAGS"
1398	        XORG_SYS_LIBS="$XORG_SYS_LIBS $XORG_MODULES_LIBS"
1399	fi
1400
1401	AC_SUBST([XORG_LIBS])
1402	AC_SUBST([XORG_SYS_LIBS])
1403	AC_SUBST([XORG_INCS])
1404	AC_SUBST([XORG_OS])
1405	AC_SUBST([XORG_OS_SUBDIR])
1406
1407	AC_PATH_PROG(PERL, perl, no)
1408	dnl unlikely as this may be ...
1409	if test "x$PERL" = xno; then
1410		AC_MSG_ERROR([Perl is required to build the XFree86/Xorg DDX.])
1411	fi
1412	AC_SUBST(PERL)
1413
1414	AC_SUBST([XORG_CFLAGS])
1415
1416	dnl these only go in xorg-config.h
1417	XF86CONFIGFILE="xorg.conf"
1418	CONFIGFILE="$sysconfdir/$XF86CONFIGFILE"
1419	LOGPREFIX="$logdir/Xorg."
1420	AC_DEFINE(XORG_SERVER, 1, [Building Xorg server])
1421	AC_DEFINE(XORGSERVER, 1, [Building Xorg server])
1422	AC_DEFINE(XFree86Server, 1, [Building XFree86 server])
1423	AC_DEFINE(XFree86LOADER, 1, [Building loadable XFree86 server])
1424	AC_DEFINE_UNQUOTED(XORG_VERSION_CURRENT, [$VENDOR_RELEASE], [Current Xorg version])
1425	AC_DEFINE(NEED_XF86_TYPES, 1, [Need XFree86 typedefs])
1426	AC_DEFINE(NEED_XF86_PROTOTYPES, 1, [Need XFree86 helper functions])
1427	AC_DEFINE(__XSERVERNAME__, "Xorg", [Name of X server])
1428	AC_DEFINE(WITH_VGAHW, 1, [Building vgahw module])
1429	AC_DEFINE_DIR(__XCONFIGFILE__, XF86CONFIGFILE, [Name of configuration file])
1430	AC_DEFINE_DIR(XF86CONFIGFILE, XF86CONFIGFILE, [Name of configuration file])
1431	AC_DEFINE_DIR(DEFAULT_MODULE_PATH, moduledir, [Default module search path])
1432	AC_DEFINE_DIR(DEFAULT_LIBRARY_PATH, libdir, [Default library install path])
1433	AC_DEFINE_DIR(DEFAULT_LOGPREFIX, LOGPREFIX, [Default log location])
1434	AC_DEFINE_UNQUOTED(__VENDORDWEBSUPPORT__, ["$VENDOR_WEB"], [Vendor web address for support])
1435	AC_DEFINE(XSERVER_LIBPCIACCESS, 1, [Use libpciaccess for all pci manipulation])
1436
1437	driverdir="$moduledir/drivers"
1438	AC_SUBST([moduledir])
1439	AC_SUBST([driverdir])
1440	sdkdir="$includedir/xorg"
1441	extdir="$includedir/X11/extensions"
1442	AC_SUBST([sdkdir])
1443	AC_SUBST([extdir])
1444	AC_SUBST([logdir])
1445
1446	# stuff the ABI versions into the pc file too
1447	extract_abi() {
1448	    grep ^.define.*${1}_VERSION ${srcdir}/hw/xfree86/common/xf86Module.h | tr '(),' '  .' | awk '{ print $4$5 }'
1449	}
1450	abi_ansic=`extract_abi ANSIC`
1451	abi_videodrv=`extract_abi VIDEODRV`
1452	abi_xinput=`extract_abi XINPUT`
1453	abi_extension=`extract_abi EXTENSION`
1454	abi_font=`extract_abi FONT`
1455	AC_SUBST([abi_ansic])
1456	AC_SUBST([abi_videodrv])
1457	AC_SUBST([abi_xinput])
1458	AC_SUBST([abi_extension])
1459	AC_SUBST([abi_font])
1460fi
1461AM_CONDITIONAL([XORG], [test "x$XORG" = xyes])
1462AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes])
1463AM_CONDITIONAL([XORG_BUS_BSDPCI], [test "x$xorg_bus_bsdpci" = xyes])
1464AM_CONDITIONAL([XORG_BUS_SPARC], [test "x$xorg_bus_sparc" = xyes])
1465AM_CONDITIONAL([LINUX_IA64], [test "x$linux_ia64" = xyes])
1466AM_CONDITIONAL([LINUX_ALPHA], [test "x$linux_alpha" = xyes])
1467AM_CONDITIONAL([LNXACPI], [test "x$linux_acpi" = xyes])
1468AM_CONDITIONAL([SOLARIS_USL_CONSOLE], [test "x$solaris_usl_console" = xyes])
1469AM_CONDITIONAL([SOLARIS_ASM_INLINE], [test "x$solaris_asm_inline" = xyes])
1470AM_CONDITIONAL([DGA], [test "x$DGA" = xyes])
1471AM_CONDITIONAL([XF86VIDMODE], [test "x$XF86VIDMODE" = xyes])
1472
1473dnl XWin DDX
1474
1475AC_MSG_CHECKING([whether to build XWin DDX])
1476if test "x$XWIN" = xauto; then
1477	case $host_os in
1478		cygwin*) XWIN="yes" ;;
1479		mingw*) XWIN="yes" ;;
1480		*) XWIN="no" ;;
1481	esac
1482	XWIN_LIBS="$FB_LIB $XEXT_LIB $CONFIG_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DAMAGE_LIB $LAYER_LIB $XPSTUBS_LIB $SHADOW_LIB"
1483	AC_SUBST([XWIN_LIBS])
1484fi
1485AC_MSG_RESULT([$XWIN])
1486
1487if test "x$XWIN" = xyes; then
1488	case $host_os in
1489		cygwin*)
1490			XWIN_SERVER_NAME=XWin
1491			PKG_CHECK_MODULES([XWINMODULES],[x11 xdmcp xau xfont])
1492			AC_DEFINE(HAS_DEVWINDOWS,1,[Cygwin has /dev/windows for signaling new win32 messages])
1493			AC_DEFINE(ROOTLESS,1,[Build Rootless code])
1494			CFLAGS="$CFLAGS -DFD_SETSIZE=256"
1495			;;
1496		mingw*)
1497			XWIN_SERVER_NAME=Xming
1498			PKG_CHECK_MODULES([XWINMODULES],[x11 xdmcp xau xfont])
1499			AC_DEFINE(RELOCATE_PROJECTROOT,1,[Make PROJECT_ROOT relative to the xserver location])
1500			AC_DEFINE(HAS_WINSOCK,1,[Use Windows sockets])
1501			XWIN_SYS_LIBS=-lwinsock2
1502			;;
1503	esac
1504	XWIN_SYS_LIBS="$XWIN_SYS_LIBS $(XWINMODULES_LIBS)"
1505	AC_SUBST(XWIN_SERVER_NAME)
1506	AC_SUBST(XWIN_SYS_LIBS)
1507
1508	if test "x$DEBUGGING" = xyes; then
1509		AC_DEFINE(CYGDEBUG, 1, [Simple debug messages])
1510		AC_DEFINE(CYGWINDOWING_DEBUG, 1, [Debug messages for window handling])
1511		AC_DEFINE(CYGMULTIWINDOW_DEBUG, 1, [Debug window manager])
1512	fi
1513
1514	AC_DEFINE(DDXOSVERRORF, 1, [Use OsVendorVErrorF])
1515	AC_DEFINE(DDXBEFORERESET, 1, [Use ddxBeforeReset ])
1516	if test "x$XF86VIDMODE" = xyes; then
1517		AC_MSG_NOTICE([Disabling XF86VidMode extension])
1518		XF86VIDMODE=no
1519	fi
1520	if test "x$COMPOSITE" = xyes; then
1521		AC_MSG_NOTICE([Disabling Composite extension])
1522		COMPOSITE=no
1523	fi
1524fi
1525AM_CONDITIONAL(XWIN, [test "x$XWIN" = xyes])
1526AM_CONDITIONAL(XWIN_MULTIWINDOW, [test "x$XWIN" = xyes])
1527AM_CONDITIONAL(XWIN_MULTIWINDOWEXTWM, [test "x$XWIN" = xyes && false])
1528AM_CONDITIONAL(XWIN_CLIPBOARD, [test "x$XWIN" = xyes])
1529AM_CONDITIONAL(XWIN_GLX_WINDOWS, [test "x$XWIN" = xyes && false])
1530AM_CONDITIONAL(XWIN_NATIVEGDI, [test "x$XWIN" = xyes && false])
1531AM_CONDITIONAL(XWIN_PRIMARYFB, [test "x$XWIN" = xyes && false])
1532AM_CONDITIONAL(XWIN_RANDR, [test "x$XWIN" = xyes])
1533AM_CONDITIONAL(XWIN_XV, [test "x$XWIN" = xyes && test "x$XV" = xyes])
1534
1535dnl Darwin / OS X DDX
1536if test "x$XQUARTZ" = xyes; then
1537	AC_DEFINE(XQUARTZ,1,[Have Quartz])
1538	AC_DEFINE(ROOTLESS,1,[Build Rootless code])
1539
1540	DARWIN_LIBS="$MI_LIB $OS_LIB $DIX_LIB $FB_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $DBE_LIB $RECORD_LIB $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $XPSTUBS_LIB"
1541	AC_SUBST([DARWIN_LIBS])
1542
1543	AC_CHECK_LIB([Xplugin],[xp_init],[:])
1544
1545	CFLAGS="${CFLAGS} -DROOTLESS_WORKAROUND -DNO_ALLOCA"
1546
1547	PKG_CHECK_MODULES(XPBPROXY, [applewmproto >= 1.1.1] [applewm >= 1.0.0] xfixes fixesproto x11)
1548
1549	if test "x$STANDALONE_XPBPROXY" = xyes ; then
1550		AC_DEFINE(STANDALONE_XPBPROXY,1,[Build a standalone xpbproxy])
1551	fi
1552fi
1553
1554# Support for objc in autotools is minimal and not documented.
1555OBJC='$(CC)'
1556OBJCLD='$(CCLD)'
1557OBJCLINK='$(LINK)'
1558OBJCFLAGS='$(CFLAGS)'
1559AC_SUBST([OBJC])
1560AC_SUBST([OBJCCLD])
1561AC_SUBST([OBJCLINK])
1562AC_SUBST([OBJCFLAGS])
1563# internal, undocumented automake func follows :(
1564_AM_DEPENDENCIES([OBJC])
1565AM_CONDITIONAL(HAVE_XPLUGIN, [test "x$ac_cv_lib_Xplugin_xp_init" = xyes])
1566AM_CONDITIONAL(HAVE_AGL_FRAMEWORK, [test "x$xorg_cv_AGL_framework" = xyes])
1567AM_CONDITIONAL(XQUARTZ, [test "x$XQUARTZ" = xyes])
1568AM_CONDITIONAL(STANDALONE_XPBPROXY, [test "x$STANDALONE_XPBPROXY" = xyes])
1569
1570dnl DMX DDX
1571
1572PKG_CHECK_MODULES([DMXMODULES], [xmuu xext x11 xrender xfixes xfont xi dmxproto xau $XDMCP_MODULES], [have_dmx=yes], [have_dmx=no])
1573AC_MSG_CHECKING([whether to build Xdmx DDX])
1574if test "x$DMX" = xauto; then
1575	DMX="$have_dmx"
1576	case $host_os in
1577		cygwin*) DMX="no" ;;
1578		darwin*) DMX="no" ;;
1579	esac
1580fi
1581AC_MSG_RESULT([$DMX])
1582AM_CONDITIONAL(DMX, [test "x$DMX" = xyes])
1583
1584if test "x$DMX" = xyes; then
1585	if test "x$have_dmx" = xno; then
1586		AC_MSG_ERROR([Xdmx build explicitly requested, but required
1587		              modules not found.])
1588	fi
1589	DMX_INCLUDES="$XEXT_INC $RENDER_INC $RECORD_INC"
1590	XDMX_CFLAGS="$DMXMODULES_CFLAGS"
1591	XDMX_LIBS="$XEXT_LIB $FB_LIB $CONFIG_LIB $RENDER_LIB $RECORD_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $MIEXT_SHADOW_LIB $MIEXT_DAMAGE_LIB"
1592	XDMX_SYS_LIBS="$DMXMODULES_LIBS"
1593	AC_SUBST([XDMX_CFLAGS])
1594	AC_SUBST([XDMX_LIBS])
1595	AC_SUBST([XDMX_SYS_LIBS])
1596
1597dnl USB sources in DMX require <linux/input.h>
1598	AC_CHECK_HEADER([linux/input.h], DMX_BUILD_USB="yes",
1599			DMX_BUILD_USB="no")
1600dnl Linux sources in DMX require <linux/keyboard.h>
1601	AC_CHECK_HEADER([linux/keyboard.h], DMX_BUILD_LNX="yes",
1602			DMX_BUILD_LNX="no")
1603	if test "x$GLX" = xyes; then
1604		PKG_CHECK_MODULES([GL], [glproto])
1605	fi
1606	PKG_CHECK_MODULES([XDMXCONFIG_DEP], [xaw7 xmu xt xpm x11])
1607	AC_SUBST(XDMXCONFIG_DEP_CFLAGS)
1608	AC_SUBST(XDMXCONFIG_DEP_LIBS)
1609	PKG_CHECK_MODULES([DMXEXAMPLES_DEP], [dmx xext x11])
1610	AC_SUBST(DMXEXAMPLES_DEP_LIBS)
1611	PKG_CHECK_MODULES([DMXXMUEXAMPLES_DEP], [dmx xmu xext x11])
1612	AC_SUBST(DMXXMUEXAMPLES_DEP_LIBS)
1613	PKG_CHECK_MODULES([DMXXIEXAMPLES_DEP], [dmx xi xext x11])
1614	AC_SUBST(DMXXIEXAMPLES_DEP_LIBS)
1615	PKG_CHECK_MODULES([XTSTEXAMPLES_DEP], [xtst xext x11])
1616	AC_SUBST(XTSTEXAMPLES_DEP_LIBS)
1617	PKG_CHECK_MODULES([XRESEXAMPLES_DEP], [xres xext x11])
1618	AC_SUBST(XRESEXAMPLES_DEP_LIBS)
1619	PKG_CHECK_MODULES([X11EXAMPLES_DEP], [xext x11])
1620	AC_SUBST(X11EXAMPLES_DEP_LIBS)
1621fi
1622AM_CONDITIONAL([DMX_BUILD_LNX], [test "x$DMX_BUILD_LNX" = xyes])
1623AM_CONDITIONAL([DMX_BUILD_USB], [test "x$DMX_BUILD_USB" = xyes])
1624
1625dnl kdrive DDX
1626
1627XEPHYR_LIBS=
1628XEPHYR_INCS=
1629XSDL_LIBS=
1630XSDL_INCS=
1631XSDL_DIRS=
1632
1633AM_CONDITIONAL(KDRIVE, [test x$KDRIVE = xyes])
1634if test "$KDRIVE" = yes; then
1635    AC_DEFINE(KDRIVESERVER,1,[Build Kdrive X server])
1636    AC_DEFINE(KDRIVEDDXACTIONS,,[Build kdrive ddx])
1637
1638    AC_CHECK_HEADERS([sys/vm86.h sys/io.h])
1639    if test "$ac_cv_header_sys_vm86_h" = yes && test "x$KDRIVEVESA" = xauto; then
1640        KDRIVEVESA=yes
1641    fi
1642
1643    if test "x$KDRIVEVESA" = xyes; then
1644        KDRIVEFBDEVLIB=yes
1645        AC_DEFINE(KDRIVEVESA, 1, [Build VESA-based kdrive servers])
1646    fi
1647
1648    AC_CHECK_HEADERS([linux/fb.h])
1649    if test "$ac_cv_header_linux_fb_h" = yes && test "x$XFBDEV" = xauto; then
1650        XFBDEV=yes
1651    fi
1652
1653    if test "x$XFBDEV" = xyes; then
1654        KDRIVEFBDEVLIB=yes
1655        AC_DEFINE(KDRIVEFBDEV, 1, [Build fbdev-based kdrive server])
1656    fi
1657    
1658    # tslib...
1659    AC_CHECK_LIB(ts, ts_open, [HAVE_TSLIB="yes"])
1660    if test "x$TSLIB" = xauto && test "x$HAVE_TSLIB" = xyes; then
1661        TSLIB=yes
1662    fi
1663
1664    if test "x$TSLIB" = xyes; then
1665        if ! test "x$HAVE_TSLIB" = xyes; then
1666            AC_MSG_ERROR([tslib must be installed to build the tslib input driver.])
1667        fi
1668        TSLIB_LIBS="-lts"
1669        AC_DEFINE(TSLIB, 1, [Have tslib support])
1670    fi
1671
1672    AC_CHECK_HEADERS([SDL/SDL.h])
1673    if test x"$ac_cv_header_SDL_SDL_h" = xyes && test "x$XSDL" = xauto; then
1674       XSDL=yes
1675    fi
1676
1677    if test x"$XSDL" = xyes; then
1678       # PKG_CHECK_MODULES(XSDL_EXTRA, Xfont xau $XDMCP_MODULES)
1679       AC_DEFINE(XSDLSERVER,1,[Build Xsdl server])
1680       XSDL_LIBS="`sdl-config --libs`"
1681       XSDL_INCS="`sdl-config --cflags` $XSERVER_CFLAGS"
1682    fi
1683
1684    XEPHYR_REQUIRED_LIBS="x11 xext xfont xau xdmcp"
1685    if test "x$XV" = xyes; then
1686        XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS xv"
1687    fi
1688    if test "x$DRI" = xyes && test "x$GLX" = xyes; then
1689        XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS gl libdrm"
1690    fi
1691
1692    PKG_CHECK_MODULES(XEPHYR, $XEPHYR_REQUIRED_LIBS, [xephyr="yes"], [xephyr="no"])
1693    if test "x$XEPHYR" = xauto; then
1694        XEPHYR=$xephyr
1695    fi
1696
1697    # Xephyr needs nanosleep() which is in librt on Solaris
1698    AC_CHECK_FUNC([nanosleep], [],
1699        AC_CHECK_LIB([rt], [nanosleep], XEPHYR_LIBS="$XEPHYR_LIBS -lrt"))
1700    
1701    if test "x$TSLIB" = xyes; then
1702        PKG_CHECK_MODULES([TSLIB], [tslib-1.0], [HAVE_TSLIB="yes"], [HAVE_TSLIB="no"])
1703        if test "x$HAVE_TSLIB" = xno; then
1704            AC_MSG_ERROR([tslib must be installed to build the tslib driver. See http://tslib.berlios.de/])
1705        fi
1706        AC_DEFINE(TSLIB, 1, [Have tslib support])
1707    fi
1708
1709    # damage shadow extension glx (NOTYET) fb mi
1710    KDRIVE_INC='-I$(top_srcdir)/hw/kdrive/src'
1711    KDRIVE_PURE_INCS="$KDRIVE_INC $MIEXT_DAMAGE_INC $MIEXT_SHADOW_INC $XEXT_INC $FB_INC $MI_INC"
1712    KDRIVE_OS_INC='-I$(top_srcdir)/hw/kdrive/linux'
1713    KDRIVE_INCS="$KDRIVE_PURE_INCS $KDRIVE_OS_INC"
1714    
1715    KDRIVE_CFLAGS="$XSERVER_CFLAGS -DHAVE_KDRIVE_CONFIG_H $TSLIB_CFLAGS"
1716
1717    KDRIVE_PURE_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $DBE_LIB $RECORD_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $OS_LIB"
1718    KDRIVE_LIB='$(top_builddir)/hw/kdrive/src/libkdrive.a'
1719    case $host_os in
1720	*linux*)
1721	    KDRIVE_OS_LIB='$(top_builddir)/hw/kdrive/linux/liblinux.a'
1722            KDRIVELINUX=yes
1723	    ;;
1724    esac
1725    KDRIVE_STUB_LIB='$(top_builddir)/hw/kdrive/src/libkdrivestubs.a'
1726    KDRIVE_LOCAL_LIBS="$DIX_LIB $KDRIVE_LIB $KDRIVE_STUB_LIB $CONFIG_LIB"
1727    KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $FB_LIB $MI_LIB $KDRIVE_PURE_LIBS"
1728    KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $KDRIVE_OS_LIB $OS_LIB"
1729    KDRIVE_LIBS="$TSLIB_LIBS $KDRIVE_LOCAL_LIBS $XSERVER_SYS_LIBS $GLX_SYS_LIBS"
1730
1731    AC_SUBST([XEPHYR_LIBS])
1732    AC_SUBST([XEPHYR_INCS])
1733    AC_SUBST([XSDL_LIBS])
1734    AC_SUBST([XSDL_INCS])
1735fi
1736AC_SUBST([KDRIVE_INCS])
1737AC_SUBST([KDRIVE_PURE_INCS])
1738AC_SUBST([KDRIVE_CFLAGS])
1739AC_SUBST([KDRIVE_PURE_LIBS])
1740AC_SUBST([KDRIVE_LOCAL_LIBS])
1741AC_SUBST([KDRIVE_LIBS])
1742AM_CONDITIONAL(KDRIVELINUX, [test "x$KDRIVELINUX" = xyes])
1743AM_CONDITIONAL(TSLIB, [test "x$HAVE_TSLIB" = xyes])
1744AM_CONDITIONAL(KDRIVEVESA, [test "x$KDRIVEVESA" = xyes])
1745AM_CONDITIONAL(KDRIVEFBDEV, [test "x$XFBDEV" = xyes])
1746AM_CONDITIONAL(XSDLSERVER, [test x"$XSDL" = xyes])
1747AM_CONDITIONAL(XEPHYR, [test "x$KDRIVE" = xyes && test "x$XEPHYR" = xyes])
1748AM_CONDITIONAL(BUILD_KDRIVEFBDEVLIB, [test "x$KDRIVE" = xyes && test "x$KDRIVEFBDEVLIB" = xyes])
1749AM_CONDITIONAL(XFAKESERVER, [test "x$KDRIVE" = xyes && test "x$XFAKE" = xyes])
1750
1751dnl these only go in xkb-config.h (which is shared by the Xorg and Xnest servers)
1752AC_DEFINE(__XKBDEFRULES__, "xorg", [Default XKB rules])
1753AC_DEFINE_DIR(XKB_BASE_DIRECTORY, XKBPATH, [Path to XKB data])
1754AC_DEFINE_DIR(XKB_BIN_DIRECTORY, bindir, [Path to XKB bin dir])
1755
1756# Make sure XKM_OUTPUT_DIR is an absolute path
1757XKBOUTPUT_FIRSTCHAR=`echo $XKBOUTPUT | cut -b 1`
1758
1759if [[ x$XKBOUTPUT_FIRSTCHAR != x/ ]] ; then
1760   XKBOUTPUT="$XKB_BASE_DIRECTORY/$XKBOUTPUT"
1761fi
1762
1763# XKM_OUTPUT_DIR (used in code) must end in / or file names get hosed
1764# XKB_COMPILED_DIR (used in Makefiles) must not or install-sh gets confused
1765
1766XKBOUTPUT=`echo $XKBOUTPUT/ | sed 's|/*$|/|'`
1767XKB_COMPILED_DIR=`echo $XKBOUTPUT | sed 's|/*$||'`
1768
1769AC_DEFINE_DIR(XKM_OUTPUT_DIR, XKBOUTPUT, [Path to XKB output dir])
1770
1771AC_SUBST(XKB_COMPILED_DIR)
1772
1773dnl and the rest of these are generic, so they're in config.h
1774dnl 
1775dnl though, thanks to the passing of some significant amount of time, the
1776dnl above is probably a complete fallacy, and you should not rely on it.
1777dnl but this is still actually better than imake, honest. -daniels
1778
1779AC_TRY_COMPILE([
1780#include <features.h>
1781#ifndef __GLIBC__
1782#error not glibc
1783#endif
1784], [], [AC_DEFINE(_GNU_SOURCE, 1,
1785	[ Enable GNU and other extensions to the C environment for glibc])])
1786
1787AC_DEFINE_DIR(PROJECTROOT, prefix, [Overall prefix])
1788
1789BUILD_DATE="$(date +'%Y%m%d')"
1790AC_SUBST([BUILD_DATE])
1791BUILD_TIME="$(date +'1%H%M%S')"
1792AC_SUBST([BUILD_TIME])
1793
1794DIX_CFLAGS="-DHAVE_DIX_CONFIG_H $XSERVER_CFLAGS"
1795
1796AC_SUBST([DIX_CFLAGS])
1797
1798AC_SUBST([libdir])
1799AC_SUBST([exec_prefix])
1800AC_SUBST([prefix])
1801
1802# Man page sections - used in config utils & generating man pages
1803XORG_MANPAGE_SECTIONS
1804
1805AC_OUTPUT([
1806Makefile
1807glx/Makefile
1808include/Makefile
1809composite/Makefile
1810damageext/Makefile
1811dbe/Makefile
1812dix/Makefile
1813doc/Makefile
1814fb/Makefile
1815record/Makefile
1816config/Makefile
1817mi/Makefile
1818miext/Makefile
1819miext/damage/Makefile
1820miext/shadow/Makefile
1821miext/cw/Makefile
1822miext/rootless/Makefile
1823os/Makefile
1824randr/Makefile
1825render/Makefile
1826xkb/Makefile
1827Xext/Makefile
1828Xi/Makefile
1829xfixes/Makefile
1830exa/Makefile
1831hw/Makefile
1832hw/xfree86/Makefile
1833hw/xfree86/common/Makefile
1834hw/xfree86/common/xf86Build.h
1835hw/xfree86/ddc/Makefile
1836hw/xfree86/dixmods/Makefile
1837hw/xfree86/dixmods/extmod/Makefile
1838hw/xfree86/doc/Makefile
1839hw/xfree86/doc/devel/Makefile
1840hw/xfree86/doc/man/Makefile
1841hw/xfree86/doc/sgml/Makefile
1842hw/xfree86/dri/Makefile
1843hw/xfree86/dri2/Makefile
1844hw/xfree86/dummylib/Makefile
1845hw/xfree86/exa/Makefile
1846hw/xfree86/fbdevhw/Makefile
1847hw/xfree86/i2c/Makefile
1848hw/xfree86/int10/Makefile
1849hw/xfree86/loader/Makefile
1850hw/xfree86/modes/Makefile
1851hw/xfree86/os-support/Makefile
1852hw/xfree86/os-support/bsd/Makefile
1853hw/xfree86/os-support/bus/Makefile
1854hw/xfree86/os-support/hurd/Makefile
1855hw/xfree86/os-support/misc/Makefile
1856hw/xfree86/os-support/linux/Makefile
1857hw/xfree86/os-support/sco/Makefile
1858hw/xfree86/os-support/solaris/Makefile
1859hw/xfree86/os-support/sysv/Makefile
1860hw/xfree86/parser/Makefile
1861hw/xfree86/ramdac/Makefile
1862hw/xfree86/shadowfb/Makefile
1863hw/xfree86/vbe/Makefile
1864hw/xfree86/vgahw/Makefile
1865hw/xfree86/x86emu/Makefile
1866hw/xfree86/xaa/Makefile
1867hw/xfree86/xf8_16bpp/Makefile
1868hw/xfree86/utils/Makefile
1869hw/xfree86/utils/cvt/Makefile
1870hw/xfree86/utils/gtf/Makefile
1871hw/dmx/config/Makefile
1872hw/dmx/doc/Makefile
1873hw/dmx/examples/Makefile
1874hw/dmx/input/Makefile
1875hw/dmx/glxProxy/Makefile
1876hw/dmx/Makefile
1877hw/vfb/Makefile
1878hw/xnest/Makefile
1879hw/xwin/Makefile
1880hw/xquartz/Makefile
1881hw/xquartz/GL/Makefile
1882hw/xquartz/bundle/Makefile
1883hw/xquartz/doc/Makefile
1884hw/xquartz/mach-startup/Makefile
1885hw/xquartz/pbproxy/Makefile
1886hw/xquartz/xpr/Makefile
1887hw/kdrive/Makefile
1888hw/kdrive/ephyr/Makefile
1889hw/kdrive/fake/Makefile
1890hw/kdrive/fbdev/Makefile
1891hw/kdrive/linux/Makefile
1892hw/kdrive/sdl/Makefile
1893hw/kdrive/src/Makefile
1894xorg-server.pc
1895])
1896