[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-xorg
Subject:    VMGL
From:       Joshua Humpich <joshua () ast ! dfs ! de>
Date:       2013-03-26 8:30:12
Message-ID: 1364286612.7956.2.camel () msmdw206 ! monza ! ast ! dfs ! de
[Download RAW message or body]

Hey there,
my name is Joshua Humpich and at the moment I'm going to get trough with
my Bachelor thesis in computer science.
At the moment I'm trying to port the VMGL module on current X.
VMGL is a X module which causes that you can run 3D apps in a VM with
hardware acceleration on the graphics card.
So there is a "GlStub" which catches OpenGl rendering commands and
forwards them to the graphics card or forwards them over network e.g
Xforwarding.

The Problem:
The module was compiled and worked on the 7.1 tree.
Now I am using RHEL 6.1 64bit with a X version of 7.7.

When I'm compiling and building X it get through with success.
Now after restarting X I'll get a segmentation fault at address 0x3.

With some 'debug' information using the function xf86Msg() I know which
function is called and when X crashed.

At this point of my research I have to stop because I haven't that
knowhow to get on with my work.

So is there anybody who can helps me to get along with my mission to run
VMGL on current X ?!?

I modified the original sources because of some debug or compile errors
(are commented in source code).
The original sources which probably run on 7.1 you get get from
http://vmgl.sourceforge.net/ .

Their are some attachments with the modified source code of VMGL (.c
and .h), the configure.ac file from toplevel X dir, Makefile.am file
in /hw/xfree86/dixmods, the xorg.conf file, Xorg.0.log file and the
startx output.


I would like to thank you for your answers !!!



Best regards,
Joshua Humpich

["configure.ac" (configure.ac)]

dnl Copyright  © 2003-2007 Keith Packard, Daniel Stone
dnl
dnl Permission is hereby granted, free of charge, to any person obtaining a
dnl copy of this software and associated documentation files (the "Software"),
dnl to deal in the Software without restriction, including without limitation
dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
dnl and/or sell copies of the Software, and to permit persons to whom the
dnl Software is furnished to do so, subject to the following conditions:
dnl
dnl The above copyright notice and this permission notice (including the next
dnl paragraph) shall be included in all copies or substantial portions of the
dnl Software.
dnl
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
dnl DEALINGS IN THE SOFTWARE.
dnl
dnl Authors: Keith Packard <keithp@keithp.com>
dnl          Daniel Stone <daniel@fooishbar.org>
dnl          an unwitting cast of miscellaneous others
dnl
dnl Process this file with autoconf to create configure.

AC_PREREQ(2.57)
AC_INIT([xorg-server], 1.7.7, \
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server) \
RELEASE_DATE="2010-05-04" AC_CONFIG_SRCDIR([Makefile.am])
AM_INIT_AUTOMAKE([dist-bzip2 foreign])
AM_MAINTAINER_MODE

AC_CONFIG_FILES([
	shave
	shave-libtool
])

# Require xorg-macros version 1.2.0 or newer for XORG_CHANGELOG and
# XORG_CWARNFLAGS
m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.2 or later \
before running autoconf/autogen])]) XORG_MACROS_VERSION(1.2)

dnl this gets generated by autoheader, and thus contains all the defines.  we
dnl don't ever actually use it, internally.
AC_CONFIG_HEADERS(include/do-not-use-config.h)
dnl xorg-server.h is an external header, designed to be included by loadable
dnl drivers.
AC_CONFIG_HEADERS(include/xorg-server.h)
dnl dix-config.h covers most of the DIX (i.e. everything but the DDX, not just
dnl dix/).
AC_CONFIG_HEADERS(include/dix-config.h)
dnl xorg-config.h covers the Xorg DDX.
AC_CONFIG_HEADERS(include/xorg-config.h)
dnl xkb-config.h covers XKB for the Xorg and Xnest DDXs.
AC_CONFIG_HEADERS(include/xkb-config.h)
dnl xwin-config.h covers the XWin DDX.
AC_CONFIG_HEADERS(include/xwin-config.h)
dnl kdrive-config.h covers the kdrive DDX
AC_CONFIG_HEADERS(include/kdrive-config.h)
dnl version-config.h covers the version numbers so they can be bumped without
dnl forcing an entire recompile.x
AC_CONFIG_HEADERS(include/version-config.h)

AC_PROG_CC
AM_PROG_AS
AC_PROG_INSTALL
AC_PROG_LN_S
AC_LIBTOOL_WIN32_DLL
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
DOLT
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG
AC_PROG_LEX
AC_PROG_YACC
AC_SYS_LARGEFILE
XORG_PROG_RAWCPP
AC_PATH_PROG(SED,sed)

dnl Check for dtrace program (needed to build Xserver dtrace probes)
dnl Also checks for <sys/sdt.h>, since some Linux distros have an 
dnl ISDN trace program named dtrace
AC_ARG_WITH(dtrace, AS_HELP_STRING([--with-dtrace=PATH],
	     [Enable dtrace probes (default: enabled if dtrace found)]),
	     [WDTRACE=$withval], [WDTRACE=auto])
if test "x$WDTRACE" = "xyes" -o "x$WDTRACE" = "xauto" ; then
	AC_PATH_PROG(DTRACE, [dtrace], [not_found], [$PATH:/usr/sbin])
	if test "x$DTRACE" = "xnot_found" ; then
		if test "x$WDTRACE" = "xyes" ; then
			AC_MSG_FAILURE([dtrace requested but not found])
		fi
		WDTRACE="no"
	else
		AC_CHECK_HEADER(sys/sdt.h, [HAS_SDT_H="yes"], [HAS_SDT_H="no"])
		if test "x$WDTRACE" = "xauto" -a "x$HAS_SDT_H" = "xno" ; then
			WDTRACE="no"
		fi
	fi
fi
if test "x$WDTRACE" != "xno" ; then
  AC_DEFINE(XSERVER_DTRACE, 1, 
      [Define to 1 if the DTrace Xserver provider probes should be built in.])

# Solaris/OpenSolaris require dtrace -G to build dtrace probe information into
# object files, and require linking with those as relocatable objects, not .a
# archives. MacOS X handles all this in the normal compiler toolchain, and on
# some releases (like Tiger), will error out on dtrace -G.  For now, other
# platforms with Dtrace ports are assumed to support -G (the FreeBSD and Linux
# ports appear to, based on my web searches, but have not yet been tested).
	case $host_os in
		darwin*)	SPECIAL_DTRACE_OBJECTS=no ;;
		*)		SPECIAL_DTRACE_OBJECTS=yes ;;
	esac
fi
AM_CONDITIONAL(XSERVER_DTRACE, [test "x$WDTRACE" != "xno"])
AM_CONDITIONAL(SPECIAL_DTRACE_OBJECTS, [test "x$SPECIAL_DTRACE_OBJECTS" = "xyes"])

AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h dlfcn.h stropts.h])

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_BIGENDIAN([ENDIAN="X_BIG_ENDIAN"], [ENDIAN="X_LITTLE_ENDIAN"])

AC_CHECK_SIZEOF([unsigned long])
if test "$ac_cv_sizeof_unsigned_long" = 8; then
	AC_DEFINE(_XSERVER64, 1, [Define to 1 if unsigned long is 64 bits.])
fi

AC_TYPE_PID_T

# Checks for headers/macros for byte swapping
# Known variants:
#	<byteswap.h> bswap_16, bswap_32, bswap_64  (glibc)
#	<sys/endian.h> __swap16, __swap32, __swap64 (OpenBSD)
#	<sys/endian.h> bswap16, bswap32, bswap64 (other BSD's)
#	and a fallback to local macros if none of the above are found

# if <byteswap.h> is found, assume it's the correct version
AC_CHECK_HEADERS([byteswap.h])

# if <sys/endian.h> is found, have to check which version
AC_CHECK_HEADER([sys/endian.h], [HAVE_SYS_ENDIAN_H="yes"], [HAVE_SYS_ENDIAN_H="no"])

if test "x$HAVE_SYS_ENDIAN_H" = "xyes" ; then
	AC_MSG_CHECKING([for __swap16 variant of <sys/endian.h> byteswapping macros])
	AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <sys/types.h>
#include <sys/endian.h>
 ], [
int a = 1, b;
b = __swap16(a);
 ])
], [SYS_ENDIAN__SWAP='yes'], [SYS_ENDIAN__SWAP='no'])
	AC_MSG_RESULT([$SYS_ENDIAN__SWAP])

	AC_MSG_CHECKING([for bswap16 variant of <sys/endian.h> byteswapping macros])
	AC_LINK_IFELSE([AC_LANG_PROGRAM([
#include <sys/types.h>
#include <sys/endian.h>
 ], [
int a = 1, b;
b = bswap16(a);
 ])
], [SYS_ENDIAN_BSWAP='yes'], [SYS_ENDIAN_BSWAP='no'])
	AC_MSG_RESULT([$SYS_ENDIAN_BSWAP])

    	if test "$SYS_ENDIAN_BSWAP" = "yes" ; then
		USE_SYS_ENDIAN_H=yes
		BSWAP=bswap
	else	
	    	if test "$SYS_ENDIAN__SWAP" = "yes" ; then
			USE_SYS_ENDIAN_H=yes
			BSWAP=__swap
		else
			USE_SYS_ENDIAN_H=no
		fi
	fi

	if test "$USE_SYS_ENDIAN_H" = "yes" ; then
	    AC_DEFINE([USE_SYS_ENDIAN_H], 1, 
		[Define to use byteswap macros from <sys/endian.h>])
	    AC_DEFINE_UNQUOTED([bswap_16], ${BSWAP}16, 
			[Define to 16-bit byteswap macro])
	    AC_DEFINE_UNQUOTED([bswap_32], ${BSWAP}32, 
			[Define to 32-bit byteswap macro])
	    AC_DEFINE_UNQUOTED([bswap_64], ${BSWAP}64, 
			[Define to 64-bit byteswap macro])
	fi
fi

dnl Check to see if dlopen is in default libraries (like Solaris, which
dnl has it in libc), or if libdl is needed to get it.
AC_CHECK_FUNC([dlopen], [],
	AC_CHECK_LIB([dl], [dlopen], DLOPEN_LIBS="-ldl"))

dnl Checks for library functions.
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr \
		strtol getopt getopt_long vsnprintf walkcontext backtrace \
		getisax getzoneid shmctl64 strcasestr ffs])
