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

From ThinkWiki
Jump to: navigation, search
m
(The script: - support historical Mesa CVS)
Line 27: Line 27:
 
# Init
 
# Init
  
PIT=$HOME/3d-pit   # Download and build here
+
PIT=$HOME/3d-pit       # Download and build here
DEST=$PIT/install   # Install here
+
DEST=$PIT/install     # Install here
 +
# MESA_DATE=2006-06-29 # Set this to get a historical Mesa CVS snapshot
  
 
set -e -E -v
 
set -e -E -v
Line 39: Line 40:
 
mkdir -p $PIT; cd $PIT
 
mkdir -p $PIT; cd $PIT
 
grep -qF $DRI_CVS ~/.cvspass || cvs -d $DRI_CVS login
 
grep -qF $DRI_CVS ~/.cvspass || cvs -d $DRI_CVS login
[ -d drm ] || cvs -d $DRI_CVS co drm
+
[ -d drm ] || cvs -z3 -d $DRI_CVS co drm
  
 
cd drm
 
cd drm
cvs update -C
+
cvs -z3 update -ACPd
  
 
./autogen.sh
 
./autogen.sh
Line 63: Line 64:
 
mkdir -p $PIT; cd $PIT
 
mkdir -p $PIT; cd $PIT
 
grep -qF $MESA_CVS ~/.cvspass || cvs -d $MESA_CVS login
 
grep -qF $MESA_CVS ~/.cvspass || cvs -d $MESA_CVS login
[ -d Mesa ] || cvs -d $MESA_CVS co Mesa
+
[ -d Mesa ] || cvs -z3 -d $MESA_CVS co ${MESA_DATE:+-D $MESA_DATE} Mesa
  
 
cd Mesa
 
cd Mesa
cvs update -C
+
cvs -z3 update -ACPd ${MESA_DATE:+-D $MESA_DATE}
 
# patch to make Google Earth use acceleration:
 
# patch to make Google Earth use acceleration:
 
perl -i -pe 'print "//DISABLE " if m/^\s*FALLBACK_IF.*Line\.SmoothFlag/' \
 
perl -i -pe 'print "//DISABLE " if m/^\s*FALLBACK_IF.*Line\.SmoothFlag/' \
Line 79: Line 80:
 
X_CVS_DIRS="proto data util \
 
X_CVS_DIRS="proto data util \
 
         driver/xf86-input-mouse driver/xf86-input-keyboard \
 
         driver/xf86-input-mouse driver/xf86-input-keyboard \
         lib/dmx lib/pciaccess lib/Xcomposite \
+
         lib/pciaccess lib/Xcomposite lib/Xcursor lib/Xdamage \
        lib/Xcursor lib/Xdamage lib/Xevie lib/Xext lib/Xfixes \
 
 
         lib/Xi lib/Xinerama lib/xkbui lib/Xmu lib/Xt \
 
         lib/Xi lib/Xinerama lib/xkbui lib/Xmu lib/Xt \
         lib/Xrandr lib/Xrender lib/XRes lib/xtrans \
+
         lib/Xrandr lib/Xrender lib/xtrans \
         lib/XTrap lib/Xv lib/XvMC lib/Xxf86dga lib/Xxf86misc \
+
         lib/Xv lib/XvMC lib/Xxf86dga lib/Xxf86misc \
 
         lib/Xxf86rush lib/Xxf86vm"
 
         lib/Xxf86rush lib/Xxf86vm"
 
X_GIT_DIRS="xserver xcb driver/xf86-video-ati lib/libX11"
 
X_GIT_DIRS="xserver xcb driver/xf86-video-ati lib/libX11"
Line 89: Line 89:
 
# In case of trouble try adding these to X_CVS_DIRS:
 
# In case of trouble try adding these to X_CVS_DIRS:
 
#  lib/Xau lib/ICE lib/SM lib/xkbfile lib/Xpm
 
#  lib/Xau lib/ICE lib/SM lib/xkbfile lib/Xpm
 +
#  lib/Xfixes lib/XTrap lib/dmx lib/XRes lib/Xevie lib/Xext
 
