#!/bin/bash # -*- mode: shell-script; coding: UTF-8 -*- # # Build Xvnc with Xorg 7.4 or 7.5 # set -e PREFIX= MAKE="make" STATIC=0 XORG_VERSION= SRCDIR=`dirname $0`/.. modules="dri2proto \ libpthread-stubs \ glproto \ xf86vidmodeproto \ xextproto \ xproto \ kbproto \ inputproto \ xcmiscproto \ bigreqsproto \ fixesproto \ damageproto \ xf86driproto \ randrproto \ renderproto \ scrnsaverproto \ resourceproto \ fontsproto \ videoproto \ compositeproto \ xineramaproto \ libdrm \ libXau \ xtrans \ libXdmcp \ libX11 \ libXext \ libXxf86vm \ libICE \ libSM \ libXt \ libXmu \ libXfixes \ libXdamage \ libXi \ libxkbfile \ libfontenc \ libXfont \ libpciaccess \ pixman" modules74="fontcacheproto \ evieext" init() { update_modules pushd xorg tar jxf ~/.tigervnc-xorg-$XORG_VERSION/util-macros.tar.bz2 pushd util-macros-* echo "Building macros" ./configure ${1+"$@"} --prefix=${PREFIX} ($MAKE install) popd pushd xserver if [ "$XORG_VERSION" = "7.4" ]; then patch -p1 < $SRCDIR/unix/xserver15.patch else patch -p1 < $SRCDIR/unix/xserver18.patch fi for all in `find $SRCDIR/unix/xorg-$XORG_VERSION-patches/ -type f |grep '.*\.patch$'`; do echo Applying $all patch -p1 < $all done popd popd pushd $SRCDIR if [ ! -f ./configure ]; then autoreconf -fiv fi popd } update_modules() { if [ -d xorg ]; then rm -rf xorg; fi if [ -d xorg.build ]; then rm -rf xorg.build; fi mkdir xorg pushd xorg $SRCDIR/unix/download-xorg-$XORG_VERSION for module in ${modules}; do tar jxf ~/.tigervnc-xorg-$XORG_VERSION/${module}.tar.bz2 done [ -r ~/.tigervnc-xorg-$XORG_VERSION/Mesa.tar.bz2 ] && \ tar jxf ~/.tigervnc-xorg-$XORG_VERSION/Mesa.tar.bz2 [ -r ~/.tigervnc-xorg-$XORG_VERSION/Mesa.tar.gz ] && \ tar zxf ~/.tigervnc-xorg-$XORG_VERSION/Mesa.tar.gz tar jxf ~/.tigervnc-xorg-$XORG_VERSION/freetype.tar.bz2 tar jxf ~/.tigervnc-xorg-$XORG_VERSION/xorg-server.tar.bz2 cp -r $SRCDIR/unix/xserver xserver cp -r xorg-server-1.*/* xserver popd } build () { # Build VNC echo "*** Building VNC ***" if [ $STATIC = 1 ]; then VNCCFGFLAGS=--with-included-zlib fi $SRCDIR/configure ${1+"$@"} --prefix=${PREFIX} ${VNCCFGFLAGS} $MAKE # Build Xorg echo "*** Building Xorg ***" pushd xorg for module in ${modules}; do extraoptions="" cd ${module}-* echo ====================== echo configuring ${module} echo ====================== if [ "${module}" = "libX11" ]; then extraoptions="${extraoptions} --without-xcb --disable-specs" fi if [ "${module}" = "libSM" ]; then extraoptions="${extraoptions} --without-libuuid" fi if [ "${module}" = "pixman" ]; then extraoptions="${extraoptions} --disable-gtk" fi if [ $STATIC = 1 ]; then extraoptions="${extraoptions} --enable-static --disable-shared" OLD_CFLAGS=${CFLAGS} OLD_CXXFLAGS=${CXXFLAGS} CFLAGS=${CFLAGS}' -fPIC' CXXFLAGS=${CXXFLAGS}' -fPIC' export CFLAGS CXXFLAGS fi ./configure ${1+"$@"} --prefix="${PREFIX}" ${extraoptions} if [ $STATIC = 1 ]; then CFLAGS=${OLD_CFLAGS} CXXFLAGS=${OLD_CXXFLAGS} export CFLAGS CXXFLAGS fi echo ====================== echo building ${module} echo ====================== if [ $? -ne 0 ]; then echo "Failed to configure ${module}." exit fi $MAKE install cd .. done # build mesa echo "*** Building Mesa ***" pushd Mesa-* ./configure ${1+"$@"} --prefix=${PREFIX} --disable-driglx-direct --with-dri-drivers=swrast --with-driver=dri --disable-glut --without-demos if [ $? -ne 0 ]; then echo "Failed to configure Mesa." exit fi $MAKE $MAKE install popd # build freetype if [ $STATIC = 1 ]; then echo "*** Building freetype ***" pushd freetype-* ./configure ${1+"$@"} --prefix=${PREFIX} --enable-static --disable-shared if [ $? -ne 0 ]; then echo "Failed to configure freetype." exit fi $MAKE install popd fi popd # build xserver echo "*** Building xserver ***" pushd xorg/xserver autoreconf -fiv XORGCFGFLAGS="--disable-xinerama --disable-xvfb --disable-xnest --disable-xorg --disable-dmx --disable-xwin --disable-xephyr --disable-kdrive --disable-config-dbus --disable-config-hal --disable-config-udev --with-sha1=libgcrypt ${XORGCFGFLAGS}" if [ $STATIC = 1 ]; then XORGCFGFLAGS="${XORGCFGFLAGS} --disable-shared --enable-static" fi ./configure ${1+"$@"} --prefix=${PREFIX} ${XORGCFGFLAGS} if [ $? -ne 0 ]; then echo "Failed to configure X server." exit fi $MAKE TIGERVNC_SRCDIR=$SRCDIR install popd } rebuild () { # Build VNC echo "*** Building VNC ***" $MAKE ${1+"$@"} # build xserver echo "*** Building xserver ***" pushd xorg/xserver $MAKE TIGERVNC_SRCDIR=$SRCDIR install ${1+"$@"} popd } usage () { echo "Usage: $0 init -version <7.4 | 7.5>" echo echo " $0 build -version <7.4 | 7.5>" echo " [-static] [additional configure flags]" echo echo " $0 rebuild [additional make options]" echo echo " $0 update -version <7.4 | 7.5>" echo echo "-static = build a stand-alone version of Xvnc which does not depend on" echo " the shared X11 libraries or any distribution-specific shared" echo " system libraries (requires GCC.) Note that this does not enable" echo " static linking with GnuTLS. See BUILDING.txt for instructions" echo " on how to do that." exit 1 } if [ -x '/usr/bin/getconf' ]; then MAKE_PARALLEL=`/usr/bin/getconf _NPROCESSORS_ONLN 2>&1` [ "$MAKE_PARALLEL" -gt 1 ] && MAKE="$MAKE -j$MAKE_PARALLEL" fi while [ $# -gt 0 ] do case "$1" in init) MODE=init ;; build) MODE=build ;; rebuild) MODE=rebuild ;; update) MODE=update ;; -static) STATIC=1 ;; -version) XORG_VERSION=$2; shift ;; -srcdir) SRCDIR=$2; shift ;; *) break ;; esac shift done case "$XORG_VERSION" in 7.4) modules=$modules" "$modules74 ;; 7.5) ;; *) if [ ! "$MODE" = "rebuild" ]; then usage; fi ;; esac pushd $SRCDIR SRCDIR=`pwd` echo "*** Using TigerVNC source tree at $SRCDIR ***" popd if [ "`pwd`" = "$SRCDIR/unix" ]; then cd $SRCDIR fi if [ "$PREFIX" = "" ]; then PREFIX=`pwd`/xorg.build fi if [ $STATIC = 1 -a "$MODE" = "build" ]; then if [ ! -d ./xorg.build/syslib ]; then mkdir -p ./xorg.build/syslib fi for i in "$@"; do case "$i" in CC=*) CC=`echo $i | sed s/^CC=//g` ;; CXX=*) CXX=`echo $i | sed s/^CXX=//g` ;; CFLAGS=*) CFLAGS=`echo $i | sed s/^CFLAGS=//g` ;; CXXFLAGS=*) CXXFLAGS=`echo $i | sed s/^CXXFLAGS=//g` ;; LDFLAGS=*) LDFLAGS=`echo $i | sed s/^LDFLAGS=//g` ;; esac done if [ "$CC" = "" ]; then CC=gcc fi if [ "$CXX" = "" ]; then CXX=g++ fi if [ "$CFLAGS" = "" ]; then CFLAGS=-O3 fi if [ "$CXXFLAGS" = "" ]; then CXXFLAGS=-O3 fi CFLAGS="$CFLAGS -static-libgcc -fPIC" CXXFLAGS="$CXXFLAGS -static-libgcc -fPIC" LDFLAGS="$LDFLAGS -static-libgcc -L`pwd`/xorg.build/syslib" echo CC = $CC echo CXX = $CXX echo CFLAGS = $CFLAGS echo CXXFLAGS = $CXXFLAGS echo LDFLAGS = $LDFLAGS if [ -f ./xorg.build/syslib/libstdc++.a ]; then rm -f ./xorg.build/syslib/libstdc++.a fi LIBSTDCPLUSPLUS=`$CC $CFLAGS -print-file-name=libstdc++.a` if [ ! -f $LIBSTDCPLUSPLUS ]; then echo Cannot find suitable libstdc++.a. Aborting ... exit 1 else ln -fs $LIBSTDCPLUSPLUS ./xorg.build/syslib fi STATICLIBS='libcrypto.a libz.a' for lib in $STATICLIBS; do if [ -f ./xorg.build/syslib/$lib ]; then rm -f ./xorg.build/syslib/$lib fi done IS64BIT=`echo -e "#ifdef __x86_64__\nis64bit_yes\n#else\nis64bit_no\n#endif" | $CC $CFLAGS -E - | grep is64bit` STATICLIBDIR= case $IS64BIT in is64bit_yes) if [ -d /usr/lib64 ]; then STATICLIBDIR=lib64; else STATICLIBDIR=lib; fi ;; is64bit_no) if [ -d /usr/lib32 ]; then STATICLIBDIR=lib32; else STATICLIBDIR=lib; fi ;; *) echo "Cannot determine whether compiler output is 64-bit or 32-bit. Are you using GCC?" exit 1 ;; esac for lib in $STATICLIBS; do if [ -f /usr/$STATICLIBDIR/$lib ]; then ln -fs /usr/$STATICLIBDIR/$lib ./xorg.build/syslib else if [ -f /$STATICLIBDIR/$lib ]; then ln -fs /$STATICLIBDIR/$lib ./xorg.build/syslib else DYLIB=`echo $lib | sed s/\\\.a/\\.so/g` if [ -f /usr/$STATICLIBDIR/$DYLIB -o -f /$STATICLIBDIR/$DYLIB ]; then echo WARNING: Cannot find suitable $lib. Xvnc will depend on $DYLIB. fi fi fi done fi export ACLOCAL="aclocal -I ${PREFIX}/share/aclocal" export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:${PREFIX}/share/pkgconfig" case "$MODE" in init) init ;; build) if [ $STATIC = 1 ]; then build ${1+"$@"} CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" LDFLAGS="$LDFLAGS"; else build ${1+"$@"}; fi ;; rebuild) rebuild ${1+"$@"} ;; update) update ;; *) usage ;; esac