AC_FUNC_ALLOCA
dnl Old HAS_* names used in os/*.c.
AC_CHECK_FUNC([getdtablesize],
	AC_DEFINE(HAS_GETDTABLESIZE, 1, [Have the 'getdtablesize' function.]))
AC_CHECK_FUNC([getifaddrs],
	AC_DEFINE(HAS_GETIFADDRS, 1, [Have the 'getifaddrs' function.]))
AC_CHECK_FUNC([getpeereid],
	AC_DEFINE(HAS_GETPEEREID, 1, [Have the 'getpeereid' function.]))
AC_CHECK_FUNC([getpeerucred],
	AC_DEFINE(HAS_GETPEERUCRED, 1, [Have the 'getpeerucred' function.]))
AC_CHECK_FUNC([strlcat], HAVE_STRLCAT=yes, HAVE_STRLCAT=no)
AM_CONDITIONAL(NEED_STRLCAT, [test x$HAVE_STRLCAT = xno])	
AC_CHECK_FUNC([strlcpy], AC_DEFINE(HAS_STRLCPY, 1, [Have the 'strlcpy' function]))

AM_CONDITIONAL(NEED_VSNPRINTF, [test x$HAVE_VSNPRINTF = xno])

dnl Check for mmap support for Xvfb
AC_CHECK_FUNC([mmap], AC_DEFINE(HAS_MMAP, 1, [Have the 'mmap' function.]))

dnl Find the math libary
AC_CHECK_LIB(m, sqrt)
AC_CHECK_LIB(m, cbrt, AC_DEFINE(HAVE_CBRT, 1, [Have the 'cbrt' function]))

AC_CHECK_HEADERS([ndbm.h dbm.h rpcsvc/dbm.h])

dnl AGPGART headers
AC_CHECK_HEADERS([linux/agpgart.h sys/agpio.h sys/agpgart.h], AGP=yes)
AM_CONDITIONAL(AGP, [test "x$AGP" = xyes])

dnl APM header
AC_CHECK_HEADERS([linux/apm_bios.h], LNXAPM=yes)
AM_CONDITIONAL(LNXAPM, [test "x$LNXAPM" = xyes])

dnl fbdev header
AC_CHECK_HEADERS([linux/fb.h], FBDEV=yes)
AM_CONDITIONAL(FBDEVHW, [test "x$FBDEV" = xyes])

dnl MTRR header
AC_CHECK_HEADERS([asm/mtrr.h], ac_cv_asm_mtrr_h=yes)
if test "x$ac_cv_asm_mtrr_h" = xyes; then
	HAVE_MTRR=yes
fi

dnl BSD MTRR header
AC_CHECK_HEADERS([sys/memrange.h], ac_cv_memrange_h=yes)
if test "x$ac_cv_memrange_h" = xyes; then
	HAVE_MTRR=yes
fi

if test "x$HAVE_MTRR" = xyes; then
	AC_DEFINE(HAS_MTRR_SUPPORT, 1, [MTRR support available])
fi

dnl A NetBSD MTRR header
AC_CHECK_HEADERS([machine/mtrr.h], ac_cv_machine_mtrr_h=yes)
if test "x$ac_cv_machine_mtrr_h" = xyes; then
	AC_DEFINE(HAS_MTRR_BUILTIN, 1, [Define to 1 if NetBSD built-in MTRR
		support is available])
fi

dnl FreeBSD kldload support (sys/linker.h)
AC_CHECK_HEADERS([sys/linker.h],
	[ac_cv_sys_linker_h=yes],
	[ac_cv_sys_linker_h=no],
	[#include <sys/param.h>])
AM_CONDITIONAL(FREEBSD_KLDLOAD, [test "x$ac_cv_sys_linker_h" = xyes])

AC_CACHE_CHECK([for SYSV IPC],
		ac_cv_sysv_ipc,
		[AC_TRY_LINK([
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
],[
{ 
    int id;
    id = shmget(IPC_PRIVATE, 512, SHM_W | SHM_R);
    if (id < 0) return -1;
    return shmctl(id, IPC_RMID, 0);
}],
	[ac_cv_sysv_ipc=yes],
	[ac_cv_sysv_ipc=no])])
if test "x$ac_cv_sysv_ipc" = xyes; then
	AC_DEFINE(HAVE_SYSV_IPC, 1, [Define to 1 if SYSV IPC is available])
fi

dnl OpenBSD /dev/xf86 aperture driver 
if test -c /dev/xf86 ; then
	AC_DEFINE(HAS_APERTURE_DRV, 1, [System has /dev/xf86 aperture driver])
fi

dnl BSD APM support 
AC_CHECK_HEADER([machine/apmvar.h],[
	AC_CHECK_HEADER([sys/event.h],
		ac_cv_BSD_KQUEUE_APM=yes,
		ac_cv_BSD_APM=yes)])

AM_CONDITIONAL(BSD_APM, [test "x$ac_cv_BSD_APM" = xyes])
AM_CONDITIONAL(BSD_KQUEUE_APM, [test "x$ac_cv_BSD_KQUEUE_APM" = xyes])
	
dnl glibc backtrace support check (hw/xfree86/common/xf86Events.c)
AC_CHECK_HEADER([execinfo.h],[
    AC_CHECK_LIB(c, backtrace, [
        AC_DEFINE(HAVE_BACKTRACE, 1, [Has backtrace support])
        AC_DEFINE(HAVE_EXECINFO_H, 1, [Have execinfo.h])
    ])]
)

dnl ---------------------------------------------------------------------------
dnl Bus options and CPU capabilities.  Replaces logic in
dnl hw/xfree86/os-support/bus/Makefile.am, among others.
dnl ---------------------------------------------------------------------------
DEFAULT_INT10="x86emu"

dnl Override defaults as needed for specific platforms:

case $host_cpu in
  alpha*)
	ALPHA_VIDEO=yes
	case $host_os in
	        *freebsd*)	SYS_LIBS=-lio ;;
		*netbsd*)	AC_DEFINE(USE_ALPHA_PIO, 1, [NetBSD PIO alpha IO]) ;;
	esac
	GLX_ARCH_DEFINES="-D__GLX_ALIGN64 -mieee"
	;;
  arm*)
	ARM_VIDEO=yes
	;;
  i*86)
	I386_VIDEO=yes
	case $host_os in
		*freebsd*)	AC_DEFINE(USE_DEV_IO) ;;
		*dragonfly*)	AC_DEFINE(USE_DEV_IO) ;;
		*netbsd*)	AC_DEFINE(USE_I386_IOPL)
				SYS_LIBS=-li386
				;;
		*openbsd*)	AC_DEFINE(USE_I386_IOPL) 
				SYS_LIBS=-li386
				;;
	esac
        ;;
  powerpc*)
	PPC_VIDEO=yes
	case $host_os in
		*freebsd*)	DEFAULT_INT10=stub ;;
	esac
	;;
  sparc*)
	SPARC64_VIDEO=yes
	BSD_ARCH_SOURCES="sparc64_video.c ioperm_noop.c"
	GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
	;;
  x86_64*|amd64*)
	I386_VIDEO=yes
	case $host_os in
		*freebsd*)	AC_DEFINE(USE_DEV_IO, 1, [BSD /dev/io]) ;;
		*dragonfly*)	AC_DEFINE(USE_DEV_IO, 1, [BSD /dev/io]) ;;
		*netbsd*)	AC_DEFINE(USE_I386_IOPL, 1, [BSD i386 iopl])
				SYS_LIBS=-lx86_64
				;;
		*openbsd*)	AC_DEFINE(USE_AMD64_IOPL, 1, [BSD AMD64 iopl])
				SYS_LIBS=-lamd64
				;;
	esac
	GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
	;;
  ia64*)
  	GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
	;;
  s390*)
  	GLX_ARCH_DEFINES="-D__GLX_ALIGN64"
	;;
esac
AC_SUBST(GLX_ARCH_DEFINES)

dnl BSD *_video.c selection
AM_CONDITIONAL(ALPHA_VIDEO, [test "x$ALPHA_VIDEO" = xyes])
AM_CONDITIONAL(ARM_VIDEO, [test "x$ARM_VIDEO" = xyes])
AM_CONDITIONAL(I386_VIDEO, [test "x$I386_VIDEO" = xyes])
AM_CONDITIONAL(PPC_VIDEO, [test "x$PPC_VIDEO" = xyes])
AM_CONDITIONAL(SPARC64_VIDEO, [test "x$SPARC64_VIDEO" = xyes])

DRI=no
USE_SIGIO_BY_DEFAULT="yes"
dnl it would be nice to autodetect these *CONS_SUPPORTs
case $host_os in
  *freebsd* | *dragonfly*)
	case $host_os in
		kfreebsd*-gnu) ;;
		*) AC_DEFINE(CSRG_BASED, 1, [System is BSD-like]) ;;
	esac
	AC_DEFINE(PCCONS_SUPPORT, 1, [System has PC console])
	AC_DEFINE(PCVT_SUPPORT, 1, [System has PCVT console])
	AC_DEFINE(SYSCONS_SUPPORT, 1, [System has syscons console])
	DRI=yes
	;;
  *netbsd*)
	AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
	AC_DEFINE(PCCONS_SUPPORT, 1, [System has PC console])
	AC_DEFINE(PCVT_SUPPORT, 1, [System has PCVT console])
	AC_DEFINE(WSCONS_SUPPORT, 1, [System has wscons console])
	DRI=yes
	;;
  *openbsd*)
	AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
	AC_DEFINE(PCVT_SUPPORT, 1, [System has PC console])
	AC_DEFINE(WSCONS_SUPPORT, 1, [System has wscons console])
	;;
  *linux*)
	DRI=yes
	;;
  *solaris*)
	PKG_CHECK_EXISTS(libdrm, DRI=yes, DRI=no)
	# Disable use of SIGIO by default until some system bugs are
	# fixed - see Sun/OpenSolaris bug id 6879897
	USE_SIGIO_BY_DEFAULT="no"
	;;
  darwin*)
	AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
	;;
esac

XORG_RELEASE_VERSION
dnl augment XORG_RELEASE_VERSION for our snapshot number and to expose the
dnl major number
PVMAJOR=`echo $PACKAGE_VERSION | cut -d . -f 1`
PVS=`echo $PACKAGE_VERSION | cut -d . -f 4 | cut -d - -f 1`
if test "x$PVS" = "x"; then
	PVS="0"
fi

VENDOR_RELEASE="((($PVMAJOR) * 10000000) + (($PVM) * 100000) + (($PVP) * 1000) + \
$PVS)" VENDOR_MAN_VERSION="Version ${PACKAGE_VERSION}"

VENDOR_NAME="The X.Org Foundation"
VENDOR_NAME_SHORT="X.Org"
VENDOR_WEB="http://wiki.x.org"

m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], \
m4_defn([AC_HELP_STRING]))])

dnl Build options.
AC_ARG_ENABLE(werror,        AS_HELP_STRING([--enable-werror],
				  [Treat warnings as errors (default: disabled)]),
			        [WERROR=$enableval], [WERROR=no])
AC_ARG_ENABLE(debug,         AS_HELP_STRING([--enable-debug],
				  [Enable debugging (default: disabled)]),
			        [DEBUGGING=$enableval], [DEBUGGING=no])
AC_ARG_ENABLE(unit-tests,    AS_HELP_STRING([--enable-unit-tests],
                                  [Enable unit-tests (default: auto)]),
                                [UNITTESTS=$enableval], [UNITTESTS=auto])
AC_ARG_ENABLE(sigio-default, AS_HELP_STRING([--enable-use-sigio-by-default]
  [Enable SIGIO input handlers by default (default: $USE_SIGIO_BY_DEFAULT)]),
                                [USE_SIGIO_BY_DEFAULT=$enableval], [])
AC_ARG_WITH(int10,           AS_HELP_STRING([--with-int10=BACKEND], [int10 backend: \
vm86, x86emu or stub]),  [INT10="$withval"],
				[INT10="$DEFAULT_INT10"])
AC_ARG_WITH(vendor-name,     AS_HELP_STRING([--with-vendor-name=VENDOR],
				  [Vendor string reported by the server]),
				[ VENDOR_NAME="$withval" ], [])
AC_ARG_WITH(vendor-name-short, AS_HELP_STRING([--with-vendor-name-short=VENDOR],
				  [Short version of vendor string reported by the server]),
				[ VENDOR_NAME_SHORT="$withval" ], [])
AC_ARG_WITH(vendor-web,      AS_HELP_STRING([--with-vendor-web=URL],
				  [Vendor web address reported by the server]),
				[ VENDOR_WEB="$withval" ], [])
AC_ARG_WITH(module-dir,      AS_HELP_STRING([--with-module-dir=DIR],
				  [Directory where modules are installed (default: $libdir/xorg/modules)]),
				[ moduledir="$withval" ],
				[ moduledir="${libdir}/xorg/modules" ])
AC_ARG_WITH(log-dir,         AS_HELP_STRING([--with-log-dir=DIR],
				  [Directory where log files are kept (default: $localstatedir/log)]),
				[ logdir="$withval" ],
				[ logdir="$localstatedir/log" ])
AC_ARG_WITH(builder-addr,    AS_HELP_STRING([--with-builder-addr=ADDRESS],
				  [Builder address (default: xorg@lists.freedesktop.org)]),
				[ BUILDERADDR="$withval" ],
				[ BUILDERADDR="xorg@lists.freedesktop.org" ])
AC_ARG_WITH(os-name,         AS_HELP_STRING([--with-os-name=OSNAME], [Name of OS \
(default: output of "uname -srm")]),  [ OSNAME="$withval" ],
				[ OSNAME=`uname -srm` ])
AC_ARG_WITH(os-vendor,       AS_HELP_STRING([--with-os-vendor=OSVENDOR], [Name of OS \
vendor]),  [ OSVENDOR="$withval" ],
				[ OSVENDOR="" ])
AC_ARG_WITH(builderstring,   AS_HELP_STRING([--with-builderstring=BUILDERSTRING], \
[Additional builder string]),  [ BUILDERSTRING="$withval" ]
				[ ])
AC_ARG_WITH(fontdir,         AS_HELP_STRING([--with-fontdir=FONTDIR], [Path to top \
level dir where fonts are installed (default: ${libdir}/X11/fonts)]),  [ \
FONTDIR="$withval" ],  [ FONTDIR="${libdir}/X11/fonts" ])
DEFAULT_FONT_PATH="${FONTDIR}/misc/,${FONTDIR}/TTF/,${FONTDIR}/OTF,${FONTDIR}/Type1/,${FONTDIR}/100dpi/,${FONTDIR}/75dpi/"
 case $host_os in
	darwin*)    DEFAULT_FONT_PATH="${DEFAULT_FONT_PATH},/Library/Fonts,/System/Library/Fonts" \
;; esac
AC_ARG_WITH(default-font-path, AS_HELP_STRING([--with-default-font-path=PATH], [Comma \
separated list of font dirs]),  [ FONTPATH="$withval" ],
				[ FONTPATH="${DEFAULT_FONT_PATH}" ])

AC_ARG_WITH(xkb-path,         AS_HELP_STRING([--with-xkb-path=PATH], [Path to XKB \
base dir (default: ${datadir}/X11/xkb)]),  [ XKBPATH="$withval" ],
				[ XKBPATH="${datadir}/X11/xkb" ])
AC_ARG_WITH(xkb-output,       AS_HELP_STRING([--with-xkb-output=PATH], [Path to XKB \
output dir (default: ${datadir}/X11/xkb/compiled)]),  [ XKBOUTPUT="$withval" ],
				[ XKBOUTPUT="compiled" ])
AC_ARG_WITH(default-xkb-rules, AS_HELP_STRING([--with-default-xkb-rules=RULES],
                                   [Keyboard ruleset (default: base/evdev)]),
                                [ XKB_DFLT_RULES="$withval" ],
                                [ XKB_DFLT_RULES="" ])
AC_ARG_WITH(default-xkb-model, AS_HELP_STRING([--with-default-xkb-model=MODEL],
                                   [Keyboard model (default: pc105)]),
                                [ XKB_DFLT_MODEL="$withval" ],
                                [ XKB_DFLT_MODEL="pc105" ])
AC_ARG_WITH(default-xkb-layout, AS_HELP_STRING([--with-default-xkb-layout=LAYOUT],
                                   [Keyboard layout (default: us)]),
                                [ XKB_DFLT_LAYOUT="$withval" ],
                                [ XKB_DFLT_LAYOUT="us" ])
AC_ARG_WITH(default-xkb-variant, AS_HELP_STRING([--with-default-xkb-variant=VARIANT],
                                   [Keyboard variant (default: (none))]),
                                [ XKB_DFLT_VARIANT="$withval" ],
                                [ XKB_DFLT_VARIANT="" ])
AC_ARG_WITH(default-xkb-options, AS_HELP_STRING([--with-default-xkb-options=OPTIONS],
                                   [Keyboard layout options (default: (none))]),
                                [ XKB_DFLT_OPTIONS="$withval" ],
                                [ XKB_DFLT_OPTIONS="" ])
AC_ARG_WITH(serverconfig-path, AS_HELP_STRING([--with-serverconfig-path=PATH],
				   [Directory where ancillary server config files are installed (default: \
${libdir}/xorg)]),  [ SERVERCONFIG="$withval" ],
				[ SERVERCONFIG="${libdir}/xorg" ])
AC_ARG_WITH(apple-applications-dir,AS_HELP_STRING([--with-apple-applications-dir=PATH], \
[Path to the Applications directory (default: /Applications/Utilities)]),  [ \
APPLE_APPLICATIONS_DIR="${withval}" ],  [ \
APPLE_APPLICATIONS_DIR="/Applications/Utilities" ]) \
AC_SUBST([APPLE_APPLICATIONS_DIR]) \
AC_ARG_WITH(apple-application-name,AS_HELP_STRING([--with-apple-application-name=NAME], \
[Name for the .app (default: X11)]),  [ APPLE_APPLICATION_NAME="${withval}" ],
				[ APPLE_APPLICATION_NAME="X11" ])
AC_SUBST([APPLE_APPLICATION_NAME])
AC_ARG_WITH(launchd-id-prefix,  AS_HELP_STRING([--with-launchd-id-prefix=PATH], \
[Prefix to use for launchd identifiers (default: org.x)]),  [ \
LAUNCHD_ID_PREFIX="${withval}" ],  [ LAUNCHD_ID_PREFIX="org.x" ])
AC_SUBST([LAUNCHD_ID_PREFIX])
AC_DEFINE_UNQUOTED(LAUNCHD_ID_PREFIX, "$LAUNCHD_ID_PREFIX", [Prefix to use for \
launchd identifiers]) AC_ARG_ENABLE(sparkle,AS_HELP_STRING([--enable-sparkle], \
[Enable updating of X11.app using the Sparkle Framework (default: disabled)]),  [ \
XQUARTZ_SPARKLE="${enableval}" ],  [ XQUARTZ_SPARKLE="no" ])
AC_SUBST([XQUARTZ_SPARKLE])
AC_ARG_ENABLE(builddocs,      AS_HELP_STRING([--enable-builddocs], [Build docs \
(default: disabled)]),  [BUILDDOCS=$enableval],
                                [BUILDDOCS=no])
AC_ARG_ENABLE(install-libxf86config,
				AS_HELP_STRING([--enable-install-libxf86config],
				[Install libxf86config (default: disabled)]),
				[INSTALL_LIBXF86CONFIG=$enableval],
				[INSTALL_LIBXF86CONFIG=no])
AC_ARG_ENABLE(null-root-cursor, AS_HELP_STRING([--enable-null-root-cursor], [Use an \
empty root cursor (default: use core cursor)]),  [NULL_ROOT_CURSOR=$enableval],
                                 [NULL_ROOT_CURSOR=no])
AC_ARG_ENABLE(visibility,     AC_HELP_STRING([--enable-visibility], [Enable symbol \
visibility (default: auto)]),  [SYMBOL_VISIBILITY=$enableval],
				[SYMBOL_VISIBILITY=auto])
AC_ARG_ENABLE(pc98,     	AC_HELP_STRING([--enable-pc98], [Enable PC98 support in Xorg \
(default: auto)]),  [SUPPORT_PC98=$enableval],
				[SUPPORT_PC98=auto])

dnl GLX build options
AC_ARG_WITH(dri-driver-path,  AS_HELP_STRING([--with-dri-driver-path=PATH], [Path to \
DRI drivers (default: ${libdir}/dri)]),  [ DRI_DRIVER_PATH="$withval" ],
				[ DRI_DRIVER_PATH="${libdir}/dri" ])
AC_ARG_ENABLE(aiglx,          AS_HELP_STRING([--enable-aiglx], [Build accelerated \
indirect GLX (default: enabled)]),  [AIGLX=$enableval],
                                [AIGLX=yes])
AC_ARG_ENABLE(glx-tls,        AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS \
support (default: disabled)]),  [GLX_USE_TLS=$enableval],
                                [GLX_USE_TLS=no])

dnl Extensions.
AC_ARG_ENABLE(registry,       AS_HELP_STRING([--disable-registry], [Build string \
registry module (default: enabled)]), [XREGISTRY=$enableval], [XREGISTRY=yes]) \
AC_ARG_ENABLE(composite,      AS_HELP_STRING([--disable-composite], [Build Composite \
extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes]) \
AC_ARG_ENABLE(mitshm,         AS_HELP_STRING([--disable-shm], [Build SHM extension \
(default: enabled)]), [MITSHM=$enableval], [MITSHM=yes]) AC_ARG_ENABLE(xres,          \
AS_HELP_STRING([--disable-xres], [Build XRes extension (default: enabled)]), \
[RES=$enableval], [RES=yes]) AC_ARG_ENABLE(record,         \
AS_HELP_STRING([--enable-record], [Build Record extension (default: disabled)]), \
[RECORD=$enableval], [RECORD=no]) AC_ARG_ENABLE(xv,             \
AS_HELP_STRING([--disable-xv], [Build Xv extension (default: enabled)]), \
[XV=$enableval], [XV=yes]) AC_ARG_ENABLE(xvmc,           \
AS_HELP_STRING([--disable-xvmc], [Build XvMC extension (default: enabled)]), \
[XVMC=$enableval], [XVMC=yes]) AC_ARG_ENABLE(dga,            \
AS_HELP_STRING([--disable-dga], [Build DGA extension (default: auto)]), \
[DGA=$enableval], [DGA=auto]) AC_ARG_ENABLE(screensaver,    \
AS_HELP_STRING([--disable-screensaver], [Build ScreenSaver extension (default: \
enabled)]), [SCREENSAVER=$enableval], [SCREENSAVER=yes]) AC_ARG_ENABLE(xdmcp,         \
AS_HELP_STRING([--disable-xdmcp], [Build XDMCP extension (default: auto)]), \
[XDMCP=$enableval], [XDMCP=auto]) AC_ARG_ENABLE(xdm-auth-1,     \
AS_HELP_STRING([--disable-xdm-auth-1], [Build XDM-Auth-1 extension (default: auto)]), \
[XDMAUTH=$enableval], [XDMAUTH=auto]) AC_ARG_ENABLE(glx,            \
AS_HELP_STRING([--disable-glx], [Build GLX extension (default: enabled)]), \
[GLX=$enableval], [GLX=yes]) AC_ARG_ENABLE(dri,            \
AS_HELP_STRING([--enable-dri], [Build DRI extension (default: auto)]), \
[DRI=$enableval]) AC_ARG_ENABLE(dri2,           AS_HELP_STRING([--enable-dri2], \
[Build DRI2 extension (default: auto)]), [DRI2=$enableval], [DRI2=auto]) \
AC_ARG_ENABLE(xinerama,	      AS_HELP_STRING([--disable-xinerama], [Build Xinerama \
extension (default: enabled)]), [XINERAMA=$enableval], [XINERAMA=yes]) \
AC_ARG_ENABLE(xf86vidmode,    AS_HELP_STRING([--disable-xf86vidmode], [Build \
XF86VidMode extension (default: auto)]), [XF86VIDMODE=$enableval], \
[XF86VIDMODE=auto]) AC_ARG_ENABLE(xace,           AS_HELP_STRING([--disable-xace], \
[Build X-ACE extension (default: enabled)]), [XACE=$enableval], [XACE=yes]) \
AC_ARG_ENABLE(xselinux,       AS_HELP_STRING([--disable-xselinux], [Build SELinux \
extension (default: disabled)]), [XSELINUX=$enableval], [XSELINUX=no]) \
AC_ARG_ENABLE(xcsecurity,     AS_HELP_STRING([--disable-xcsecurity], [Build Security \
extension (default: disabled)]), [XCSECURITY=$enableval], [XCSECURITY=no]) \
AC_ARG_ENABLE(xcalibrate,     AS_HELP_STRING([--enable-xcalibrate], [Build XCalibrate \
extension (default: disabled)]), [XCALIBRATE=$enableval], [XCALIBRATE=no]) \
AC_ARG_ENABLE(tslib,          AS_HELP_STRING([--enable-tslib], [Build kdrive tslib \
touchscreen support (default: disabled)]), [TSLIB=$enableval], [TSLIB=no]) \
AC_ARG_ENABLE(multibuffer,    AS_HELP_STRING([--enable-multibuffer], [Build \
Multibuffer extension (default: disabled)]), [MULTIBUFFER=$enableval], \
[MULTIBUFFER=no]) AC_ARG_ENABLE(dbe,            AS_HELP_STRING([--disable-dbe], \
[Build DBE extension (default: enabled)]), [DBE=$enableval], [DBE=yes]) \
AC_ARG_ENABLE(xf86bigfont,    AS_HELP_STRING([--disable-xf86bigfont], [Build XF86 Big \
Font extension (default: disabled)]), [XF86BIGFONT=$enableval], [XF86BIGFONT=no]) \
AC_ARG_ENABLE(dpms,           AS_HELP_STRING([--disable-dpms], [Build DPMS extension \
(default: enabled)]), [DPMSExtension=$enableval], [DPMSExtension=yes]) \
AC_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]) \
AC_ARG_ENABLE(config-hal,     AS_HELP_STRING([--disable-config-hal], [Build HAL \
support (default: auto)]), [CONFIG_HAL=$enableval], [CONFIG_HAL=auto]) \
AC_ARG_ENABLE(xfree86-utils,     AS_HELP_STRING([--enable-xfree86-utils], [Build \
xfree86 DDX utilities (default: enabled)]), [XF86UTILS=$enableval], [XF86UTILS=yes]) \
AC_ARG_ENABLE(xaa,               AS_HELP_STRING([--enable-xaa], [Build XAA (default: \
enabled)]), [XAA=$enableval], [XAA=yes]) AC_ARG_ENABLE(vgahw,          \
AS_HELP_STRING([--enable-vgahw], [Build Xorg with vga access (default: enabled)]), \
[VGAHW=$enableval], [VGAHW=yes]) AC_ARG_ENABLE(vbe,            \
AS_HELP_STRING([--enable-vbe], [Build Xorg with VBE module (default: enabled)]), \
[VBE=$enableval], [VBE=yes]) AC_ARG_ENABLE(int10-module,     \
AS_HELP_STRING([--enable-int10-module], [Build Xorg with int10 module (default: \
enabled)]), [INT10MODULE=$enableval], [INT10MODULE=yes])

dnl DDXes.
AC_ARG_ENABLE(xorg,    	      AS_HELP_STRING([--enable-xorg], [Build Xorg server \
(default: auto)]), [XORG=$enableval], [XORG=auto]) AC_ARG_ENABLE(dmx,    	      \
AS_HELP_STRING([--enable-dmx], [Build DMX server (default: auto)]), [DMX=$enableval], \
[DMX=auto]) AC_ARG_ENABLE(xvfb,    	      AS_HELP_STRING([--enable-xvfb], [Build Xvfb \
server (default: yes)]), [XVFB=$enableval], [XVFB=yes]) AC_ARG_ENABLE(xnest,   	      \
AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: auto)]), \
[XNEST=$enableval], [XNEST=auto]) AC_ARG_ENABLE(xquartz,        \
AS_HELP_STRING([--enable-xquartz], [Build Xquartz server for OS-X (default: auto)]), \
[XQUARTZ=$enableval], [XQUARTZ=auto]) AC_ARG_ENABLE(standalone-xpbproxy, \
AS_HELP_STRING([--enable-standalone-xpbproxy], [Build a standalone xpbproxy (in \
addition to the one integrated into Xquartz as a separate thread) (default: no)]), \
[STANDALONE_XPBPROXY=$enableval], [STANDALONE_XPBPROXY=no]) AC_ARG_ENABLE(xwin,    	  \
AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), \
[XWIN=$enableval], [XWIN=auto]) dnl kdrive and its subsystems
AC_ARG_ENABLE(kdrive,         AS_HELP_STRING([--enable-kdrive], [Build kdrive servers \
(default: no)]), [KDRIVE=$enableval], [KDRIVE=no]) AC_ARG_ENABLE(xephyr,         \
AS_HELP_STRING([--enable-xephyr], [Build the kdrive Xephyr server (default: auto)]), \
[XEPHYR=$enableval], [XEPHYR=auto]) AC_ARG_ENABLE(xsdl,           \
AS_HELP_STRING([--enable-xsdl], [Build the kdrive Xsdl server (default: auto)]), \
[XSDL=$enableval], [XSDL=auto]) AC_ARG_ENABLE(xfake,          \
AS_HELP_STRING([--enable-xfake], [Build the kdrive 'fake' server (default: auto)]), \
[XFAKE=$enableval], [XFAKE=auto]) AC_ARG_ENABLE(xfbdev,         \
AS_HELP_STRING([--enable-xfbdev], [Build the kdrive framebuffer device server \
(default: auto)]), [XFBDEV=$enableval], [XFBDEV=auto])


dnl chown/chmod to be setuid root as part of build
dnl Replaces InstallXserverSetUID in imake
AC_ARG_ENABLE(install-setuid, 
    AS_HELP_STRING([--enable-install-setuid],
       [Install Xorg server as owned by root with setuid bit (default: auto)]),
    [SETUID=$enableval], [SETUID=auto])
AC_MSG_CHECKING([to see if we can install the Xorg server as root])
if test "x$SETUID" = "xauto" ; then
	case $host_os in
	    darwin*)		SETUID="no"  ;;
	    *)
	   	case $host_cpu in
		    sparc)	SETUID="no"  ;;
		    *)		SETUID="yes" ;;
		esac
	esac
	if test "x$SETUID" = xyes; then
		touch testfile
		chown root testfile > /dev/null 2>&1 || SETUID="no"
		rm -f testfile
	fi
fi
AC_MSG_RESULT([$SETUID])
AM_CONDITIONAL(INSTALL_SETUID, [test "x$SETUID" = "xyes"])

dnl Issue an error if xtrans.m4 was not found and XTRANS_CONNECTION_FLAGS macro
dnl was not expanded, since xorg-server with no transport types is rather useless.
dnl
dnl If you're seeing an error here, be sure you installed the lib/xtrans module
dnl first and if it's not in the default location, that you set the ACLOCAL
dnl environment variable to find it, such as:
dnl	ACLOCAL="aclocal -I ${PREFIX}/share/aclocal"
m4_pattern_forbid(XTRANS_CONNECTION_FLAGS)

# Transport selection macro from xtrans.m4
XTRANS_CONNECTION_FLAGS

# Secure RPC detection macro from xtrans.m4
XTRANS_SECURE_RPC_FLAGS
AM_CONDITIONAL(SECURE_RPC, [test "x$SECURE_RPC" = xyes])

AM_CONDITIONAL(INT10_VM86, [test "x$INT10" = xvm86])
AM_CONDITIONAL(INT10_X86EMU, [test "x$INT10" = xx86emu])
AM_CONDITIONAL(INT10_STUB, [test "x$INT10" = xstub])
if test "x$INT10" = xyes; then
	dnl VM86 headers
	AC_CHECK_HEADERS([sys/vm86.h sys/io.h])
fi

dnl Handle building documentation
AM_CONDITIONAL(BUILDDOCS, test "x$BUILDDOCS" = xyes)

dnl Only build sgml docs when linuxdoc is available and
dnl def.ents has been installed
XORG_CHECK_LINUXDOC

dnl Handle installing libxf86config
AM_CONDITIONAL(INSTALL_LIBXF86CONFIG, [test "x$INSTALL_LIBXF86CONFIG" = xyes])

dnl XQuartz DDX Detection... Yes, it's ugly to have it here... but we need to handle \
this early on case $host_os in
	darwin*)
		DRI2=no

		if test x$XQUARTZ = xauto; then
			AC_CACHE_CHECK([whether to build Xquartz],xorg_cv_Carbon_framework,[
		 		save_LDFLAGS=$LDFLAGS
				LDFLAGS="$LDFLAGS -framework Carbon"
				AC_LINK_IFELSE([char FSFindFolder(); int main() { FSFindFolder(); return 0;}],
				[xorg_cv_Carbon_framework=yes],
				[xorg_cv_Carbon_framework=no])
			LDFLAGS=$save_LDFLAGS])
                
			if test "X$xorg_cv_Carbon_framework" = Xyes; then
				XQUARTZ=yes
			else
				XQUARTZ=no
			fi
		fi

		if test "x$XQUARTZ" = xyes ; then
			XQUARTZ=yes
			XVFB=no
			XNEST=no

			COMPOSITE=no
			DGA=no
			DPMSExtension=no
			XF86VIDMODE=no
		fi
		;;
	*) XQUARTZ=no ;;
esac

dnl ---------------------------------------------------------------------------
dnl Extension section
dnl ---------------------------------------------------------------------------
XEXT_INC='-I$(top_srcdir)/Xext'
XEXT_LIB='$(top_builddir)/Xext/libXext.la'
XEXTXORG_LIB='$(top_builddir)/Xext/libXextbuiltin.la'

dnl Optional modules
VIDEOPROTO="videoproto"
COMPOSITEPROTO="compositeproto >= 0.4"
RECORDPROTO="recordproto >= 1.13.99.1"
SCRNSAVERPROTO="scrnsaverproto >= 1.1"
RESOURCEPROTO="resourceproto"
DRIPROTO="xf86driproto >= 2.1.0"
DRI2PROTO="dri2proto >= 2.1"
XINERAMAPROTO="xineramaproto"
BIGFONTPROTO="xf86bigfontproto >= 1.2.0"
XCALIBRATEPROTO="xcalibrateproto"
DGAPROTO="xf86dgaproto >= 2.0.99.1"
GLPROTO="glproto >= 1.4.9"
DMXPROTO="dmxproto >= 2.2.99.1"
VIDMODEPROTO="xf86vidmodeproto >= 2.2.99.1"
WINDOWSWMPROTO="windowswmproto"
APPLEWMPROTO="applewmproto >= 1.4"

dnl Core modules for most extensions, et al.
REQUIRED_MODULES="[randrproto >= 1.2.99.3] [renderproto >= 0.11] [fixesproto >= 4.1] \
[damageproto >= 1.1] [xcmiscproto >= 1.2.0] [xextproto >= 7.0.99.3] [xproto >= \
7.0.13] [xtrans >= 1.2.2] [bigreqsproto >= 1.1.0] fontsproto [inputproto >= \
1.9.99.902] [kbproto >= 1.0.3] vmglproto" REQUIRED_LIBS="xfont xau [pixman-1 >= \
0.15.20]"

dnl List of libraries that require a specific version
LIBAPPLEWM="applewm >= 1.4"
LIBDMX="dmx >= 1.0.99.1"
LIBDRI="dri >= 7.1.0"
LIBDRM="libdrm >= 2.3.0"
LIBGL="gl >= 7.1.0"
LIBXEXT="xext >= 1.0.99.4"
LIBXI="xi >= 1.2.99.1"
LIBXTST="xtst >= 1.0.99.2"
LIBPCIACCESS="pciaccess >= 0.8.0"
LIBGLIB="glib-2.0 >= 2.16"
LIBSELINUX="libselinux >= 2.0.86"

dnl HAVE_DBUS is true if we actually have the D-Bus library, whereas
dnl CONFIG_DBUS_API is true if we want to enable the D-Bus config
dnl API.
PKG_CHECK_MODULES(DBUS, dbus-1, [HAVE_DBUS=yes], [HAVE_DBUS=no])
if test "x$HAVE_DBUS" = xyes; then
	AC_DEFINE(HAVE_DBUS, 1, [Have D-Bus support])
fi
AM_CONDITIONAL(HAVE_DBUS, [test "x$HAVE_DBUS" = xyes])

if test "x$CONFIG_DBUS_API" = xauto; then
	CONFIG_DBUS_API="$HAVE_DBUS"
fi
if test "x$CONFIG_DBUS_API" = xyes; then
	if ! test "x$HAVE_DBUS" = xyes; then
		AC_MSG_ERROR([D-Bus configuration API requested, but D-Bus is not installed.])
	fi

	AC_DEFINE(CONFIG_DBUS_API, 1, [Use the D-Bus input configuration API])
	CONFIG_NEED_DBUS="yes"
fi
AM_CONDITIONAL(CONFIG_DBUS_API, [test "x$CONFIG_DBUS_API" = xyes])

PKG_CHECK_MODULES(HAL, hal, [HAVE_HAL=yes], [HAVE_HAL=no])
if test "x$CONFIG_HAL" = xauto; then
	CONFIG_HAL="$HAVE_HAL"
fi
if test "x$CONFIG_HAL" = xyes; then
	if ! test "x$HAVE_HAL" = xyes; then
		AC_MSG_ERROR([HAL hotplug API requested, but HAL is not installed.])
	fi

	AC_DEFINE(CONFIG_HAL, 1, [Use the HAL hotplug API])
        REQUIRED_LIBS="$REQUIRED_LIBS hal"
	CONFIG_NEED_DBUS="yes"
fi
AM_CONDITIONAL(CONFIG_HAL, [test "x$CONFIG_HAL" = xyes])

if test "x$CONFIG_NEED_DBUS" = xyes; then
	REQUIRED_LIBS="$REQUIRED_LIBS dbus-1"
        AC_DEFINE(CONFIG_NEED_DBUS, 1, [Use D-Bus for input hotplug])
fi
AM_CONDITIONAL(CONFIG_NEED_DBUS, [test "x$CONFIG_NEED_DBUS" = xyes])
CONFIG_LIB='$(top_builddir)/config/libconfig.la'

if test "x$USE_SIGIO_BY_DEFAULT" = xyes; then
	USE_SIGIO_BY_DEFAULT_VALUE=TRUE
else
	USE_SIGIO_BY_DEFAULT_VALUE=FALSE
fi
AC_DEFINE_UNQUOTED([USE_SIGIO_BY_DEFAULT], [$USE_SIGIO_BY_DEFAULT_VALUE],
		   [Use SIGIO handlers for input device events by default])

AC_MSG_CHECKING([for glibc...])
AC_PREPROC_IFELSE([
#include <features.h>
#ifndef __GLIBC__
#error
#endif
], glibc=yes, glibc=no)
AC_MSG_RESULT([$glibc])

AC_CHECK_FUNCS([clock_gettime], [have_clock_gettime=yes],
               [AC_CHECK_LIB([rt], [clock_gettime], [have_clock_gettime=-lrt],
                             [have_clock_gettime=no])])

AC_MSG_CHECKING([for a useful monotonic clock ...])

if ! test "x$have_clock_gettime" = xno; then
    if ! test "x$have_clock_gettime" = xyes; then
        CLOCK_LIBS="$have_clock_gettime"
    else
        CLOCK_LIBS=""
    fi

    LIBS_SAVE="$LIBS"
    LIBS="$CLOCK_LIBS"
    CPPFLAGS_SAVE="$CPPFLAGS"

    if test x"$glibc" = xyes; then
        CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=200112L"
    fi

    AC_RUN_IFELSE([
#include <time.h>

int main(int argc, char *argv[[]]) {
    struct timespec tp;

    if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
        return 0;
    else
        return 1;
}
    ], [MONOTONIC_CLOCK=yes], [MONOTONIC_CLOCK=no],
       [MONOTONIC_CLOCK="cross compiling"])

    LIBS="$LIBS_SAVE"
    CPPFLAGS="$CPPFLAGS_SAVE"
else
    MONOTONIC_CLOCK=no
fi

AC_MSG_RESULT([$MONOTONIC_CLOCK])

if test "x$MONOTONIC_CLOCK" = xyes; then
    AC_DEFINE(MONOTONIC_CLOCK, 1, [Have monotonic clock from clock_gettime()])
    LIBS="$LIBS $CLOCK_LIBS"
fi

AM_CONDITIONAL(XV, [test "x$XV" = xyes])
if test "x$XV" = xyes; then
	AC_DEFINE(XV, 1, [Support Xv extension])
	AC_DEFINE(XvExtension, 1, [Build Xv extension])
	REQUIRED_MODULES="$REQUIRED_MODULES $VIDEOPROTO"
else
	XVMC=no
fi

AM_CONDITIONAL(XVMC, [test "x$XVMC" = xyes])
if test "x$XVMC" = xyes; then
	AC_DEFINE(XvMCExtension, 1, [Build XvMC extension])
fi

AM_CONDITIONAL(XREGISTRY, [test "x$XREGISTRY" = xyes])
if test "x$XREGISTRY" = xyes; then
	AC_DEFINE(XREGISTRY, 1, [Build registry module])
fi

AM_CONDITIONAL(COMPOSITE, [test "x$COMPOSITE" = xyes])
if test "x$COMPOSITE" = xyes; then
	AC_DEFINE(COMPOSITE, 1, [Support Composite Extension])
	REQUIRED_MODULES="$REQUIRED_MODULES $COMPOSITEPROTO"
	COMPOSITE_LIB='$(top_builddir)/composite/libcomposite.la'
	COMPOSITE_INC='-I$(top_srcdir)/composite'
fi

AM_CONDITIONAL(MITSHM, [test "x$MITSHM" = xyes])
if test "x$MITSHM" = xyes; then
	AC_DEFINE(MITSHM, 1, [Support MIT-SHM extension])
	AC_DEFINE(HAS_SHM, 1, [Support SHM])
fi

AM_CONDITIONAL(RECORD, [test "x$RECORD" = xyes])
if test "x$RECORD" = xyes; then
	AC_DEFINE(XRECORD, 1, [Support Record extension])
	REQUIRED_MODULES="$REQUIRED_MODULES $RECORDPROTO"
	RECORD_LIB='$(top_builddir)/record/librecord.la'
fi

AM_CONDITIONAL(SCREENSAVER, [test "x$SCREENSAVER" = xyes])
if test "x$SCREENSAVER" = xyes; then
	AC_DEFINE(SCREENSAVER, 1, [Support MIT-SCREEN-SAVER extension])
	REQUIRED_MODULES="$REQUIRED_MODULES $SCRNSAVERPROTO"
fi

AM_CONDITIONAL(RES, [test "x$RES" = xyes])
if test "x$RES" = xyes; then
	AC_DEFINE(RES, 1, [Support X resource extension])
	REQUIRED_MODULES="$REQUIRED_MODULES $RESOURCEPROTO"
fi

if test "x$GLX" = xyes; then
	PKG_CHECK_MODULES([XLIB], [x11])
	PKG_CHECK_MODULES([GL], $GLPROTO $LIBGL)
	AC_SUBST(XLIB_CFLAGS)
	AC_DEFINE(GLXEXT, 1, [Build GLX extension])
	GLX_LIBS='$(top_builddir)/glx/libglx.la'
	GLX_SYS_LIBS="$GLX_SYS_LIBS $DLOPEN_LIBS"
else
        GLX=no
fi
AM_CONDITIONAL(GLX, test "x$GLX" = xyes)

if test "x$AIGLX" = xyes -a "x$GLX" = xyes -a "x$DRI" = xyes; then
	AC_DEFINE(AIGLX, 1, [Build AIGLX loader])
else
	AIGLX=no
fi
AM_CONDITIONAL(AIGLX, test "x$AIGLX" = xyes)

if test "x$GLX_USE_TLS" = xyes -a "x$AIGLX" = xyes; then
	GLX_DEFINES="-DGLX_USE_TLS -DPTHREADS"
	GLX_SYS_LIBS="$GLX_SYS_LIBS -lpthread"
fi
AC_SUBST([GLX_DEFINES])

AM_CONDITIONAL(DRI, test "x$DRI" = xyes)
if test "x$DRI" = xyes; then
	AC_DEFINE(XF86DRI, 1, [Build DRI extension])
	PKG_CHECK_MODULES([DRIPROTO], [$DRIPROTO])
	PKG_CHECK_MODULES([DRI], $GLPROTO $LIBDRI)
	AC_SUBST(DRIPROTO_CFLAGS)
fi

PKG_CHECK_MODULES([DRI2PROTO], $DRI2PROTO,
                  [HAVE_DRI2PROTO=yes], [HAVE_DRI2PROTO=no])
case "$DRI2,$HAVE_DRI2PROTO" in
	yes,no)
		AC_MSG_ERROR([DRI2 requested, but dri2proto not found.])
		;;
	yes,yes | auto,yes)
		AC_DEFINE(DRI2, 1, [Build DRI2 extension])
		DRI2=yes
		;;
esac
AM_CONDITIONAL(DRI2, test "x$DRI2" = xyes)

if test "x$DRI" = xyes || test "x$DRI2" = xyes; then
	PKG_CHECK_MODULES([LIBDRM], $LIBDRM)
	AC_SUBST(LIBDRM_CFLAGS)
	AC_SUBST(LIBDRM_LIBS)
fi

if test "x$DRI2" = xyes; then
	save_CFLAGS=$CFLAGS
	CFLAGS="$GL_CFLAGS $LIBDRM_CFLAGS"
	AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <GL/gl.h>
#include <GL/internal/dri_interface.h>
#ifndef __DRI_DRI2
#error DRI2 extension not available.
#endif]])],
			  [HAVE_DRI2EXTENSION=yes],
			  [HAVE_DRI2EXTENSION=no])
	CFLAGS=$save_CFLAGS
	if test "x$HAVE_DRI2EXTENSION" = xyes; then
		AC_DEFINE(DRI2_AIGLX, 1, [Build DRI2 AIGLX loader])
		DRI2_AIGLX=yes
	else
		AC_MSG_NOTICE([DRI2 AIGLX disabled, __DRI_DRI2 not defined in dri_interface.h.])
		DRI2_AIGLX=no
	fi
fi
AM_CONDITIONAL(DRI2_AIGLX, test "x$DRI2_AIGLX" = xyes)


AM_CONDITIONAL(XINERAMA, [test "x$XINERAMA" = xyes])
if test "x$XINERAMA" = xyes; then
	AC_DEFINE(XINERAMA, 1, [Support Xinerama extension])
	AC_DEFINE(PANORAMIX, 1, [Internal define for Xinerama])
	REQUIRED_MODULES="$REQUIRED_MODULES $XINERAMAPROTO"
fi

AM_CONDITIONAL(XACE, [test "x$XACE" = xyes])
if test "x$XACE" = xyes; then
	AC_DEFINE(XACE, 1, [Build X-ACE extension])
fi

AM_CONDITIONAL(XSELINUX, [test "x$XSELINUX" = xyes])
if test "x$XSELINUX" = xyes; then
	if test "x$XACE" != xyes; then
		AC_MSG_ERROR([cannot build SELinux extension without X-ACE])
	fi
	AC_CHECK_HEADERS([libaudit.h], [], AC_MSG_ERROR([SELinux extension requires audit \
system headers]))  AC_CHECK_LIB(audit, audit_open, [], AC_MSG_ERROR([SELinux \
extension requires audit system library]))  PKG_CHECK_MODULES([SELINUX], $LIBSELINUX)
	SELINUX_LIBS="$SELINUX_LIBS -laudit"
	AC_DEFINE(XSELINUX, 1, [Build SELinux extension])
fi

AM_CONDITIONAL(XCSECURITY, [test "x$XCSECURITY" = xyes])
if test "x$XCSECURITY" = xyes; then
	if test "x$XACE" != xyes; then
		AC_MSG_ERROR([cannot build Security extension without X-ACE])
	fi
	AC_DEFINE(XCSECURITY, 1, [Build Security extension])
fi

AM_CONDITIONAL(MULTIBUFFER, [test "x$MULTIBUFFER" = xyes])
if test "x$MULTIBUFFER" = xyes; then
	AC_DEFINE(MULTIBUFFER, 1, [Build Multibuffer extension])
	# Requires xextproto which is always required
fi

AM_CONDITIONAL(DBE, [test "x$DBE" = xyes])
if test "x$DBE" = xyes; then
	AC_DEFINE(DBE, 1, [Support DBE extension])
	DBE_LIB='$(top_builddir)/dbe/libdbe.la'
fi

AM_CONDITIONAL(XF86BIGFONT, [test "x$XF86BIGFONT" = xyes])
if test "x$XF86BIGFONT" = xyes; then
	AC_DEFINE(XF86BIGFONT, 1, [Support XF86 Big font extension])
	REQUIRED_MODULES="$REQUIRED_MODULES $BIGFONTPROTO"
fi

AM_CONDITIONAL(DPMSExtension, [test "x$DPMSExtension" = xyes])
if test "x$DPMSExtension" = xyes; then
	AC_DEFINE(DPMSExtension, 1, [Support DPMS extension])
fi

if test "x$XCALIBRATE" = xyes && test "$KDRIVE" = yes; then
   AC_DEFINE(XCALIBRATE, 1, [Build XCalibrate extension])
   REQUIRED_MODULES="$REQUIRED_MODULES $XCALIBRATEPROTO"
else
   XCALIBRATE=no
fi
AM_CONDITIONAL(XCALIBRATE, [test "x$XCALIBRATE" = xyes])

AC_DEFINE(RENDER, 1, [Support RENDER extension])
RENDER_LIB='$(top_builddir)/render/librender.la'
RENDER_INC='-I$(top_srcdir)/render'

AC_DEFINE(RANDR, 1, [Support RANDR extension])
RANDR_LIB='$(top_builddir)/randr/librandr.la'
RANDR_INC='-I$(top_srcdir)/randr'

AC_DEFINE(XFIXES,1,[Support XFixes extension])
FIXES_LIB='$(top_builddir)/xfixes/libxfixes.la'
FIXES_INC='-I$(top_srcdir)/xfixes'

AC_DEFINE(DAMAGE,1,[Support Damage extension])
DAMAGE_LIB='$(top_builddir)/damageext/libdamageext.la'
DAMAGE_INC='-I$(top_srcdir)/damageext'
MIEXT_DAMAGE_LIB='$(top_builddir)/miext/damage/libdamage.la'
MIEXT_DAMAGE_INC='-I$(top_srcdir)/miext/damage'

# XINPUT extension is integral part of the server
AC_DEFINE(XINPUT, 1, [Support X Input extension])
XI_LIB='$(top_builddir)/Xi/libXi.la'
XI_INC='-I$(top_srcdir)/Xi'

AM_CONDITIONAL(XF86UTILS, test "x$XF86UTILS" = xyes)
AM_CONDITIONAL(XAA, test "x$XAA" = xyes)
AM_CONDITIONAL(VGAHW, test "x$VGAHW" = xyes)
AM_CONDITIONAL(VBE, test "x$VBE" = xyes)
AM_CONDITIONAL(INT10MODULE, test "x$INT10MODULE" = xyes)

AC_DEFINE(SHAPE, 1, [Support SHAPE extension])

AC_DEFINE_DIR(XKB_BASE_DIRECTORY, XKBPATH, [Path to XKB data])
AC_ARG_WITH(xkb-bin-directory,
				AS_HELP_STRING([--with-xkb-bin-directory=DIR], [Directory containing xkbcomp \
program]),  [XKB_BIN_DIRECTORY="$withval"],
				[XKB_BIN_DIRECTORY="$bindir"])

AC_DEFINE_DIR(XKB_BIN_DIRECTORY, XKB_BIN_DIRECTORY, [Path to XKB bin dir])

dnl Make sure XKM_OUTPUT_DIR is an absolute path
XKBOUTPUT_FIRSTCHAR=`echo $XKBOUTPUT | cut -b 1`
if [[ x$XKBOUTPUT_FIRSTCHAR != x/ -a x$XKBOUTPUT_FIRSTCHAR != 'x$' ]] ; then
   XKBOUTPUT="$XKB_BASE_DIRECTORY/$XKBOUTPUT"
fi

dnl XKM_OUTPUT_DIR (used in code) must end in / or file names get hosed
dnl XKB_COMPILED_DIR (used in Makefiles) must not or install-sh gets confused

XKBOUTPUT=`echo $XKBOUTPUT/ | sed 's|/*$|/|'`
XKB_COMPILED_DIR=`echo $XKBOUTPUT | sed 's|/*$||'`
AC_DEFINE_DIR(XKM_OUTPUT_DIR, XKBOUTPUT, [Path to XKB output dir])
AC_SUBST(XKB_COMPILED_DIR)

if test "x$XKB_DFLT_RULES" = x; then
    case $host_os in
    linux*)
        dnl doesn't take AutoAddDevices into account, but whatever.
        if test "x$CONFIG_HAL" = xyes; then
            XKB_DFLT_RULES="evdev"
        else
            XKB_DFLT_RULES="base"
        fi
        ;;
    *)
        XKB_DFLT_RULES="base"
        ;;
    esac
fi
AC_DEFINE_UNQUOTED(XKB_DFLT_RULES, ["$XKB_DFLT_RULES"], [Default XKB ruleset])
AC_DEFINE_UNQUOTED(XKB_DFLT_MODEL, ["$XKB_DFLT_MODEL"], [Default XKB model])
AC_DEFINE_UNQUOTED(XKB_DFLT_LAYOUT, ["$XKB_DFLT_LAYOUT"], [Default XKB layout])
AC_DEFINE_UNQUOTED(XKB_DFLT_VARIANT, ["$XKB_DFLT_VARIANT"], [Default XKB variant])
AC_DEFINE_UNQUOTED(XKB_DFLT_OPTIONS, ["$XKB_DFLT_OPTIONS"], [Default XKB options])

XKB_LIB='$(top_builddir)/xkb/libxkb.la'
XKB_STUB_LIB='$(top_builddir)/xkb/libxkbstubs.la'
REQUIRED_MODULES="$REQUIRED_MODULES xkbfile"

AC_CHECK_FUNC(strcasecmp, [], AC_DEFINE([NEED_STRCASECMP], 1,
                                        [Do not have 'strcasecmp'.]))
AC_CHECK_FUNC(strncasecmp, [], AC_DEFINE([NEED_STRNCASECMP], 1,
                                        [Do not have 'strncasecmp'.]))
AC_CHECK_FUNC(strcasestr, [], AC_DEFINE([NEED_STRCASESTR], 1,
                                       [Do not have 'strcasestr'.]))

if test "x$NULL_ROOT_CURSOR" = xyes; then
        AC_DEFINE(NULL_ROOT_CURSOR, 1, [Use an empty root cursor])
fi

PKG_CHECK_MODULES([XDMCP], [xdmcp], [have_libxdmcp="yes"], [have_libxdmcp="no"])
if test "x$have_libxdmcp" = xyes; then
	AC_CHECK_LIB(Xdmcp, XdmcpWrap, [have_xdmcpwrap="yes"], [have_xdmcpwrap="no"], \
[$XDMCP_LIBS]) fi
if test "x$XDMCP" = xauto; then
	if test "x$have_libxdmcp" = xyes; then
		XDMCP=yes
	else
		XDMCP=no
	fi
fi
if test "x$XDMAUTH" = xauto; then
	if test "x$have_libxdmcp" = xyes && test "x$have_xdmcpwrap" = xyes; then
		XDMAUTH=yes
	else
		XDMAUTH=no
	fi
fi

AM_CONDITIONAL(XDMCP, [test "x$XDMCP" = xyes])
if test "x$XDMCP" = xyes; then
	AC_DEFINE(XDMCP, 1, [Support XDM Control Protocol])
	REQUIRED_LIBS="$REQUIRED_LIBS xdmcp"
	XDMCP_MODULES="xdmcp"
fi

AM_CONDITIONAL(XDMAUTH, [test "x$XDMAUTH" = xyes])
if test "x$XDMAUTH" = xyes; then
	AC_DEFINE(HASXDMAUTH,1,[Support XDM-AUTH*-1])
	if ! test "x$XDMCP" = xyes; then
		REQUIRED_LIBS="$REQUIRED_LIBS xdmcp"
		XDMCP_MODULES="xdmcp"
	fi
fi

AC_DEFINE_DIR(COMPILEDDEFAULTFONTPATH, FONTPATH, [Default font path])
AC_DEFINE_DIR(PCI_TXT_IDS_PATH, PCI_TXT_IDS_DIR, [Default PCI text file ID path])
AC_DEFINE_DIR(SERVER_MISC_CONFIG_PATH, SERVERCONFIG, [Server miscellaneous config \
path]) AC_DEFINE_DIR(BASE_FONT_PATH, FONTDIR, [Default base font path])
AC_DEFINE_DIR(DRI_DRIVER_PATH, DRI_DRIVER_PATH, [Default DRI driver path])
AC_DEFINE_UNQUOTED(XVENDORNAME, ["$VENDOR_NAME"], [Vendor name])
AC_DEFINE_UNQUOTED(XVENDORNAMESHORT, ["$VENDOR_NAME_SHORT"], [Short vendor name])
AC_DEFINE_UNQUOTED(XORG_DATE, ["$RELEASE_DATE"], [Vendor release])
AC_DEFINE_UNQUOTED(XORG_MAN_VERSION, ["$VENDOR_MAN_VERSION"], [Vendor man version])
AC_DEFINE_UNQUOTED(BUILDERADDR, ["$BUILDERADDR"], [Builder address])

if test -z "$OSNAME"; then
    OSNAME="UNKNOWN"
fi

AC_DEFINE_UNQUOTED(OSNAME, ["$OSNAME"], [Operating System Name])
AC_DEFINE_UNQUOTED(OSVENDOR, ["$OSVENDOR"], [Operating System Vendor])
AC_DEFINE_UNQUOTED(BUILDERSTRING, ["$BUILDERSTRING"], [Builder string])

AC_SUBST([VENDOR_NAME_SHORT])
AC_DEFINE_UNQUOTED(VENDOR_NAME, ["$VENDOR_NAME"], [Vendor name])
AC_DEFINE_UNQUOTED(VENDOR_NAME_SHORT, ["$VENDOR_NAME_SHORT"], [Vendor name])
AC_DEFINE_UNQUOTED(VENDOR_RELEASE, [$VENDOR_RELEASE], [Vendor release])
AC_DEFINE_UNQUOTED(VENDOR_MAN_VERSION, ["$VENDOR_MAN_VERSION"], [Vendor man version])

AC_DEFINE(NO_LIBCWRAPPER, 1, [Define to 1 if modules should avoid the libcwrapper])

if test "x$DEBUGGING" = xyes; then
       AC_DEFINE(DEBUG, 1, [Enable debugging code])
fi
AM_CONDITIONAL(DEBUG, [test "x$DEBUGGING" = xyes])

# If unittests aren't explicitly disabled, check for required support
if test "x$UNITTESTS" != xno ; then
       PKG_CHECK_MODULES([GLIB], $LIBGLIB,
                         [HAVE_GLIB=yes], [HAVE_GLIB=no])

       # Check if linker supports -wrap, passed via compiler flags
       # When cross-compiling, reports no, since unit tests run from
       # "make check", so would be running on build machine,  not target
       AC_MSG_CHECKING([whether the linker supports -wrap])
       save_LDFLAGS="$LDFLAGS"
       LDFLAGS="$LDFLAGS -Wl,-wrap,exit"
       AC_RUN_IFELSE([AC_LANG_PROGRAM([[
	void __wrap_exit (int s)
	{
	    __real_exit (0);
	}]],
	[[exit (1);]])],
                     [linker_can_wrap="yes"],
                     [linker_can_wrap="no"],
                     [linker_can_wrap="no"])
       AC_MSG_RESULT([$linker_can_wrap])
       LDFLAGS="$save_LDFLAGS"
fi

if test "x$UNITTESTS" = xauto; then
       if test "x$HAVE_GLIB" = xyes && test "x$linker_can_wrap" = xyes; then
           UNITTESTS=yes
       else
           UNITTESTS=no
       fi
fi
if test "x$UNITTESTS" = xyes; then
       if test "x$HAVE_GLIB" = xno; then
           AC_MSG_ERROR([glib required to build unit tests])
       fi
       if test "x$linker_can_wrap" = xno; then
           AC_MSG_ERROR([ld -wrap support required to build unit tests])
       fi
       AC_DEFINE(UNITTESTS, 1, [Enable unit tests])
       AC_SUBST([GLIB_LIBS])
       AC_SUBST([GLIB_CFLAGS])
fi
AM_CONDITIONAL(UNITTESTS, [test "x$UNITTESTS" = xyes])

AC_DEFINE(XTEST, 1, [Support XTest extension])
AC_DEFINE(XSYNC, 1, [Support XSync extension])
AC_DEFINE(XCMISC, 1, [Support XCMisc extension])
AC_DEFINE(BIGREQS, 1, [Support BigRequests extension])

if test "x$SPECIAL_DTRACE_OBJECTS" = "xyes" ; then
  DIX_LIB='$(top_builddir)/dix/dix.O'
  OS_LIB='$(top_builddir)/os/os.O'
else
  DIX_LIB='$(top_builddir)/dix/libdix.la'
  OS_LIB='$(top_builddir)/os/libos.la'
fi
AC_SUBST([DIX_LIB])
AC_SUBST([OS_LIB])

MAIN_LIB='$(top_builddir)/dix/libmain.la'
AC_SUBST([MAIN_LIB])

MI_LIB='$(top_builddir)/mi/libmi.la'
MI_EXT_LIB='$(top_builddir)/mi/libmiext.la'
MI_INC='-I$(top_srcdir)/mi'
FB_LIB='$(top_builddir)/fb/libfb.la'
FB_INC='-I$(top_srcdir)/fb'
MIEXT_SHADOW_INC='-I$(top_srcdir)/miext/shadow'
MIEXT_SHADOW_LIB='$(top_builddir)/miext/shadow/libshadow.la'
CORE_INCS='-I$(top_srcdir)/include -I$(top_builddir)/include'

# OpenSSL used for SHA1 hashing in render/glyph.c, but we don't need all of
# the OpenSSL libraries, just libcrypto
# Some systems have matching functionality in the smaller/simpler libmd
# Builders who want to force a choice can set SHA1_LIB and SHA1_CFLAGS
if test "x$SHA1_LIB" = "x" ; then
  AC_CHECK_LIB([md], [SHA1Init], [SHA1_LIB="-lmd"
            AC_DEFINE([HAVE_SHA1_IN_LIBMD], [1],
            [Use libmd SHA1 functions instead of OpenSSL libcrypto])])
fi

if test "x$SHA1_LIB" = "x" ; then
  PKG_CHECK_EXISTS([OPENSSL], [openssl], [HAVE_OPENSSL_PKC=yes],
                    [HAVE_OPENSSL_PKC=no])
  if test "x$HAVE_OPENSSL_PKC" = xyes; then
    REQUIRED_LIBS="$REQUIRED_LIBS openssl"
  else
    AC_CHECK_LIB([crypto], [SHA1_Init], [SHA1_LIB="-lcrypto"],
                 [AC_MSG_ERROR([OpenSSL must be installed in order to build the X \
server.])])  fi
fi

PKG_CHECK_MODULES([XSERVERCFLAGS], [$REQUIRED_MODULES $REQUIRED_LIBS])
PKG_CHECK_MODULES([XSERVERLIBS], [$REQUIRED_LIBS])

# Autotools has some unfortunate issues with library handling.  In order to
# get a server to rebuild when a dependency in the tree is changed, it must
# be listed in SERVERNAME_DEPENDENCIES.  However, no system libraries may be
# listed there, or some versions of autotools will break (especially if a -L
# is required to find the library).  So, we keep two sets of libraries
# detected: NAMESPACE_LIBS for in-tree libraries to be linked against, which
# will go into the _DEPENDENCIES and _LDADD of the server, and
# NAMESPACE_SYS_LIBS which will go into only the _LDADD.  The
# NAMESPACEMODULES_LIBS detected from pkgconfig should always go in
# NAMESPACE_SYS_LIBS.
#
# XSERVER_LIBS is the set of in-tree libraries which all servers require.
# XSERVER_SYS_LIBS is the set of out-of-tree libraries which all servers
# require.
#
XSERVER_CFLAGS="${XSERVERCFLAGS_CFLAGS} ${SHA1_CFLAGS}"
XSERVER_LIBS="$DIX_LIB $CONFIG_LIB $MI_LIB $OS_LIB"
XSERVER_SYS_LIBS="${XSERVERLIBS_LIBS} ${SYS_LIBS} ${LIBS} ${SHA1_LIB}"
AC_SUBST([XSERVER_LIBS])
AC_SUBST([XSERVER_SYS_LIBS])

UTILS_SYS_LIBS="${SYS_LIBS}"
AC_SUBST([UTILS_SYS_LIBS])

# The Xorg binary needs to export symbols so that they can be used from modules
# Some platforms require extra flags to do this.   gcc should set these flags
# when -rdynamic is passed to it, other compilers/linkers may need to be added
# here.
XORG_CWARNFLAGS
if test "x$GCC" = "xyes"; then
       if test "x$WERROR" = "xyes"; then
               CWARNFLAGS="${CWARNFLAGS} -Werror"
       fi
       LD_EXPORT_SYMBOLS_FLAG="-rdynamic"
fi
XSERVER_CFLAGS="$CWARNFLAGS $XSERVER_CFLAGS"
case $host_os in
       openbsd*)
       LD_EXPORT_SYMBOLS_FLAG="-Wl,--export-dynamic"
       ;;
esac
AC_SUBST([LD_EXPORT_SYMBOLS_FLAG])

dnl Imake defines SVR4 on SVR4 systems, and many files check for it, so
dnl we need to replicate that here until those can all be fixed
AC_MSG_CHECKING([if SVR4 needs to be defined])
AC_EGREP_CPP([I_AM_SVR4],[
#if defined(SVR4) || defined(__svr4__) || defined(__SVR4)
 I_AM_SVR4
#endif
],[
AC_DEFINE([SVR4],1,[Define to 1 on systems derived from System V Release 4])
AC_MSG_RESULT([yes])], AC_MSG_RESULT([no]))

XSERVER_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"

dnl ---------------------------------------------------------------------------
dnl DDX section.
dnl ---------------------------------------------------------------------------

dnl Xvfb DDX

AC_MSG_CHECKING([whether to build Xvfb DDX])
AC_MSG_RESULT([$XVFB])
AM_CONDITIONAL(XVFB, [test "x$XVFB" = xyes])

if test "x$XVFB" = xyes; then
	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"  XVFB_SYS_LIBS="$XVFBMODULES_LIBS \
$GLX_SYS_LIBS"  AC_SUBST([XVFB_LIBS])
	AC_SUBST([XVFB_SYS_LIBS])
fi


dnl Xnest DDX

PKG_CHECK_MODULES(XNESTMODULES, [xfont $LIBXEXT x11 xau $XDMCP_MODULES], \
[have_xnest=yes], [have_xnest=no]) AC_MSG_CHECKING([whether to build Xnest DDX])
if test "x$XNEST" = xauto; then
	XNEST="$have_xnest"
fi
AC_MSG_RESULT([$XNEST])
AM_CONDITIONAL(XNEST, [test "x$XNEST" = xyes])

if test "x$XNEST" = xyes; then
	if test "x$have_xnest" = xno; then
		AC_MSG_ERROR([Xnest build explicitly requested, but required modules not found.])
	fi
	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 $MAIN_LIB $OS_LIB $CONFIG_LIB"  \
XNEST_SYS_LIBS="$XNESTMODULES_LIBS $GLX_SYS_LIBS"  AC_SUBST([XNEST_LIBS])
	AC_SUBST([XNEST_SYS_LIBS])
fi


dnl Xorg DDX

AC_MSG_CHECKING([whether to build Xorg DDX])
if test "x$XORG" = xauto; then
	XORG="yes"
	case $host_os in
		cygwin*) XORG="no" ;;
		darwin*) XORG="no" ;;
	esac
fi
AC_MSG_RESULT([$XORG])

xorg_bus_linuxpci=no
xorg_bus_bsdpci=no
xorg_bus_sparc=no

if test "x$XORG" = xyes; then
	XORG_DDXINCS='-I$(top_srcdir)/hw/xfree86 -I$(top_srcdir)/hw/xfree86/include \
-I$(top_srcdir)/hw/xfree86/common'  \
XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support \
-I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os'  \
XORG_INCS="$XORG_DDXINCS $XORG_OSINCS"  XORG_CFLAGS="$XORGSERVER_CFLAGS \
-DHAVE_XORG_CONFIG_H"  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"

	dnl ==================================================================
	dnl symbol visibility
	symbol_visibility=
	have_visibility=disabled
	if test x$SYMBOL_VISIBILITY != xno; then
	    AC_MSG_CHECKING(for symbol visibility support)
	    if test x$GCC = xyes; then
		VISIBILITY_CFLAGS="-fvisibility=hidden"
	    else
		AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
		if test x$SUNCC = xyes; then
		    VISIBILITY_CFLAGS="-xldscope=hidden"
		else
		    have_visibility=no
		fi
	    fi
	    if test x$have_visibility != xno; then
		save_CFLAGS="$CFLAGS"
		CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
		AC_TRY_COMPILE(
		    [#include <X11/Xfuncproto.h>
		     extern _X_HIDDEN int hidden_int;
		     extern _X_EXPORT int public_int;
		     extern _X_HIDDEN int hidden_int_func(void);
		     extern _X_EXPORT int public_int_func(void);],
		    [],
		    have_visibility=yes,
		    have_visibility=no)
		CFLAGS=$save_CFLAGS
	    fi
	    AC_MSG_RESULT([$have_visibility])
	    if test x$have_visibility != xno; then
		symbol_visibility=$VISIBILITY_CFLAGS
		XORG_CFLAGS="$XORG_CFLAGS $VISIBILITY_CFLAGS"
		XSERVER_CFLAGS="$XSERVER_CFLAGS $VISIBILITY_CFLAGS"
	    fi
	fi
	dnl added to xorg-server.pc
	AC_SUBST([symbol_visibility])
	dnl ===================================================================

	PKG_CHECK_MODULES([PCIACCESS], $LIBPCIACCESS)
	SAVE_LIBS=$LIBS
	SAVE_CFLAGS=$CFLAGS
	CFLAGS=$PCIACCESS_CFLAGS
	LIBS=$PCIACCESS_LIBS
	AC_CHECK_FUNCS([pci_system_init_dev_mem])
	AC_CHECK_FUNCS([pci_device_enable])
	AC_CHECK_FUNCS([pci_device_is_boot_vga])
	AC_CHECK_FUNCS([pci_device_vgaarb_init])
	LIBS=$SAVE_LIBS
	CFLAGS=$SAVE_CFLAGS
	XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $DLOPEN_LIBS $GLX_SYS_LIBS"
	XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS"

	case $host_os in
	  linux*)
		if test "x$LNXAPM" = xyes; then
			XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
		fi
	  	XORG_OS="linux"
		XORG_OS_SUBDIR="linux"
		xorg_bus_linuxpci="yes"
		linux_acpi="no"
		case $host_cpu in
		  ia64*)
			linux_ia64=yes
			linux_acpi="yes"
			;;
		  alpha*)
		  	linux_alpha=yes
			;;
		  i*86|amd64*|x86_64*)
			linux_acpi="yes"
			;;
		  *)
			;;
		esac
		;;
	  freebsd* | kfreebsd*-gnu | dragonfly*)
	  	XORG_OS="freebsd"
		XORG_OS_SUBDIR="bsd"
		xorg_bus_bsdpci="yes"
		;;
	  netbsd*)
	  	XORG_OS="netbsd"
		XORG_OS_SUBDIR="bsd"
		xorg_bus_bsdpci="yes"
		;;
	  openbsd*)
		if test "x$ac_cv_BSD_APM" = xyes \
			-o "x$ac_cv_BSD_KQUEUE_APM" = xyes; then
			XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
		fi
	  	XORG_OS="openbsd"
		XORG_OS_SUBDIR="bsd"
		xorg_bus_bsdpci="yes"
		;;
	  solaris*)
	  	XORG_OS="solaris"
		XORG_OS_SUBDIR="solaris"
		XORG_CFLAGS="$XORG_CFLAGS -DXF86PM"
		# Use the same stubs as BSD for old functions, since we now
		# use libpciaccess for PCI
		xorg_bus_bsdpci="yes"
		AC_CHECK_HEADERS([sys/kd.h])
		AC_CHECK_HEADERS([sys/vt.h], [solaris_vt=yes], [solaris_vt=no])
		# Check for minimum supported release
		AC_MSG_CHECKING([Solaris version])
	        OS_MINOR=`echo ${host_os}|sed -e 's/^.*solaris2\.//' -e s'/\..*$//'`
		if test "${OS_MINOR}" -ge 7 ; then
	        	AC_MSG_RESULT(Solaris ${OS_MINOR})
		else
			AC_MSG_RESULT(Solaris `echo ${host_os}|sed -e 's/^.*solaris//`)
		fi
		if test "${OS_MINOR}" -lt 8 ; then
			AC_MSG_ERROR([This release no longer supports Solaris versions older than Solaris \
8.])  fi
		AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
		if test "x$SUNCC" = "xyes"; then
			solaris_asm_inline="yes"
		fi
		AC_CHECK_DECL([_LP64], [SOLARIS_64="yes"], [SOLARIS_64="no"])
			
		case $host_cpu in
		  sparc*)	
			SOLARIS_INOUT_ARCH="sparcv8plus"
			;;
		  i*86)	
			if test x$SOLARIS_64 = xyes ; then
				SOLARIS_INOUT_ARCH="amd64"
			else
				SOLARIS_INOUT_ARCH="ia32"
			fi
			;;
		  *)
			AC_MSG_ERROR([Unsupported Solaris platform. Only SPARC & x86 \
			are supported on Solaris in this release.   If you are \
			interested in porting Xorg to your platform, please email \
			xorg@lists.freedesktop.org.]) ;;
		esac
		AC_SUBST([SOLARIS_INOUT_ARCH])
		if test x$solaris_asm_inline = xyes ; then
			SOLARIS_ASM_CFLAGS='$(top_srcdir)/hw/xfree86/os-support/solaris/solaris-$(SOLARIS_INOUT_ARCH).il'
  XORG_CFLAGS="${XORG_CFLAGS} "'$(SOLARIS_ASM_CFLAGS)'
		fi
		AC_SUBST([SOLARIS_ASM_CFLAGS])
		if test "x$SUPPORT_PC98" = xauto; then
			SUPPORT_PC98="no"
		fi
		;;
	  gnu*)
	  	XORG_OS="gnu"
		XORG_OS_SUBDIR="hurd"
		# Use the same stubs as BSD for old functions, since we now
		# use libpciaccess for PCI
		xorg_bus_bsdpci="yes"
		;;
	  *)
	  	XORG_OS="unknown"
		XORG_OS_SUBDIR="unknown"
		AC_MSG_ERROR([Your OS is unknown. Xorg currently only supports Linux, \
		Free/Open/NetBSD, Solaris, and OS X. If you are interested in porting \
	        Xorg to your platform, please email xorg@lists.freedesktop.org.])
		;;
	esac

	case $host_cpu in
	  sparc*)
		xorg_bus_sparc="yes"
		;;
	  i*86)
		if test "x$SUPPORT_PC98" = xauto; then
			SUPPORT_PC98="yes"
		fi
		;;
	esac

	if test "x$SUPPORT_PC98" = xauto; then
		SUPPORT_PC98="no"
	fi
	if test "x$SUPPORT_PC98" = xyes; then
		AC_DEFINE(SUPPORT_PC98, 1, [Support PC98])
	fi
	if test "x$XORG_OS_PCI" = x ; then
		XORG_OS_PCI=$XORG_OS
	fi
	if test "x$DGA" = xauto; then
		PKG_CHECK_MODULES(DGA, $DGAPROTO, [DGA=yes], [DGA=no])
	fi
	if test "x$DGA" = xyes; then
		XORG_MODULES="$XORG_MODULES $DGAPROTO"
		PKG_CHECK_MODULES(DGA, $DGAPROTO)
		AC_DEFINE(DGA, 1, [Support DGA extension])
		AC_DEFINE(XFreeXDGA, 1, [Build XDGA support])
	fi

	if test "x$XF86VIDMODE" = xauto; then
		PKG_CHECK_MODULES(XF86VIDMODE, $VIDMODEPROTO, [XF86VIDMODE=yes], [XF86VIDMODE=no])
	fi
	if test "x$XF86VIDMODE" = xyes; then
		XORG_MODULES="$XORG_MODULES $VIDMODEPROTO"
		PKG_CHECK_MODULES(XF86VIDMODE, $VIDMODEPROTO)
		AC_DEFINE(XF86VIDMODE, 1, [Support XFree86 Video Mode extension])
	fi

	if test -n "$XORG_MODULES"; then
	        PKG_CHECK_MODULES(XORG_MODULES, [$XORG_MODULES])
	        XORG_CFLAGS="$XORG_CFLAGS $XORG_MODULES_CFLAGS"
	        XORG_SYS_LIBS="$XORG_SYS_LIBS $XORG_MODULES_LIBS"
	fi

	AC_SUBST([XORG_LIBS])
	AC_SUBST([XORG_SYS_LIBS])
	AC_SUBST([XORG_INCS])
	AC_SUBST([XORG_OS])
	AC_SUBST([XORG_OS_SUBDIR])

	AC_PATH_PROG(PERL, perl, no)
	dnl unlikely as this may be ...
	if test "x$PERL" = xno; then
		AC_MSG_ERROR([Perl is required to build the XFree86/Xorg DDX.])
	fi
	AC_SUBST(PERL)

	AC_SUBST([XORG_CFLAGS])

	dnl these only go in xorg-config.h
	XF86CONFIGFILE="xorg.conf"
	CONFIGFILE="$sysconfdir/$XF86CONFIGFILE"
	LOGPREFIX="$logdir/Xorg."
	AC_DEFINE(XORG_SERVER, 1, [Building Xorg server])
	AC_DEFINE(XORGSERVER, 1, [Building Xorg server])
	AC_DEFINE(XFree86Server, 1, [Building XFree86 server])
	AC_DEFINE(XFree86LOADER, 1, [Building loadable XFree86 server])
	AC_DEFINE_UNQUOTED(XORG_VERSION_CURRENT, [$VENDOR_RELEASE], [Current Xorg version])
	AC_DEFINE(NEED_XF86_TYPES, 1, [Need XFree86 typedefs])
	AC_DEFINE(NEED_XF86_PROTOTYPES, 1, [Need XFree86 helper functions])
	AC_DEFINE(__XSERVERNAME__, "Xorg", [Name of X server])
	AC_DEFINE_DIR(__XCONFIGFILE__, XF86CONFIGFILE, [Name of configuration file])
	AC_DEFINE_DIR(XF86CONFIGFILE, XF86CONFIGFILE, [Name of configuration file])
	AC_DEFINE_DIR(DEFAULT_MODULE_PATH, moduledir, [Default module search path])
	AC_DEFINE_DIR(DEFAULT_LIBRARY_PATH, libdir, [Default library install path])
	AC_DEFINE_DIR(DEFAULT_LOGPREFIX, LOGPREFIX, [Default log location])
	AC_DEFINE_UNQUOTED(__VENDORDWEBSUPPORT__, ["$VENDOR_WEB"], [Vendor web address for \
support])  AC_DEFINE(XSERVER_LIBPCIACCESS, 1, [Use libpciaccess for all pci \
manipulation])  if test "x$VGAHW" = xyes; then
		AC_DEFINE(WITH_VGAHW, 1, [Building vgahw module])
	fi

	driverdir="$moduledir/drivers"
	AC_SUBST([moduledir])
	AC_SUBST([driverdir])
	sdkdir="$includedir/xorg"
	extdir="$includedir/X11/extensions"
	AC_SUBST([sdkdir])
	AC_SUBST([extdir])
	AC_SUBST([logdir])

	# stuff the ABI versions into the pc file too
	extract_abi() {
	    grep ^.define.*${1}_VERSION ${srcdir}/hw/xfree86/common/xf86Module.h | tr '(),' \
'  .' | awk '{ print $4$5 }'  }
	abi_ansic=`extract_abi ANSIC`
	abi_videodrv=`extract_abi VIDEODRV`
	abi_xinput=`extract_abi XINPUT`
	abi_extension=`extract_abi EXTENSION`
	AC_SUBST([abi_ansic])
	AC_SUBST([abi_videodrv])
	AC_SUBST([abi_xinput])
	AC_SUBST([abi_extension])
fi
AM_CONDITIONAL([XORG], [test "x$XORG" = xyes])
AM_CONDITIONAL([XORG_BUS_LINUXPCI], [test "x$xorg_bus_linuxpci" = xyes])
AM_CONDITIONAL([XORG_BUS_BSDPCI], [test "x$xorg_bus_bsdpci" = xyes])
AM_CONDITIONAL([XORG_BUS_SPARC], [test "x$xorg_bus_sparc" = xyes])
AM_CONDITIONAL([LINUX_IA64], [test "x$linux_ia64" = xyes])
AM_CONDITIONAL([LINUX_ALPHA], [test "x$linux_alpha" = xyes])
AM_CONDITIONAL([LNXACPI], [test "x$linux_acpi" = xyes])
AM_CONDITIONAL([SOLARIS_ASM_INLINE], [test "x$solaris_asm_inline" = xyes])
AM_CONDITIONAL([SOLARIS_VT], [test "x$solaris_vt" = xyes])
AM_CONDITIONAL([DGA], [test "x$DGA" = xyes])
AM_CONDITIONAL([XF86VIDMODE], [test "x$XF86VIDMODE" = xyes])

dnl XWin DDX

AC_MSG_CHECKING([whether to build XWin DDX])
if test "x$XWIN" = xauto; then
	case $host_os in
		cygwin*) XWIN="yes" ;;
		mingw*) XWIN="yes" ;;
		*) XWIN="no" ;;
	esac
fi
AC_MSG_RESULT([$XWIN])

if test "x$XWIN" = xyes; then
	PKG_CHECK_EXISTS($WINDOWSWMPROTO, [WINDOWSWM=yes], [WINDOWSWM=no])
	AC_DEFINE_UNQUOTED(XORG_VERSION_CURRENT, [$VENDOR_RELEASE], [Current Xorg version])
	AC_CHECK_TOOL(WINDRES, windres)
	case $host_os in
		cygwin*)
			XWIN_SERVER_NAME=XWin
			PKG_CHECK_MODULES([XWINMODULES],[x11 xdmcp xau xfont])
			AC_DEFINE(HAS_DEVWINDOWS,1,[Cygwin has /dev/windows for signaling new win32 \
messages])

			dnl if we have windowswmproto, build rootless extension for multwindowextwm mode
			if test "x$WINDOWSWM" = xyes ; then
			       AC_DEFINE(ROOTLESS,1,[Build Rootless code])
			       CFLAGS="$CFLAGS -DROOTLESS_WORKAROUND"
			fi

			CFLAGS="$CFLAGS -DFD_SETSIZE=256"
			;;
		mingw*)
			XWIN_SERVER_NAME=Xming
			PKG_CHECK_MODULES([XWINMODULES],[x11 xdmcp xau xfont])
			AC_DEFINE(RELOCATE_PROJECTROOT,1,[Make PROJECT_ROOT relative to the xserver \
location])  AC_DEFINE(HAS_WINSOCK,1,[Use Windows sockets])
			XWIN_SYS_LIBS=-lwinsock2
			;;
	esac
	XWIN_LIBS="$FB_LIB $MI_LIB $FIXES_LIB $XEXT_LIB $CONFIG_LIB $RANDR_LIB $RENDER_LIB \
$DBE_LIB $RECORD_LIB $GLX_LIBS $XKB_LIB $XKB_STUB_LIB $COMPOSITE_LIB $DAMAGE_LIB \
$MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $OS_LIB"  XWIN_SYS_LIBS="$XWIN_SYS_LIBS \
$XWINMODULES_LIBS"  AC_SUBST(XWIN_LIBS)
	AC_SUBST(XWIN_SERVER_NAME)
	AC_SUBST(XWIN_SYS_LIBS)

	if test "x$DEBUGGING" = xyes; then
		AC_DEFINE(CYGDEBUG, 1, [Simple debug messages])
		AC_DEFINE(CYGWINDOWING_DEBUG, 1, [Debug messages for window handling])
		AC_DEFINE(CYGMULTIWINDOW_DEBUG, 1, [Debug window manager])
	fi

	AC_DEFINE(DDXOSVERRORF, 1, [Use OsVendorVErrorF])
	AC_DEFINE(DDXBEFORERESET, 1, [Use ddxBeforeReset ])
	if test "x$XF86VIDMODE" = xyes; then
		AC_MSG_NOTICE([Disabling XF86VidMode extension])
		XF86VIDMODE=no
	fi
	if test "x$COMPOSITE" = xyes; then
		AC_MSG_NOTICE([Disabling Composite extension])
		COMPOSITE=no
	fi
fi
AM_CONDITIONAL(XWIN, [test "x$XWIN" = xyes])
AM_CONDITIONAL(XWIN_MULTIWINDOW, [test "x$XWIN" = xyes])
AM_CONDITIONAL(XWIN_MULTIWINDOWEXTWM, [test "x$XWIN" = xyes && test "x$WINDOWSWM" = \
xyes]) AM_CONDITIONAL(XWIN_CLIPBOARD, [test "x$XWIN" = xyes])
AM_CONDITIONAL(XWIN_GLX_WINDOWS, [test "x$XWIN" = xyes && false])
AM_CONDITIONAL(XWIN_NATIVEGDI, [test "x$XWIN" = xyes && false])
AM_CONDITIONAL(XWIN_PRIMARYFB, [test "x$XWIN" = xyes && false])
AM_CONDITIONAL(XWIN_RANDR, [test "x$XWIN" = xyes])
AM_CONDITIONAL(XWIN_XV, [test "x$XWIN" = xyes && test "x$XV" = xyes])

dnl Darwin / OS X DDX
if test "x$XQUARTZ" = xyes; then
	AC_DEFINE(XQUARTZ,1,[Have Quartz])
	AC_DEFINE(ROOTLESS,1,[Build Rootless code])

	DARWIN_LIBS="$MI_LIB $OS_LIB $DIX_LIB $MAIN_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"  \
AC_SUBST([DARWIN_LIBS])

	AC_CHECK_LIB([Xplugin],[xp_init],[:])

	CFLAGS="${CFLAGS} -DROOTLESS_WORKAROUND -DROOTLESS_SAFEALPHA -DNO_ALLOCA"

	PKG_CHECK_MODULES(XPBPROXY, $APPLEWMPROTO $LIBAPPLEWM xfixes x11)

        if test "x$XQUARTZ_SPARKLE" = xyes ; then
                AC_DEFINE(XQUARTZ_SPARKLE,1,[Support application updating through \
sparkle.])  fi

	if test "x$STANDALONE_XPBPROXY" = xyes ; then
		AC_DEFINE(STANDALONE_XPBPROXY,1,[Build a standalone xpbproxy])
	fi
fi

# Support for objc in autotools is minimal and not documented.
OBJC='$(CC)'
OBJCLD='$(CCLD)'
OBJCLINK='$(LINK)'
OBJCFLAGS='$(CFLAGS)'
AC_SUBST([OBJC])
AC_SUBST([OBJCCLD])
AC_SUBST([OBJCLINK])
AC_SUBST([OBJCFLAGS])
# internal, undocumented automake func follows :(
_AM_DEPENDENCIES([OBJC])
AM_CONDITIONAL(XQUARTZ, [test "x$XQUARTZ" = xyes])
AM_CONDITIONAL(XQUARTZ_SPARKLE, [test "x$XQUARTZ_SPARKLE" != "xno"])
AM_CONDITIONAL(STANDALONE_XPBPROXY, [test "x$STANDALONE_XPBPROXY" = xyes])

dnl DMX DDX
PKG_CHECK_MODULES(
	[DMXMODULES],
	[xmuu $LIBXEXT x11 xrender xfixes xfont $LIBXI $DMXPROTO xau $XDMCP_MODULES],
	[PKG_CHECK_MODULES(
		[XDMXCONFIG_DEP],
		[xaw7 xmu xt xpm x11],
		[have_dmx=yes],
		[have_dmx=no])],
	[have_dmx=no])
AC_MSG_CHECKING([whether to build Xdmx DDX])
if test "x$DMX" = xauto; then
	DMX="$have_dmx"
	case $host_os in
		cygwin*) DMX="no" ;;
		darwin*) DMX="no" ;;
	esac
fi
AC_MSG_RESULT([$DMX])
AM_CONDITIONAL(DMX, [test "x$DMX" = xyes])

if test "x$DMX" = xyes; then
	if test "x$have_dmx" = xno; then
		AC_MSG_ERROR([Xdmx build explicitly requested, but required
		              modules not found.])
	fi
	DMX_INCLUDES="$XEXT_INC $RENDER_INC $RECORD_INC"
	XDMX_CFLAGS="$DMXMODULES_CFLAGS"
	XDMX_LIBS="$FB_LIB $MI_LIB $RENDER_LIB $RECORD_LIB $XI_LIB $XKB_LIB $XKB_STUB_LIB \
$MIEXT_SHADOW_LIB $MIEXT_DAMAGE_LIB $XEXT_LIB $MAIN_LIB $DIX_LIB $CONFIG_LIB $OS_LIB \
$FIXES_LIB"  XDMX_SYS_LIBS="$DMXMODULES_LIBS"
	AC_SUBST([XDMX_CFLAGS])
	AC_SUBST([XDMX_LIBS])
	AC_SUBST([XDMX_SYS_LIBS])

dnl USB sources in DMX require <linux/input.h>
	AC_CHECK_HEADER([linux/input.h], DMX_BUILD_USB="yes",
			DMX_BUILD_USB="no")
dnl Linux sources in DMX require <linux/keyboard.h>
	AC_CHECK_HEADER([linux/keyboard.h], DMX_BUILD_LNX="yes",
			DMX_BUILD_LNX="no")
	AC_SUBST(XDMXCONFIG_DEP_CFLAGS)
	AC_SUBST(XDMXCONFIG_DEP_LIBS)
	PKG_CHECK_MODULES([DMXEXAMPLES_DEP], [$LIBDMX $LIBXEXT x11])
	AC_SUBST(DMXEXAMPLES_DEP_LIBS)
	PKG_CHECK_MODULES([DMXXMUEXAMPLES_DEP], [$LIBDMX xmu $LIBXEXT x11])
	AC_SUBST(DMXXMUEXAMPLES_DEP_LIBS)
	PKG_CHECK_MODULES([DMXXIEXAMPLES_DEP], [$LIBDMX $LIBXI $LIBXEXT x11])
	AC_SUBST(DMXXIEXAMPLES_DEP_LIBS)
	PKG_CHECK_MODULES([XTSTEXAMPLES_DEP], [$LIBXTST $LIBXEXT x11])
	AC_SUBST(XTSTEXAMPLES_DEP_LIBS)
	PKG_CHECK_MODULES([XRESEXAMPLES_DEP], [xres $LIBXEXT x11])
	AC_SUBST(XRESEXAMPLES_DEP_LIBS)
	PKG_CHECK_MODULES([X11EXAMPLES_DEP], [$LIBXEXT x11])
	AC_SUBST(X11EXAMPLES_DEP_LIBS)
fi
AM_CONDITIONAL([DMX_BUILD_LNX], [test "x$DMX_BUILD_LNX" = xyes])
AM_CONDITIONAL([DMX_BUILD_USB], [test "x$DMX_BUILD_USB" = xyes])

dnl kdrive DDX

XEPHYR_LIBS=
XEPHYR_INCS=
XSDL_LIBS=
XSDL_INCS=
XSDL_DIRS=

AM_CONDITIONAL(KDRIVE, [test x$KDRIVE = xyes])
if test "$KDRIVE" = yes; then
    AC_DEFINE(KDRIVESERVER,1,[Build Kdrive X server])
    AC_DEFINE(KDRIVEDDXACTIONS,,[Build kdrive ddx])

    AC_CHECK_HEADERS([sys/vm86.h sys/io.h])
    if test "$ac_cv_header_sys_vm86_h" = yes && test "x$KDRIVEVESA" = xauto; then
        KDRIVEVESA=yes
    fi

    if test "x$KDRIVEVESA" = xyes; then
        KDRIVEFBDEVLIB=yes
        AC_DEFINE(KDRIVEVESA, 1, [Build VESA-based kdrive servers])
    fi

    AC_CHECK_HEADERS([linux/fb.h])
    if test "$ac_cv_header_linux_fb_h" = yes && test "x$XFBDEV" = xauto; then
        XFBDEV=yes
    fi

    if test "x$XFBDEV" = xyes; then
        KDRIVEFBDEVLIB=yes
        AC_DEFINE(KDRIVEFBDEV, 1, [Build fbdev-based kdrive server])
    fi


    PKG_CHECK_MODULES([TSLIB], [tslib-0.0], [HAVE_TSLIB="yes"], [HAVE_TSLIB="no"])
    if test "x$HAVE_TSLIB" = xno; then
        AC_CHECK_LIB(ts, ts_open, [HAVE_TSLIB="yes"])
    fi

    if test "xTSLIB" = xauto; then
        TSLIB="$HAVE_TSLIB"
    fi

    if test "x$TSLIB" = xyes; then
        if ! test "x$HAVE_TSLIB" = xyes; then
            AC_MSG_ERROR([tslib must be installed to build the tslib driver. See \
http://tslib.berlios.de/])  else
            AC_DEFINE(TSLIB, 1, [Have tslib support])
        fi
    fi

    AC_CHECK_HEADERS([SDL/SDL.h])
    if test x"$ac_cv_header_SDL_SDL_h" = xyes && test "x$XSDL" = xauto; then
       XSDL=yes
    fi

    if test x"$XSDL" = xyes; then
       # PKG_CHECK_MODULES(XSDL_EXTRA, Xfont xau $XDMCP_MODULES)
       AC_DEFINE(XSDLSERVER,1,[Build Xsdl server])
       XSDL_LIBS="`sdl-config --libs`"
       XSDL_INCS="`sdl-config --cflags` $XSERVER_CFLAGS"
    fi

    XEPHYR_REQUIRED_LIBS="x11 $LIBXEXT xfont xau xdmcp"
    if test "x$XV" = xyes; then
        XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS xv"
    fi
    if test "x$DRI" = xyes && test "x$GLX" = xyes; then
        XEPHYR_REQUIRED_LIBS="$XEPHYR_REQUIRED_LIBS $LIBGL libdrm"
    fi

    PKG_CHECK_MODULES(XEPHYR, $XEPHYR_REQUIRED_LIBS, [xephyr="yes"], [xephyr="no"])
    if test "x$XEPHYR" = xauto; then
        XEPHYR=$xephyr
    fi

    # Xephyr needs nanosleep() which is in librt on Solaris
    AC_CHECK_FUNC([nanosleep], [],
        AC_CHECK_LIB([rt], [nanosleep], XEPHYR_LIBS="$XEPHYR_LIBS -lrt"))
    
    # damage shadow extension glx (NOTYET) fb mi
    KDRIVE_INC='-I$(top_srcdir)/hw/kdrive/src'
    KDRIVE_PURE_INCS="$KDRIVE_INC $MIEXT_DAMAGE_INC $MIEXT_SHADOW_INC $XEXT_INC \
$FB_INC $MI_INC"  KDRIVE_OS_INC='-I$(top_srcdir)/hw/kdrive/linux'
    KDRIVE_INCS="$KDRIVE_PURE_INCS $KDRIVE_OS_INC"
    
    KDRIVE_CFLAGS="$XSERVER_CFLAGS -DHAVE_KDRIVE_CONFIG_H $TSLIB_CFLAGS"

    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"  \
KDRIVE_LIB='$(top_builddir)/hw/kdrive/src/libkdrive.la'  case $host_os in
	*linux*)
	    KDRIVE_OS_LIB='$(top_builddir)/hw/kdrive/linux/liblinux.la'
            KDRIVELINUX=yes
	    ;;
    esac
    KDRIVE_STUB_LIB='$(top_builddir)/hw/kdrive/src/libkdrivestubs.la'
    KDRIVE_LOCAL_LIBS="$MAIN_LIB $DIX_LIB $KDRIVE_LIB $KDRIVE_STUB_LIB $CONFIG_LIB"
    KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $FB_LIB $MI_LIB $KDRIVE_PURE_LIBS"
    KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $KDRIVE_OS_LIB $OS_LIB"
    KDRIVE_LIBS="$TSLIB_LIBS $KDRIVE_LOCAL_LIBS $XSERVER_SYS_LIBS $GLX_SYS_LIBS"

    AC_SUBST([XEPHYR_LIBS])
    AC_SUBST([XEPHYR_INCS])
    AC_SUBST([XSDL_LIBS])
    AC_SUBST([XSDL_INCS])
fi
AC_SUBST([KDRIVE_INCS])
AC_SUBST([KDRIVE_PURE_INCS])
AC_SUBST([KDRIVE_CFLAGS])
AC_SUBST([KDRIVE_PURE_LIBS])
AC_SUBST([KDRIVE_LOCAL_LIBS])
AC_SUBST([KDRIVE_LIBS])
AM_CONDITIONAL(KDRIVELINUX, [test "x$KDRIVELINUX" = xyes])
AM_CONDITIONAL(TSLIB, [test "x$HAVE_TSLIB" = xyes])
AM_CONDITIONAL(KDRIVEVESA, [test "x$KDRIVEVESA" = xyes])
AM_CONDITIONAL(KDRIVEFBDEV, [test "x$XFBDEV" = xyes])
AM_CONDITIONAL(XSDLSERVER, [test x"$XSDL" = xyes])
AM_CONDITIONAL(XEPHYR, [test "x$KDRIVE" = xyes && test "x$XEPHYR" = xyes])
AM_CONDITIONAL(BUILD_KDRIVEFBDEVLIB, [test "x$KDRIVE" = xyes && test \
"x$KDRIVEFBDEVLIB" = xyes]) AM_CONDITIONAL(XFAKESERVER, [test "x$KDRIVE" = xyes && \
test "x$XFAKE" = xyes])

dnl and the rest of these are generic, so they're in config.h
dnl 
dnl though, thanks to the passing of some significant amount of time, the
dnl above is probably a complete fallacy, and you should not rely on it.
dnl but this is still actually better than imake, honest. -daniels

AC_TRY_COMPILE([
#include <features.h>
#ifndef __GLIBC__
#error not glibc
#endif
], [], [AC_DEFINE(_GNU_SOURCE, 1,
	[ Enable GNU and other extensions to the C environment for glibc])])

AC_DEFINE_DIR(PROJECTROOT, prefix, [Overall prefix])

BUILD_DATE="`date +'%Y%m%d'`"
AC_SUBST([BUILD_DATE])
BUILD_TIME="`date +'1%H%M%S'`"
AC_SUBST([BUILD_TIME])

DIX_CFLAGS="-DHAVE_DIX_CONFIG_H $XSERVER_CFLAGS"

AC_SUBST([DIX_CFLAGS])

AC_SUBST([libdir])
AC_SUBST([exec_prefix])
AC_SUBST([prefix])

# Man page sections - used in config utils & generating man pages
XORG_MANPAGE_SECTIONS
XORG_CHANGELOG

SHAVE_INIT([.], [enable])

AC_OUTPUT([
Makefile
glx/Makefile
include/Makefile
composite/Makefile
damageext/Makefile
dbe/Makefile
dix/Makefile
doc/Makefile
fb/Makefile
record/Makefile
config/Makefile
mi/Makefile
miext/Makefile
miext/damage/Makefile
miext/shadow/Makefile
miext/cw/Makefile
miext/rootless/Makefile
os/Makefile
randr/Makefile
render/Makefile
xkb/Makefile
Xext/Makefile
Xi/Makefile
xfixes/Makefile
exa/Makefile
hw/Makefile
hw/xfree86/Makefile
hw/xfree86/common/Makefile
hw/xfree86/common/xf86Build.h
hw/xfree86/ddc/Makefile
hw/xfree86/dixmods/Makefile
hw/xfree86/dixmods/extmod/Makefile
hw/xfree86/doc/Makefile
hw/xfree86/doc/devel/Makefile
hw/xfree86/doc/man/Makefile
hw/xfree86/doc/sgml/Makefile
hw/xfree86/dri/Makefile
hw/xfree86/dri2/Makefile
hw/xfree86/exa/Makefile
hw/xfree86/fbdevhw/Makefile
hw/xfree86/i2c/Makefile
hw/xfree86/int10/Makefile
hw/xfree86/loader/Makefile
hw/xfree86/modes/Makefile
hw/xfree86/os-support/Makefile
hw/xfree86/os-support/bsd/Makefile
hw/xfree86/os-support/bus/Makefile
hw/xfree86/os-support/hurd/Makefile
hw/xfree86/os-support/misc/Makefile
hw/xfree86/os-support/linux/Makefile
hw/xfree86/os-support/sco/Makefile
hw/xfree86/os-support/solaris/Makefile
hw/xfree86/os-support/sysv/Makefile
hw/xfree86/parser/Makefile
hw/xfree86/ramdac/Makefile
hw/xfree86/shadowfb/Makefile
hw/xfree86/vbe/Makefile
hw/xfree86/vgahw/Makefile
hw/xfree86/x86emu/Makefile
hw/xfree86/xaa/Makefile
hw/xfree86/xf8_16bpp/Makefile
hw/xfree86/utils/Makefile
hw/xfree86/utils/cvt/Makefile
hw/xfree86/utils/gtf/Makefile
hw/dmx/config/Makefile
hw/dmx/doc/Makefile
hw/dmx/examples/Makefile
hw/dmx/input/Makefile
hw/dmx/glxProxy/Makefile
hw/dmx/Makefile
hw/vfb/Makefile
hw/xnest/Makefile
hw/xwin/Makefile
hw/xquartz/Makefile
hw/xquartz/GL/Makefile
hw/xquartz/bundle/Makefile
hw/xquartz/doc/Makefile
hw/xquartz/mach-startup/Makefile
hw/xquartz/pbproxy/Makefile
hw/xquartz/xpr/Makefile
hw/kdrive/Makefile
hw/kdrive/ephyr/Makefile
hw/kdrive/fake/Makefile
hw/kdrive/fbdev/Makefile
hw/kdrive/linux/Makefile
hw/kdrive/sdl/Makefile
hw/kdrive/src/Makefile
test/Makefile
test/xi2/Makefile
xorg-server.pc
])


["Makefile.am" (Makefile.am)]

noinst_LTLIBRARIES = libdixmods.la libxorgxkb.la

SUBDIRS = extmod

if GLX
GLXMODS = libglx.la
endif

if DBE
DBEMOD = libdbe.la
endif

if RECORD
RECORDMOD = librecord.la
endif

module_LTLIBRARIES = libfb.la \
                     libwfb.la \
                     libshadow.la

extsmoduledir = $(moduledir)/extensions
extsmodule_LTLIBRARIES = $(RECORDMOD) \
			 $(DBEMOD) \
                         $(GLXMODS) \
			 libvmglext.la

AM_CFLAGS = @XORG_CFLAGS@ @DIX_CFLAGS@
INCLUDES = @XORG_INCS@ \
           -I$(top_srcdir)/dbe \
           -I$(top_srcdir)/hw/xfree86/loader \
           -I$(top_srcdir)/miext/shadow \
           -I$(top_srcdir)/glx

libdbe_la_LDFLAGS = -avoid-version
libdbe_la_LIBADD = $(top_builddir)/dbe/libdbe.la
libdbe_la_SOURCES = dbemodule.c

libfb_la_LDFLAGS = -avoid-version
libfb_la_LIBADD = $(top_builddir)/fb/libfb.la
libfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
libfb_la_CFLAGS = $(AM_CFLAGS)

libwfb_la_LDFLAGS = -avoid-version
libwfb_la_LIBADD = $(top_builddir)/fb/libwfb.la
libwfb_la_SOURCES = $(top_builddir)/fb/fbcmap_mi.c fbmodule.c
libwfb_la_CFLAGS = $(AM_CFLAGS) -DFB_ACCESS_WRAPPER

libglx_la_LDFLAGS = -avoid-version
if AIGLX
GLXDRI_LIBRARY = $(top_builddir)/glx/libglxdri.la
endif
libglx_la_LIBADD = \
	$(top_builddir)/glx/libglx.la \
	$(GLXDRI_LIBRARY)
libglx_la_SOURCES = glxmodule.c

librecord_la_LDFLAGS = -avoid-version
librecord_la_LIBADD = $(top_builddir)/record/librecord.la
librecord_la_SOURCES = recordmod.c

libvmglext_la_LDFLAGS = -avoid-version
libvmglext_la_SOURCES = vmglmod.c VMGLExtension.c

libshadow_la_LDFLAGS = -avoid-version
libshadow_la_LIBADD = $(top_builddir)/miext/shadow/libshadow.la
libshadow_la_SOURCES = shmodule.c

libdixmods_la_SOURCES = $(top_srcdir)/mi/miinitext.c
libdixmods_la_CFLAGS = -DXFree86LOADER $(AM_CFLAGS)

libxorgxkb_la_SOURCES = xkbVT.c xkbPrivate.c xkbKillSrv.c
libxorgxkb_la_LIBADD = $(top_builddir)/dix/libdix.la

["startx_ouput.txt" (startx_ouput.txt)]

xauth:  creating new authority file /home/joshua/.serverauth.7470


X.Org X Server 1.7.7
Release Date: 2010-05-04
X Protocol Version 11, Revision 0
Build Operating System: Linux 2.6.32-131.17.1.el6.x86_64 x86_64 
Current Operating System: Linux msmdw206 2.6.32-131.17.1.el6.x86_64 #1 SMP Thu Sep 29 \
10:24:25 EDT 2011 x86_64 Kernel command line: ro \
root=UUID=7141a345-a97d-4f6a-9b94-2ff9e91d1dfd rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM \
LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc \
KEYTABLE=de-latin1-nodeadkeys crashkernel=129M@0M rhgb quiet rdblacklist=nouveau \
vga=791 nouveau.modeset=0 Build Date: 25 March 2013  01:57:49PM
 
Current version of pixman: 0.18.4
	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
	(++) from command line, (!!) notice, (II) informational,
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/usr/local/var/log/Xorg.0.log", Time: Tue Mar 26 09:25:31 2013
(==) Using config file: "/etc/X11/xorg.conf"

Backtrace:
0: /usr/local/bin/X (xorg_backtrace+0x28) [0x45fe58]
1: /usr/local/bin/X (0x400000+0x62a09) [0x462a09]
2: /lib64/libpthread.so.0 (0x310d400000+0xf490) [0x310d40f490]
3: /usr/local/lib/xorg/modules/extensions/libvmglext.so (0x7f35ae9b8000+0x13a3) \
                [0x7f35ae9b93a3]
4: /usr/local/bin/X (MapWindow+0x2b6) [0x42c936]
5: /usr/local/bin/X (0x400000+0x218e0) [0x4218e0]
6: /lib64/libc.so.6 (__libc_start_main+0xfd) [0x310c81ecdd]
7: /usr/local/bin/X (0x400000+0x214e9) [0x4214e9]
Segmentation fault at address 0x3

Fatal server error:
Caught signal 11 (Segmentation fault). Server aborting


Please consult the The X.Org Foundation support 
	 at http://wiki.x.org
 for help. 
Please also check the log file at "/usr/local/var/log/Xorg.0.log" for additional \
information.

giving up.
xinit:  No such file or directory (errno 2):  unable to connect to X server
xinit:  No such process (errno 3):  Server error.


["vmgl_ext.h" (vmgl_ext.h)]

/*
* Copyright (c) 2006-2007 H. Andres Lagar-Cavilla <andreslc@cs.toronto.edu>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
*   1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*   2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*   3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

/* vmgl project */