#  lib/AppleWM lib/fontenc lib/FS lib/lbxutil lib/oldX lib/WindowsWM  
 
#  lib/AppleWM lib/fontenc lib/FS lib/lbxutil lib/oldX lib/WindowsWM  
 
#  lib/Xaw lib/Xdmcp lib/Xfont lib/Xfontcache lib/Xft  
 
#  lib/Xaw lib/Xdmcp lib/Xfont lib/Xfontcache lib/Xft  
Line 96: Line 97:
 
grep -qF $XORG_CVS ~/.cvspass || cvs -d $XORG_CVS login
 
grep -qF $XORG_CVS ~/.cvspass || cvs -d $XORG_CVS login
 
for D in $X_CVS_DIRS; do
 
for D in $X_CVS_DIRS; do
   [ -d $D ] || { echo @$D; cvs -d $XORG_CVS co $D; }
+
   [ -d $D ] || { echo @$D; cvs -z3 -d $XORG_CVS co $D; }
 
done
 
done
 
for D in $X_GIT_DIRS; do
 
for D in $X_GIT_DIRS; do
Line 103: Line 104:
 
done
 
done
  
for D in $X_CVS_DIRS; do ( echo @$D; cd $D && cvs update -C ); done |grep -v '^\?'
+
for D in $X_CVS_DIRS; do ( echo @$D; cd $D && cvs -z3 update -ACPd -d ); done |grep -v '^\?'
 
for D in $X_GIT_DIRS; do ( echo @$D; cd $D && git pull ); done
 
for D in $X_GIT_DIRS; do ( echo @$D; cd $D && git pull ); done
  
Line 127: Line 128:
 
         DRI_DIRS=r300 \
 
         DRI_DIRS=r300 \
 
         OPT_FLAGS='-O2 -g -march=pentium-m'
 
         OPT_FLAGS='-O2 -g -march=pentium-m'
 +
  mkdir -p $DRI_DRIVER_INSTALL_DIR
 
   make -e linux-dri-x86
 
   make -e linux-dri-x86
 
   make -e install
 
   make -e install

Revision as of 18:14, 29 June 2006

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 r300 DRI driver are fetched and compiled. If you need different drivers, search for "radeon" and "r300" and modify as needed.

The script

#!/bin/bash
# Script to build X.org, DRI and Mesa from CVS and GIT.
# Source http://thinkwiki.org/index.php?title=How_to_compile_an_experimental_X_server
# See also:
#   http://wiki.x.org/wiki/ModularDevelopersGuide
#   http://wiki.x.org/wiki/GitPage
#   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

set -e -E -v

#############################################
# Fetching and building libDRM and DRM kernel drivers

DRI_CVS=:pserver:anonymous@anoncvs.freedesktop.org:2401/cvs/dri

mkdir -p $PIT; cd $PIT
grep -qF $DRI_CVS ~/.cvspass || cvs -d $DRI_CVS login
[ -d drm ] || cvs -z3 -d $DRI_CVS co drm

cd drm
cvs -z3 update -ACPd

./autogen.sh
CFLAGS=-march=pentium-m XCCFLAGS=-march=pentium=m ./configure --prefix=$DEST
make clean
make
make install

cd $PIT/drm/linux-core
make DRM_MODULES="radeon" 
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

MESA_CVS=:pserver:anonymous@anoncvs.freedesktop.org:2401/cvs/mesa

mkdir -p $PIT; cd $PIT
grep -qF $MESA_CVS ~/.cvspass || cvs -d $MESA_CVS login
[ -d Mesa ] || cvs -z3 -d $MESA_CVS co ${MESA_DATE:+-D $MESA_DATE} Mesa

cd Mesa
cvs -z3 update -ACPd ${MESA_DATE:+-D $MESA_DATE}
# patch to make Google Earth use acceleration:
perl -i -pe 'print "//DISABLE " if m/^\s*FALLBACK_IF.*Line\.SmoothFlag/' \
  ./src/mesa/drivers/dri/r300/r300_render.c 

#############################################
# Fetching and building X.org

