Difference between revisions of "How to compile an experimental X server"

From ThinkWiki
Jump to: navigation, search
m (The script: - fixed accidental commentout)
(cat: howtos)
 
(9 intermediate revisions by one other user not shown)
Line 2: Line 2:
  
 
The following script automates fetching, compilation and installation of the following:
 
The following script automates fetching, compilation and installation of the following:
* Modular X.org server+libraries from CVS and GIT (see http://wiki.x.org/wiki/ModularDevelopersGuide and http://wiki.x.org/wiki/GitPage)
+
* Modular X.org server+libraries from GIT (see http://wiki.x.org/wiki/ModularDevelopersGuide and http://wiki.x.org/wiki/GitPage)
* libDRM and DRM kernel modules (see http://dri.freedesktop.org/wiki/Building)
+
* libDRM and DRM kernel modules from GIT (see http://dri.freedesktop.org/wiki/Building)
* Mesa libraries and DRI drivers (see http://www.mesa3d.org/install.html and http://www.mesa3d.org/cvs_access.html)
+
* Mesa libraries and DRI drivers from CVS (see http://www.mesa3d.org/install.html and http://www.mesa3d.org/cvs_access.html)
 +
* X keyboard configuration database from CVS (see http://www.freedesktop.org/wiki/Software_2fXKeyboardConfig)
 +
* Synaptics touchpad driver from GIT (see http://web.telia.com/~u89404340/touchpad)
  
 
By default all compilation happens in {{path|~/3d-pit}} and everything is installed into {{path|~/3d-pit/install}}. The built DRM kernel module is installed to {{path|/lib/modules/...}}. No other paths are touched (but run as a non-root user, just in case).
 
By default all compilation happens in {{path|~/3d-pit}} and everything is installed into {{path|~/3d-pit/install}}. The built DRM kernel module is installed to {{path|/lib/modules/...}}. No other paths are touched (but run as a non-root user, just in case).
Line 13: Line 15:
  
 
==The script==
 
==The script==
<pre>
+
{{CodeRef|build-experimental-X}}
#!/bin/bash
 
# Script to fetch and build X.org, DRI and Mesa from CVS and GIT.
 
# If you want to skip some tasks, comment them out at the bottom of the script.
 
# Source http://thinkwiki.org/wiki/How_to_compile_an_experimental_X_server
 
# See also:
 
#  http://wiki.x.org/wiki/ModularDevelopersGuide
 
#  http://wiki.x.org/wiki/GitPage
 
#  http://gitweb.freedesktop.org
 
#  http://dri.freedesktop.org/wiki/Building
 
#  http://www.mesa3d.org/cvs_access.html
 
#  http://www.mesa3d.org/install.html
 
 
 
#############################################
 
# Init
 
 
 
PIT=$HOME/3d-pit      # Download and build here
 
DEST=$PIT/install      # Install here
 
# MESA_DATE=2006-06-29 # Set this to get a historical Mesa CVS snapshot
 
FLAGS='-O2 -g -march=pentium-m'
 
 
 
trap "echo Aborting.; exit 1" ERR
 
 
 
die() {
 
  echo "$*"
 
  exit 1
 
}
 
run() {
 
  echo "@ $@"
 
  "$@" || { echo "ERROR: Command \"$*\" failed in `pwd`"; exit 1; }
 
}
 
 
 
#############################################
 
# Fetching and building libDRM and DRM kernel drivers
 
 
 
fetch_drm() {
 
  echo "########### Fetch DRM ###########"
 
  DRI_CVS=:pserver:anonymous@anoncvs.freedesktop.org:2401/cvs/dri
 
  run mkdir -p $PIT
 
  run cd $PIT
 
  grep -qF $DRI_CVS ~/.cvspass || run cvs -d $DRI_CVS login
 
  [ -d drm ] || run cvs -z3 -d $DRI_CVS co drm
 
  run cd drm
 
  run cvs -z3 update -ACPd
 
}
 
 
 
build_libdrm() {
 
  echo "########### Build libdrm ###########"
 
  run cd $PIT/drm
 
  run ./autogen.sh
 
  CFLAGS="$FLAGS" run ./configure --prefix=$DEST --quiet
 
  run make clean
 
  run make
 
  run make install
 
}
 
 
 
build_drm_modules() {
 
  echo "########### Build DRM kernel modules ###########"
 
  run cd $PIT/drm/linux-core
 
  run make DRM_MODULES="radeon"
 
  run sudo sh -c \
 
    'rm -fv /lib/modules/`uname -r`/kernel/drivers/char/drm/*.ko; \
 
    cp -v *.ko /lib/modules/`uname -r`/extra/; \
 
    /sbin/depmod -a'
 
}
 
 
 
#############################################
 
# Fetching Mesa
 
 
 
fetch_mesa() {
 
  echo "########### Fetching Mesa ###########"
 
  MESA_CVS=:pserver:anonymous@anoncvs.freedesktop.org:2401/cvs/mesa
 
  run mkdir -p $PIT
 
  run cd $PIT
 
  grep -qF $MESA_CVS ~/.cvspass || run cvs -d $MESA_CVS login
 
  [ -d Mesa ] || run cvs -z3 -d $MESA_CVS co ${MESA_DATE:+-D $MESA_DATE} Mesa
 
  run cd $PIT/Mesa
 
  run cvs -z3 update -ACPd ${MESA_DATE:+-D $MESA_DATE}
 
}
 
 
 
patch_mesa() {
 
  # patch to make Google Earth use acceleration:
 
  run perl -i -pe 'print "//DISABLE " if m/^\s*FALLBACK_IF.*Line\.SmoothFlag/' \
 
    cd $PIT/Mesa/src/mesa/drivers/dri/r300/r300_render.c
 
}
 
 
 
#############################################
 
# Building Mesa (do this *after* installing X.org)
 
 
 
build_mesa() { (
 
  echo "########### Building Mesa ###########"
 
  # This uses both old-style and new-style vars, to support older Mesa snapshots.
 
  run cd $PIT/Mesa
 
  export DRM_SOURCE_PATH=$PIT/drm
 
  export PKG_CONFIG_PATH="$DEST/lib/pkgconfig:$PKG_CONFIG_PATH"
 
  export DRM_SOURCE_PATH="$PIT/drm"
 
  export DESTDIR=$DEST  INSTALL_DIR=$DEST
 
  export DRI_DRIVER_INSTALL_DIR=$DEST/lib/dri
 
  export DRI_DIRS='r300 r200 r128 radeon'
 
  export OPT_FLAGS="$FLAGS"
 
  export PATH="$DEST/bin:$PATH"
 
  run mkdir -p $DRI_DRIVER_INSTALL_DIR
 
  run make -e linux-dri-x86
 
  run make -e install
 
  run cp -v lib/*_dri.so $DRI_DRIVER_INSTALL_DIR
 
) }
 
 
 
#############################################
 
# X.org setup
 
# This is a list of modules that are in flux and likely to be related to
 
# whatever you're testing (or are required for the build), sorted by
 
# build order (see util/modular/build.sh for dependencies).
 
# Check CVS and the above URLs for other modules.
 
 
 
XORG_DIRS=(
 
  util/macros
 
  proto/{bigreqs,composite,fixes,damage,gl,input,kb,pm,randr,resource}proto
 
  proto/{render,scrnsaver,video}proto
 
  proto/{x11,xf86dga,xf86dri,xf86misc,xf86vidmode,xinerama}proto
 
  lib/lib{xtrans,X11,Xt,Xmu,Xcomposite,Xrender,Xdamage,Xcursor,Xi,Xinerama}
 
  lib/lib{xkbui,Xrandr,Xv,XvMC,Xxf86dga,Xxf86misc,Xxf86vm}
 
  xserver
 
  driver/xf86-video-ati
 
  driver/xf86-input-mouse driver/xf86-input-keyboard
 
)
 
 
 
#############################################
 
# Fetching X.org
 
 
 
fetch_xorg() {
 
  echo "########### Fetching (selected) X.org modules ###########"
 
  XORG_GIT=git://anongit.freedesktop.org/git/xorg
 
  run mkdir -p $PIT/xorg
 
  run cd $PIT/xorg
 
  for D in "${XORG_DIRS[@]}"; do
 
    if [ -d $PIT/xorg/$D ]; then
 
      run cd $PIT/xorg/$D
 
      run git pull
 
    else
 
      run cd $PIT/xorg
 
      run git clone $XORG_GIT/$D $D
 
    fi
 
  done
 
}
 
 
 
#############################################
 
# Building and installing X.org
 
# (On repeated runs we avoid rerunning autotools if nothing changed.)
 
 
 
LAST_HASH=last_dir_hash
 
dir_hash() {
 
  find . \( -path ./$LAST_HASH -o -path ./.git -prune \) -o -ls | sort | md5sum
 
}
 
should_autogen() {
 
  [ ! -f $LAST_HASH ] || [ "`dir_hash`" != "`cat $LAST_HASH`" ]
 
}
 
done_build() {
 
  dir_hash > $LAST_HASH
 
}
 
build_x_module() { (
 
  D=$1
 
  echo "########### Building xorg/$D ###########"
 
  export PATH="$DEST/bin:$PATH"
 
  export PKG_CONFIG_PATH="$DEST/lib/pkgconfig:$PKG_CONFIG_PATH"
 
  export ACLOCAL="${AC_LOCAL:-aclocal} -I $DEST/share/aclocal"
 
  export LD_LIBRARY_PATH="$DEST/lib:$LD_LIBRARY_PATH"
 
  if [ $D == "xserver" ]; then
 
    CONF_OPT="--with-mesa-source=$PIT/Mesa --enable-xorg --disable-dmx --disable-xvfb --disable-xnest"
 
  elif [ $D == "lib/libX11" ]; then
 
    CONF_OPT="--with-xcb=no"
 
  else
 
    CONF_OPT=
 
  fi
 
  run cd $PIT/xorg/$D
 
  if should_autogen; then
 
    CFLAGS="$FLAGS" run sh autogen.sh --prefix=$DEST --quiet --cache-file=$PIT/xorg/autoconf.cache $CONF_OPT
 
  fi
 
  run make
 
  done_build
 
  run make install
 
) }
 
 
 
build_xorg() {
 
  run cd $PIT/xorg
 
  run mkdir -p $DEST/share/aclocal
 
  run mkdir -p $DEST/var/log
 
  for D in "${XORG_DIRS[@]}"; do
 
    build_x_module $D || return 1
 
  done
 
  run sudo sh -c "chown -v root $DEST/bin/Xorg; \
 
                  chmod -v 4711 $DEST/bin/Xorg"
 
}
 
 
 
#############################################
 
# Creating a script which sets env vars
 
 
 
create_xsetenv() {
 
  cat <<EOF > $DEST/bin/xsetenv || die "Can't create $DEST/bin/xsetenv"
 
export PATH="$DEST/bin:$PATH"
 
export LD_LIBRARY_PATH="$DEST/lib:$LD_LIBRARY_PATH"
 
export LIBGL_DRIVERS_PATH=$DEST/lib/dri
 
EOF
 
  echo -e "\nRun '. $DEST/bin/xsetenv' to point env vars to this installation."
 
}
 
 
 
#############################################
 
# Do it:
 
 
 
fetch_drm
 
build_libdrm
 
build_drm_modules
 
fetch_mesa
 
patch_mesa
 
fetch_xorg
 
build_xorg
 
build_mesa
 
create_xsetenv
 
 
 
echo 'Done.'
 
</pre>
 
  
 
==Running==
 
==Running==
Line 240: Line 23:
 
Prepare a config file called (say) {{path|/etc/X11/xorg.dri-test.conf}} with DRI enabled.
 
Prepare a config file called (say) {{path|/etc/X11/xorg.dri-test.conf}} with DRI enabled.
  
Then, exit your current X server (e.g., via {{cmdroot|init 3}}) and run something like:
+
Then, exit your current X server (e.g., via {{cmdroot|init 3}}) and run this for a full session with the new X server:
 +
{{cmduser|1=. ~/3d-pit/install/bin/xsetenv; startx -- ~/3d-pit/install/bin/X -config xorg.dri-test.conf :0 >& xout.log}}
 +
 
 +
For a minimal test session, try something like this instead:
 
{{cmduser|1=. ~/3d-pit/install/bin/xsetenv; X -config xorg.dri-test.conf :0 >& xout.log & ( export DISPLAY=:0; sleep 3; kwin& xterm& )}}
 
{{cmduser|1=. ~/3d-pit/install/bin/xsetenv; X -config xorg.dri-test.conf :0 >& xout.log & ( export DISPLAY=:0; sleep 3; kwin& xterm& )}}
  
If all goes well, you'll get a minimal X session with just an xterm open. Some things to do now:
+
Some things to do now:
 
* {{cmduser|xdriinfo}}
 
* {{cmduser|xdriinfo}}
 
* {{cmduser|1=LIBGL_DEBUG=verbose glxinfo 2>&1 <nowiki>|</nowiki> less}}
 
* {{cmduser|1=LIBGL_DEBUG=verbose glxinfo 2>&1 <nowiki>|</nowiki> less}}
 
* {{cmduser|glxgears}}
 
* {{cmduser|glxgears}}
 
* {{cmduser|sudo less ~3d-pit/install/var/log/Xorg.0.log}}
 
* {{cmduser|sudo less ~3d-pit/install/var/log/Xorg.0.log}}
* {{cmduser|ppracer}} (and report on the [https://bugs.freedesktop.org/show_bug.cgi?id=6991 associated bug] including the relevant {{cmdroot|lspci -v}} lines)
+
* {{cmduser|ppracer}}
 
* {{cmduser|googleearth}} (Linux version [http://earth.google.com/download-earth.html here])
 
* {{cmduser|googleearth}} (Linux version [http://earth.google.com/download-earth.html here])
  
Line 256: Line 42:
  
 
[[Category:Scripts]]
 
[[Category:Scripts]]
 +
[[Category:HOWTOs]]

Latest revision as of 16:40, 2 July 2007

Some functions of the X.org server, such as 3D acceleration for newer cards, are under constant developments. To test the latest features, you need to build the X server and related software directly from the developers' CVS and GIT repositories. Since several projects and dozens of sub-projects are involved, this is a complicated task.

The following script automates fetching, compilation and installation of the following:

By default all compilation happens in ~/3d-pit and everything is installed into ~/3d-pit/install. The built DRM kernel module is installed to /lib/modules/.... No other paths are touched (but run as a non-root user, just in case).

To save time not all X libraries are built, so you'll need the usual X development environment packages installed (see above links).

Currently only the ATI radeon X.org drivers and DRI driver (e.g., r300) are fetched and compiled. If you need different drivers, search for "radeon" "ati" and "r300" and modify as needed.

The script

build-experimental-X (download)

Running

Just run the above. If prompted for a CVS password, press Enter. There are two sudo invocations for which you may need to provide a password.

Prepare a config file called (say) /etc/X11/xorg.dri-test.conf with DRI enabled.

Then, exit your current X server (e.g., via # init 3) and run this for a full session with the new X server: $ . ~/3d-pit/install/bin/xsetenv; startx -- ~/3d-pit/install/bin/X -config xorg.dri-test.conf :0 >& xout.log

For a minimal test session, try something like this instead: $ . ~/3d-pit/install/bin/xsetenv; X -config xorg.dri-test.conf :0 >& xout.log & ( export DISPLAY=:0; sleep 3; kwin& xterm& )

Some things to do now:

  • $ xdriinfo
  • $ LIBGL_DEBUG=verbose glxinfo 2>&1 | less
  • $ glxgears
  • $ sudo less ~3d-pit/install/var/log/Xorg.0.log
  • $ ppracer
  • $ googleearth (Linux version here)

To keep up with the latest CVS and GIT versions, just run the script again. You don't need to (and shouldn't) delete ~/3d-pit beforehand.

If you encounter problems, please file bugs on the Freedesktop Bugzilla.