#ifndef _VMGLEXT_H
#define _VMGLEXT_H

/* Constants */
#define VMGL_EXTENSION_NAME	"VMGLExt"
#define VMGL_MAJOR_VERSION		1
#define VMGL_MINOR_VERSION		0

#define X_VMGLInit			0
#define X_VMGLWatchWindow		1
#define X_VMGLReset			2

/* X internal structs */
#define sz_xVMGLInitReq 12
typedef struct xVMGLInitReq_struct{
    CARD8       reqType;
    CARD8       VMGLRequestType;
    CARD16      length B16;
    CARD32      address B32;
    CARD16      port B16;
    CARD16      pad0 B16;
} xVMGLInitReq;

#define sz_XVMGLInitReply 32
typedef struct XVMGLInitReply_struct {
    CARD8   	type;
    CARD8   	retVal;
    CARD16  	sequenceNumber B16;
    CARD32  	length B32;
    CARD32      pad1 B32;
    CARD32	pad2 B32;
    CARD32  	pad3 B32;
    CARD32  	pad4 B32;
    CARD32  	pad5 B32;
    CARD32  	pad6 B32;
} XVMGLInitReply;

#define sz_xVMGLWatchWindowReq 20
typedef struct xVMGLWatchWindowReq_struct {
    CARD8       reqType;
    CARD8       VMGLRequestType;
    CARD16      length B16;
    CARD32      XWindow B32;
    CARD32	glWindow B32;
    CARD32      address B32;
    CARD16      port B16;
    CARD16      pad0 B16;
} xVMGLWatchWindowReq;