XORG_CVS=:pserver:anoncvs@anoncvs.freedesktop.org:2401/cvs/xorg
XORG_GIT=git://anongit.freedesktop.org/git/xorg

X_CVS_DIRS="proto data util \
         driver/xf86-input-mouse driver/xf86-input-keyboard \
         lib/pciaccess lib/Xcomposite lib/Xcursor lib/Xdamage \
         lib/Xi lib/Xinerama lib/xkbui lib/Xmu lib/Xt \
         lib/Xrandr lib/Xrender lib/xtrans \
         lib/Xv lib/XvMC lib/Xxf86dga lib/Xxf86misc \
         lib/Xxf86rush lib/Xxf86vm"
X_GIT_DIRS="xserver xcb driver/xf86-video-ati lib/libX11"

# In case of trouble try adding these to X_CVS_DIRS:
#   lib/Xau lib/ICE lib/SM lib/xkbfile lib/Xpm
#   lib/Xfixes lib/XTrap lib/dmx lib/XRes lib/Xevie lib/Xext
#   lib/AppleWM lib/fontenc lib/FS lib/lbxutil lib/oldX lib/WindowsWM 
#   lib/Xaw lib/Xdmcp lib/Xfont lib/Xfontcache lib/Xft 
#   lib/Xp lib/XprintAppUtil lib/XprintUtil lib/XScrnSaver lib/Xtst

mkdir -p $PIT/xorg; cd $PIT/xorg
grep -qF $XORG_CVS ~/.cvspass || cvs -d $XORG_CVS login
for D in $X_CVS_DIRS; do
  [ -d $D ] || { echo @$D; cvs -z3 -d $XORG_CVS co $D; }
done
for D in $X_GIT_DIRS; do
  G=$XORG_GIT/$D; G=${G/xorg\/xcb/xcb}
  [ -d $D ] || { echo @$D; git clone $G $D; }
done

for D in $X_CVS_DIRS; do ( echo @$D; cd $D && cvs -z3 update -ACPd -d ); done |grep -v '^\?'
for D in $X_GIT_DIRS; do ( echo @$D; cd $D && git pull ); done

( export PATH="$DEST/bin:$PATH" \
         PKG_CONFIG_PATH="$DEST/lib/pkgconfig:$PKG_CONFIG_PATH" \
         CACHE=$PIT/xorg/autoconf.cache  MAKE="make -j2"  QUIET=y
  nice ./util/modular/build.sh -n -m $PIT/Mesa $DEST 2>&1 \
  | tee xbuild.log )
sudo sh -c "chown -v root $DEST/bin/Xorg; \
            chmod -v 4711 $DEST/bin/Xorg"

#############################################
# Building Mesa (after installing X.org)

# This uses both old-style and new-style vars, to support older Mesa snapshots.

cd $PIT/Mesa
( export DRM_SOURCE_PATH=$PIT/drm \
         PKG_CONFIG_PATH="$DEST/lib/pkgconfig:$PKG_CONFIG_PATH" \
         DESTDIR=$DEST \
         INSTALL_DIR=$DEST \
         DRI_DRIVER_INSTALL_DIR=$DEST/lib/dri \
         DRI_DIRS=r300 \
         OPT_FLAGS='-O2 -g -march=pentium-m'
  mkdir -p $DRI_DRIVER_INSTALL_DIR
  make -e linux-dri-x86
  make -e install
  cp -v lib/r300_dri.so $DRI_DRIVER_INSTALL_DIR/ )

#############################################
# Creating a script which sets env vars

cat <<EOF > $DEST/bin/xsetenv
export PATH="$DEST/bin:$PATH" 
export LD_LIBRARY_PATH=$DEST/lib
export LIBGL_DRIVERS_PATH=$DEST/lib/dri
EOF

echo "Run '. $DEST/bin/xsetenv' to point env vars to this installation."

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 something like: $ . ~/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:

  • $ xdriinfo
  • $ LIBGL_DEBUG=verbose glxinfo 2>&1 | less
  • $ glxgears
  • $ sudo less ~3d-pit/install/var/log/Xorg.0.log
  • $ ppracer (and report on the associated bug including the relevant # lspci -v lines)
  • $ 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.