From d40f0a49c88fc7b5162a9d8f7b64b571094e8593 Mon Sep 17 00:00:00 2001 From: marha Date: Thu, 5 May 2011 07:26:05 +0000 Subject: libX11 libxcb mesa git update 5 May 2011 --- libX11/configure.ac | 972 +++++++++---------- libX11/include/X11/Xlibint.h | 2 +- libX11/src/xkb/XKBGeom.c | 1384 ++++++++++++++-------------- libxcb/configure.ac | 2 +- libxcb/src/c_client.py | 39 +- mesalib/configure.ac | 4 +- mesalib/scons/custom.py | 1 + mesalib/scons/gallium.py | 1248 ++++++++++++------------- mesalib/src/mesa/drivers/windows/gdi/wgl.c | 2 +- 9 files changed, 1828 insertions(+), 1826 deletions(-) diff --git a/libX11/configure.ac b/libX11/configure.ac index 8a0a4faa8..a39ab8d94 100644 --- a/libX11/configure.ac +++ b/libX11/configure.ac @@ -1,486 +1,486 @@ - -# Initialize Autoconf -AC_PREREQ([2.60]) -AC_INIT([libX11], [1.4.3], - [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libX11]) -AC_CONFIG_SRCDIR([Makefile.am]) -AC_CONFIG_HEADERS([src/config.h include/X11/XlibConf.h]) -AC_CONFIG_MACRO_DIR([m4]) -AC_CANONICAL_BUILD -AC_CANONICAL_HOST -# Set common system defines for POSIX extensions, such as _GNU_SOURCE -# Must be called before any macros that run the compiler (like AC_PROG_LIBTOOL) -# to avoid autoconf errors. -AC_USE_SYSTEM_EXTENSIONS - -# Initialize Automake -AM_INIT_AUTOMAKE([foreign dist-bzip2]) -AM_MAINTAINER_MODE - -# Initialize libtool -AC_PROG_LIBTOOL - -# Require xorg-macros minimum of 1.12 for DocBook external references -m4_ifndef([XORG_MACROS_VERSION], - [m4_fatal([must install xorg-macros 1.12 or later before running autoconf/autogen])]) -XORG_MACROS_VERSION(1.12) -XORG_DEFAULT_OPTIONS -XORG_ENABLE_SPECS -XORG_WITH_XMLTO(0.0.22) -XORG_WITH_FOP([no]) -XORG_WITH_XSLTPROC -XORG_CHECK_SGML_DOCTOOLS(1.7) -XORG_PROG_RAWCPP - -# Required when PKG_CHECK_MODULES called within an if statement -PKG_PROG_PKG_CONFIG - -if test x"$CC_FOR_BUILD" = x; then - if test x"$cross_compiling" = xyes; then - AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc) - else - CC_FOR_BUILD="$CC" - fi -fi -AC_SUBST([CC_FOR_BUILD]) - -if test x"$CPPFLAGS_FOR_BUILD" = x; then - if test ! x"$cross_compiling" = xyes; then - CPPFLAGS_FOR_BUILD=${CPPFLAGS} - fi -fi -AC_SUBST(CPPFLAGS_FOR_BUILD) - -if test x"$CFLAGS_FOR_BUILD" = x; then - if test ! x"$cross_compiling" = xyes; then - CFLAGS_FOR_BUILD=${CFLAGS} - fi -fi -AC_SUBST(CFLAGS_FOR_BUILD) - -if test x"$LDFLAGS_FOR_BUILD" = x; then - if test ! x"$cross_compiling" = xyes; then - LDFLAGS_FOR_BUILD=${LDFLAGS} - fi -fi -AC_SUBST(LDFLAGS_FOR_BUILD) - -# Find perl for "make check" tests in nls/Makefile.am -AC_ARG_WITH(perl, - AS_HELP_STRING([--with-perl=], - [path to perl interpreter for build-time tests]), - [PERL=$withval ; AC_MSG_CHECKING([perl]) ; - AC_MSG_RESULT([(from --with-perl) $PERL])], - AC_CHECK_PROGS([PERL], [perl], [no])) -AM_CONDITIONAL(HAVE_PERL, test x$PERL != xno) - -# Checks for pkg-config packages - -# Always required -X11_REQUIRES='xproto >= 7.0.13 xextproto xtrans xcb >= 1.1.92' -X11_EXTRA_DEPS="xcb >= 1.1.92" - -PKG_PROG_PKG_CONFIG() - -AC_SUBST(X11_EXTRA_DEPS) - -# Issue an error if xtrans.m4 was not found and XTRANS_CONNECTION_FLAGS macro -# was not expanded, since libX11 with no transport types is rather useless. -# -# If you're seeing an error here, be sure you installed the lib/xtrans module -# first and if it's not in the default location, that you set the ACLOCAL -# environment variable to find it, such as: -# 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 - -# Preferred order to try transports for local connections -AC_MSG_CHECKING([what order to try transports in for local connections]) -DEFAULT_LOCAL_TRANS="" -case $host_os in - solaris*) - # On Solaris 2.6 through 9, named pipes (LOCAL_TRANS) were - # faster than Unix domain sockets, but on Solaris 10 & later, - # Unix domain sockets are faster now. - if test "$UNIXCONN" = "yes" ; then - if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then - DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}," - fi - DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}UNIX_TRANS" - fi - if test "$LOCALCONN" = "yes" ; then - if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then - DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}," - fi - DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}LOCAL_TRANS" - fi - if test "$TCPCONN" = "yes" ; then - if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then - DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}," - fi - DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}TCP_TRANS" - fi - ;; - linux*) - # LOCAL_TRANS is used for abstract sockets. - if test "$UNIXCONN" = "yes" ; then - if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then - DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}," - fi - DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}LOCAL_TRANS,UNIX_TRANS" - fi - if test "$TCPCONN" = "yes" ; then - if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then - DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}," - fi - DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}TCP_TRANS" - fi - ;; - *) - if test "$LOCALCONN" = "yes" ; then - if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then - DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}," - fi - DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}LOCAL_TRANS" - fi - if test "$UNIXCONN" = "yes" ; then - if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then - DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}," - fi - DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}UNIX_TRANS" - fi - if test "$TCPCONN" = "yes" ; then - if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then - DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}," - fi - DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}TCP_TRANS" - fi - ;; -esac - -AC_ARG_WITH(local-transport-order, - AS_HELP_STRING([--with-local-transport-order=LIST], [preference sorted list of transport types to try for local connections]), - [LOCAL_TRANSPORT_LIST=$withval], - [LOCAL_TRANSPORT_LIST=$DEFAULT_LOCAL_TRANS]) -AC_DEFINE_UNQUOTED([LOCAL_TRANSPORT_LIST], [$LOCAL_TRANSPORT_LIST], - [preference sorted list of transport types to try for local connections]) -AC_MSG_RESULT([$LOCAL_TRANSPORT_LIST]) - -# Check for dlopen -AC_MSG_CHECKING([if run-time linking is supported]) -AC_SEARCH_LIBS(dlopen,[dl svld]) -if test "x$ac_cv_search_dlopen" = xno; then - AC_SEARCH_LIBS(shl_load,[dld]) - if test "x$ac_cv_search_shl_load" != xno; then - AC_DEFINE(HAVE_SHL_LOAD,1, - [Use shl_load to load shared libraries]) - AC_CHECK_HEADERS([dl.h]) - fi -else - AC_DEFINE(HAVE_DLOPEN,1,[Use dlopen to load shared libraries]) - AC_CHECK_HEADERS([dlfcn.h]) -fi -if test x$ac_cv_header_dlcfn_h -o x$ac_cv_header_dl_h; then - HAVE_LOADABLE_MODULES=yes -else - HAVE_LOADABLE_MODULES=no -fi -AC_MSG_RESULT($HAVE_LOADABLE_MODULES) - -AC_MSG_CHECKING([if loadable i18n module support should be enabled]) -AC_ARG_ENABLE(loadable-i18n, - AS_HELP_STRING([--enable-loadable-i18n], - [Controls loadable i18n module support]), - [XLIB_LOADABLE_I18N=$enableval], - [XLIB_LOADABLE_I18N="no"]) -if test x$XLIB_LOADABLE_I18N = xyes; then - if test x$HAVE_LOADABLE_MODULES = xno; then - AC_MSG_ERROR([Loadable module support is required to enable loadable i18n module support]) - fi - AC_DEFINE(USE_DYNAMIC_LC,1, - [Split some i18n functions into loadable modules]) - AC_SUBST(I18N_MODULE_LIBS,'${top_builddir}/src/libX11.la') -fi -AC_MSG_RESULT($XLIB_LOADABLE_I18N) - -AM_CONDITIONAL(XLIB_LOADABLE_I18N, test x$XLIB_LOADABLE_I18N = xyes) - -AC_MSG_CHECKING([if loadable Xcursor library support should be enabled]) -AC_ARG_ENABLE(loadable-xcursor, - AS_HELP_STRING([--disable-loadable-xcursor], - [Controls loadable xcursor library support]), - [XLIB_LOADABLE_XCURSOR=$enableval], - [XLIB_LOADABLE_XCURSOR=$HAVE_LOADABLE_MODULES]) -if test x$XLIB_LOADABLE_XCURSOR = xyes; then - AC_DEFINE(USE_DYNAMIC_XCURSOR,1, - [Use the X cursor library to load cursors]) -fi -AC_MSG_RESULT($XLIB_LOADABLE_XCURSOR) - -# Checks for header files. -AC_CHECK_HEADERS([sys/select.h]) - -# Checks for typedefs, structures, and compiler characteristics. - -# Checks for library functions. -AC_CHECK_FUNCS([strtol]) -# Used in lcFile.c (see also --enable-xlocaledir settings below) -XLOCALEDIR_IS_SAFE="no" -AC_CHECK_FUNC([issetugid], [XLOCALEDIR_IS_SAFE="yes"] - AC_DEFINE(HASSETUGID,1,[Has issetugid() function])) -AC_CHECK_FUNC([getresuid], [XLOCALEDIR_IS_SAFE="yes"] - AC_DEFINE(HASGETRESUID,1,[Has getresuid() & getresgid() functions])) -# Used in Font.c -AC_CHECK_FUNC([shmat], AC_DEFINE(HAS_SHM,1,[Has shm*() functions])) - -# Checks for system services -# AC_PATH_XTRA - -# arch specific things -WCHAR32="1" -case $host_os in - os2*) os2="true" ; WCHAR32="0" ;; - *) ;; -esac -AC_SUBST(WCHAR32) - -AM_CONDITIONAL(OS2, test x$os2 = xtrue) - -AC_ARG_WITH(launchd, AS_HELP_STRING([--with-launchd], [Build with support for Apple's launchd (default: auto)]), [LAUNCHD=$withval], [LAUNCHD=auto]) -if test "x$LAUNCHD" = xauto; then - unset LAUNCHD - AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no], [$PATH$PATH_SEPARATOR/sbin]) -fi - -if test "x$LAUNCHD" = xyes ; then - AC_DEFINE(HAVE_LAUNCHD, 1, [launchd support available]) - AC_DEFINE(TRANS_REOPEN, 1, [launchd support available]) -fi - -AC_ARG_ENABLE(xthreads, - AS_HELP_STRING([--disable-xthreads], - [Disable Xlib support for Multithreading]), - [xthreads=$enableval],[xthreads=yes]) - -AC_CHECK_LIB(c, getpwuid_r, [mtsafeapi="yes"], [mtsafeapi="no"]) - -case x$xthreads in -xyes) - AC_DEFINE(XTHREADS,1,[Whether libX11 is compiled with thread support]) - if test x$mtsafeapi = xyes - then - AC_DEFINE(XUSE_MTSAFE_API,1,[Whether libX11 needs to use MT safe API's]) - fi - ;; -*) - ;; -esac - -AC_CHECK_LIB(c, pthread_self, [thrstubs="no"], [thrstubs="yes"]) -AM_CONDITIONAL(THRSTUBS, test x$thrstubs = xyes) - -# XXX incomplete, please fill this in -if test x$xthreads = xyes ; then - case $host_os in - linux*|openbsd*|gnu*|k*bsd*-gnu) - XTHREADLIB=-lpthread ;; - netbsd*) - XTHREAD_CFLAGS="-D_POSIX_THREAD_SAFE_FUNCTIONS" - XTHREADLIB="-lpthread" ;; - freebsd*) - XTHREAD_CFLAGS="-D_THREAD_SAFE" - XTHREADLIB="-pthread" ;; - dragonfly*) - XTHREADLIB="-pthread" ;; - solaris*) - XTHREAD_CFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS" ;; - esac -fi -AC_SUBST(XTHREADLIB) -AC_SUBST(XTHREAD_CFLAGS) - -AC_CHECK_FUNC(poll, [AC_DEFINE(USE_POLL, 1, [poll() function is available])], ) - -# -# Find keysymdef.h -# -AC_MSG_CHECKING([keysym definitions]) -KEYSYMDEFDIR=`$PKG_CONFIG --variable=includedir xproto`/X11 -FILES="keysymdef.h XF86keysym.h Sunkeysym.h DECkeysym.h HPkeysym.h" -for i in $FILES; do - if test -f "$KEYSYMDEFDIR/$i"; then - KEYSYMDEFS="$KEYSYMDEFS $KEYSYMDEFDIR/$i" - elif test "x$i" = "xkeysymdef.h"; then - AC_MSG_ERROR([Cannot find keysymdef.h]) - fi -done -AC_MSG_RESULT([$KEYSYMDEFS]) -AC_SUBST(KEYSYMDEFS) - -AM_CONDITIONAL(UDC, test xfalse = xtrue) - -AC_ARG_ENABLE(xcms, - AS_HELP_STRING([--disable-xcms], - [Disable Xlib support for CMS *EXPERIMENTAL*]), - [XCMS=$enableval],[XCMS=yes]) -AM_CONDITIONAL(XCMS, [test x$XCMS = xyes ]) -if test x"$XCMS" = "xyes"; then - AC_DEFINE(XCMS,1,[Include support for XCMS]) -fi - -AC_ARG_ENABLE(xlocale, - AS_HELP_STRING([--disable-xlocale], - [Disable Xlib locale implementation *EXPERIMENTAL*]), - [XLOCALE=$enableval],[XLOCALE=yes]) - -AM_CONDITIONAL(XLOCALE, [ test x$XLOCALE = xyes ]) -if test x"$XLOCALE" = "xyes"; then - AC_DEFINE(XLOCALE,1,[support for X Locales]) -fi - -# This disables XLOCALEDIR. Set it if you're using BuildLoadableXlibI18n, -# don't have either issetugid() or getresuid(), and you need to protect -# clients that are setgid or setuid to an id other than 0. -AC_MSG_CHECKING([if XLOCALEDIR support should be enabled]) -AC_ARG_ENABLE(xlocaledir, - AS_HELP_STRING([--enable-xlocaledir], - [Enable XLOCALEDIR environment variable support]), - [ENABLE_XLOCALEDIR=$enableval],[ENABLE_XLOCALEDIR=$XLOCALEDIR_IS_SAFE]) -if test "x$ENABLE_XLOCALEDIR" = "xno"; then - AC_DEFINE(NO_XLOCALEDIR,1,[Disable XLOCALEDIR environment variable]) -fi -AC_MSG_RESULT($ENABLE_XLOCALEDIR) - -AC_ARG_ENABLE(xf86bigfont, - AS_HELP_STRING([--disable-xf86bigfont], - [Disable XF86BigFont extension support]), - [XF86BIGFONT=$enableval],[XF86BIGFONT="yes"]) -if test "x$XF86BIGFONT" = "xyes"; then - PKG_CHECK_MODULES(BIGFONT, [xf86bigfontproto >= 1.2.0], - AC_DEFINE(XF86BIGFONT,1,[Enable XF86BIGFONT extension]),XF86BIGFONT="no") -fi - -AC_ARG_ENABLE(xkb, - AS_HELP_STRING([--disable-xkb], - [Disable XKB support *EXPERIMENTAL*]), - [XKB=$enableval],[XKB=yes]) - -AM_CONDITIONAL(XKB, [ test x$XKB = xyes ]) -if test x"$XKB" = "xyes"; then - XKBPROTO_REQUIRES="kbproto" - X11_REQUIRES="${X11_REQUIRES} kbproto inputproto" - AC_DEFINE(XKB,1,[Use XKB]) -else - XKBPROTO_REQUIRES="" -fi -AC_SUBST(XKBPROTO_REQUIRES) - -AC_FUNC_MMAP() -composecache_default=$ac_cv_func_mmap_fixed_mapped -AC_CHECK_FUNC(nl_langinfo, , [composecache_default=no]) -AC_ARG_ENABLE(composecache, - AS_HELP_STRING([--disable-composecache], - [Disable compose table cache support]), - [COMPOSECACHE=$enableval],[COMPOSECACHE=$composecache_default]) -if test x"$COMPOSECACHE" = "xyes"; then - AC_DEFINE(COMPOSECACHE,1,[Include compose table cache support]) -fi - -# Allow checking code with lint, sparse, etc. -XORG_WITH_LINT -XORG_LINT_LIBRARY([X11]) - -X11_DATADIR="${datadir}/X11" -AX_DEFINE_DIR(X11_DATADIR, X11_DATADIR, [Location of libX11 data]) -AC_SUBST(X11_DATADIR) - -X11_LIBDIR="${libdir}/X11" -AX_DEFINE_DIR(X11_LIBDIR, X11_LIBDIR, [Location of libX11 library data]) -AC_SUBST(X11_LIBDIR) - -PKG_CHECK_MODULES(X11, [$X11_REQUIRES]) -X11_CFLAGS="$X11_CFLAGS $XTHREAD_CFLAGS" - -# -# Yes, it would be nice to put the locale data in -# /usr/share, but the locale stuff includes loadable -# libraries which must be located in the same directory -# as the other locale data, so for now, everything lives -# in ${libdir} -# - -X11_LOCALEDATADIR="${X11_DATADIR}/locale" -AX_DEFINE_DIR(XLOCALEDATADIR, X11_LOCALEDATADIR, [Location of libX11 locale data]) -AC_SUBST(X11_LOCALEDATADIR) - -AC_ARG_WITH(locale-lib-dir, AS_HELP_STRING([--with-locale-lib-dir=DIR], - [Directory where locale libraries files are installed (default: $libdir/X11/locale)]), - [ X11_LOCALELIBDIR="$withval" ], - [ X11_LOCALELIBDIR="${X11_LIBDIR}/locale" ]) -AX_DEFINE_DIR(XLOCALELIBDIR, X11_LOCALELIBDIR, [Location of libX11 locale libraries]) -AC_SUBST(X11_LOCALELIBDIR) - -X11_LOCALEDIR="${X11_LOCALEDATADIR}" -AX_DEFINE_DIR(XLOCALEDIR, X11_LOCALEDIR, [Location of libX11 locale data]) -AC_SUBST(X11_LOCALEDIR) - -XKEYSYMDB="${X11_DATADIR}/XKeysymDB" -AX_DEFINE_DIR(XKEYSYMDB, XKEYSYMDB, [Location of keysym database]) - -XERRORDB="${X11_DATADIR}/XErrorDB" -AX_DEFINE_DIR(XERRORDB, XERRORDB, [Location of error message database]) - -XORG_CHECK_MALLOC_ZERO - -AC_CONFIG_FILES([Makefile - include/Makefile - man/Makefile - man/xkb/Makefile - src/Makefile - src/util/Makefile - src/xcms/Makefile - src/xlibi18n/Makefile - modules/Makefile - modules/im/Makefile - modules/im/ximcp/Makefile - modules/lc/Makefile - modules/lc/def/Makefile - modules/lc/gen/Makefile - modules/lc/Utf8/Makefile - modules/lc/xlocale/Makefile - modules/om/Makefile - modules/om/generic/Makefile - src/xkb/Makefile - nls/Makefile - specs/Makefile - specs/i18n/Makefile - specs/i18n/framework/Makefile - specs/i18n/localedb/Makefile - specs/i18n/trans/Makefile - specs/libX11/Makefile - specs/XIM/Makefile - specs/XKB/Makefile - x11.pc - x11-xcb.pc]) -AC_OUTPUT - -echo "" -echo "X11 will be built with the following settings:" -echo " Loadable i18n module support: "$XLIB_LOADABLE_I18N -echo " Loadable xcursor library support: "$XLIB_LOADABLE_XCURSOR -echo " Threading support: "$xthreads -echo " Use Threads safe API: "$mtsafeapi -echo " Threads stubs in libX11: "$thrstubs -echo " XCMS: "$XCMS -echo " Internationalization support: "$XLOCALE -echo " XF86BigFont support: "$XF86BIGFONT -echo " XKB support: "$XKB -echo " XLOCALEDIR environment variable support: "$ENABLE_XLOCALEDIR -echo " Compose table cache enabled: "$COMPOSECACHE -echo " Functional specs building enabled: "$build_specs -echo "" + +# Initialize Autoconf +AC_PREREQ([2.60]) +AC_INIT([libX11], [1.4.3], + [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libX11]) +AC_CONFIG_SRCDIR([Makefile.am]) +AC_CONFIG_HEADERS([src/config.h include/X11/XlibConf.h]) +AC_CONFIG_MACRO_DIR([m4]) +AC_CANONICAL_BUILD +AC_CANONICAL_HOST +# Set common system defines for POSIX extensions, such as _GNU_SOURCE +# Must be called before any macros that run the compiler (like AC_PROG_LIBTOOL) +# to avoid autoconf errors. +AC_USE_SYSTEM_EXTENSIONS + +# Initialize Automake +AM_INIT_AUTOMAKE([foreign dist-bzip2]) +AM_MAINTAINER_MODE + +# Initialize libtool +AC_PROG_LIBTOOL + +# Require xorg-macros minimum of 1.12 for DocBook external references +m4_ifndef([XORG_MACROS_VERSION], + [m4_fatal([must install xorg-macros 1.12 or later before running autoconf/autogen])]) +XORG_MACROS_VERSION(1.12) +XORG_DEFAULT_OPTIONS +XORG_ENABLE_SPECS +XORG_WITH_XMLTO(0.0.22) +XORG_WITH_FOP([no]) +XORG_WITH_XSLTPROC +XORG_CHECK_SGML_DOCTOOLS(1.7) +XORG_PROG_RAWCPP + +# Required when PKG_CHECK_MODULES called within an if statement +PKG_PROG_PKG_CONFIG + +if test x"$CC_FOR_BUILD" = x; then + if test x"$cross_compiling" = xyes; then + AC_CHECK_PROGS(CC_FOR_BUILD, gcc cc) + else + CC_FOR_BUILD="$CC" + fi +fi +AC_SUBST([CC_FOR_BUILD]) + +if test x"$CPPFLAGS_FOR_BUILD" = x; then + if test ! x"$cross_compiling" = xyes; then + CPPFLAGS_FOR_BUILD=${CPPFLAGS} + fi +fi +AC_SUBST(CPPFLAGS_FOR_BUILD) + +if test x"$CFLAGS_FOR_BUILD" = x; then + if test ! x"$cross_compiling" = xyes; then + CFLAGS_FOR_BUILD=${CFLAGS} + fi +fi +AC_SUBST(CFLAGS_FOR_BUILD) + +if test x"$LDFLAGS_FOR_BUILD" = x; then + if test ! x"$cross_compiling" = xyes; then + LDFLAGS_FOR_BUILD=${LDFLAGS} + fi +fi +AC_SUBST(LDFLAGS_FOR_BUILD) + +# Find perl for "make check" tests in nls/Makefile.am +AC_ARG_WITH(perl, + AS_HELP_STRING([--with-perl=], + [path to perl interpreter for build-time tests]), + [PERL=$withval ; AC_MSG_CHECKING([perl]) ; + AC_MSG_RESULT([(from --with-perl) $PERL])], + AC_CHECK_PROGS([PERL], [perl], [no])) +AM_CONDITIONAL(HAVE_PERL, test x$PERL != xno) + +# Checks for pkg-config packages + +# Always required +X11_REQUIRES='xproto >= 7.0.17 xextproto xtrans xcb >= 1.1.92' +X11_EXTRA_DEPS="xcb >= 1.1.92" + +PKG_PROG_PKG_CONFIG() + +AC_SUBST(X11_EXTRA_DEPS) + +# Issue an error if xtrans.m4 was not found and XTRANS_CONNECTION_FLAGS macro +# was not expanded, since libX11 with no transport types is rather useless. +# +# If you're seeing an error here, be sure you installed the lib/xtrans module +# first and if it's not in the default location, that you set the ACLOCAL +# environment variable to find it, such as: +# 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 + +# Preferred order to try transports for local connections +AC_MSG_CHECKING([what order to try transports in for local connections]) +DEFAULT_LOCAL_TRANS="" +case $host_os in + solaris*) + # On Solaris 2.6 through 9, named pipes (LOCAL_TRANS) were + # faster than Unix domain sockets, but on Solaris 10 & later, + # Unix domain sockets are faster now. + if test "$UNIXCONN" = "yes" ; then + if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then + DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}," + fi + DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}UNIX_TRANS" + fi + if test "$LOCALCONN" = "yes" ; then + if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then + DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}," + fi + DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}LOCAL_TRANS" + fi + if test "$TCPCONN" = "yes" ; then + if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then + DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}," + fi + DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}TCP_TRANS" + fi + ;; + linux*) + # LOCAL_TRANS is used for abstract sockets. + if test "$UNIXCONN" = "yes" ; then + if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then + DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}," + fi + DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}LOCAL_TRANS,UNIX_TRANS" + fi + if test "$TCPCONN" = "yes" ; then + if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then + DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}," + fi + DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}TCP_TRANS" + fi + ;; + *) + if test "$LOCALCONN" = "yes" ; then + if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then + DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}," + fi + DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}LOCAL_TRANS" + fi + if test "$UNIXCONN" = "yes" ; then + if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then + DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}," + fi + DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}UNIX_TRANS" + fi + if test "$TCPCONN" = "yes" ; then + if test ! "x$DEFAULT_LOCAL_TRANS" = "x" ; then + DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}," + fi + DEFAULT_LOCAL_TRANS="${DEFAULT_LOCAL_TRANS}TCP_TRANS" + fi + ;; +esac + +AC_ARG_WITH(local-transport-order, + AS_HELP_STRING([--with-local-transport-order=LIST], [preference sorted list of transport types to try for local connections]), + [LOCAL_TRANSPORT_LIST=$withval], + [LOCAL_TRANSPORT_LIST=$DEFAULT_LOCAL_TRANS]) +AC_DEFINE_UNQUOTED([LOCAL_TRANSPORT_LIST], [$LOCAL_TRANSPORT_LIST], + [preference sorted list of transport types to try for local connections]) +AC_MSG_RESULT([$LOCAL_TRANSPORT_LIST]) + +# Check for dlopen +AC_MSG_CHECKING([if run-time linking is supported]) +AC_SEARCH_LIBS(dlopen,[dl svld]) +if test "x$ac_cv_search_dlopen" = xno; then + AC_SEARCH_LIBS(shl_load,[dld]) + if test "x$ac_cv_search_shl_load" != xno; then + AC_DEFINE(HAVE_SHL_LOAD,1, + [Use shl_load to load shared libraries]) + AC_CHECK_HEADERS([dl.h]) + fi +else + AC_DEFINE(HAVE_DLOPEN,1,[Use dlopen to load shared libraries]) + AC_CHECK_HEADERS([dlfcn.h]) +fi +if test x$ac_cv_header_dlcfn_h -o x$ac_cv_header_dl_h; then + HAVE_LOADABLE_MODULES=yes +else + HAVE_LOADABLE_MODULES=no +fi +AC_MSG_RESULT($HAVE_LOADABLE_MODULES) + +AC_MSG_CHECKING([if loadable i18n module support should be enabled]) +AC_ARG_ENABLE(loadable-i18n, + AS_HELP_STRING([--enable-loadable-i18n], + [Controls loadable i18n module support]), + [XLIB_LOADABLE_I18N=$enableval], + [XLIB_LOADABLE_I18N="no"]) +if test x$XLIB_LOADABLE_I18N = xyes; then + if test x$HAVE_LOADABLE_MODULES = xno; then + AC_MSG_ERROR([Loadable module support is required to enable loadable i18n module support]) + fi + AC_DEFINE(USE_DYNAMIC_LC,1, + [Split some i18n functions into loadable modules]) + AC_SUBST(I18N_MODULE_LIBS,'${top_builddir}/src/libX11.la') +fi +AC_MSG_RESULT($XLIB_LOADABLE_I18N) + +AM_CONDITIONAL(XLIB_LOADABLE_I18N, test x$XLIB_LOADABLE_I18N = xyes) + +AC_MSG_CHECKING([if loadable Xcursor library support should be enabled]) +AC_ARG_ENABLE(loadable-xcursor, + AS_HELP_STRING([--disable-loadable-xcursor], + [Controls loadable xcursor library support]), + [XLIB_LOADABLE_XCURSOR=$enableval], + [XLIB_LOADABLE_XCURSOR=$HAVE_LOADABLE_MODULES]) +if test x$XLIB_LOADABLE_XCURSOR = xyes; then + AC_DEFINE(USE_DYNAMIC_XCURSOR,1, + [Use the X cursor library to load cursors]) +fi +AC_MSG_RESULT($XLIB_LOADABLE_XCURSOR) + +# Checks for header files. +AC_CHECK_HEADERS([sys/select.h]) + +# Checks for typedefs, structures, and compiler characteristics. + +# Checks for library functions. +AC_CHECK_FUNCS([strtol]) +# Used in lcFile.c (see also --enable-xlocaledir settings below) +XLOCALEDIR_IS_SAFE="no" +AC_CHECK_FUNC([issetugid], [XLOCALEDIR_IS_SAFE="yes"] + AC_DEFINE(HASSETUGID,1,[Has issetugid() function])) +AC_CHECK_FUNC([getresuid], [XLOCALEDIR_IS_SAFE="yes"] + AC_DEFINE(HASGETRESUID,1,[Has getresuid() & getresgid() functions])) +# Used in Font.c +AC_CHECK_FUNC([shmat], AC_DEFINE(HAS_SHM,1,[Has shm*() functions])) + +# Checks for system services +# AC_PATH_XTRA + +# arch specific things +WCHAR32="1" +case $host_os in + os2*) os2="true" ; WCHAR32="0" ;; + *) ;; +esac +AC_SUBST(WCHAR32) + +AM_CONDITIONAL(OS2, test x$os2 = xtrue) + +AC_ARG_WITH(launchd, AS_HELP_STRING([--with-launchd], [Build with support for Apple's launchd (default: auto)]), [LAUNCHD=$withval], [LAUNCHD=auto]) +if test "x$LAUNCHD" = xauto; then + unset LAUNCHD + AC_CHECK_PROG(LAUNCHD, [launchd], [yes], [no], [$PATH$PATH_SEPARATOR/sbin]) +fi + +if test "x$LAUNCHD" = xyes ; then + AC_DEFINE(HAVE_LAUNCHD, 1, [launchd support available]) + AC_DEFINE(TRANS_REOPEN, 1, [launchd support available]) +fi + +AC_ARG_ENABLE(xthreads, + AS_HELP_STRING([--disable-xthreads], + [Disable Xlib support for Multithreading]), + [xthreads=$enableval],[xthreads=yes]) + +AC_CHECK_LIB(c, getpwuid_r, [mtsafeapi="yes"], [mtsafeapi="no"]) + +case x$xthreads in +xyes) + AC_DEFINE(XTHREADS,1,[Whether libX11 is compiled with thread support]) + if test x$mtsafeapi = xyes + then + AC_DEFINE(XUSE_MTSAFE_API,1,[Whether libX11 needs to use MT safe API's]) + fi + ;; +*) + ;; +esac + +AC_CHECK_LIB(c, pthread_self, [thrstubs="no"], [thrstubs="yes"]) +AM_CONDITIONAL(THRSTUBS, test x$thrstubs = xyes) + +# XXX incomplete, please fill this in +if test x$xthreads = xyes ; then + case $host_os in + linux*|openbsd*|gnu*|k*bsd*-gnu) + XTHREADLIB=-lpthread ;; + netbsd*) + XTHREAD_CFLAGS="-D_POSIX_THREAD_SAFE_FUNCTIONS" + XTHREADLIB="-lpthread" ;; + freebsd*) + XTHREAD_CFLAGS="-D_THREAD_SAFE" + XTHREADLIB="-pthread" ;; + dragonfly*) + XTHREADLIB="-pthread" ;; + solaris*) + XTHREAD_CFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS" ;; + esac +fi +AC_SUBST(XTHREADLIB) +AC_SUBST(XTHREAD_CFLAGS) + +AC_CHECK_FUNC(poll, [AC_DEFINE(USE_POLL, 1, [poll() function is available])], ) + +# +# Find keysymdef.h +# +AC_MSG_CHECKING([keysym definitions]) +KEYSYMDEFDIR=`$PKG_CONFIG --variable=includedir xproto`/X11 +FILES="keysymdef.h XF86keysym.h Sunkeysym.h DECkeysym.h HPkeysym.h" +for i in $FILES; do + if test -f "$KEYSYMDEFDIR/$i"; then + KEYSYMDEFS="$KEYSYMDEFS $KEYSYMDEFDIR/$i" + elif test "x$i" = "xkeysymdef.h"; then + AC_MSG_ERROR([Cannot find keysymdef.h]) + fi +done +AC_MSG_RESULT([$KEYSYMDEFS]) +AC_SUBST(KEYSYMDEFS) + +AM_CONDITIONAL(UDC, test xfalse = xtrue) + +AC_ARG_ENABLE(xcms, + AS_HELP_STRING([--disable-xcms], + [Disable Xlib support for CMS *EXPERIMENTAL*]), + [XCMS=$enableval],[XCMS=yes]) +AM_CONDITIONAL(XCMS, [test x$XCMS = xyes ]) +if test x"$XCMS" = "xyes"; then + AC_DEFINE(XCMS,1,[Include support for XCMS]) +fi + +AC_ARG_ENABLE(xlocale, + AS_HELP_STRING([--disable-xlocale], + [Disable Xlib locale implementation *EXPERIMENTAL*]), + [XLOCALE=$enableval],[XLOCALE=yes]) + +AM_CONDITIONAL(XLOCALE, [ test x$XLOCALE = xyes ]) +if test x"$XLOCALE" = "xyes"; then + AC_DEFINE(XLOCALE,1,[support for X Locales]) +fi + +# This disables XLOCALEDIR. Set it if you're using BuildLoadableXlibI18n, +# don't have either issetugid() or getresuid(), and you need to protect +# clients that are setgid or setuid to an id other than 0. +AC_MSG_CHECKING([if XLOCALEDIR support should be enabled]) +AC_ARG_ENABLE(xlocaledir, + AS_HELP_STRING([--enable-xlocaledir], + [Enable XLOCALEDIR environment variable support]), + [ENABLE_XLOCALEDIR=$enableval],[ENABLE_XLOCALEDIR=$XLOCALEDIR_IS_SAFE]) +if test "x$ENABLE_XLOCALEDIR" = "xno"; then + AC_DEFINE(NO_XLOCALEDIR,1,[Disable XLOCALEDIR environment variable]) +fi +AC_MSG_RESULT($ENABLE_XLOCALEDIR) + +AC_ARG_ENABLE(xf86bigfont, + AS_HELP_STRING([--disable-xf86bigfont], + [Disable XF86BigFont extension support]), + [XF86BIGFONT=$enableval],[XF86BIGFONT="yes"]) +if test "x$XF86BIGFONT" = "xyes"; then + PKG_CHECK_MODULES(BIGFONT, [xf86bigfontproto >= 1.2.0], + AC_DEFINE(XF86BIGFONT,1,[Enable XF86BIGFONT extension]),XF86BIGFONT="no") +fi + +AC_ARG_ENABLE(xkb, + AS_HELP_STRING([--disable-xkb], + [Disable XKB support *EXPERIMENTAL*]), + [XKB=$enableval],[XKB=yes]) + +AM_CONDITIONAL(XKB, [ test x$XKB = xyes ]) +if test x"$XKB" = "xyes"; then + XKBPROTO_REQUIRES="kbproto" + X11_REQUIRES="${X11_REQUIRES} kbproto inputproto" + AC_DEFINE(XKB,1,[Use XKB]) +else + XKBPROTO_REQUIRES="" +fi +AC_SUBST(XKBPROTO_REQUIRES) + +AC_FUNC_MMAP() +composecache_default=$ac_cv_func_mmap_fixed_mapped +AC_CHECK_FUNC(nl_langinfo, , [composecache_default=no]) +AC_ARG_ENABLE(composecache, + AS_HELP_STRING([--disable-composecache], + [Disable compose table cache support]), + [COMPOSECACHE=$enableval],[COMPOSECACHE=$composecache_default]) +if test x"$COMPOSECACHE" = "xyes"; then + AC_DEFINE(COMPOSECACHE,1,[Include compose table cache support]) +fi + +# Allow checking code with lint, sparse, etc. +XORG_WITH_LINT +XORG_LINT_LIBRARY([X11]) + +X11_DATADIR="${datadir}/X11" +AX_DEFINE_DIR(X11_DATADIR, X11_DATADIR, [Location of libX11 data]) +AC_SUBST(X11_DATADIR) + +X11_LIBDIR="${libdir}/X11" +AX_DEFINE_DIR(X11_LIBDIR, X11_LIBDIR, [Location of libX11 library data]) +AC_SUBST(X11_LIBDIR) + +PKG_CHECK_MODULES(X11, [$X11_REQUIRES]) +X11_CFLAGS="$X11_CFLAGS $XTHREAD_CFLAGS" + +# +# Yes, it would be nice to put the locale data in +# /usr/share, but the locale stuff includes loadable +# libraries which must be located in the same directory +# as the other locale data, so for now, everything lives +# in ${libdir} +# + +X11_LOCALEDATADIR="${X11_DATADIR}/locale" +AX_DEFINE_DIR(XLOCALEDATADIR, X11_LOCALEDATADIR, [Location of libX11 locale data]) +AC_SUBST(X11_LOCALEDATADIR) + +AC_ARG_WITH(locale-lib-dir, AS_HELP_STRING([--with-locale-lib-dir=DIR], + [Directory where locale libraries files are installed (default: $libdir/X11/locale)]), + [ X11_LOCALELIBDIR="$withval" ], + [ X11_LOCALELIBDIR="${X11_LIBDIR}/locale" ]) +AX_DEFINE_DIR(XLOCALELIBDIR, X11_LOCALELIBDIR, [Location of libX11 locale libraries]) +AC_SUBST(X11_LOCALELIBDIR) + +X11_LOCALEDIR="${X11_LOCALEDATADIR}" +AX_DEFINE_DIR(XLOCALEDIR, X11_LOCALEDIR, [Location of libX11 locale data]) +AC_SUBST(X11_LOCALEDIR) + +XKEYSYMDB="${X11_DATADIR}/XKeysymDB" +AX_DEFINE_DIR(XKEYSYMDB, XKEYSYMDB, [Location of keysym database]) + +XERRORDB="${X11_DATADIR}/XErrorDB" +AX_DEFINE_DIR(XERRORDB, XERRORDB, [Location of error message database]) + +XORG_CHECK_MALLOC_ZERO + +AC_CONFIG_FILES([Makefile + include/Makefile + man/Makefile + man/xkb/Makefile + src/Makefile + src/util/Makefile + src/xcms/Makefile + src/xlibi18n/Makefile + modules/Makefile + modules/im/Makefile + modules/im/ximcp/Makefile + modules/lc/Makefile + modules/lc/def/Makefile + modules/lc/gen/Makefile + modules/lc/Utf8/Makefile + modules/lc/xlocale/Makefile + modules/om/Makefile + modules/om/generic/Makefile + src/xkb/Makefile + nls/Makefile + specs/Makefile + specs/i18n/Makefile + specs/i18n/framework/Makefile + specs/i18n/localedb/Makefile + specs/i18n/trans/Makefile + specs/libX11/Makefile + specs/XIM/Makefile + specs/XKB/Makefile + x11.pc + x11-xcb.pc]) +AC_OUTPUT + +echo "" +echo "X11 will be built with the following settings:" +echo " Loadable i18n module support: "$XLIB_LOADABLE_I18N +echo " Loadable xcursor library support: "$XLIB_LOADABLE_XCURSOR +echo " Threading support: "$xthreads +echo " Use Threads safe API: "$mtsafeapi +echo " Threads stubs in libX11: "$thrstubs +echo " XCMS: "$XCMS +echo " Internationalization support: "$XLOCALE +echo " XF86BigFont support: "$XF86BIGFONT +echo " XKB support: "$XKB +echo " XLOCALEDIR environment variable support: "$ENABLE_XLOCALEDIR +echo " Compose table cache enabled: "$COMPOSECACHE +echo " Functional specs building enabled: "$build_specs +echo "" diff --git a/libX11/include/X11/Xlibint.h b/libX11/include/X11/Xlibint.h index d199a8b36..3266e0d00 100644 --- a/libX11/include/X11/Xlibint.h +++ b/libX11/include/X11/Xlibint.h @@ -899,7 +899,7 @@ extern int _XError( ); extern int _XIOError( Display* /* dpy */ -); +) _X_NORETURN; extern int (*_XIOErrorFunction)( Display* /* dpy */ ); diff --git a/libX11/src/xkb/XKBGeom.c b/libX11/src/xkb/XKBGeom.c index 2572b9964..7594a3de4 100644 --- a/libX11/src/xkb/XKBGeom.c +++ b/libX11/src/xkb/XKBGeom.c @@ -1,692 +1,692 @@ -/************************************************************ -Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. - -Permission to use, copy, modify, and distribute this -software and its documentation for any purpose and without -fee is hereby granted, provided that the above copyright -notice appear in all copies and that both that copyright -notice and this permission notice appear in supporting -documentation, and that the name of Silicon Graphics not be -used in advertising or publicity pertaining to distribution -of the software without specific prior written permission. -Silicon Graphics makes no representation about the suitability -of this software for any purpose. It is provided "as is" -without any express or implied warranty. - -SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, -DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH -THE USE OR PERFORMANCE OF THIS SOFTWARE. - -********************************************************/ - -#ifdef DEBUG -#ifdef HAVE_CONFIG_H -#include -#endif -#include -#endif - -#define NEED_MAP_READERS -#include "Xlibint.h" -#include -#include -#include "XKBlibint.h" - -#ifndef MINSHORT -#define MINSHORT -32768 -#endif -#ifndef MAXSHORT -#define MAXSHORT 32767 -#endif - -/***====================================================================***/ - -static void -_XkbCheckBounds(XkbBoundsPtr bounds,int x,int y) -{ - if (xx1) bounds->x1= x; - if (x>bounds->x2) bounds->x2= x; - if (yy1) bounds->y1= y; - if (y>bounds->y2) bounds->y2= y; - return; -} - -Bool -XkbComputeShapeBounds(XkbShapePtr shape) -{ -register int o,p; -XkbOutlinePtr outline; -XkbPointPtr pt; - - if ((!shape)||(shape->num_outlines<1)) - return False; - shape->bounds.x1= shape->bounds.y1= MAXSHORT; - shape->bounds.x2= shape->bounds.y2= MINSHORT; - for (outline=shape->outlines,o=0;onum_outlines;o++,outline++) { - for (pt=outline->points,p=0;pnum_points;p++,pt++) { - _XkbCheckBounds(&shape->bounds,pt->x,pt->y); - } - if (outline->num_points<2) { - _XkbCheckBounds(&shape->bounds,0,0); - } - } - return True; -} - -Bool -XkbComputeShapeTop(XkbShapePtr shape,XkbBoundsPtr bounds) -{ -register int p; -XkbOutlinePtr outline; -XkbPointPtr pt; - - if ((!shape)||(shape->num_outlines<1)) - return False; - if (shape->approx) outline= shape->approx; - else outline= &shape->outlines[shape->num_outlines-1]; - if (outline->num_points<2) { - bounds->x1= bounds->y1= 0; - bounds->x2= bounds->y2= 0; - } - else { - bounds->x1= bounds->y1= MAXSHORT; - bounds->x2= bounds->y2= MINSHORT; - } - for (pt=outline->points,p=0;pnum_points;p++,pt++) { - _XkbCheckBounds(bounds,pt->x,pt->y); - } - return True; -} - -Bool -XkbComputeRowBounds(XkbGeometryPtr geom,XkbSectionPtr section,XkbRowPtr row) -{ -register int k,pos; -XkbKeyPtr key; -XkbBoundsPtr bounds,sbounds; - - if ((!geom)||(!section)||(!row)) - return False; - pos= 0; - bounds= &row->bounds; - bzero(bounds,sizeof(XkbBoundsRec)); - for (key=row->keys,pos=k=0;knum_keys;k++,key++) { - sbounds= &XkbKeyShape(geom,key)->bounds; - _XkbCheckBounds(bounds,pos,0); - if (!row->vertical) { - if (key->gap!=0) { - pos+= key->gap; - _XkbCheckBounds(bounds,pos,0); - } - _XkbCheckBounds(bounds,pos+sbounds->x1,sbounds->y1); - _XkbCheckBounds(bounds,pos+sbounds->x2,sbounds->y2); - pos+= sbounds->x2; - } - else { - if (key->gap!=0) { - pos+= key->gap; - _XkbCheckBounds(bounds,0,pos); - } - _XkbCheckBounds(bounds,pos+sbounds->x1,sbounds->y1); - _XkbCheckBounds(bounds,pos+sbounds->x2,sbounds->y2); - pos+= sbounds->y2; - } - } - return True; -} - -Bool -XkbComputeSectionBounds(XkbGeometryPtr geom,XkbSectionPtr section) -{ -register int i; -XkbShapePtr shape; -XkbRowPtr row; -XkbDoodadPtr doodad; -XkbBoundsPtr bounds,rbounds=NULL; - - if ((!geom)||(!section)) - return False; - bounds= §ion->bounds; - bzero(bounds,sizeof(XkbBoundsRec)); - for (i=0,row=section->rows;inum_rows;i++,row++) { - if (!XkbComputeRowBounds(geom,section,row)) - return False; - rbounds= &row->bounds; - _XkbCheckBounds(bounds,row->left+rbounds->x1,row->top+rbounds->y1); - _XkbCheckBounds(bounds,row->left+rbounds->x2,row->top+rbounds->y2); - } - for (i=0,doodad=section->doodads;inum_doodads;i++,doodad++) { - static XkbBoundsRec tbounds; - switch (doodad->any.type) { - case XkbOutlineDoodad: - case XkbSolidDoodad: - shape= XkbShapeDoodadShape(geom,&doodad->shape); - rbounds= &shape->bounds; - break; - case XkbTextDoodad: - tbounds.x1= doodad->text.left; - tbounds.y1= doodad->text.top; - tbounds.x2= tbounds.x1+doodad->text.width; - tbounds.y2= tbounds.y1+doodad->text.height; - rbounds= &tbounds; - break; - case XkbIndicatorDoodad: - shape= XkbIndicatorDoodadShape(geom,&doodad->indicator); - rbounds= &shape->bounds; - break; - case XkbLogoDoodad: - shape= XkbLogoDoodadShape(geom,&doodad->logo); - rbounds= &shape->bounds; - break; - default: - tbounds.x1= tbounds.x2= doodad->any.left; - tbounds.y1= tbounds.y2= doodad->any.top; - break; - } - _XkbCheckBounds(bounds,rbounds->x1,rbounds->y1); - _XkbCheckBounds(bounds,rbounds->x2,rbounds->y2); - } - return True; -} - -/***====================================================================***/ - -char * -XkbFindOverlayForKey(XkbGeometryPtr geom,XkbSectionPtr wanted,char *under) -{ -int s; -XkbSectionPtr section; - - if ((geom==NULL)||(under==NULL)||(geom->num_sections<1)) - return NULL; - - if (wanted) - section= wanted; - else section= geom->sections; - - for (s=0;snum_sections;s++,section++) { - XkbOverlayPtr ol; - int o; - - if (section->num_overlays<1) - continue; - for (o=0,ol=section->overlays;onum_overlays;o++,ol++) { - XkbOverlayRowPtr row; - int r; - - for (r=0,row=ol->rows;rnum_rows;r++,row++) { - XkbOverlayKeyPtr key; - int k; - for (k=0,key=row->keys;knum_keys;k++,key++) { - if (strncmp(under,key->under.name,XkbKeyNameLength)==0) - return key->over.name; - } - } - } - if (wanted!=NULL) - break; - } - return NULL; -} - -/***====================================================================***/ - -static Status -_XkbReadGeomProperties( XkbReadBufferPtr buf, - XkbGeometryPtr geom, - xkbGetGeometryReply * rep) -{ -Status rtrn; - - if (rep->nProperties<1) - return Success; - if ((rtrn=XkbAllocGeomProps(geom,rep->nProperties))==Success) { - register int i; - register Bool ok; - char *name,*value; - ok= True; - for (i=0;(inProperties)&&ok;i++) { - name=NULL; - value=NULL; - ok= _XkbGetReadBufferCountedString(buf,&name)&&ok; - ok= _XkbGetReadBufferCountedString(buf,&value)&&ok; - ok= ok&&(XkbAddGeomProperty(geom,name,value)!=NULL); - if (name) - _XkbFree(name); - if (value) - _XkbFree(value); - } - if (ok) rtrn= Success; - else rtrn= BadLength; - } - return rtrn; -} - -static Status -_XkbReadGeomKeyAliases( XkbReadBufferPtr buf, - XkbGeometryPtr geom, - xkbGetGeometryReply * rep) -{ -Status rtrn; - - if (rep->nKeyAliases<1) - return Success; - if ((rtrn=XkbAllocGeomKeyAliases(geom,rep->nKeyAliases))==Success) { - if (!_XkbCopyFromReadBuffer(buf,(char *)geom->key_aliases, - (rep->nKeyAliases*XkbKeyNameLength*2))) - return BadLength; - geom->num_key_aliases= rep->nKeyAliases; - return Success; - } - else { /* alloc failed, just skip the aliases */ - _XkbSkipReadBufferData(buf,(rep->nKeyAliases*XkbKeyNameLength*2)); - } - return rtrn; -} - -static Status -_XkbReadGeomColors( XkbReadBufferPtr buf, - XkbGeometryPtr geom, - xkbGetGeometryReply * rep) -{ -Status rtrn; - - if (rep->nColors<1) - return Success; - if ((rtrn=XkbAllocGeomColors(geom,rep->nColors))==Success) { - register int i; - char *spec; - for (i=0;inColors;i++) { - spec = NULL; - if (!_XkbGetReadBufferCountedString(buf,&spec)) - rtrn = BadLength; - else if (XkbAddGeomColor(geom,spec,geom->num_colors)==NULL) - rtrn = BadAlloc; - if (spec) - _XkbFree(spec); - if (rtrn != Success) - return rtrn; - } - return Success; - } - return rtrn; -} - -static Status -_XkbReadGeomShapes( XkbReadBufferPtr buf, - XkbGeometryPtr geom, - xkbGetGeometryReply * rep) -{ -register int i; -Status rtrn; - - if (rep->nShapes<1) - return Success; - if ((rtrn=XkbAllocGeomShapes(geom,rep->nShapes))!=Success) - return rtrn; - for (i=0;inShapes;i++) { - xkbShapeWireDesc *shapeWire; - XkbShapePtr shape; - register int o; - shapeWire= (xkbShapeWireDesc *) - _XkbGetReadBufferPtr(buf,SIZEOF(xkbShapeWireDesc)); - if (!shapeWire) - return BadLength; - shape= XkbAddGeomShape(geom,shapeWire->name,shapeWire->nOutlines); - if (!shape) - return BadAlloc; - for (o=0;onOutlines;o++) { - xkbOutlineWireDesc *olWire; - XkbOutlinePtr ol; - register int p; - XkbPointPtr pt; - olWire= (xkbOutlineWireDesc *) - _XkbGetReadBufferPtr(buf,SIZEOF(xkbOutlineWireDesc)); - if (!olWire) - return BadLength; - ol= XkbAddGeomOutline(shape,olWire->nPoints); - if (!ol) - return BadAlloc; - ol->corner_radius= olWire->cornerRadius; - for (p=0,pt=ol->points;pnPoints;p++,pt++) { - xkbPointWireDesc * ptWire; - ptWire= (xkbPointWireDesc *) - _XkbGetReadBufferPtr(buf,SIZEOF(xkbPointWireDesc)); - if (!ptWire) - return BadLength; - pt->x= ptWire->x; - pt->y= ptWire->y; - } - ol->num_points= olWire->nPoints; - } - if (shapeWire->primaryNdx!=XkbNoShape) - shape->primary= &shape->outlines[shapeWire->primaryNdx]; - else shape->primary= NULL; - if (shapeWire->approxNdx!=XkbNoShape) - shape->approx= &shape->outlines[shapeWire->approxNdx]; - else shape->approx= NULL; - XkbComputeShapeBounds(shape); - } - return Success; -} - -static Status -_XkbReadGeomDoodad( XkbReadBufferPtr buf, - XkbGeometryPtr geom, - XkbSectionPtr section) -{ -XkbDoodadPtr doodad; -xkbDoodadWireDesc * doodadWire; - - doodadWire= (xkbDoodadWireDesc *) - _XkbGetReadBufferPtr(buf,SIZEOF(xkbDoodadWireDesc)); - if (!doodadWire) - return BadLength; - doodad= XkbAddGeomDoodad(geom,section,doodadWire->any.name); - if (!doodad) - return BadAlloc; - doodad->any.type= doodadWire->any.type; - doodad->any.priority= doodadWire->any.priority; - doodad->any.top= doodadWire->any.top; - doodad->any.left= doodadWire->any.left; - doodad->any.angle= doodadWire->any.angle; - switch (doodad->any.type) { - case XkbOutlineDoodad: - case XkbSolidDoodad: - doodad->shape.color_ndx= doodadWire->shape.colorNdx; - doodad->shape.shape_ndx= doodadWire->shape.shapeNdx; - break; - case XkbTextDoodad: - doodad->text.width= doodadWire->text.width; - doodad->text.height= doodadWire->text.height; - doodad->text.color_ndx= doodadWire->text.colorNdx; - if (!_XkbGetReadBufferCountedString(buf,&doodad->text.text)) - return BadLength; - if (!_XkbGetReadBufferCountedString(buf,&doodad->text.font)) - return BadLength; - break; - case XkbIndicatorDoodad: - doodad->indicator.shape_ndx= doodadWire->indicator.shapeNdx; - doodad->indicator.on_color_ndx= doodadWire->indicator.onColorNdx; - doodad->indicator.off_color_ndx= doodadWire->indicator.offColorNdx; - break; - case XkbLogoDoodad: - doodad->logo.color_ndx= doodadWire->logo.colorNdx; - doodad->logo.shape_ndx= doodadWire->logo.shapeNdx; - if (!_XkbGetReadBufferCountedString(buf,&doodad->logo.logo_name)) - return BadLength; - break; - default: - return BadValue; - } - return Success; -} - -static Status -_XkbReadGeomOverlay( XkbReadBufferPtr buf, - XkbGeometryPtr geom, - XkbSectionPtr section) -{ -XkbOverlayPtr ol; -xkbOverlayWireDesc * olWire; -register int r; - - olWire= (xkbOverlayWireDesc *) - _XkbGetReadBufferPtr(buf,SIZEOF(xkbOverlayWireDesc)); - if (olWire==NULL) - return BadLength; - ol= XkbAddGeomOverlay(section,olWire->name,olWire->nRows); - if (ol==NULL) - return BadLength; - for (r=0;rnRows;r++) { - register int k; - XkbOverlayRowPtr row; - xkbOverlayRowWireDesc * rowWire; - xkbOverlayKeyWireDesc * keyWire; - rowWire= (xkbOverlayRowWireDesc *) - _XkbGetReadBufferPtr(buf,SIZEOF(xkbOverlayRowWireDesc)); - if (rowWire==NULL) - return BadLength; - row= XkbAddGeomOverlayRow(ol,rowWire->rowUnder,rowWire->nKeys); - row->row_under= rowWire->rowUnder; - if (!row) - return BadAlloc; - if (rowWire->nKeys<1) - continue; - keyWire= (xkbOverlayKeyWireDesc *) - _XkbGetReadBufferPtr(buf, - SIZEOF(xkbOverlayKeyWireDesc)*rowWire->nKeys); - if (keyWire==NULL) - return BadLength; - for (k=0;knKeys;k++,keyWire++,row->num_keys++) { - memcpy(row->keys[row->num_keys].over.name,keyWire->over, - XkbKeyNameLength); - memcpy(row->keys[row->num_keys].under.name,keyWire->under, - XkbKeyNameLength); - } - } - return Success; -} - -static Status -_XkbReadGeomSections( XkbReadBufferPtr buf, - XkbGeometryPtr geom, - xkbGetGeometryReply * rep) -{ -register int s; -XkbSectionPtr section; -xkbSectionWireDesc * sectionWire; -Status rtrn; - - if (rep->nSections<1) - return Success; - if ((rtrn=XkbAllocGeomSections(geom,rep->nSections))!=Success) - return rtrn; - for (s=0;snSections;s++) { - sectionWire= (xkbSectionWireDesc *) - _XkbGetReadBufferPtr(buf,SIZEOF(xkbSectionWireDesc)); - if (!sectionWire) - return BadLength; - section= XkbAddGeomSection(geom,sectionWire->name,sectionWire->nRows, - sectionWire->nDoodads, - sectionWire->nOverlays); - if (!section) - return BadAlloc; - section->top= sectionWire->top; - section->left= sectionWire->left; - section->width= sectionWire->width; - section->height= sectionWire->height; - section->angle= sectionWire->angle; - section->priority= sectionWire->priority; - if (sectionWire->nRows>0) { - register int r; - XkbRowPtr row; - xkbRowWireDesc * rowWire; - for (r=0;rnRows;r++) { - rowWire= (xkbRowWireDesc *) - _XkbGetReadBufferPtr(buf,SIZEOF(xkbRowWireDesc)); - if (!rowWire) - return BadLength; - row= XkbAddGeomRow(section,rowWire->nKeys); - if (!row) - return BadAlloc; - row->top= rowWire->top; - row->left= rowWire->left; - row->vertical= rowWire->vertical; - if (rowWire->nKeys>0) { - register int k; - XkbKeyPtr key; - xkbKeyWireDesc * keyWire; - for (k=0;knKeys;k++) { - keyWire= (xkbKeyWireDesc *) - _XkbGetReadBufferPtr(buf,SIZEOF(xkbKeyWireDesc)); - if (!keyWire) - return BadLength; - key= XkbAddGeomKey(row); - if (!key) - return BadAlloc; - memcpy(key->name.name,keyWire->name,XkbKeyNameLength); - key->gap= keyWire->gap; - key->shape_ndx= keyWire->shapeNdx; - key->color_ndx= keyWire->colorNdx; - } - } - } - } - if (sectionWire->nDoodads>0) { - register int d; - for (d=0;dnDoodads;d++) { - if ((rtrn=_XkbReadGeomDoodad(buf,geom,section))!=Success) - return rtrn; - } - } - if (sectionWire->nOverlays>0) { - register int o; - for (o=0;onOverlays;o++) { - if ((rtrn=_XkbReadGeomOverlay(buf,geom,section))!=Success) - return rtrn; - } - } - } - return Success; -} - -static Status -_XkbReadGeomDoodads( XkbReadBufferPtr buf, - XkbGeometryPtr geom, - xkbGetGeometryReply * rep) -{ -register int d; -Status rtrn; - - if (rep->nDoodads<1) - return Success; - if ((rtrn=XkbAllocGeomDoodads(geom,rep->nDoodads))!=Success) - return rtrn; - for (d=0;dnDoodads;d++) { - if ((rtrn=_XkbReadGeomDoodad(buf,geom,NULL))!=Success) - return rtrn; - } - return Success; -} - -Status -_XkbReadGetGeometryReply( Display * dpy, - xkbGetGeometryReply * rep, - XkbDescPtr xkb, - int * nread_rtrn) -{ -XkbGeometryPtr geom; - - geom= _XkbTypedCalloc(1,XkbGeometryRec); - if (!geom) - return BadAlloc; - if (xkb->geom) - XkbFreeGeometry(xkb->geom,XkbGeomAllMask,True); - xkb->geom= geom; - - geom->name= rep->name; - geom->width_mm= rep->widthMM; - geom->height_mm= rep->heightMM; - if (rep->length) { - XkbReadBufferRec buf; - int left; - if (_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4)) { - Status status= Success; - if (nread_rtrn) - *nread_rtrn= (int)rep->length*4; - if (!_XkbGetReadBufferCountedString(&buf,&geom->label_font)) - status= BadLength; - if (status==Success) - status= _XkbReadGeomProperties(&buf,geom,rep); - if (status==Success) - status= _XkbReadGeomColors(&buf,geom,rep); - if (status==Success) - status= _XkbReadGeomShapes(&buf,geom,rep); - if (status==Success) - status= _XkbReadGeomSections(&buf,geom,rep); - if (status==Success) - status= _XkbReadGeomDoodads(&buf,geom,rep); - if (status==Success) - status= _XkbReadGeomKeyAliases(&buf,geom,rep); - left= _XkbFreeReadBuffer(&buf); - if ((status!=Success) || left || buf.error) { - if (status==Success) - status= BadLength; - XkbFreeGeometry(geom,XkbGeomAllMask,True); - xkb->geom= NULL; - return status; - } - geom->base_color= &geom->colors[rep->baseColorNdx]; - geom->label_color= &geom->colors[rep->labelColorNdx]; - } - else { - XkbFreeGeometry(geom,XkbGeomAllMask,True); - xkb->geom= NULL; - return BadAlloc; - } - } - return Success; -} - -Status -XkbGetGeometry(Display *dpy,XkbDescPtr xkb) -{ -xkbGetGeometryReq *req; -xkbGetGeometryReply rep; -Status status; - - if ( (!xkb) || (dpy->flags & XlibDisplayNoXkb) || - (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) - return BadAccess; - - LockDisplay(dpy); - GetReq(kbGetGeometry, req); - req->reqType = dpy->xkb_info->codes->major_opcode; - req->xkbReqType = X_kbGetGeometry; - req->deviceSpec = xkb->device_spec; - req->name= None; - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) - status = BadImplementation; - else if (!rep.found) - status = BadName; - else - status = _XkbReadGetGeometryReply(dpy,&rep,xkb,NULL); - UnlockDisplay(dpy); - SyncHandle(); - return status; -} - -Status -XkbGetNamedGeometry(Display *dpy,XkbDescPtr xkb,Atom name) -{ -xkbGetGeometryReq *req; -xkbGetGeometryReply rep; -Status status; - - if ( (name==None) || (dpy->flags & XlibDisplayNoXkb) || - (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) ) - return BadAccess; - - LockDisplay(dpy); - GetReq(kbGetGeometry, req); - req->reqType = dpy->xkb_info->codes->major_opcode; - req->xkbReqType = X_kbGetGeometry; - req->deviceSpec = xkb->device_spec; - req->name= (CARD32)name; - if ((!_XReply(dpy, (xReply *)&rep, 0, xFalse))||(!rep.found)) - status = BadImplementation; - else if (!rep.found) - status = BadName; - else - status = _XkbReadGetGeometryReply(dpy,&rep,xkb,NULL); - UnlockDisplay(dpy); - SyncHandle(); - return status; -} - +/************************************************************ +Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. + +Permission to use, copy, modify, and distribute this +software and its documentation for any purpose and without +fee is hereby granted, provided that the above copyright +notice appear in all copies and that both that copyright +notice and this permission notice appear in supporting +documentation, and that the name of Silicon Graphics not be +used in advertising or publicity pertaining to distribution +of the software without specific prior written permission. +Silicon Graphics makes no representation about the suitability +of this software for any purpose. It is provided "as is" +without any express or implied warranty. + +SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON +GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL +DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE +OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH +THE USE OR PERFORMANCE OF THIS SOFTWARE. + +********************************************************/ + +#ifdef DEBUG +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#endif + +#define NEED_MAP_READERS +#include "Xlibint.h" +#include +#include +#include "XKBlibint.h" + +#ifndef MINSHORT +#define MINSHORT -32768 +#endif +#ifndef MAXSHORT +#define MAXSHORT 32767 +#endif + +/***====================================================================***/ + +static void +_XkbCheckBounds(XkbBoundsPtr bounds,int x,int y) +{ + if (xx1) bounds->x1= x; + if (x>bounds->x2) bounds->x2= x; + if (yy1) bounds->y1= y; + if (y>bounds->y2) bounds->y2= y; + return; +} + +Bool +XkbComputeShapeBounds(XkbShapePtr shape) +{ +register int o,p; +XkbOutlinePtr outline; +XkbPointPtr pt; + + if ((!shape)||(shape->num_outlines<1)) + return False; + shape->bounds.x1= shape->bounds.y1= MAXSHORT; + shape->bounds.x2= shape->bounds.y2= MINSHORT; + for (outline=shape->outlines,o=0;onum_outlines;o++,outline++) { + for (pt=outline->points,p=0;pnum_points;p++,pt++) { + _XkbCheckBounds(&shape->bounds,pt->x,pt->y); + } + if (outline->num_points<2) { + _XkbCheckBounds(&shape->bounds,0,0); + } + } + return True; +} + +Bool +XkbComputeShapeTop(XkbShapePtr shape,XkbBoundsPtr bounds) +{ +register int p; +XkbOutlinePtr outline; +XkbPointPtr pt; + + if ((!shape)||(shape->num_outlines<1)) + return False; + if (shape->approx) outline= shape->approx; + else outline= &shape->outlines[shape->num_outlines-1]; + if (outline->num_points<2) { + bounds->x1= bounds->y1= 0; + bounds->x2= bounds->y2= 0; + } + else { + bounds->x1= bounds->y1= MAXSHORT; + bounds->x2= bounds->y2= MINSHORT; + } + for (pt=outline->points,p=0;pnum_points;p++,pt++) { + _XkbCheckBounds(bounds,pt->x,pt->y); + } + return True; +} + +Bool +XkbComputeRowBounds(XkbGeometryPtr geom,XkbSectionPtr section,XkbRowPtr row) +{ +register int k,pos; +XkbKeyPtr key; +XkbBoundsPtr bounds,sbounds; + + if ((!geom)||(!section)||(!row)) + return False; + bounds= &row->bounds; + bzero(bounds,sizeof(XkbBoundsRec)); + for (key=row->keys,pos=k=0;knum_keys;k++,key++) { + sbounds= &XkbKeyShape(geom,key)->bounds; + _XkbCheckBounds(bounds,pos,0); + if (!row->vertical) { + if (key->gap!=0) { + pos+= key->gap; + _XkbCheckBounds(bounds,pos,0); + } + _XkbCheckBounds(bounds,pos+sbounds->x1,sbounds->y1); + _XkbCheckBounds(bounds,pos+sbounds->x2,sbounds->y2); + pos+= sbounds->x2; + } + else { + if (key->gap!=0) { + pos+= key->gap; + _XkbCheckBounds(bounds,0,pos); + } + _XkbCheckBounds(bounds,pos+sbounds->x1,sbounds->y1); + _XkbCheckBounds(bounds,pos+sbounds->x2,sbounds->y2); + pos+= sbounds->y2; + } + } + return True; +} + +Bool +XkbComputeSectionBounds(XkbGeometryPtr geom,XkbSectionPtr section) +{ +register int i; +XkbShapePtr shape; +XkbRowPtr row; +XkbDoodadPtr doodad; +XkbBoundsPtr bounds,rbounds; + + if ((!geom)||(!section)) + return False; + bounds= §ion->bounds; + bzero(bounds,sizeof(XkbBoundsRec)); + for (i=0,row=section->rows;inum_rows;i++,row++) { + if (!XkbComputeRowBounds(geom,section,row)) + return False; + rbounds= &row->bounds; + _XkbCheckBounds(bounds,row->left+rbounds->x1,row->top+rbounds->y1); + _XkbCheckBounds(bounds,row->left+rbounds->x2,row->top+rbounds->y2); + } + for (i=0,doodad=section->doodads;inum_doodads;i++,doodad++) { + static XkbBoundsRec tbounds; + switch (doodad->any.type) { + case XkbOutlineDoodad: + case XkbSolidDoodad: + shape= XkbShapeDoodadShape(geom,&doodad->shape); + rbounds= &shape->bounds; + break; + case XkbTextDoodad: + tbounds.x1= doodad->text.left; + tbounds.y1= doodad->text.top; + tbounds.x2= tbounds.x1+doodad->text.width; + tbounds.y2= tbounds.y1+doodad->text.height; + rbounds= &tbounds; + break; + case XkbIndicatorDoodad: + shape= XkbIndicatorDoodadShape(geom,&doodad->indicator); + rbounds= &shape->bounds; + break; + case XkbLogoDoodad: + shape= XkbLogoDoodadShape(geom,&doodad->logo); + rbounds= &shape->bounds; + break; + default: + tbounds.x1= tbounds.x2= doodad->any.left; + tbounds.y1= tbounds.y2= doodad->any.top; + rbounds= &tbounds; + break; + } + _XkbCheckBounds(bounds,rbounds->x1,rbounds->y1); + _XkbCheckBounds(bounds,rbounds->x2,rbounds->y2); + } + return True; +} + +/***====================================================================***/ + +char * +XkbFindOverlayForKey(XkbGeometryPtr geom,XkbSectionPtr wanted,char *under) +{ +int s; +XkbSectionPtr section; + + if ((geom==NULL)||(under==NULL)||(geom->num_sections<1)) + return NULL; + + if (wanted) + section= wanted; + else section= geom->sections; + + for (s=0;snum_sections;s++,section++) { + XkbOverlayPtr ol; + int o; + + if (section->num_overlays<1) + continue; + for (o=0,ol=section->overlays;onum_overlays;o++,ol++) { + XkbOverlayRowPtr row; + int r; + + for (r=0,row=ol->rows;rnum_rows;r++,row++) { + XkbOverlayKeyPtr key; + int k; + for (k=0,key=row->keys;knum_keys;k++,key++) { + if (strncmp(under,key->under.name,XkbKeyNameLength)==0) + return key->over.name; + } + } + } + if (wanted!=NULL) + break; + } + return NULL; +} + +/***====================================================================***/ + +static Status +_XkbReadGeomProperties( XkbReadBufferPtr buf, + XkbGeometryPtr geom, + xkbGetGeometryReply * rep) +{ +Status rtrn; + + if (rep->nProperties<1) + return Success; + if ((rtrn=XkbAllocGeomProps(geom,rep->nProperties))==Success) { + register int i; + register Bool ok; + char *name,*value; + ok= True; + for (i=0;(inProperties)&&ok;i++) { + name=NULL; + value=NULL; + ok= _XkbGetReadBufferCountedString(buf,&name)&&ok; + ok= _XkbGetReadBufferCountedString(buf,&value)&&ok; + ok= ok&&(XkbAddGeomProperty(geom,name,value)!=NULL); + if (name) + _XkbFree(name); + if (value) + _XkbFree(value); + } + if (ok) rtrn= Success; + else rtrn= BadLength; + } + return rtrn; +} + +static Status +_XkbReadGeomKeyAliases( XkbReadBufferPtr buf, + XkbGeometryPtr geom, + xkbGetGeometryReply * rep) +{ +Status rtrn; + + if (rep->nKeyAliases<1) + return Success; + if ((rtrn=XkbAllocGeomKeyAliases(geom,rep->nKeyAliases))==Success) { + if (!_XkbCopyFromReadBuffer(buf,(char *)geom->key_aliases, + (rep->nKeyAliases*XkbKeyNameLength*2))) + return BadLength; + geom->num_key_aliases= rep->nKeyAliases; + return Success; + } + else { /* alloc failed, just skip the aliases */ + _XkbSkipReadBufferData(buf,(rep->nKeyAliases*XkbKeyNameLength*2)); + } + return rtrn; +} + +static Status +_XkbReadGeomColors( XkbReadBufferPtr buf, + XkbGeometryPtr geom, + xkbGetGeometryReply * rep) +{ +Status rtrn; + + if (rep->nColors<1) + return Success; + if ((rtrn=XkbAllocGeomColors(geom,rep->nColors))==Success) { + register int i; + char *spec; + for (i=0;inColors;i++) { + spec = NULL; + if (!_XkbGetReadBufferCountedString(buf,&spec)) + rtrn = BadLength; + else if (XkbAddGeomColor(geom,spec,geom->num_colors)==NULL) + rtrn = BadAlloc; + if (spec) + _XkbFree(spec); + if (rtrn != Success) + return rtrn; + } + return Success; + } + return rtrn; +} + +static Status +_XkbReadGeomShapes( XkbReadBufferPtr buf, + XkbGeometryPtr geom, + xkbGetGeometryReply * rep) +{ +register int i; +Status rtrn; + + if (rep->nShapes<1) + return Success; + if ((rtrn=XkbAllocGeomShapes(geom,rep->nShapes))!=Success) + return rtrn; + for (i=0;inShapes;i++) { + xkbShapeWireDesc *shapeWire; + XkbShapePtr shape; + register int o; + shapeWire= (xkbShapeWireDesc *) + _XkbGetReadBufferPtr(buf,SIZEOF(xkbShapeWireDesc)); + if (!shapeWire) + return BadLength; + shape= XkbAddGeomShape(geom,shapeWire->name,shapeWire->nOutlines); + if (!shape) + return BadAlloc; + for (o=0;onOutlines;o++) { + xkbOutlineWireDesc *olWire; + XkbOutlinePtr ol; + register int p; + XkbPointPtr pt; + olWire= (xkbOutlineWireDesc *) + _XkbGetReadBufferPtr(buf,SIZEOF(xkbOutlineWireDesc)); + if (!olWire) + return BadLength; + ol= XkbAddGeomOutline(shape,olWire->nPoints); + if (!ol) + return BadAlloc; + ol->corner_radius= olWire->cornerRadius; + for (p=0,pt=ol->points;pnPoints;p++,pt++) { + xkbPointWireDesc * ptWire; + ptWire= (xkbPointWireDesc *) + _XkbGetReadBufferPtr(buf,SIZEOF(xkbPointWireDesc)); + if (!ptWire) + return BadLength; + pt->x= ptWire->x; + pt->y= ptWire->y; + } + ol->num_points= olWire->nPoints; + } + if (shapeWire->primaryNdx!=XkbNoShape) + shape->primary= &shape->outlines[shapeWire->primaryNdx]; + else shape->primary= NULL; + if (shapeWire->approxNdx!=XkbNoShape) + shape->approx= &shape->outlines[shapeWire->approxNdx]; + else shape->approx= NULL; + XkbComputeShapeBounds(shape); + } + return Success; +} + +static Status +_XkbReadGeomDoodad( XkbReadBufferPtr buf, + XkbGeometryPtr geom, + XkbSectionPtr section) +{ +XkbDoodadPtr doodad; +xkbDoodadWireDesc * doodadWire; + + doodadWire= (xkbDoodadWireDesc *) + _XkbGetReadBufferPtr(buf,SIZEOF(xkbDoodadWireDesc)); + if (!doodadWire) + return BadLength; + doodad= XkbAddGeomDoodad(geom,section,doodadWire->any.name); + if (!doodad) + return BadAlloc; + doodad->any.type= doodadWire->any.type; + doodad->any.priority= doodadWire->any.priority; + doodad->any.top= doodadWire->any.top; + doodad->any.left= doodadWire->any.left; + doodad->any.angle= doodadWire->any.angle; + switch (doodad->any.type) { + case XkbOutlineDoodad: + case XkbSolidDoodad: + doodad->shape.color_ndx= doodadWire->shape.colorNdx; + doodad->shape.shape_ndx= doodadWire->shape.shapeNdx; + break; + case XkbTextDoodad: + doodad->text.width= doodadWire->text.width; + doodad->text.height= doodadWire->text.height; + doodad->text.color_ndx= doodadWire->text.colorNdx; + if (!_XkbGetReadBufferCountedString(buf,&doodad->text.text)) + return BadLength; + if (!_XkbGetReadBufferCountedString(buf,&doodad->text.font)) + return BadLength; + break; + case XkbIndicatorDoodad: + doodad->indicator.shape_ndx= doodadWire->indicator.shapeNdx; + doodad->indicator.on_color_ndx= doodadWire->indicator.onColorNdx; + doodad->indicator.off_color_ndx= doodadWire->indicator.offColorNdx; + break; + case XkbLogoDoodad: + doodad->logo.color_ndx= doodadWire->logo.colorNdx; + doodad->logo.shape_ndx= doodadWire->logo.shapeNdx; + if (!_XkbGetReadBufferCountedString(buf,&doodad->logo.logo_name)) + return BadLength; + break; + default: + return BadValue; + } + return Success; +} + +static Status +_XkbReadGeomOverlay( XkbReadBufferPtr buf, + XkbGeometryPtr geom, + XkbSectionPtr section) +{ +XkbOverlayPtr ol; +xkbOverlayWireDesc * olWire; +register int r; + + olWire= (xkbOverlayWireDesc *) + _XkbGetReadBufferPtr(buf,SIZEOF(xkbOverlayWireDesc)); + if (olWire==NULL) + return BadLength; + ol= XkbAddGeomOverlay(section,olWire->name,olWire->nRows); + if (ol==NULL) + return BadLength; + for (r=0;rnRows;r++) { + register int k; + XkbOverlayRowPtr row; + xkbOverlayRowWireDesc * rowWire; + xkbOverlayKeyWireDesc * keyWire; + rowWire= (xkbOverlayRowWireDesc *) + _XkbGetReadBufferPtr(buf,SIZEOF(xkbOverlayRowWireDesc)); + if (rowWire==NULL) + return BadLength; + row= XkbAddGeomOverlayRow(ol,rowWire->rowUnder,rowWire->nKeys); + row->row_under= rowWire->rowUnder; + if (!row) + return BadAlloc; + if (rowWire->nKeys<1) + continue; + keyWire= (xkbOverlayKeyWireDesc *) + _XkbGetReadBufferPtr(buf, + SIZEOF(xkbOverlayKeyWireDesc)*rowWire->nKeys); + if (keyWire==NULL) + return BadLength; + for (k=0;knKeys;k++,keyWire++,row->num_keys++) { + memcpy(row->keys[row->num_keys].over.name,keyWire->over, + XkbKeyNameLength); + memcpy(row->keys[row->num_keys].under.name,keyWire->under, + XkbKeyNameLength); + } + } + return Success; +} + +static Status +_XkbReadGeomSections( XkbReadBufferPtr buf, + XkbGeometryPtr geom, + xkbGetGeometryReply * rep) +{ +register int s; +XkbSectionPtr section; +xkbSectionWireDesc * sectionWire; +Status rtrn; + + if (rep->nSections<1) + return Success; + if ((rtrn=XkbAllocGeomSections(geom,rep->nSections))!=Success) + return rtrn; + for (s=0;snSections;s++) { + sectionWire= (xkbSectionWireDesc *) + _XkbGetReadBufferPtr(buf,SIZEOF(xkbSectionWireDesc)); + if (!sectionWire) + return BadLength; + section= XkbAddGeomSection(geom,sectionWire->name,sectionWire->nRows, + sectionWire->nDoodads, + sectionWire->nOverlays); + if (!section) + return BadAlloc; + section->top= sectionWire->top; + section->left= sectionWire->left; + section->width= sectionWire->width; + section->height= sectionWire->height; + section->angle= sectionWire->angle; + section->priority= sectionWire->priority; + if (sectionWire->nRows>0) { + register int r; + XkbRowPtr row; + xkbRowWireDesc * rowWire; + for (r=0;rnRows;r++) { + rowWire= (xkbRowWireDesc *) + _XkbGetReadBufferPtr(buf,SIZEOF(xkbRowWireDesc)); + if (!rowWire) + return BadLength; + row= XkbAddGeomRow(section,rowWire->nKeys); + if (!row) + return BadAlloc; + row->top= rowWire->top; + row->left= rowWire->left; + row->vertical= rowWire->vertical; + if (rowWire->nKeys>0) { + register int k; + XkbKeyPtr key; + xkbKeyWireDesc * keyWire; + for (k=0;knKeys;k++) { + keyWire= (xkbKeyWireDesc *) + _XkbGetReadBufferPtr(buf,SIZEOF(xkbKeyWireDesc)); + if (!keyWire) + return BadLength; + key= XkbAddGeomKey(row); + if (!key) + return BadAlloc; + memcpy(key->name.name,keyWire->name,XkbKeyNameLength); + key->gap= keyWire->gap; + key->shape_ndx= keyWire->shapeNdx; + key->color_ndx= keyWire->colorNdx; + } + } + } + } + if (sectionWire->nDoodads>0) { + register int d; + for (d=0;dnDoodads;d++) { + if ((rtrn=_XkbReadGeomDoodad(buf,geom,section))!=Success) + return rtrn; + } + } + if (sectionWire->nOverlays>0) { + register int o; + for (o=0;onOverlays;o++) { + if ((rtrn=_XkbReadGeomOverlay(buf,geom,section))!=Success) + return rtrn; + } + } + } + return Success; +} + +static Status +_XkbReadGeomDoodads( XkbReadBufferPtr buf, + XkbGeometryPtr geom, + xkbGetGeometryReply * rep) +{ +register int d; +Status rtrn; + + if (rep->nDoodads<1) + return Success; + if ((rtrn=XkbAllocGeomDoodads(geom,rep->nDoodads))!=Success) + return rtrn; + for (d=0;dnDoodads;d++) { + if ((rtrn=_XkbReadGeomDoodad(buf,geom,NULL))!=Success) + return rtrn; + } + return Success; +} + +Status +_XkbReadGetGeometryReply( Display * dpy, + xkbGetGeometryReply * rep, + XkbDescPtr xkb, + int * nread_rtrn) +{ +XkbGeometryPtr geom; + + geom= _XkbTypedCalloc(1,XkbGeometryRec); + if (!geom) + return BadAlloc; + if (xkb->geom) + XkbFreeGeometry(xkb->geom,XkbGeomAllMask,True); + xkb->geom= geom; + + geom->name= rep->name; + geom->width_mm= rep->widthMM; + geom->height_mm= rep->heightMM; + if (rep->length) { + XkbReadBufferRec buf; + int left; + if (_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4)) { + Status status= Success; + if (nread_rtrn) + *nread_rtrn= (int)rep->length*4; + if (!_XkbGetReadBufferCountedString(&buf,&geom->label_font)) + status= BadLength; + if (status==Success) + status= _XkbReadGeomProperties(&buf,geom,rep); + if (status==Success) + status= _XkbReadGeomColors(&buf,geom,rep); + if (status==Success) + status= _XkbReadGeomShapes(&buf,geom,rep); + if (status==Success) + status= _XkbReadGeomSections(&buf,geom,rep); + if (status==Success) + status= _XkbReadGeomDoodads(&buf,geom,rep); + if (status==Success) + status= _XkbReadGeomKeyAliases(&buf,geom,rep); + left= _XkbFreeReadBuffer(&buf); + if ((status!=Success) || left || buf.error) { + if (status==Success) + status= BadLength; + XkbFreeGeometry(geom,XkbGeomAllMask,True); + xkb->geom= NULL; + return status; + } + geom->base_color= &geom->colors[rep->baseColorNdx]; + geom->label_color= &geom->colors[rep->labelColorNdx]; + } + else { + XkbFreeGeometry(geom,XkbGeomAllMask,True); + xkb->geom= NULL; + return BadAlloc; + } + } + return Success; +} + +Status +XkbGetGeometry(Display *dpy,XkbDescPtr xkb) +{ +xkbGetGeometryReq *req; +xkbGetGeometryReply rep; +Status status; + + if ( (!xkb) || (dpy->flags & XlibDisplayNoXkb) || + (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) + return BadAccess; + + LockDisplay(dpy); + GetReq(kbGetGeometry, req); + req->reqType = dpy->xkb_info->codes->major_opcode; + req->xkbReqType = X_kbGetGeometry; + req->deviceSpec = xkb->device_spec; + req->name= None; + if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) + status = BadImplementation; + else if (!rep.found) + status = BadName; + else + status = _XkbReadGetGeometryReply(dpy,&rep,xkb,NULL); + UnlockDisplay(dpy); + SyncHandle(); + return status; +} + +Status +XkbGetNamedGeometry(Display *dpy,XkbDescPtr xkb,Atom name) +{ +xkbGetGeometryReq *req; +xkbGetGeometryReply rep; +Status status; + + if ( (name==None) || (dpy->flags & XlibDisplayNoXkb) || + (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) ) + return BadAccess; + + LockDisplay(dpy); + GetReq(kbGetGeometry, req); + req->reqType = dpy->xkb_info->codes->major_opcode; + req->xkbReqType = X_kbGetGeometry; + req->deviceSpec = xkb->device_spec; + req->name= (CARD32)name; + if ((!_XReply(dpy, (xReply *)&rep, 0, xFalse))||(!rep.found)) + status = BadImplementation; + else if (!rep.found) + status = BadName; + else + status = _XkbReadGetGeometryReply(dpy,&rep,xkb,NULL); + UnlockDisplay(dpy); + SyncHandle(); + return status; +} + diff --git a/libxcb/configure.ac b/libxcb/configure.ac index 7e88481bf..1a8cd2ef2 100644 --- a/libxcb/configure.ac +++ b/libxcb/configure.ac @@ -9,7 +9,7 @@ AC_CONFIG_SRCDIR([xcb.pc.in]) AM_INIT_AUTOMAKE([foreign dist-bzip2]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) -AM_PATH_PYTHON([2.5]) +AM_PATH_PYTHON([2.6]) PKG_CHECK_MODULES(CHECK, [check >= 0.9.4], [HAVE_CHECK=yes], [HAVE_CHECK=no]) AM_CONDITIONAL(HAVE_CHECK, test x$HAVE_CHECK = xyes) diff --git a/libxcb/src/c_client.py b/libxcb/src/c_client.py index a10b3f1d8..3e77e9ef2 100644 --- a/libxcb/src/c_client.py +++ b/libxcb/src/c_client.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from xml.etree.cElementTree import * from os.path import basename +from functools import reduce import getopt import sys import re @@ -323,7 +324,7 @@ def _c_type_setup(self, name, postfix): field.c_field_type = _t(field.field_type) field.c_field_const_type = ('' if field.type.nmemb == 1 else 'const ') + field.c_field_type field.c_field_name = _cpp(field.field_name) - field.c_subscript = '[%d]' % field.type.nmemb if (field.type.nmemb > 1) else '' + field.c_subscript = '[%d]' % field.type.nmemb if (field.type.nmemb and field.type.nmemb > 1) else '' field.c_pointer = ' ' if field.type.nmemb == 1 else '*' # correct the c_pointer field for variable size non-list types @@ -443,7 +444,7 @@ def _c_helper_field_mapping(complex_type, prefix, flat=False): else: for f in complex_type.fields: fname = _c_helper_absolute_name(prefix, f) - if all_fields.has_key(f.field_name): + if f.field_name in all_fields: raise Exception("field name %s has been registered before" % f.field_name) all_fields[f.field_name] = (fname, f) @@ -524,7 +525,7 @@ def get_expr_fields(self): prefix.append(('', '', self)) all_fields = _c_helper_resolve_field_names (prefix) - resolved_fields_names = filter(lambda x: x in all_fields.keys(), unresolved_fields_names) + resolved_fields_names = list(filter(lambda x: x in all_fields.keys(), unresolved_fields_names)) if len(unresolved_fields_names) != len(resolved_fields_names): raise Exception("could not resolve all fields for %s" % self.name) @@ -743,8 +744,8 @@ def _c_serialize_helper_list_field(context, self, field, param_names = [p[2] for p in params] expr_fields_names = [f.field_name for f in get_expr_fields(field.type)] - resolved = filter(lambda x: x in param_names, expr_fields_names) - unresolved = filter(lambda x: x not in param_names, expr_fields_names) + resolved = list(filter(lambda x: x in param_names, expr_fields_names)) + unresolved = list(filter(lambda x: x not in param_names, expr_fields_names)) field_mapping = {} for r in resolved: @@ -757,8 +758,8 @@ def _c_serialize_helper_list_field(context, self, field, field.c_field_name) field_mapping.update(_c_helper_resolve_field_names(prefix)) - resolved += filter(lambda x: x in field_mapping, unresolved) - unresolved = filter(lambda x: x not in field_mapping, unresolved) + resolved += list(filter(lambda x: x in field_mapping, unresolved)) + unresolved = list(filter(lambda x: x not in field_mapping, unresolved)) if len(unresolved)>0: raise Exception('could not resolve the length fields required for list %s' % field.c_field_name) @@ -1083,7 +1084,7 @@ def _c_serialize(context, self): param_str.append("%s%s%s %s%s /**< */" % (indent, typespec, spacing, pointerspec, field_name)) # insert function name param_str[0] = "%s (%s" % (func_name, param_str[0].strip()) - param_str = map(lambda x: "%s," % x, param_str) + param_str = list(map(lambda x: "%s," % x, param_str)) for s in param_str[:-1]: _hc(s) _h("%s);" % param_str[-1].rstrip(',')) @@ -1159,7 +1160,7 @@ def _c_serialize(context, self): if not (self.is_switch or self.var_followed_by_fixed_fields): # look if we have to declare an '_aux' variable at all - if len(filter(lambda x: x.find('_aux')!=-1, code_lines))>0: + if len(list(filter(lambda x: x.find('_aux')!=-1, code_lines)))>0: if not self.var_followed_by_fixed_fields: _c(' const %s *_aux = (%s *)_buffer;', self.c_type, self.c_type) else: @@ -2282,9 +2283,9 @@ output = {'open' : c_open, # Check for the argument that specifies path to the xcbgen python package. try: opts, args = getopt.getopt(sys.argv[1:], 'p:') -except getopt.GetoptError, err: - print str(err) - print 'Usage: c_client.py [-p path] file.xml' +except getopt.GetoptError as err: + print(err) + print('Usage: c_client.py [-p path] file.xml') sys.exit(1) for (opt, arg) in opts: @@ -2295,13 +2296,13 @@ for (opt, arg) in opts: try: from xcbgen.state import Module except ImportError: - print '' - print 'Failed to load the xcbgen Python package!' - print 'Make sure that xcb/proto installed it on your Python path.' - print 'If not, you will need to create a .pth file or define $PYTHONPATH' - print 'to extend the path.' - print 'Refer to the README file in xcb/proto for more info.' - print '' + print(''' +Failed to load the xcbgen Python package! +Make sure that xcb/proto installed it on your Python path. +If not, you will need to create a .pth file or define $PYTHONPATH +to extend the path. +Refer to the README file in xcb/proto for more info. +''') raise # Parse the xml header diff --git a/mesalib/configure.ac b/mesalib/configure.ac index 54d9c2968..7bd1f2e21 100644 --- a/mesalib/configure.ac +++ b/mesalib/configure.ac @@ -21,8 +21,8 @@ dnl Versions for external dependencies LIBDRM_REQUIRED=2.4.24 LIBDRM_RADEON_REQUIRED=2.4.24 LIBDRM_INTEL_REQUIRED=2.4.24 -DRI2PROTO_REQUIRED=2.1 -GLPROTO_REQUIRED=1.4.11 +DRI2PROTO_REQUIRED=2.4 +GLPROTO_REQUIRED=1.4.13 LIBDRM_XORG_REQUIRED=2.4.24 LIBKMS_XORG_REQUIRED=1.0.0 diff --git a/mesalib/scons/custom.py b/mesalib/scons/custom.py index 7c59fe985..a2c690f65 100644 --- a/mesalib/scons/custom.py +++ b/mesalib/scons/custom.py @@ -59,6 +59,7 @@ def quietCommandLines(env): env['LEXCOMSTR'] = " Generating $TARGET ..." env['YACCCOMSTR'] = " Generating $TARGET ..." env['CODEGENCOMSTR'] = " Generating $TARGET ..." + env['INSTALLSTR'] = " Installing $TARGET ..." def createConvenienceLibBuilder(env): diff --git a/mesalib/scons/gallium.py b/mesalib/scons/gallium.py index a61a9af8c..a94bf7364 100644 --- a/mesalib/scons/gallium.py +++ b/mesalib/scons/gallium.py @@ -1,624 +1,624 @@ -"""gallium - -Frontend-tool for Gallium3D architecture. - -""" - -# -# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sub license, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice (including the -# next paragraph) shall be included in all copies or substantial portions -# of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. -# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR -# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - - -import distutils.version -import os -import os.path -import re -import subprocess -import platform as _platform - -import SCons.Action -import SCons.Builder -import SCons.Scanner - - -def symlink(target, source, env): - target = str(target[0]) - source = str(source[0]) - if os.path.islink(target) or os.path.exists(target): - os.remove(target) - os.symlink(os.path.basename(source), target) - -def install(env, source, subdir): - target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir'], subdir) - return env.Install(target_dir, source) - -def install_program(env, source): - return install(env, source, 'bin') - -def install_shared_library(env, sources, version = ()): - targets = [] - install_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir']) - version = tuple(map(str, version)) - if env['SHLIBSUFFIX'] == '.dll': - dlls = env.FindIxes(sources, 'SHLIBPREFIX', 'SHLIBSUFFIX') - targets += install(env, dlls, 'bin') - libs = env.FindIxes(sources, 'LIBPREFIX', 'LIBSUFFIX') - targets += install(env, libs, 'lib') - else: - for source in sources: - target_dir = os.path.join(install_dir, 'lib') - target_name = '.'.join((str(source),) + version) - last = env.InstallAs(os.path.join(target_dir, target_name), source) - targets += last - while len(version): - version = version[:-1] - target_name = '.'.join((str(source),) + version) - action = SCons.Action.Action(symlink, "$TARGET -> $SOURCE") - last = env.Command(os.path.join(target_dir, target_name), last, action) - targets += last - return targets - - -def createInstallMethods(env): - env.AddMethod(install_program, 'InstallProgram') - env.AddMethod(install_shared_library, 'InstallSharedLibrary') - - -def num_jobs(): - try: - return int(os.environ['NUMBER_OF_PROCESSORS']) - except (ValueError, KeyError): - pass - - try: - return os.sysconf('SC_NPROCESSORS_ONLN') - except (ValueError, OSError, AttributeError): - pass - - try: - return int(os.popen2("sysctl -n hw.ncpu")[1].read()) - except ValueError: - pass - - return 1 - - -def pkg_config_modules(env, name, modules): - '''Simple wrapper for pkg-config.''' - - env[name] = False - - if env['platform'] == 'windows': - return - - if not env.Detect('pkg-config'): - return - - if subprocess.call(["pkg-config", "--exists", ' '.join(modules)]) != 0: - return - - # Put -I and -L flags directly into the environment, as these don't affect - # the compilation of targets that do not use them - try: - env.ParseConfig('pkg-config --cflags-only-I --libs-only-L ' + ' '.join(modules)) - except OSError: - return - - # Other flags may affect the compilation of unrelated targets, so store - # them with a prefix, (e.g., XXX_CFLAGS, XXX_LIBS, etc) - try: - flags = env.ParseFlags('!pkg-config --cflags-only-other --libs-only-l --libs-only-other ' + ' '.join(modules)) - except OSError: - return - prefix = name.upper() + '_' - for flag_name, flag_value in flags.iteritems(): - env[prefix + flag_name] = flag_value - - env[name] = True - - - -def generate(env): - """Common environment generation code""" - - # Tell tools which machine to compile for - env['TARGET_ARCH'] = env['machine'] - env['MSVS_ARCH'] = env['machine'] - - # Toolchain - platform = env['platform'] - if env['toolchain'] == 'default': - if platform == 'winddk': - env['toolchain'] = 'winddk' - elif platform == 'wince': - env['toolchain'] = 'wcesdk' - env.Tool(env['toolchain']) - - # Allow override compiler and specify additional flags from environment - if os.environ.has_key('CC'): - env['CC'] = os.environ['CC'] - # Update CCVERSION to match - pipe = SCons.Action._subproc(env, [env['CC'], '--version'], - stdin = 'devnull', - stderr = 'devnull', - stdout = subprocess.PIPE) - if pipe.wait() == 0: - line = pipe.stdout.readline() - match = re.search(r'[0-9]+(\.[0-9]+)+', line) - if match: - env['CCVERSION'] = match.group(0) - if os.environ.has_key('CFLAGS'): - env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS']) - if os.environ.has_key('CXX'): - env['CXX'] = os.environ['CXX'] - if os.environ.has_key('CXXFLAGS'): - env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS']) - if os.environ.has_key('LDFLAGS'): - env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS']) - - env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-') - env['msvc'] = env['CC'] == 'cl' - - if env['msvc'] and env['toolchain'] == 'default' and env['machine'] == 'x86_64': - # MSVC x64 support is broken in earlier versions of scons - env.EnsurePythonVersion(2, 0) - - # shortcuts - machine = env['machine'] - platform = env['platform'] - x86 = env['machine'] == 'x86' - ppc = env['machine'] == 'ppc' - gcc = env['gcc'] - msvc = env['msvc'] - - # Determine whether we are cross compiling; in particular, whether we need - # to compile code generators with a different compiler as the target code. - host_platform = _platform.system().lower() - if host_platform.startswith('cygwin'): - host_platform = 'cygwin' - host_machine = os.environ.get('PROCESSOR_ARCHITEW6432', os.environ.get('PROCESSOR_ARCHITECTURE', _platform.machine())) - host_machine = { - 'x86': 'x86', - 'i386': 'x86', - 'i486': 'x86', - 'i586': 'x86', - 'i686': 'x86', - 'ppc' : 'ppc', - 'AMD64': 'x86_64', - 'x86_64': 'x86_64', - }.get(host_machine, 'generic') - env['crosscompile'] = platform != host_platform - if machine == 'x86_64' and host_machine != 'x86_64': - env['crosscompile'] = True - env['hostonly'] = False - - # Backwards compatability with the debug= profile= options - if env['build'] == 'debug': - if not env['debug']: - print 'scons: warning: debug option is deprecated and will be removed eventually; use instead' - print - print ' scons build=release' - print - env['build'] = 'release' - if env['profile']: - print 'scons: warning: profile option is deprecated and will be removed eventually; use instead' - print - print ' scons build=profile' - print - env['build'] = 'profile' - if False: - # Enforce SConscripts to use the new build variable - env.popitem('debug') - env.popitem('profile') - else: - # Backwards portability with older sconscripts - if env['build'] in ('debug', 'checked'): - env['debug'] = True - env['profile'] = False - if env['build'] == 'profile': - env['debug'] = False - env['profile'] = True - if env['build'] == 'release': - env['debug'] = False - env['profile'] = False - - # Put build output in a separate dir, which depends on the current - # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample - build_topdir = 'build' - build_subdir = env['platform'] - if env['machine'] != 'generic': - build_subdir += '-' + env['machine'] - if env['build'] != 'release': - build_subdir += '-' + env['build'] - build_dir = os.path.join(build_topdir, build_subdir) - # Place the .sconsign file in the build dir too, to avoid issues with - # different scons versions building the same source file - env['build_dir'] = build_dir - env.SConsignFile(os.path.join(build_dir, '.sconsign')) - if 'SCONS_CACHE_DIR' in os.environ: - print 'scons: Using build cache in %s.' % (os.environ['SCONS_CACHE_DIR'],) - env.CacheDir(os.environ['SCONS_CACHE_DIR']) - env['CONFIGUREDIR'] = os.path.join(build_dir, 'conf') - env['CONFIGURELOG'] = os.path.join(os.path.abspath(build_dir), 'config.log') - - # Parallel build - if env.GetOption('num_jobs') <= 1: - env.SetOption('num_jobs', num_jobs()) - - env.Decider('MD5-timestamp') - env.SetOption('max_drift', 60) - - # C preprocessor options - cppdefines = [] - if env['build'] in ('debug', 'checked'): - cppdefines += ['DEBUG'] - else: - cppdefines += ['NDEBUG'] - if env['build'] == 'profile': - cppdefines += ['PROFILE'] - if platform == 'windows': - cppdefines += [ - 'WIN32', - '_WINDOWS', - #'_UNICODE', - #'UNICODE', - # http://msdn.microsoft.com/en-us/library/aa383745.aspx - ('_WIN32_WINNT', '0x0601'), - ('WINVER', '0x0601'), - ] - if msvc and env['toolchain'] != 'winddk': - cppdefines += [ - 'VC_EXTRALEAN', - '_USE_MATH_DEFINES', - '_CRT_SECURE_NO_WARNINGS', - '_CRT_SECURE_NO_DEPRECATE', - '_SCL_SECURE_NO_WARNINGS', - '_SCL_SECURE_NO_DEPRECATE', - ] - if env['build'] in ('debug', 'checked'): - cppdefines += ['_DEBUG'] - if env['toolchain'] == 'winddk': - # Mimic WINDDK's builtin flags. See also: - # - WINDDK's bin/makefile.new i386mk.inc for more info. - # - buildchk_wxp_x86.log files, generated by the WINDDK's build - # - http://alter.org.ua/docs/nt_kernel/vc8_proj/ - if machine == 'x86': - cppdefines += ['_X86_', 'i386'] - if machine == 'x86_64': - cppdefines += ['_AMD64_', 'AMD64'] - if platform == 'winddk': - cppdefines += [ - 'STD_CALL', - ('CONDITION_HANDLING', '1'), - ('NT_INST', '0'), - ('WIN32', '100'), - ('_NT1X_', '100'), - ('WINNT', '1'), - ('_WIN32_WINNT', '0x0501'), # minimum required OS version - ('WINVER', '0x0501'), - ('_WIN32_IE', '0x0603'), - ('WIN32_LEAN_AND_MEAN', '1'), - ('DEVL', '1'), - ('__BUILDMACHINE__', 'WinDDK'), - ('FPO', '0'), - ] - if env['build'] in ('debug', 'checked'): - cppdefines += [('DBG', 1)] - if platform == 'wince': - cppdefines += [ - '_CRT_SECURE_NO_DEPRECATE', - '_USE_32BIT_TIME_T', - 'UNICODE', - '_UNICODE', - ('UNDER_CE', '600'), - ('_WIN32_WCE', '0x600'), - 'WINCEOEM', - 'WINCEINTERNAL', - 'WIN32', - 'STRICT', - 'x86', - '_X86_', - 'INTERNATIONAL', - ('INTLMSG_CODEPAGE', '1252'), - ] - if platform == 'windows': - cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_USER'] - if platform == 'winddk': - cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY'] - if platform == 'wince': - cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE'] - cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL'] - if platform == 'embedded': - cppdefines += ['PIPE_OS_EMBEDDED'] - env.Append(CPPDEFINES = cppdefines) - - # C compiler options - cflags = [] # C - cxxflags = [] # C++ - ccflags = [] # C & C++ - if gcc: - ccversion = env['CCVERSION'] - if env['build'] == 'debug': - ccflags += ['-O0'] - elif ccversion.startswith('4.2.'): - # gcc 4.2.x optimizer is broken - print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations" - ccflags += ['-O0'] - else: - ccflags += ['-O3'] - ccflags += ['-g3'] - if env['build'] in ('checked', 'profile'): - # See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling? - ccflags += [ - '-fno-omit-frame-pointer', - '-fno-optimize-sibling-calls', - ] - if env['machine'] == 'x86': - ccflags += [ - '-m32', - #'-march=pentium4', - ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2') \ - and (platform != 'windows' or env['build'] == 'debug' or True): - # NOTE: We need to ensure stack is realigned given that we - # produce shared objects, and have no control over the stack - # alignment policy of the application. Therefore we need - # -mstackrealign ore -mincoming-stack-boundary=2. - # - # XXX: -O and -mstackrealign causes stack corruption on MinGW - # - # XXX: We could have SSE without -mstackrealign if we always used - # __attribute__((force_align_arg_pointer)), but that's not - # always the case. - ccflags += [ - '-mstackrealign', # ensure stack is aligned - '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics - #'-mfpmath=sse', - ] - if platform in ['windows', 'darwin']: - # Workaround http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216 - ccflags += ['-fno-common'] - if env['machine'] == 'x86_64': - ccflags += ['-m64'] - if platform == 'darwin': - ccflags += ['-fno-common'] - # See also: - # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html - ccflags += [ - '-Wall', - '-Wno-long-long', - '-ffast-math', - '-fmessage-length=0', # be nice to Eclipse - ] - cflags += [ - '-Wmissing-prototypes', - '-std=gnu99', - ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.0'): - ccflags += [ - '-Wmissing-field-initializers', - ] - if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'): - ccflags += [ - '-Werror=pointer-arith', - ] - cflags += [ - '-Werror=declaration-after-statement', - ] - if msvc: - # See also: - # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx - # - cl /? - if env['build'] == 'debug': - ccflags += [ - '/Od', # disable optimizations - '/Oi', # enable intrinsic functions - '/Oy-', # disable frame pointer omission - ] - else: - ccflags += [ - '/O2', # optimize for speed - ] - if env['build'] == 'release': - ccflags += [ - '/GL', # enable whole program optimization - ] - else: - ccflags += [ - '/GL-', # disable whole program optimization - ] - ccflags += [ - '/fp:fast', # fast floating point - '/W3', # warning level - #'/Wp64', # enable 64 bit porting warnings - ] - if env['machine'] == 'x86': - ccflags += [ - #'/arch:SSE2', # use the SSE2 instructions - ] - if platform == 'windows': - ccflags += [ - # TODO - ] - if platform == 'winddk': - ccflags += [ - '/Zl', # omit default library name in .OBJ - '/Zp8', # 8bytes struct member alignment - '/Gy', # separate functions for linker - '/Gm-', # disable minimal rebuild - '/WX', # treat warnings as errors - '/Gz', # __stdcall Calling convention - '/GX-', # disable C++ EH - '/GR-', # disable C++ RTTI - '/GF', # enable read-only string pooling - '/G6', # optimize for PPro, P-II, P-III - '/Ze', # enable extensions - '/Gi-', # disable incremental compilation - '/QIfdiv-', # disable Pentium FDIV fix - '/hotpatch', # prepares an image for hotpatching. - #'/Z7', #enable old-style debug info - ] - if platform == 'wince': - # See also C:\WINCE600\public\common\oak\misc\makefile.def - ccflags += [ - '/Zl', # omit default library name in .OBJ - '/GF', # enable read-only string pooling - '/GR-', # disable C++ RTTI - '/GS', # enable security checks - # Allow disabling language conformance to maintain backward compat - #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef - #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules - #'/wd4867', - #'/wd4430', - #'/MT', - #'/U_MT', - ] - # Automatic pdb generation - # See http://scons.tigris.org/issues/show_bug.cgi?id=1656 - env.EnsureSConsVersion(0, 98, 0) - env['PDB'] = '${TARGET.base}.pdb' - env.Append(CCFLAGS = ccflags) - env.Append(CFLAGS = cflags) - env.Append(CXXFLAGS = cxxflags) - - if env['platform'] == 'windows' and msvc: - # Choose the appropriate MSVC CRT - # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx - if env['build'] in ('debug', 'checked'): - env.Append(CCFLAGS = ['/MTd']) - env.Append(SHCCFLAGS = ['/LDd']) - else: - env.Append(CCFLAGS = ['/MT']) - env.Append(SHCCFLAGS = ['/LD']) - - # Assembler options - if gcc: - if env['machine'] == 'x86': - env.Append(ASFLAGS = ['-m32']) - if env['machine'] == 'x86_64': - env.Append(ASFLAGS = ['-m64']) - - # Linker options - linkflags = [] - shlinkflags = [] - if gcc: - if env['machine'] == 'x86': - linkflags += ['-m32'] - if env['machine'] == 'x86_64': - linkflags += ['-m64'] - if env['platform'] not in ('darwin'): - shlinkflags += [ - '-Wl,-Bsymbolic', - ] - # Handle circular dependencies in the libraries - if env['platform'] in ('darwin'): - pass - else: - env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group' - if msvc: - if env['build'] == 'release': - # enable Link-time Code Generation - linkflags += ['/LTCG'] - env.Append(ARFLAGS = ['/LTCG']) - if platform == 'windows' and msvc: - # See also: - # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx - linkflags += [ - '/fixed:no', - '/incremental:no', - ] - if platform == 'winddk': - linkflags += [ - '/merge:_PAGE=PAGE', - '/merge:_TEXT=.text', - '/section:INIT,d', - '/opt:ref', - '/opt:icf', - '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221', - '/incremental:no', - '/fullbuild', - '/release', - '/nodefaultlib', - '/wx', - '/debug', - '/debugtype:cv', - '/version:5.1', - '/osversion:5.1', - '/functionpadmin:5', - '/safeseh', - '/pdbcompress', - '/stack:0x40000,0x1000', - '/driver', - '/align:0x80', - '/subsystem:native,5.01', - '/base:0x10000', - - '/entry:DrvEnableDriver', - ] - if env['build'] != 'release': - linkflags += [ - '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx - ] - if platform == 'wince': - linkflags += [ - '/nodefaultlib', - #'/incremental:no', - #'/fullbuild', - '/entry:_DllMainCRTStartup', - ] - env.Append(LINKFLAGS = linkflags) - env.Append(SHLINKFLAGS = shlinkflags) - - # We have C++ in several libraries, so always link with the C++ compiler - if env['gcc']: - env['LINK'] = env['CXX'] - - # Default libs - env.Append(LIBS = []) - - # Load tools - env.Tool('lex') - env.Tool('yacc') - if env['llvm']: - env.Tool('llvm') - - pkg_config_modules(env, 'x11', ['x11', 'xext']) - pkg_config_modules(env, 'drm', ['libdrm']) - pkg_config_modules(env, 'drm_intel', ['libdrm_intel']) - pkg_config_modules(env, 'drm_radeon', ['libdrm_radeon']) - pkg_config_modules(env, 'xorg', ['xorg-server']) - pkg_config_modules(env, 'kms', ['libkms']) - - env['dri'] = env['x11'] and env['drm'] - - # Custom builders and methods - env.Tool('custom') - createInstallMethods(env) - - # for debugging - #print env.Dump() - - -def exists(env): - return 1 +"""gallium + +Frontend-tool for Gallium3D architecture. + +""" + +# +# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sub license, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice (including the +# next paragraph) shall be included in all copies or substantial portions +# of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR +# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + + +import distutils.version +import os +import os.path +import re +import subprocess +import platform as _platform + +import SCons.Action +import SCons.Builder +import SCons.Scanner + + +def symlink(target, source, env): + target = str(target[0]) + source = str(source[0]) + if os.path.islink(target) or os.path.exists(target): + os.remove(target) + os.symlink(os.path.basename(source), target) + +def install(env, source, subdir): + target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir'], subdir) + return env.Install(target_dir, source) + +def install_program(env, source): + return install(env, source, 'bin') + +def install_shared_library(env, sources, version = ()): + targets = [] + install_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir']) + version = tuple(map(str, version)) + if env['SHLIBSUFFIX'] == '.dll': + dlls = env.FindIxes(sources, 'SHLIBPREFIX', 'SHLIBSUFFIX') + targets += install(env, dlls, 'bin') + libs = env.FindIxes(sources, 'LIBPREFIX', 'LIBSUFFIX') + targets += install(env, libs, 'lib') + else: + for source in sources: + target_dir = os.path.join(install_dir, 'lib') + target_name = '.'.join((str(source),) + version) + last = env.InstallAs(os.path.join(target_dir, target_name), source) + targets += last + while len(version): + version = version[:-1] + target_name = '.'.join((str(source),) + version) + action = SCons.Action.Action(symlink, " Symlinking $TARGET ...") + last = env.Command(os.path.join(target_dir, target_name), last, action) + targets += last + return targets + + +def createInstallMethods(env): + env.AddMethod(install_program, 'InstallProgram') + env.AddMethod(install_shared_library, 'InstallSharedLibrary') + + +def num_jobs(): + try: + return int(os.environ['NUMBER_OF_PROCESSORS']) + except (ValueError, KeyError): + pass + + try: + return os.sysconf('SC_NPROCESSORS_ONLN') + except (ValueError, OSError, AttributeError): + pass + + try: + return int(os.popen2("sysctl -n hw.ncpu")[1].read()) + except ValueError: + pass + + return 1 + + +def pkg_config_modules(env, name, modules): + '''Simple wrapper for pkg-config.''' + + env[name] = False + + if env['platform'] == 'windows': + return + + if not env.Detect('pkg-config'): + return + + if subprocess.call(["pkg-config", "--exists", ' '.join(modules)]) != 0: + return + + # Put -I and -L flags directly into the environment, as these don't affect + # the compilation of targets that do not use them + try: + env.ParseConfig('pkg-config --cflags-only-I --libs-only-L ' + ' '.join(modules)) + except OSError: + return + + # Other flags may affect the compilation of unrelated targets, so store + # them with a prefix, (e.g., XXX_CFLAGS, XXX_LIBS, etc) + try: + flags = env.ParseFlags('!pkg-config --cflags-only-other --libs-only-l --libs-only-other ' + ' '.join(modules)) + except OSError: + return + prefix = name.upper() + '_' + for flag_name, flag_value in flags.iteritems(): + env[prefix + flag_name] = flag_value + + env[name] = True + + + +def generate(env): + """Common environment generation code""" + + # Tell tools which machine to compile for + env['TARGET_ARCH'] = env['machine'] + env['MSVS_ARCH'] = env['machine'] + + # Toolchain + platform = env['platform'] + if env['toolchain'] == 'default': + if platform == 'winddk': + env['toolchain'] = 'winddk' + elif platform == 'wince': + env['toolchain'] = 'wcesdk' + env.Tool(env['toolchain']) + + # Allow override compiler and specify additional flags from environment + if os.environ.has_key('CC'): + env['CC'] = os.environ['CC'] + # Update CCVERSION to match + pipe = SCons.Action._subproc(env, [env['CC'], '--version'], + stdin = 'devnull', + stderr = 'devnull', + stdout = subprocess.PIPE) + if pipe.wait() == 0: + line = pipe.stdout.readline() + match = re.search(r'[0-9]+(\.[0-9]+)+', line) + if match: + env['CCVERSION'] = match.group(0) + if os.environ.has_key('CFLAGS'): + env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS']) + if os.environ.has_key('CXX'): + env['CXX'] = os.environ['CXX'] + if os.environ.has_key('CXXFLAGS'): + env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS']) + if os.environ.has_key('LDFLAGS'): + env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS']) + + env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-') + env['msvc'] = env['CC'] == 'cl' + + if env['msvc'] and env['toolchain'] == 'default' and env['machine'] == 'x86_64': + # MSVC x64 support is broken in earlier versions of scons + env.EnsurePythonVersion(2, 0) + + # shortcuts + machine = env['machine'] + platform = env['platform'] + x86 = env['machine'] == 'x86' + ppc = env['machine'] == 'ppc' + gcc = env['gcc'] + msvc = env['msvc'] + + # Determine whether we are cross compiling; in particular, whether we need + # to compile code generators with a different compiler as the target code. + host_platform = _platform.system().lower() + if host_platform.startswith('cygwin'): + host_platform = 'cygwin' + host_machine = os.environ.get('PROCESSOR_ARCHITEW6432', os.environ.get('PROCESSOR_ARCHITECTURE', _platform.machine())) + host_machine = { + 'x86': 'x86', + 'i386': 'x86', + 'i486': 'x86', + 'i586': 'x86', + 'i686': 'x86', + 'ppc' : 'ppc', + 'AMD64': 'x86_64', + 'x86_64': 'x86_64', + }.get(host_machine, 'generic') + env['crosscompile'] = platform != host_platform + if machine == 'x86_64' and host_machine != 'x86_64': + env['crosscompile'] = True + env['hostonly'] = False + + # Backwards compatability with the debug= profile= options + if env['build'] == 'debug': + if not env['debug']: + print 'scons: warning: debug option is deprecated and will be removed eventually; use instead' + print + print ' scons build=release' + print + env['build'] = 'release' + if env['profile']: + print 'scons: warning: profile option is deprecated and will be removed eventually; use instead' + print + print ' scons build=profile' + print + env['build'] = 'profile' + if False: + # Enforce SConscripts to use the new build variable + env.popitem('debug') + env.popitem('profile') + else: + # Backwards portability with older sconscripts + if env['build'] in ('debug', 'checked'): + env['debug'] = True + env['profile'] = False + if env['build'] == 'profile': + env['debug'] = False + env['profile'] = True + if env['build'] == 'release': + env['debug'] = False + env['profile'] = False + + # Put build output in a separate dir, which depends on the current + # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample + build_topdir = 'build' + build_subdir = env['platform'] + if env['machine'] != 'generic': + build_subdir += '-' + env['machine'] + if env['build'] != 'release': + build_subdir += '-' + env['build'] + build_dir = os.path.join(build_topdir, build_subdir) + # Place the .sconsign file in the build dir too, to avoid issues with + # different scons versions building the same source file + env['build_dir'] = build_dir + env.SConsignFile(os.path.join(build_dir, '.sconsign')) + if 'SCONS_CACHE_DIR' in os.environ: + print 'scons: Using build cache in %s.' % (os.environ['SCONS_CACHE_DIR'],) + env.CacheDir(os.environ['SCONS_CACHE_DIR']) + env['CONFIGUREDIR'] = os.path.join(build_dir, 'conf') + env['CONFIGURELOG'] = os.path.join(os.path.abspath(build_dir), 'config.log') + + # Parallel build + if env.GetOption('num_jobs') <= 1: + env.SetOption('num_jobs', num_jobs()) + + env.Decider('MD5-timestamp') + env.SetOption('max_drift', 60) + + # C preprocessor options + cppdefines = [] + if env['build'] in ('debug', 'checked'): + cppdefines += ['DEBUG'] + else: + cppdefines += ['NDEBUG'] + if env['build'] == 'profile': + cppdefines += ['PROFILE'] + if platform == 'windows': + cppdefines += [ + 'WIN32', + '_WINDOWS', + #'_UNICODE', + #'UNICODE', + # http://msdn.microsoft.com/en-us/library/aa383745.aspx + ('_WIN32_WINNT', '0x0601'), + ('WINVER', '0x0601'), + ] + if msvc and env['toolchain'] != 'winddk': + cppdefines += [ + 'VC_EXTRALEAN', + '_USE_MATH_DEFINES', + '_CRT_SECURE_NO_WARNINGS', + '_CRT_SECURE_NO_DEPRECATE', + '_SCL_SECURE_NO_WARNINGS', + '_SCL_SECURE_NO_DEPRECATE', + ] + if env['build'] in ('debug', 'checked'): + cppdefines += ['_DEBUG'] + if env['toolchain'] == 'winddk': + # Mimic WINDDK's builtin flags. See also: + # - WINDDK's bin/makefile.new i386mk.inc for more info. + # - buildchk_wxp_x86.log files, generated by the WINDDK's build + # - http://alter.org.ua/docs/nt_kernel/vc8_proj/ + if machine == 'x86': + cppdefines += ['_X86_', 'i386'] + if machine == 'x86_64': + cppdefines += ['_AMD64_', 'AMD64'] + if platform == 'winddk': + cppdefines += [ + 'STD_CALL', + ('CONDITION_HANDLING', '1'), + ('NT_INST', '0'), + ('WIN32', '100'), + ('_NT1X_', '100'), + ('WINNT', '1'), + ('_WIN32_WINNT', '0x0501'), # minimum required OS version + ('WINVER', '0x0501'), + ('_WIN32_IE', '0x0603'), + ('WIN32_LEAN_AND_MEAN', '1'), + ('DEVL', '1'), + ('__BUILDMACHINE__', 'WinDDK'), + ('FPO', '0'), + ] + if env['build'] in ('debug', 'checked'): + cppdefines += [('DBG', 1)] + if platform == 'wince': + cppdefines += [ + '_CRT_SECURE_NO_DEPRECATE', + '_USE_32BIT_TIME_T', + 'UNICODE', + '_UNICODE', + ('UNDER_CE', '600'), + ('_WIN32_WCE', '0x600'), + 'WINCEOEM', + 'WINCEINTERNAL', + 'WIN32', + 'STRICT', + 'x86', + '_X86_', + 'INTERNATIONAL', + ('INTLMSG_CODEPAGE', '1252'), + ] + if platform == 'windows': + cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_USER'] + if platform == 'winddk': + cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY'] + if platform == 'wince': + cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE'] + cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL'] + if platform == 'embedded': + cppdefines += ['PIPE_OS_EMBEDDED'] + env.Append(CPPDEFINES = cppdefines) + + # C compiler options + cflags = [] # C + cxxflags = [] # C++ + ccflags = [] # C & C++ + if gcc: + ccversion = env['CCVERSION'] + if env['build'] == 'debug': + ccflags += ['-O0'] + elif ccversion.startswith('4.2.'): + # gcc 4.2.x optimizer is broken + print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations" + ccflags += ['-O0'] + else: + ccflags += ['-O3'] + ccflags += ['-g3'] + if env['build'] in ('checked', 'profile'): + # See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling? + ccflags += [ + '-fno-omit-frame-pointer', + '-fno-optimize-sibling-calls', + ] + if env['machine'] == 'x86': + ccflags += [ + '-m32', + #'-march=pentium4', + ] + if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2') \ + and (platform != 'windows' or env['build'] == 'debug' or True): + # NOTE: We need to ensure stack is realigned given that we + # produce shared objects, and have no control over the stack + # alignment policy of the application. Therefore we need + # -mstackrealign ore -mincoming-stack-boundary=2. + # + # XXX: -O and -mstackrealign causes stack corruption on MinGW + # + # XXX: We could have SSE without -mstackrealign if we always used + # __attribute__((force_align_arg_pointer)), but that's not + # always the case. + ccflags += [ + '-mstackrealign', # ensure stack is aligned + '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics + #'-mfpmath=sse', + ] + if platform in ['windows', 'darwin']: + # Workaround http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216 + ccflags += ['-fno-common'] + if env['machine'] == 'x86_64': + ccflags += ['-m64'] + if platform == 'darwin': + ccflags += ['-fno-common'] + # See also: + # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html + ccflags += [ + '-Wall', + '-Wno-long-long', + '-ffast-math', + '-fmessage-length=0', # be nice to Eclipse + ] + cflags += [ + '-Wmissing-prototypes', + '-std=gnu99', + ] + if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.0'): + ccflags += [ + '-Wmissing-field-initializers', + ] + if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'): + ccflags += [ + '-Werror=pointer-arith', + ] + cflags += [ + '-Werror=declaration-after-statement', + ] + if msvc: + # See also: + # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx + # - cl /? + if env['build'] == 'debug': + ccflags += [ + '/Od', # disable optimizations + '/Oi', # enable intrinsic functions + '/Oy-', # disable frame pointer omission + ] + else: + ccflags += [ + '/O2', # optimize for speed + ] + if env['build'] == 'release': + ccflags += [ + '/GL', # enable whole program optimization + ] + else: + ccflags += [ + '/GL-', # disable whole program optimization + ] + ccflags += [ + '/fp:fast', # fast floating point + '/W3', # warning level + #'/Wp64', # enable 64 bit porting warnings + ] + if env['machine'] == 'x86': + ccflags += [ + #'/arch:SSE2', # use the SSE2 instructions + ] + if platform == 'windows': + ccflags += [ + # TODO + ] + if platform == 'winddk': + ccflags += [ + '/Zl', # omit default library name in .OBJ + '/Zp8', # 8bytes struct member alignment + '/Gy', # separate functions for linker + '/Gm-', # disable minimal rebuild + '/WX', # treat warnings as errors + '/Gz', # __stdcall Calling convention + '/GX-', # disable C++ EH + '/GR-', # disable C++ RTTI + '/GF', # enable read-only string pooling + '/G6', # optimize for PPro, P-II, P-III + '/Ze', # enable extensions + '/Gi-', # disable incremental compilation + '/QIfdiv-', # disable Pentium FDIV fix + '/hotpatch', # prepares an image for hotpatching. + #'/Z7', #enable old-style debug info + ] + if platform == 'wince': + # See also C:\WINCE600\public\common\oak\misc\makefile.def + ccflags += [ + '/Zl', # omit default library name in .OBJ + '/GF', # enable read-only string pooling + '/GR-', # disable C++ RTTI + '/GS', # enable security checks + # Allow disabling language conformance to maintain backward compat + #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef + #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules + #'/wd4867', + #'/wd4430', + #'/MT', + #'/U_MT', + ] + # Automatic pdb generation + # See http://scons.tigris.org/issues/show_bug.cgi?id=1656 + env.EnsureSConsVersion(0, 98, 0) + env['PDB'] = '${TARGET.base}.pdb' + env.Append(CCFLAGS = ccflags) + env.Append(CFLAGS = cflags) + env.Append(CXXFLAGS = cxxflags) + + if env['platform'] == 'windows' and msvc: + # Choose the appropriate MSVC CRT + # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx + if env['build'] in ('debug', 'checked'): + env.Append(CCFLAGS = ['/MTd']) + env.Append(SHCCFLAGS = ['/LDd']) + else: + env.Append(CCFLAGS = ['/MT']) + env.Append(SHCCFLAGS = ['/LD']) + + # Assembler options + if gcc: + if env['machine'] == 'x86': + env.Append(ASFLAGS = ['-m32']) + if env['machine'] == 'x86_64': + env.Append(ASFLAGS = ['-m64']) + + # Linker options + linkflags = [] + shlinkflags = [] + if gcc: + if env['machine'] == 'x86': + linkflags += ['-m32'] + if env['machine'] == 'x86_64': + linkflags += ['-m64'] + if env['platform'] not in ('darwin'): + shlinkflags += [ + '-Wl,-Bsymbolic', + ] + # Handle circular dependencies in the libraries + if env['platform'] in ('darwin'): + pass + else: + env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group' + if msvc: + if env['build'] == 'release': + # enable Link-time Code Generation + linkflags += ['/LTCG'] + env.Append(ARFLAGS = ['/LTCG']) + if platform == 'windows' and msvc: + # See also: + # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx + linkflags += [ + '/fixed:no', + '/incremental:no', + ] + if platform == 'winddk': + linkflags += [ + '/merge:_PAGE=PAGE', + '/merge:_TEXT=.text', + '/section:INIT,d', + '/opt:ref', + '/opt:icf', + '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221', + '/incremental:no', + '/fullbuild', + '/release', + '/nodefaultlib', + '/wx', + '/debug', + '/debugtype:cv', + '/version:5.1', + '/osversion:5.1', + '/functionpadmin:5', + '/safeseh', + '/pdbcompress', + '/stack:0x40000,0x1000', + '/driver', + '/align:0x80', + '/subsystem:native,5.01', + '/base:0x10000', + + '/entry:DrvEnableDriver', + ] + if env['build'] != 'release': + linkflags += [ + '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx + ] + if platform == 'wince': + linkflags += [ + '/nodefaultlib', + #'/incremental:no', + #'/fullbuild', + '/entry:_DllMainCRTStartup', + ] + env.Append(LINKFLAGS = linkflags) + env.Append(SHLINKFLAGS = shlinkflags) + + # We have C++ in several libraries, so always link with the C++ compiler + if env['gcc']: + env['LINK'] = env['CXX'] + + # Default libs + env.Append(LIBS = []) + + # Load tools + env.Tool('lex') + env.Tool('yacc') + if env['llvm']: + env.Tool('llvm') + + pkg_config_modules(env, 'x11', ['x11', 'xext']) + pkg_config_modules(env, 'drm', ['libdrm']) + pkg_config_modules(env, 'drm_intel', ['libdrm_intel']) + pkg_config_modules(env, 'drm_radeon', ['libdrm_radeon']) + pkg_config_modules(env, 'xorg', ['xorg-server']) + pkg_config_modules(env, 'kms', ['libkms']) + + env['dri'] = env['x11'] and env['drm'] + + # Custom builders and methods + env.Tool('custom') + createInstallMethods(env) + + # for debugging + #print env.Dump() + + +def exists(env): + return 1 diff --git a/mesalib/src/mesa/drivers/windows/gdi/wgl.c b/mesalib/src/mesa/drivers/windows/gdi/wgl.c index 1dafe6e29..bf4ca9c90 100644 --- a/mesalib/src/mesa/drivers/windows/gdi/wgl.c +++ b/mesalib/src/mesa/drivers/windows/gdi/wgl.c @@ -390,7 +390,7 @@ static FIXED FixedFromDouble(double d) static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar, DWORD numChars, DWORD listBase) { -#define VERIFY(a) a +#define VERIFY(a) (void)(a) TEXTMETRIC metric; BITMAPINFO *dibInfo; -- cgit v1.2.3