#define sz_XVMGLWatchWindowReply 32
typedef struct XVMGLWatchWindowReply_struct {
    CARD8   	type;
    CARD8   	retVal;
    CARD16  	sequenceNumber B16;
    CARD32  	length B32;
    CARD32  	pad1 B32;
    CARD32  	pad2 B32;
    CARD32  	pad3 B32;
    CARD32  	pad4 B32;
    CARD32  	pad5 B32;
    CARD32  	pad6 B32;
} XVMGLWatchWindowReply;

#endif /* _VMGLEXT_H */


["VMGLExtension.c" (VMGLExtension.c)]

/*
* Copyright (c) 2006-2007 H. Andres Lagar-Cavilla <andreslc@cs.toronto.edu>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
*   1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*   2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*   3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

/* VMGL project: Body of the loadable extension for the Xorg Server */

#include "scrnintstr.h"
#include "extnsionst.h"
#include "dixstruct.h"
#include "windowstr.h"
#include "xf86Module.h"
#include "xf86.h"

#include <X11/extensions/vmgl_ext.h>
#include <X11/extensions/vmgl_extproto.h>

#include <errno.h>
#include <stdio.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <unistd.h>

#include "regionstr.h"
#include <dix-config.h>
#include "../../../composite/compint.h"


/* List of windows to watch on behalf of a gl stub */
typedef struct GlWindowWatcher_struct {
    unsigned int XWindow;
    unsigned int glWindow;
    int sock;
    struct GlWindowWatcher_struct *next;
} GlWindowWatcher;

