#!/bin/sh
#
# gitradeonhd.sh
#
# Made by Mike Thomas
# on best understanding of instructions at
#   http://www.x.org/wiki/radeonhd:DRI
#
# REMARK:
# It was necessary to remove file
#   /usr/include/xorg/xf86_ansic.h
# in order to avoid a runtime error "undefined symbol xf86stat".
#
#
WOMBAT1="/home/rmthomas/h1"
WOMBAT2="/home/rmthomas/h2"
SRC="/var/tmp/radeonhd-dri"
PKG_CONFIG_PATH=$SRC
if [ ! -d $SRC ]; then mkdir $SRC; fi
cd $SRC

git clone git://anongit.freedesktop.org/git/mesa/drm
git clone git://anongit.freedesktop.org/git/mesa/mesa
git clone git://anongit.freedesktop.org/git/xorg/xserver
git clone git://anongit.freedesktop.org/git/xorg/driver/xf86-video-radeonhd
wget ftp://ftp.freedesktop.org/pub/individual/proto/dri2proto-1.1.tar.bz2 -a wget.log
wget ftp://ftp.freedesktop.org/pub/individual/proto/xextproto-7.0.3.tar.bz2 -a wget.log
wget ftp://ftp.freedesktop.org/pub/individual/proto/xproto-7.0.13.tar.bz2 -a wget.log
wget ftp://ftp.freedesktop.org/pub/individual/lib/pixman-0.10.0.tar.bz2 -a wget.log
git clone git://anongit.freedesktop.org/git/xorg/proto/inputproto
git clone git://anongit.freedesktop.org/git/xorg/driver/xf86-input-mouse
git clone git://anongit.freedesktop.org/git/xorg/driver/xf86-input-keyboard

# ****
# extra, some headers needed to build mesa
git clone git://anongit.freedesktop.org/git/xorg/proto/glproto
cp -p $SRC/glproto/glxint.h $SRC/mesa/include/GL
cp -p $SRC/glproto/glxproto.h $SRC/mesa/include/GL
cp -p $SRC/glproto/glxmd.h $SRC/mesa/include/GL
# ****

# ****
# extra, packages needed to build xserver and others
git clone git://anongit.freedesktop.org/git/xorg/proto/xf86driproto
git clone git://anongit.freedesktop.org/git/xorg/proto/xcmiscproto
git clone git://anongit.freedesktop.org/git/xorg/proto/scrnsaverproto
git clone git://anongit.freedesktop.org/git/xorg/proto/bigreqsproto
git clone git://anongit.freedesktop.org/git/xorg/proto/resourceproto
git clone git://anongit.freedesktop.org/git/xorg/proto/trapproto
git clone git://anongit.freedesktop.org/git/xorg/proto/compositeproto
git clone git://anongit.freedesktop.org/git/xorg/proto/evieproto
git clone git://anongit.freedesktop.org/git/xorg/lib/libxkbfile
git clone git://anongit.freedesktop.org/git/xorg/lib/libXfont
git clone git://anongit.freedesktop.org/git/xorg/lib/libfontenc
git clone git://anongit.freedesktop.org/git/xorg/proto/fontcacheproto
git clone git://anongit.freedesktop.org/git/xorg/lib/libpciaccess
git clone git://anongit.freedesktop.org/git/xorg/proto/xf86dgaproto
# ****

bunzip2 dri2proto-1.1.tar.bz2 && tar xvf dri2proto-1.1.tar
bunzip2 xextproto-7.0.3.tar.bz2 && tar xvf xextproto-7.0.3.tar
bunzip2 xproto-7.0.13.tar.bz2 && tar xvf xproto-7.0.13.tar
bunzip2 pixman-0.10.0.tar.bz2 && tar xvf pixman-0.10.0.tar

#--------------------------------------------------------------------------

>$WOMBAT1
>$WOMBAT2

cd $SRC/drm
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2
cd linux-core
make DRM_MODULES="radeon" 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2
depmod -a

cd $SRC/dri2proto-1.1
./configure --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/mesa
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/xextproto-7.0.3
./configure --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/xproto-7.0.13
./configure --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/inputproto
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/pixman-0.10.0
./configure --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

# ****
# extra, packages needed to build xserver

cd $SRC/glproto
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/xf86driproto
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/xcmiscproto
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/scrnsaverproto
/autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/bigreqsproto
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/resourceproto
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/trapproto
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/compositeproto
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/evieproto
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/libxkbfile
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/fontcacheproto
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/libfontenc
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/libXfont
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/libpciaccess
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/xf86dgaproto
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

# ****

cd $SRC/xserver
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/xf86-input-mouse
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/xf86-input-keyboard
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

cd $SRC/xf86-video-radeonhd
./autogen.sh --prefix=/usr 1>>$WOMBAT1 2>>$WOMBAT2
make 1>>$WOMBAT1 2>>$WOMBAT2
make install 1>>$WOMBAT1 2>>$WOMBAT2

exit 0

#
# REMARK ADDED AFTERWARDS:
#
# Files WOMBAT1 and WOMBAT2 show no obvious errors.
#