/* List of glStubs on behalf of whom we watch windows */
typedef struct GlStubWatcher_struct {
    int sock;
    unsigned int address;
    unsigned short port;
    GlWindowWatcher *WindowWatchersList;
    struct GlStubWatcher_struct *next;
} GlStubWatcher;

/* Globals */
GlStubWatcher *GlStubWatchersList;
void (*ClipNotify_wrap[MAXSCREENS])();
Bool (*DestroyWindow_wrap[MAXSCREENS])();

/*compile error because of a naming conflict*/
/*extern WindowPtr *WindowTable;*/
/*since 7.1 included in globals.h*/

/* Helper */
static char *IP2String(in_addr_t address) {
    xf86Msg(X_INFO, "VMGL: Entering IP2String function\n");
    struct in_addr tmp;
    tmp.s_addr= htonl(address);
    xf86Msg(X_INFO, "VMGL: Leaving IP2String function\n");
    return ((char *) inet_ntoa(tmp));
}

/* This function does the communication with a gl Stub */
static void SendWindowClipList(int sock, unsigned int glWindow, RegionRec *clipList,
		         int x, int y, unsigned int w, unsigned int h) {
    xf86Msg(X_INFO, "VMGL: Entering SendWindowClipList function\n");
    XVMGLWindowingCommand cmd;
    BoxPtr boxes;
    size_t writeLen;
    unsigned int len = REGION_NUM_RECTS(clipList);

    cmd.length = htonl(len);
    cmd.glWindow = htonl(glWindow);
    cmd.x = htonl(x);
    cmd.y = htonl(y);
    cmd.width = htonl(w);
    cmd.height = htonl(h);
    boxes = REGION_RECTS(clipList);

    writeLen = sizeof(XVMGLWindowingCommand);
    if (write(sock, (void *) &cmd, writeLen) != ((ssize_t) writeLen))
	xf86ErrorF("Error writing on socket %d\n", sock);

    writeLen = sizeof(BoxRec)*len;
    if (writeLen)
	if (write(sock, (void *) boxes, writeLen) != ((ssize_t) writeLen))
    	    xf86ErrorF("Error writing on socket %d\n", sock);

#ifdef VERBOSE_VMGLEXT
    xf86ErrorF("SendWindowClipList for window %u on socket %d: %d %d %u %u -> %u\n",
	    glWindow, sock, x, y, w, h, len);
#endif
    xf86Msg(X_INFO, "VMGL: Leaving SendWindowClipList function\n");
}

/* Windowing functions hooks */
static GlWindowWatcher *findWindow(unsigned int XWindow)
{
    xf86Msg(X_INFO, "VMGL: Entering findWindow function\n");

    xf86Msg(X_INFO, "VMGL: pWin->drawable.id: %u \n", XWindow);
    GlWindowWatcher *ptr;
    GlStubWatcher *srvPtr;


    /*some logfile information*/
    xf86Msg(X_INFO, "VMGL: try to access on GlStubWatchersList\n");  
    if(GlStubWatchersList == NULL)
    {
	xf86Msg(X_INFO, "VMGL: GlStubWatchersList is NULL\n");
    }
    else
    {
	xf86Msg(X_INFO, "VMGL: GlStubWatchersList: %p \n", GlStubWatchersList);
    }
    xf86Msg(X_INFO, "VMGL: srvPtr = GlStubWatchersList\n");
    srvPtr = GlStubWatchersList;
    xf86Msg(X_INFO, "VMGL: srvPtr: %p \n", srvPtr);


    xf86Msg(X_INFO, "VMGL: try to access on srvPtr->next\n");  
    if(srvPtr->next == NULL)
    {
	xf86Msg(X_INFO, "VMGL: srvPtr->next is NULL\n");
    }
    else
    {
        xf86Msg(X_INFO, "VMGL: srvPtr->next: %p \n", srvPtr->next);
	xf86Msg(X_INFO, "VMGL: try to access on srvPtr->next->WindowWatchersList\n");  
        if(srvPtr->next->WindowWatchersList == NULL)
        {
	    xf86Msg(X_INFO, "VMGL: srvPtr->next->WindowWatchersList is NULL\n");
        }
	else
	{
	    xf86Msg(X_INFO, "VMGL: srvPtr->next->WindowWatchersList: %p \n", \
srvPtr->next->WindowWatchersList);  xf86Msg(X_INFO, "VMGL: ptr = \
srvPtr->next->WindowWatchersList\n");  ptr = srvPtr->next->WindowWatchersList;
	    xf86Msg(X_INFO, "VMGL: ptr: %p \n", ptr);
	}
    }
    /*end logfile information*/

    int i = 0;
    int j = 0;
    for (srvPtr = GlStubWatchersList; srvPtr->next != NULL; srvPtr = srvPtr->next)
    {
	xf86Msg(X_INFO, "VMGL: i value: %i \n", i);
        for (ptr = srvPtr->next->WindowWatchersList; ptr->next != NULL; ptr = \
ptr->next)  {
	    xf86Msg(X_INFO, "VMGL: j value: %i \n", j);
            if (ptr->next->XWindow == XWindow)
	    {
		xf86Msg(X_INFO, "VMGL: Leaving findWindow function: SUCCESS\n");
                return ptr;
	    }
	    j++;
	}
	i++;
    }

    xf86Msg(X_INFO, "VMGL: Leaving findWindow function: FAILED\n");
    return NULL;
}

static Bool VMGLDestroyWindow(WindowPtr pWin)
{
    xf86Msg(X_INFO, "VMGL: Entering VMGLDestroyWindow function\n");
    GlWindowWatcher *tmp, *ptr = findWindow(pWin->drawable.id);
    BOOL retVal = TRUE;
    
    if (ptr) /*ptr is not NULL*/
    {
	xf86Msg(X_INFO, "Destroy %u XID %u\n", ptr->next->glWindow, (unsigned int) \
pWin->drawable.id);  tmp = ptr->next;
	ptr->next = tmp->next;
	xfree(tmp);
    }
    else /*ptr is NULL*/
    {
	xf86Msg(X_INFO, "VMGL: function 'findWindow' returns NULL for VMGLDestroyWindow\n");
    }

    xf86Msg(X_INFO, "VMGL: try to access on \
DestroyWindow_wrap[pWin->drawable.pScreen->myNum]\n");  if \
(DestroyWindow_wrap[pWin->drawable.pScreen->myNum])  {
        retVal = (*DestroyWindow_wrap[pWin->drawable.pScreen->myNum])(pWin);
    }
 
  /* Insist */
    screenInfo.screens[pWin->drawable.pScreen->myNum]->DestroyWindow = \
VMGLDestroyWindow;  xf86Msg(X_INFO, "VMGL: Leaving VMGLDestroyWindow function\n");
    return retVal;
}

static void VMGLClipNotify(WindowPtr pWin, int x, int y)
{
    xf86Msg(X_INFO, "VMGL: Entering VMGLClipNotify function\n");

    xf86Msg(X_INFO, "VMGL: pWin : %p \n", pWin);
    xf86Msg(X_INFO, "VMGL: x : %i \n", x);
    xf86Msg(X_INFO, "VMGL: y : %i \n", y);

    GlWindowWatcher *ptr = findWindow(pWin->drawable.id);
    
    xf86Msg(X_INFO, "VMGL: try to access on ptr\n");
    if (ptr) /*ptr is not NULL*/
    {
	SendWindowClipList(ptr->next->sock, ptr->next->glWindow, &(pWin->clipList) \
                /*RegionRec*/,
    		pWin->drawable.x, pWin->drawable.y, pWin->drawable.width, \
pWin->drawable.height);  }
    else /*ptr is NULL*/
    {
	xf86Msg(X_INFO, "VMGL: function 'findWindow' returns NULL for VMGLClipNotify\n");
    }

    xf86Msg(X_INFO, "VMGL: ScreenPtr screenptr = pWin->drawable.pScreen\n");
    ScreenPtr screenPtr = pWin->drawable.pScreen; /*address: 0x3 !!!!!*/
    xf86Msg(X_INFO, "VMGL: screenPtr: %p \n", screenPtr);

    xf86Msg(X_INFO, "VMGL: num = screenPtr->myNum\n");
    unsigned int num = screenPtr->myNum; /*this causes the segmentation fault at \
address 0x3*/  xf86Msg(X_INFO, "VMGL: num: %d \n", num);



    xf86Msg(X_INFO, "VMGL: try to access on \
ClipNotify_wrap[pWin->drawable.pScreen->myNum]\n");  if \
(ClipNotify_wrap[pWin->drawable.pScreen->myNum])  {
	xf86Msg(X_INFO, "VMGL: ClipNotify_wrap[pWin->drawable.pScreen->myNum]: %p \n", \
ClipNotify_wrap[pWin->drawable.pScreen->myNum]);  \
(*ClipNotify_wrap[pWin->drawable.pScreen->myNum])(pWin, x, y);    }
    else
    {
	xf86Msg(X_INFO, "VMGL: ClipNotify_wrap[pWin->drawable.pScreen->myNum] is NULL\n");
    }
    		
    /* Insist */
    screenInfo.screens[pWin->drawable.pScreen->myNum]->ClipNotify = VMGLClipNotify;
    xf86Msg(X_INFO, "VMGL: Leaving VMGLClipNotify function\n");
}

static Bool RemoveGlStub(in_addr_t address, in_addr_t port) {    
    xf86Msg(X_INFO, "VMGL: Entering RemoveGlStub function\n");
    GlStubWatcher *tmp, *ptr;
    GlWindowWatcher *windowList, *windowTmp;
    for (tmp=GlStubWatchersList; tmp->next != NULL; tmp=tmp->next)
	if ((tmp->next->address == address)&&(tmp->next->port == port)) {
	    /* Removal */
	    ptr = tmp->next;
	    if (close(ptr->sock))
		xf86ErrorF("Error %s closing socket to GlStub on address %s:%hu\n", \
strerror(errno),   IP2String(address), (unsigned short) port);

	    windowList = ptr->WindowWatchersList;
	    if (windowList->next)
		xf86Msg(X_WARNING, "Removing GlStub with pending windows, address %s:%hu\n",
			IP2String(address), (unsigned short) port);
	    while (windowList) {
		windowTmp = windowList;
		windowList = windowList->next;
		xfree(windowTmp);
	    }

	    tmp->next = ptr->next;
	    xfree(ptr);
	    xf86Msg(X_INFO, "GlStub for address %s:%hu removed\n",
		    IP2String(address), (unsigned short) port);
            xf86Msg(X_INFO, "VMGL: Leaving RemoveGlStub function: SUCCESS\n");
	    return TRUE;
	}
    
    /* Never found it? */
    xf86ErrorF("Couldn't find GlStub for address %s:%hu\n",
	    IP2String(address), (unsigned short) port);
    xf86Msg(X_INFO, "VMGL: Leaving RemoveGlStub function: FAILED\n");
    return FALSE;
}

/* These *are* the extension functions */
static Bool AddGlStub(in_addr_t address, in_addr_t port) {
    xf86Msg(X_INFO, "VMGL: Entering AddGlStub function\n");
    GlStubWatcher *tmp;
    int sock;
    struct sockaddr_in addr;
    
    /* Establish connection with listening part */		
    if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
	xf86ErrorF("Failed to create socket: %s\n", strerror(errno));
        xf86Msg(X_INFO, "VMGL: Leaving AddGlStub function: FAILED\n");
	return FALSE;
    }
    memset((void *) &addr, 0, sizeof(struct sockaddr_in));
    addr.sin_family = AF_INET;
    addr.sin_port = htons(port);
    addr.sin_addr.s_addr = htonl(address);
    if (connect(sock, (struct sockaddr *) &addr, sizeof(struct sockaddr_in)) < 0) {
	xf86ErrorF("Failed to connect to address %s:%hu: %s\n",IP2String(address),
		(unsigned short) port, strerror(errno));
        xf86Msg(X_INFO, "VMGL: Leaving AddGlStub function: FAILED\n");
	return FALSE;
    }

    /* Check it hasn't been already added */
    for (tmp=GlStubWatchersList; tmp->next != NULL; tmp=tmp->next)
	if ((tmp->next->address == address)&&(tmp->next->port == port)) {
	    xf86Msg(X_WARNING, "GlStub for address %s:%hu already added\n", 
		    IP2String(address), (unsigned short) port);
	    close(tmp->next->sock);
	    tmp->next->sock = sock;
	    xf86Msg(X_INFO, "VMGL: Leaving AddGlStub function: SUCCESS\n");
	    return TRUE;
	}
		
    /* Now add server to list */
    tmp = (GlStubWatcher *) xalloc(sizeof(GlStubWatcher));
    if (!tmp) {
	close(sock);
	xf86Msg(X_INFO, "VMGL: Leaving AddGlStub function: FAILED\n");
	return FALSE;
    }
    tmp->sock = sock;
    tmp->address = address;
    tmp->port = port;
    tmp->WindowWatchersList = (GlWindowWatcher *) xalloc(sizeof(GlWindowWatcher));
    if (!(tmp->WindowWatchersList)) {
	xfree(tmp);
	close(sock);
        xf86Msg(X_INFO, "VMGL: Leaving AddGlStub function: FAILED\n");
	return FALSE;
    }
    tmp->WindowWatchersList->next = NULL;
    tmp->next = tmp->next = GlStubWatchersList->next;
    GlStubWatchersList->next = tmp;
    xf86Msg(X_INFO, "Added GlStub for address %s:%hu\n", 
	    IP2String(address), (unsigned short) port);
    xf86Msg(X_INFO, "VMGL: Leaving AddGlStub function: SUCCESS\n");
    return TRUE;
}

/* Ugly ugly ugly helper */
static WindowPtr DepthSearchHelper(unsigned int XWindow, WindowPtr root) {
    xf86Msg(X_INFO, "VMGL: Entering DepthSearchHelper function\n");
    WindowPtr pWin, tmp;
    
    for (pWin = root->firstChild; pWin; pWin = pWin->nextSib)
    {
	if (pWin->drawable.id == XWindow)
	{
	    xf86Msg(X_INFO, "VMGL: Leaving DepthSearchHelper function: SUCCESS\n");
	    return pWin;
	}		
	else
        {
	    if ((tmp = DepthSearchHelper(XWindow, pWin)))
	    {
		xf86Msg(X_INFO, "VMGL: Leaving DepthSearchHelper function: SUCCESS\n");
		return tmp;
	    }
	}
    }
    
    xf86Msg(X_INFO, "VMGL: Leaving DepthSearchHelper function: FAILED\n");
    return NULL;
}

static WindowPtr DepthSearch(unsigned int XWindow) {
    xf86Msg(X_INFO, "VMGL: Entering DepthSearch function\n");
    int i;
    WindowPtr tmp;
    for (i=0;i<screenInfo.numScreens;i++)
    {
	if ((tmp = DepthSearchHelper(XWindow, WindowTable[i])))
	{
	    xf86Msg(X_INFO, "VMGL: Leaving DepthSearch function: SUCCESS\n");
	    return tmp;
	}
    }
    
    xf86Msg(X_INFO, "VMGL: Leaving DepthSearch function: FAILED\n");
    return NULL;
}

static Bool AddWindowWatch(unsigned int XWindow, unsigned int glWindow, 
		    in_addr_t address, in_port_t port)
{
    xf86Msg(X_INFO, "VMGL: Entering AddWindowWatch function\n");
    GlWindowWatcher *tmp, *ptr, *list;
    GlStubWatcher *srvTmp;
    WindowPtr thisWindow;
    
    if (!XWindow) {
	xf86ErrorF("Meaningless XID to watch for address %s:%hu\n",
		IP2String(address), (unsigned short) port);
	xf86Msg(X_INFO, "VMGL: Leaving AddWindowWatch function: FAILED\n");
	return FALSE;
    }
    
    /* First find the server */
    for (srvTmp=GlStubWatchersList; srvTmp->next != NULL; srvTmp=srvTmp->next)
	if ((srvTmp->next->address == address)&&(srvTmp->next->port == port)) {
		list = srvTmp->next->WindowWatchersList;
		break;
	}
    if (!srvTmp->next) {
	/* Didn't find server ?!?! */
	xf86ErrorF("Couldn't find gl stub for address %s:%hu\n",
		IP2String(address), (unsigned short) port);
        xf86Msg(X_INFO, "VMGL: Leaving AddWindowWatch function: FAILED\n");
	return FALSE;
    }
    
    /* Are we unwatching a window? */
    if (XWindow && !glWindow) {
	for (ptr=list; ptr->next != NULL; ptr=ptr->next) 
	    if (ptr->next->XWindow == XWindow) {
		xf86Msg(X_INFO, "Removing window %u for address %s:%hu\n",
			XWindow, IP2String(address), (unsigned short) port);
		tmp = ptr->next;
		ptr->next = tmp->next;
		xfree(tmp);
		/* Assume that once the list of windows is depleted
		   we can safely destroy the gl stub entry. NO!! */
/*		if (!(list->next))
		    return RemoveGlStub(srvTmp->next->address, srvTmp->next->port);
		else */  
		    xf86Msg(X_INFO, "VMGL: Leaving AddWindowWatch function: SUCCESS\n");
		    return TRUE;
	    }
	/* Could not find it */
        xf86Msg(X_INFO, "VMGL: Leaving AddWindowWatch function: FAILED\n");
	return FALSE;
    }
    
    for (ptr=list; ptr->next != NULL; ptr=ptr->next) 
	if (ptr->next->glWindow == glWindow) {
	    /* We have this, updating XWindow... */
	    ptr->next->XWindow = XWindow;
            xf86Msg(X_INFO, "VMGL: Leaving AddWindowWatch function: SUCCESS\n");
	    return TRUE;
	}
    
    /* We don't have this, add... */    
    tmp = (GlWindowWatcher *) xalloc(sizeof(GlWindowWatcher));
    if (!tmp)
    {
	xf86Msg(X_INFO, "VMGL: Leaving AddWindowWatch function: FAILED\n");
	return FALSE;
    }
    tmp->XWindow = XWindow;
    tmp->glWindow = glWindow;
    tmp->sock = srvTmp->next->sock;
    tmp->next = list->next;
    list->next = tmp;
    xf86ErrorF("Watching window %u (XID %u) for GlStub address %s:%hu, socket %d\n", 
	    glWindow, XWindow, IP2String(address), (unsigned short) port, tmp->sock);
    if (thisWindow = DepthSearch(XWindow))
    {
	VMGLClipNotify(thisWindow, 0, 0); 
	xf86Msg(X_INFO, "ClipNotify sent for XID %u, glWindow %u\n", XWindow, glWindow);
    }
    else xf86ErrorF("Odd, no window found for XID %u\n", XWindow);
    
    xf86Msg(X_INFO, "VMGL: Leaving AddWindowWatch function: SUCCESS\n");
    return TRUE;
}

/* These are X proto wrappers for the extension functions */
static int VMGLInitSrv(ClientPtr client)
{
    xf86Msg(X_INFO, "VMGL: Entering VMGLInitSrv function\n");
    REQUEST(xVMGLInitReq);
    XVMGLInitReply reply;

    REQUEST_SIZE_MATCH(xVMGLInitReq);
    reply.retVal = AddGlStub(stuff->address, stuff->port) ? 1:0;

    reply.type = X_Reply;
    reply.length = 0;
    reply.sequenceNumber = client->sequence;
    if(client->swapped)
    {
	register char swapper;
    	swaps(&reply.sequenceNumber, swapper);
    }

    WriteToClient(client, SIZEOF(XVMGLInitReply), (char *) &reply);
    xf86Msg(X_INFO, "VMGL: Leaving VMGLInitSrv function\n");
    return (client->noClientException);
}

static int VMGLWatchWindowSrv(ClientPtr client)
{
    xf86Msg(X_INFO, "VMGL: Entering VMGLWatchWindowSrv function\n");
    REQUEST(xVMGLWatchWindowReq);
    XVMGLWatchWindowReply reply;

    REQUEST_SIZE_MATCH(xVMGLWatchWindowReq);
    reply.retVal = AddWindowWatch(stuff->XWindow, stuff->glWindow, 
				  stuff->address, stuff->port) ? 1:0;
    
    reply.type = X_Reply;
    reply.length = 0;
    reply.sequenceNumber = client->sequence;
    if(client->swapped)
    {
	register char swapper;
    	swaps(&reply.sequenceNumber, swapper);
    }

    WriteToClient(client, SIZEOF(XVMGLWatchWindowReply), (char *) &reply);
    xf86Msg(X_INFO, "VMGL: Leaving VMGLWatchWindowSrv function\n");
    return (client->noClientException);
}

static int VMGLResetSrv(ClientPtr client)
{
    xf86Msg(X_INFO, "VMGL: Entering VMGLResetSrv function\n");
    REQUEST(xVMGLInitReq);
    XVMGLInitReply reply;

    REQUEST_SIZE_MATCH(xVMGLInitReq);
    reply.retVal = RemoveGlStub(stuff->address, stuff->port) ? 1:0;

    reply.type = X_Reply;
    reply.length = 0;
    reply.sequenceNumber = client->sequence;
    if(client->swapped)
    {
	register char swapper;
    	swaps(&reply.sequenceNumber, swapper);
    }

    WriteToClient(client, SIZEOF(XVMGLInitReply), (char *) &reply);
    xf86Msg(X_INFO, "VMGL: Leaving VMGLResetSrv function\n");
    return (client->noClientException);
}

/* Dispatching. Boring. Need to handle swapping/endiannes as well */
static int NormalDispatcher(ClientPtr client)
{
    xf86Msg(X_INFO, "VMGL: Entering NormalDispatcher function\n");
    REQUEST(xReq);

    switch (stuff->data)
    {
	case X_VMGLInit:
	    return VMGLInitSrv(client);
	case X_VMGLWatchWindow:
	    return VMGLWatchWindowSrv(client);
	case X_VMGLReset:
	    return VMGLResetSrv(client);
	default:
	    return BadRequest;
    }
}

static int SwappedVMGLInitSrv(ClientPtr client)
{
    xf86Msg(X_INFO, "VMGL: Entering SwappedVMGLInitSrv function\n");
    REQUEST(xVMGLInitReq);
    register char swapper;

    swaps(&stuff->length, swapper);
    REQUEST_SIZE_MATCH(xVMGLInitReq);
    swaps(&stuff->address, swapper);
    swaps(&stuff->port, swapper);
    xf86Msg(X_INFO, "VMGL: Leaving SwappedVMGLInitSrv function\n");
    return VMGLInitSrv(client);
}

static int SwappedVMGLWatchWindowSrv(ClientPtr client)
{
    xf86Msg(X_INFO, "VMGL: Entering SwappedVMGLWatchWindowSrv function\n");
    REQUEST(xVMGLWatchWindowReq);
    register char swapper;

    swaps(&stuff->length, swapper);
    REQUEST_SIZE_MATCH(xVMGLWatchWindowReq);
    swaps(&stuff->XWindow, swapper);
    swaps(&stuff->glWindow, swapper);
    swaps(&stuff->address, swapper);
    swaps(&stuff->port, swapper);
    xf86Msg(X_INFO, "VMGL: Leaving SwappedVMGLWatchWindowSrv function\n");
    return VMGLWatchWindowSrv(client);
}

static int SwappedVMGLResetSrv(ClientPtr client)
{
    xf86Msg(X_INFO, "VMGL: Entering SwappedVMGLResetSrv function\n");
    REQUEST(xVMGLInitReq);
    register char swapper;

    swaps(&stuff->length, swapper);
    REQUEST_SIZE_MATCH(xVMGLInitReq);
    swaps(&stuff->address, swapper);
    swaps(&stuff->port, swapper);
    xf86Msg(X_INFO, "VMGL: Leaving SwappedVMGLResetSrv function\n");
    return VMGLInitSrv(client);
}

static int SwappedDispatcher(ClientPtr client)
{
    xf86Msg(X_INFO, "VMGL: Entering SwappedDispatcher function\n");
    REQUEST(xReq);

    switch (stuff->data)
    {
	case X_VMGLInit:
	    return SwappedVMGLInitSrv(client);
	case X_VMGLWatchWindow:
	    return SwappedVMGLWatchWindowSrv(client);
	case X_VMGLReset:
	    return SwappedVMGLResetSrv(client);
	default:
	    return BadRequest;
    }
}

/* Extension initialization */
static void VMGLDummyReset(ExtensionEntry *extEntry)
{
    xf86Msg(X_INFO, "VMGL: Entering VMGLDummyReset function\n");
    xf86Msg(X_INFO, "VMGL: Leaving VMGLDummyReset function\n");
}

void VMGLExtensionInit(INITARGS)
{
    xf86Msg(X_INFO, "VMGL: Entering VMGLExtensionInit function\n");
    ExtensionEntry *extEntry;
    int i;

    /* Initialize globals */
    GlStubWatchersList = (GlStubWatcher*) xalloc(sizeof(GlStubWatcher));
    if (!GlStubWatchersList)
    {
	xf86ErrorF("Unable to start VMGL extension\n");
        xf86Msg(X_INFO, "VMGL: Leaving VMGLExtensionInit function: FAILED\n");
	return;
    }
    GlStubWatchersList->next = NULL; /*end of list*/


    /* Initialize extension */
    extEntry = AddExtension(VMGL_EXTENSION_NAME, 0, 0,
			    NormalDispatcher, SwappedDispatcher,
                            VMGLDummyReset, StandardMinorOpcode);
   if (!extEntry)
   {
	xfree(GlStubWatchersList);
	xf86ErrorF("Unable to start VMGL extension\n");
        xf86Msg(X_INFO, "VMGL: Leaving VMGLExtensionInit function: FAILED\n");
	return;
    }
    
    xf86Msg(X_INFO, "VMGL: screenInfo.numScreens: %i \n", screenInfo.numScreens);
    for (i = 0; i < screenInfo.numScreens; i++)
    {
	xf86Msg(X_INFO, "VMGL: i value: %i \n", i);


	/*Overriding X-Server function pointers with VMGL function pointers*/	
	/*So X-Server will now call those VMGL functions*/

	xf86Msg(X_INFO, "VMGL: ClipNotify_wrap[i] = screenInfo.screens[i]->ClipNotify\n");
        ClipNotify_wrap[i] = screenInfo.screens[i]->ClipNotify; /*backup of the old \
pointers*/  xf86Msg(X_INFO, "VMGL: ClipNotify_wrap[i]: %p \n", ClipNotify_wrap[i]);

	xf86Msg(X_INFO, "VMGL: screenInfo.screens[i]->ClipNotify = VMGLClipNotify\n");
        screenInfo.screens[i]->ClipNotify = VMGLClipNotify;
	xf86Msg(X_INFO, "VMGL: screenInfo.screens[i]->ClipNotify: %p \n", \
screenInfo.screens[i]->ClipNotify);

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  
	xf86Msg(X_INFO, "VMGL: DestroyWindow_wrap[i] = \
                screenInfo.screens[i]->DestroyWindow\n");
        DestroyWindow_wrap[i] = screenInfo.screens[i]->DestroyWindow; /*backup of the \
old pointer*/  xf86Msg(X_INFO, "VMGL: DestroyWindow_wrap[i]: %p \n", \
DestroyWindow_wrap[i]);

	xf86Msg(X_INFO, "VMGL: screenInfo.screens[i]->DestroyWindow = \
VMGLDestroyWindow;\n");  screenInfo.screens[i]->DestroyWindow = VMGLDestroyWindow;
	xf86Msg(X_INFO, "VMGL: screenInfo.screens[i]->DestroyWindow: %p \n", \
screenInfo.screens[i]->DestroyWindow);  }

    xf86Msg(X_INFO, "VMGL: extension succesfully loaded (by Andres \
Lagar-Cavilla)\n");  xf86Msg(X_INFO, "VMGL: Leaving VMGLExtensionInit function: \
SUCCESS\n");                                                                          \
  return;
}


["vmgl_extproto.h" (vmgl_extproto.h)]

/*
* Copyright (c) 2006-2007 H. Andres Lagar-Cavilla <andreslc@cs.toronto.edu>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
*   1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*   2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*   3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

/* vmgl project */

#ifndef _VMGLEXT_PROTO_H
#define _VMGLEXT_PROTO_H

/* Network proto between X server and gl stub */

typedef struct XVMGLWindowingCommand_struct {
    unsigned int	length;
    unsigned int	glWindow;
    int			x;
    int			y;
    unsigned int	width;
    unsigned int	height;
} XVMGLWindowingCommand;

#endif /* _VMGLEXT_PROTO_H */



["vmglmod.c" (vmglmod.c)]

/*
* Copyright (c) 2006-2007 H. Andres Lagar-Cavilla <andreslc@cs.toronto.edu>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
*   1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*   2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*   3. The name of the author may not be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/

/* Xfree86 loadable module interface for the vmgl extension to the X server
 * vmgl project */
 
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif

#include "xf86Module.h"
#include "xf86.h"

static MODULESETUPPROTO(VMGLSetup);

extern void VMGLExtensionInit(INITARGS);

static ExtensionModule VMGLExt = {
    VMGLExtensionInit,
    "VMGL Extension",
    NULL,
    NULL,
    NULL
};

static XF86ModuleVersionInfo VersRec = {
	"VMGL Extension",
	"VMGL, H. Andres Lagar-Cavilla",
	MODINFOSTRING1,
	MODINFOSTRING2,
	XORG_VERSION_CURRENT,
	0, 1, 0,
	ABI_CLASS_EXTENSION,
	ABI_EXTENSION_VERSION,
	MOD_CLASS_EXTENSION,
	{0,0,0,0}
};

_X_EXPORT XF86ModuleData vmglextModuleData = { &VersRec, VMGLSetup, NULL };

static pointer VMGLSetup(pointer module, pointer opts, int *errmaj, int *errmin)
{
    xf86Msg(X_INFO, "VMGL: Entering VMGLSetup function\n");
    LoadExtension(&VMGLExt, FALSE);
    xf86Msg(X_INFO, "VMGL: Leaving VMGLSetup function\n");

    /* Need a non-NULL return value to indicate success */
    return (pointer)1;
}


["xorg.conf" (xorg.conf)]

# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 275.21  \
(buildmeister@swio-display-x86-rhel47-02.nvidia.com)  Mon Jul 18 15:02:03 PDT 2011

Section "ServerLayout"
    Identifier     "X.org Configured"
    Screen      0  "Screen0" 0 0
    InputDevice    "Mouse0" "CorePointer"
    InputDevice    "Keyboard0" "CoreKeyboard"
EndSection

Section "ServerFlags"
    Option	   "DisableVidModeExtension"
    Option	   "AllowNonLocalXvidtune" "yes"
EndSection

Section "Files"
    ModulePath      "/usr/local/lib/xorg/modules"
    FontPath        "/usr/local/lib/X11/fonts/misc/"
    FontPath        "/usr/local/lib/X11/fonts/TTF/"
    FontPath        "/usr/local/lib/X11/fonts/OTF"
    FontPath        "/usr/local/lib/X11/fonts/Type1/"
    FontPath        "/usr/local/lib/X11/fonts/100dpi/"
    FontPath        "/usr/local/lib/X11/fonts/75dpi/"
EndSection

Section "Module"
    Load           "extmod"
    Load           "dbe"
    Load	   "dri"
    Load           "dri2"
    Load           "glx"
    Load           "vmglext"
EndSection

Section "Extensions"
    Option	   "Composite" "Disable"
EndSection

Section "InputDevice"
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/input/mice"
    Option         "ZAxisMapping" "4 5 6 7"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Monitor Vendor"
    ModelName      "Monitor Model"
EndSection

Section "Device"

        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz"
        ### [arg]: arg optional
        #Option     "SWcursor"           	# [<bool>]
        #Option     "HWcursor"           	# [<bool>]
        #Option     "NoAccel"            	# [<bool>]
        #Option     "ShadowFB"           	# [<bool>]
        #Option     "VideoKey"           	# <i>
        #Option     "WrappedFB"          	# [<bool>]
        #Option     "ZaphodHeads"        	# <str>
    Identifier     "Card0"
    Driver         "nvidia"
    VendorName     "nVidia Corporation"
    BoardName      "G96 [Quadro FX 580]"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Card0"
    Monitor        "Monitor0"
    SubSection     "Display"
        Viewport    0 0
    EndSubSection
    SubSection     "Display"
        Viewport    0 0
        Depth       4
    EndSubSection
    SubSection     "Display"
        Viewport    0 0
        Depth       8
    EndSubSection
    SubSection     "Display"
        Viewport    0 0
        Depth       15
    EndSubSection
    SubSection     "Display"
        Viewport    0 0
        Depth       16
    EndSubSection
    SubSection     "Display"
        Viewport    0 0
        Depth       24
    EndSubSection
EndSection


["Xorg.0.log" (Xorg.0.log)]

X.Org X Server 1.7.7
Release Date: 2010-05-04
X Protocol Version 11, Revision 0
Build Operating System: Linux 2.6.32-131.17.1.el6.x86_64 x86_64 
Current Operating System: Linux msmdw206 2.6.32-131.17.1.el6.x86_64 #1 SMP Thu Sep 29 \
10:24:25 EDT 2011 x86_64 Kernel command line: ro \
root=UUID=7141a345-a97d-4f6a-9b94-2ff9e91d1dfd rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM \
LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc \
KEYTABLE=de-latin1-nodeadkeys crashkernel=129M@0M rhgb quiet rdblacklist=nouveau \
vga=791 nouveau.modeset=0 Build Date: 25 March 2013  01:57:49PM
 
Current version of pixman: 0.18.4
	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
	(++) from command line, (!!) notice, (II) informational,
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/usr/local/var/log/Xorg.0.log", Time: Tue Mar 26 09:25:31 2013
(==) Using config file: "/etc/X11/xorg.conf"
(==) ServerLayout "X.org Configured"
(**) |-->Screen "Screen0" (0)
(**) |   |-->Monitor "Monitor0"
(**) |   |-->Device "Card0"
(**) |-->Input Device "Mouse0"
(**) |-->Input Device "Keyboard0"
(**) Option "DisableVidModeExtension"
(**) Option "AllowNonLocalXvidtune" "yes"
(==) Automatically adding devices
(==) Automatically enabling devices
(WW) The directory "/usr/local/lib/X11/fonts/TTF/" does not exist.
	Entry deleted from font path.
(WW) The directory "/usr/local/lib/X11/fonts/OTF" does not exist.
	Entry deleted from font path.
(WW) The directory "/usr/local/lib/X11/fonts/TTF/" does not exist.
	Entry deleted from font path.
(WW) The directory "/usr/local/lib/X11/fonts/OTF" does not exist.
	Entry deleted from font path.
(**) FontPath set to:
	/usr/local/lib/X11/fonts/misc/,
	/usr/local/lib/X11/fonts/Type1/,
	/usr/local/lib/X11/fonts/100dpi/,
	/usr/local/lib/X11/fonts/75dpi/,
	/usr/local/lib/X11/fonts/misc/,
	/usr/local/lib/X11/fonts/Type1/,
	/usr/local/lib/X11/fonts/100dpi/,
	/usr/local/lib/X11/fonts/75dpi/
(**) ModulePath set to "/usr/local/lib/xorg/modules"
(**) Extension "Composite" is disabled
(WW) AllowEmptyInput is on, devices using drivers 'kbd', 'mouse' or 'vmmouse' will be \
disabled. (WW) Disabling Mouse0
(WW) Disabling Keyboard0
(II) Loader magic: 0x7c6f00
(II) Module ABI versions:
	X.Org ANSI C Emulation: 0.4
	X.Org Video Driver: 6.0
	X.Org XInput driver : 7.0
	X.Org Server Extension : 2.0
(--) using VT number 7

(--) PCI:*(0:40:0:0) 10de:0659:10de:063a nVidia Corporation G96 [Quadro FX 580] rev \
161, Mem @ 0xf6000000/16777216, 0xe0000000/268435456, 0xf4000000/33554432, I/O @ \
0x0000e000/128, BIOS @ 0x????????/131072 (II) Open ACPI successful \
(/var/run/acpid.socket) (II) "extmod" will be loaded. This was enabled by default and \
also specified in the config file. (II) "dbe" will be loaded. This was enabled by \
default and also specified in the config file. (II) "glx" will be loaded. This was \
enabled by default and also specified in the config file. (II) "dri" will be loaded. \
This was enabled by default and also specified in the config file. (II) "dri2" will \
be loaded. This was enabled by default and also specified in the config file. (II) \
LoadModule: "extmod" (II) Loading /usr/local/lib/xorg/modules/extensions/libextmod.so
(II) Module extmod: vendor="X.Org Foundation"
	compiled for 1.7.7, module version = 1.0.0
	Module class: X.Org Server Extension
	ABI class: X.Org Server Extension, version 2.0
(II) Loading extension MIT-SCREEN-SAVER
(II) Loading extension XFree86-VidModeExtension
(II) Loading extension XFree86-DGA
(II) Loading extension DPMS
(II) Loading extension XVideo
(II) Loading extension XVideo-MotionCompensation
(II) Loading extension X-Resource
(II) LoadModule: "dbe"
(II) Loading /usr/local/lib/xorg/modules/extensions/libdbe.so
(II) Module dbe: vendor="X.Org Foundation"
	compiled for 1.7.7, module version = 1.0.0
	Module class: X.Org Server Extension
	ABI class: X.Org Server Extension, version 2.0
(II) Loading extension DOUBLE-BUFFER
(II) LoadModule: "dri"
(II) Loading /usr/local/lib/xorg/modules/extensions/libdri.so
(II) Module dri: vendor="X.Org Foundation"
	compiled for 1.7.7, module version = 1.0.0
	ABI class: X.Org Server Extension, version 2.0
(II) Loading extension XFree86-DRI
(II) LoadModule: "dri2"
(II) Loading /usr/local/lib/xorg/modules/extensions/libdri2.so
(II) Module dri2: vendor="X.Org Foundation"
	compiled for 1.7.7, module version = 1.1.0
	ABI class: X.Org Server Extension, version 2.0
(II) Loading extension DRI2
(II) LoadModule: "glx"
(II) Loading /usr/local/lib/xorg/modules/extensions/nvidia/libglx.so
(II) Module glx: vendor="NVIDIA Corporation"
	compiled for 4.0.2, module version = 1.0.0
	Module class: X.Org Server Extension
(II) NVIDIA GLX Module  275.21  Mon Jul 18 14:58:18 PDT 2011
(II) Loading extension GLX
(II) LoadModule: "vmglext"
(II) Loading /usr/local/lib/xorg/modules/extensions/libvmglext.so
(II) Module VMGL Extension: vendor="VMGL, H. Andres Lagar-Cavilla"
	compiled for 1.7.7, module version = 0.1.0
	Module class: X.Org Server Extension
	ABI class: X.Org Server Extension, version 2.0
(II) VMGL: Entering VMGLSetup function
(II) Loading extension VMGL Extension
(II) VMGL: Leaving VMGLSetup function
(II) LoadModule: "nvidia"
(II) Loading /usr/local/lib/xorg/modules/drivers/nvidia_drv.so
(II) Module nvidia: vendor="NVIDIA Corporation"
	compiled for 4.0.2, module version = 1.0.0
	Module class: X.Org Video Driver
(II) NVIDIA dlloader X Driver  275.21  Mon Jul 18 14:41:51 PDT 2011
(II) NVIDIA Unified Driver for all Supported NVIDIA GPUs
(II) Primary Device is: PCI 28@00:00:0
(II) Loading sub module "fb"
(II) LoadModule: "fb"
(II) Loading /usr/local/lib/xorg/modules/libfb.so
(II) Module fb: vendor="X.Org Foundation"
	compiled for 1.7.7, module version = 1.0.0
	ABI class: X.Org ANSI C Emulation, version 0.4
(II) Loading sub module "wfb"
(II) LoadModule: "wfb"
(II) Loading /usr/local/lib/xorg/modules/libwfb.so
(II) Module wfb: vendor="X.Org Foundation"
	compiled for 1.7.7, module version = 1.0.0
	ABI class: X.Org ANSI C Emulation, version 0.4
(II) Loading sub module "ramdac"
(II) LoadModule: "ramdac"
(II) Module "ramdac" already built-in
(==) NVIDIA(0): Depth 24, (==) framebuffer bpp 32
(==) NVIDIA(0): RGB weight 888
(==) NVIDIA(0): Default visual is TrueColor
(==) NVIDIA(0): Using gamma correction (1.0, 1.0, 1.0)
(II) Mar 26 09:25:32 NVIDIA(GPU-0): Display (DELL U2711 (DFP-0)) does not support \
NVIDIA 3D Vision (II) Mar 26 09:25:32 NVIDIA(GPU-0):     stereo.
(II) Mar 26 09:25:32 NVIDIA(0): NVIDIA GPU Quadro FX 580 (G96GL) at PCI:40:0:0 \
(GPU-0) (--) Mar 26 09:25:32 NVIDIA(0): Memory: 524288 kBytes
(--) Mar 26 09:25:32 NVIDIA(0): VideoBIOS: 62.94.96.00.08
(II) Mar 26 09:25:32 NVIDIA(0): Detected PCI Express Link width: 16X
(--) Mar 26 09:25:32 NVIDIA(0): Interlaced video modes are supported on this GPU
(--) Mar 26 09:25:32 NVIDIA(0): Connected display device(s) on Quadro FX 580 at \
PCI:40:0:0 (--) Mar 26 09:25:32 NVIDIA(0):     DELL U2711 (DFP-0)
(--) Mar 26 09:25:32 NVIDIA(0): DELL U2711 (DFP-0): 330.0 MHz maximum pixel clock
(--) Mar 26 09:25:32 NVIDIA(0): DELL U2711 (DFP-0): Internal Dual Link TMDS
(II) Mar 26 09:25:32 NVIDIA(0): Assigned Display Device: DFP-0
(==) Mar 26 09:25:32 NVIDIA(0): 
(==) Mar 26 09:25:32 NVIDIA(0): No modes were requested; the default mode \
"nvidia-auto-select" (==) Mar 26 09:25:32 NVIDIA(0):     will be used as the \
requested mode. (==) Mar 26 09:25:32 NVIDIA(0): 
(II) Mar 26 09:25:32 NVIDIA(0): Validated modes:
(II) Mar 26 09:25:32 NVIDIA(0):     "nvidia-auto-select"
(II) Mar 26 09:25:32 NVIDIA(0): Virtual screen size determined to be 2560 x 1440
(--) Mar 26 09:25:32 NVIDIA(0): DPI set to (108, 107); computed from "UseEdidDpi" X \
config (--) Mar 26 09:25:32 NVIDIA(0):     option
(--) Depth 24 pixmap format is 32 bpp
(II) Mar 26 09:25:32 NVIDIA: Using 768.00 MB of virtual memory for indirect memory \
access. (II) Mar 26 09:25:32 NVIDIA(0): Setting mode "nvidia-auto-select"
(II) Loading extension NV-GLX
(==) NVIDIA(0): Disabling shared memory pixmaps
(==) NVIDIA(0): Backing store disabled
(==) NVIDIA(0): Silken mouse enabled
(==) NVIDIA(0): DPMS enabled
(II) Loading extension NV-CONTROL
(II) Loading extension XINERAMA
(==) RandR enabled
(II) Initializing built-in extension Generic Event Extension
(II) Initializing built-in extension SHAPE
(II) Initializing built-in extension MIT-SHM
(II) Initializing built-in extension XInputExtension
(II) Initializing built-in extension XTEST
(II) Initializing built-in extension BIG-REQUESTS
(II) Initializing built-in extension SYNC
(II) Initializing built-in extension XKEYBOARD
(II) Initializing built-in extension XC-MISC
(II) Initializing built-in extension XINERAMA
(II) Initializing built-in extension XFIXES
(II) Initializing built-in extension RENDER
(II) Initializing built-in extension RANDR
(II) Initializing built-in extension COMPOSITE
(II) Initializing built-in extension DAMAGE
(II) Initializing extension GLX
(II) VMGL: Entering VMGLExtensionInit function
(II) VMGL: screenInfo.numScreens: 1 
(II) VMGL: i value: 0 
(II) VMGL: ClipNotify_wrap[i] = screenInfo.screens[i]->ClipNotify
(II) VMGL: ClipNotify_wrap[i]: 0x7f35ae3fe9a0 
(II) VMGL: screenInfo.screens[i]->ClipNotify = VMGLClipNotify
(II) VMGL: screenInfo.screens[i]->ClipNotify: 0x7f35ae9b91e0 
(II) VMGL: DestroyWindow_wrap[i] = screenInfo.screens[i]->DestroyWindow
(II) VMGL: DestroyWindow_wrap[i]: 0x7f35af9f7b20 
(II) VMGL: screenInfo.screens[i]->DestroyWindow = VMGLDestroyWindow;
(II) VMGL: screenInfo.screens[i]->DestroyWindow: 0x7f35ae9b90e0 
(II) VMGL: extension succesfully loaded (by Andres Lagar-Cavilla)
(II) VMGL: Leaving VMGLExtensionInit function: SUCCESS
(II) VMGL: Entering VMGLClipNotify function
(II) VMGL: pWin : 0xed4d00 
(II) VMGL: x : 0 
(II) VMGL: y : 0 
(II) VMGL: Entering findWindow function
(II) VMGL: pWin->drawable.id: 0 
(II) VMGL: try to access on GlStubWatchersList
(II) VMGL: GlStubWatchersList: 0xecbe20 
(II) VMGL: srvPtr = GlStubWatchersList
(II) VMGL: srvPtr: 0xecbe20 
(II) VMGL: try to access on srvPtr->next
(II) VMGL: srvPtr->next is NULL
(II) VMGL: Leaving findWindow function: FAILED
(II) VMGL: try to access on ptr
(II) VMGL: function 'findWindow' returns NULL for VMGLClipNotify
(II) VMGL: ScreenPtr screenptr = pWin->drawable.pScreen
(II) VMGL: screenPtr: 0x3 
(II) VMGL: num = screenPtr->myNum

Backtrace:
0: /usr/local/bin/X (xorg_backtrace+0x28) [0x45fe58]
1: /usr/local/bin/X (0x400000+0x62a09) [0x462a09]
2: /lib64/libpthread.so.0 (0x310d400000+0xf490) [0x310d40f490]
3: /usr/local/lib/xorg/modules/extensions/libvmglext.so (0x7f35ae9b8000+0x13a3) \
                [0x7f35ae9b93a3]
4: /usr/local/bin/X (MapWindow+0x2b6) [0x42c936]
5: /usr/local/bin/X (0x400000+0x218e0) [0x4218e0]
6: /lib64/libc.so.6 (__libc_start_main+0xfd) [0x310c81ecdd]
7: /usr/local/bin/X (0x400000+0x214e9) [0x4214e9]
Segmentation fault at address 0x3

Fatal server error:
Caught signal 11 (Segmentation fault). Server aborting


Please consult the The X.Org Foundation support 
	 at http://wiki.x.org
 for help. 
Please also check the log file at "/usr/local/var/log/Xorg.0.log" for additional \
information.



_______________________________________________
xorg@lists.x.org: X.Org support
Archives: http://lists.freedesktop.org/archives/xorg
Info: http://lists.x.org/mailman/listinfo/xorg
Your subscription address: freedesktop-xorg@progressive-comp.com

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic