core/catalyst/PKGBUILD
2011-01-05 20:48:47 +00:00

220 lines
6.4 KiB
Bash

#
# Chakra Packages for Chakra, part of chakra-project.org
#
# maintainer (i686): Phil Miller <philm[at]chakra-project[dog]org>
# maintainer (x86_64): Manuel Tortosa <manutortosa[at]chakra-project[dot]org>
_kernver=`pacman -Qf kernel26 | cut -c10-15 | sed 's/kernel26 //g'`-CHAKRA
pkgname=catalyst
pkgver=10.12
pkgrel=2
pkgdesc="AMD/ATI Catalyst drivers for kernel26. fglrx kernel module only"
arch=('i686' 'x86_64')
url="http://www.ati.amd.com"
license=('custom')
depends=('kernel26>=2.6.26' 'kernel26<2.6.38' 'kernel26-headers' "catalyst-utils=${pkgver}" 'gcc-libs' 'gcc>4.0.0' 'make')
conflicts=('catalyst-test' 'nvidia' 'xf86-video-ati' 'xf86-video-radeonhd' 'ati-dri')
install=${pkgname}.install
patch_file="fglrx-2.6.36.patch"
patch_md5="eb58dbf993dbf8d77924055cc8caaeb6"
patch_target="2.6.36"
source=(
http://www2.ati.com/drivers/linux/ati-driver-installer-${pkgver/./-}-x86.x86_64.run
makefile_compat.patch
sema_init.patch
${patch_file})
md5sums=('debf1518bd58c49b49aafddbae60b748'
'3e1b82bd69774ea808da69c983d6a43b'
'ae25aec26013bdd541441617bb112a24'
${patch_md5})
build() {
## Unpack archive
msg "Unpacking archive ..."
/bin/sh ./ati-driver-installer-${pkgver/./-}-x86.x86_64.run --extract archive_files
if [ "${CARCH}" = "x86_64" ]; then
BUILDARCH=x86_64
_archdir=x86_64
fi
if [ "${CARCH}" = "i686" ]; then
BUILDARCH=i386
_archdir=x86
fi
cd "${srcdir}/archive_files/"
patch -Np1 -i ../makefile_compat.patch || return 1
patch -Np1 -i ../fglrx-2.6.36.patch || return 1
if [[ ${_kernver:0:6} == "2.6.37" ]]; then
patch -Np1 -i ../sema_init.patch || return 1
fi
###--- cut ---### ati's code from their make.sh file
# Copyright 1999-2005 ATI Technologies Inc., Markham, Ontario, CANADA.
# All Rights Reserved.
# ==============================================================
# resolve if we are running a SMP enabled kernel
SMP=0
# 1
# grep in OsVersion string for SMP specific keywords
OsVersion=`uname -v`
if [ `echo $OsVersion | grep [sS][mM][pP] -c` -ne 0 ]; then
SMP=1
echo "OsVersion says: SMP=$SMP"
fi
# 2
# grep in /proc/ksyms for SMP specific kernel symbols
# use triggerlevel of 10 occurences
# (UP kernels might have 0-1, SMP kernels might have 32-45 or much more)
src_file=/proc/kallsyms
if [ -e $src_file ]; then
if [ `fgrep smp $src_file -c` -gt 10 ]; then
SMP=1
echo "file $src_file says: SMP=$SMP"
fi
fi
# 3
# linux/autoconf.h may contain this: #define CONFIG_SMP 1
# Before 2.6.33 autoconf.h is under linux/.
# For 2.6.33 and later autoconf.h is under generated/.
if [ -f /lib/modules/${_kernver}/build/include/generated/autoconf.h ]; then
autoconf_h=/lib/modules/${_kernver}/build/include/generated/autoconf.h
else
autoconf_h=/lib/modules/${_kernver}/build/include/linux/autoconf.h
fi
src_file=$autoconf_h
if [ ! -e $src_file ]; then
echo "Warning:"
echo "kernel includes at /lib/modules/${_kernver}/build/include not found or incomplete"
echo "file: $src_file"
echo ""
else
if [ `cat $src_file | grep "#undef" | grep "CONFIG_SMP" -c` = 0 ]; then
SMP=`cat $src_file | grep CONFIG_SMP | cut -d' ' -f3`
echo "file $src_file says: SMP=$SMP"
fi
fi
if [ "$SMP" = 0 ]; then
echo "assuming default: SMP=$SMP"
fi
# act on final result
if [ ! "$SMP" = 0 ]; then
smp="-SMP"
def_smp=-D__SMP__
fi
# ==============================================================
# resolve whether we need to set PAGE_ATTR_FIX
PAGE_ATTR_FIX=0
src_file=/proc/kallsyms
if [ -e $src_file ]; then
if [ `fgrep " change_page_attr\$" $src_file -c` -gt 0 ]; then
PAGE_ATTR_FIX=1
echo "file $src_file says: PAGE_ATTR_FIX=$PAGE_ATTR_FIX"
fi
fi
# ==============================================================
# resolve if we are running a MODVERSIONS enabled kernel
MODVERSIONS=0
# autoconf.h may contain this: #define CONFIG_MODVERSIONS 1
src_file=$autoconf_h
if [ ! -e $src_file ];
then
echo "Warning:"
echo "kernel includes at /lib/modules/${_kernver}/build/include not found or incomplete"
echo "file: $src_file"
echo ""
else
if [ `cat $src_file | grep "#undef" | grep "CONFIG_MODVERSIONS" -c` = 0 ]
then
MODVERSIONS=`cat $src_file | grep CONFIG_MODVERSIONS | cut -d' ' -f3`
echo "file $src_file says: MODVERSIONS=$MODVERSIONS"
fi
fi
if [ "$MODVERSIONS" = 0 ]
then
echo "assuming default: MODVERSIONS=$MODVERSIONS"
fi
# act on final result
if [ ! "$MODVERSIONS" = 0 ]
then
def_modversions="-DMODVERSIONS"
fi
# ==============================================================
# resolve if we are building for a kernel with a fix for CVE-2010-3081
# On kernels with the fix, use arch_compat_alloc_user_space instead
# of compat_alloc_user_space since the latter is GPL-only
COMPAT_ALLOC_USER_SPACE=compat_alloc_user_space
src_file=/lib/modules/${_kernver}/build/arch/x86/include/asm/compat.h
if [ ! -e $src_file ];
then
echo "Warning:"
echo "kernel includes at /lib/modules/${_kernver}/build/include not found or incomplete"
echo "file: $src_file"
echo ""
else
if [ `cat $src_file | grep -c arch_compat_alloc_user_space` -gt 0 ]
then
COMPAT_ALLOC_USER_SPACE=arch_compat_alloc_user_space
fi
echo "file $src_file says: COMPAT_ALLOC_USER_SPACE=$COMPAT_ALLOC_USER_SPACE"
fi
# ==============================================================
###--- cut ---###
cd "${srcdir}/archive_files/common/lib/modules/fglrx/build_mod"
cp "${srcdir}/archive_files/arch/${_archdir}/lib/modules/fglrx/build_mod/libfglrx_ip.a.GCC4" . || return 1
cp 2.6.x/Makefile . || return 1
## Compiling module
make -C /lib/modules/${_kernver}/build SUBDIRS="`pwd`" ARCH=${BUILDARCH} \
MODFLAGS="-DMODULE -DATI -DFGL -DPAGE_ATTR_FIX=$PAGE_ATTR_FIX -DCOMPAT_ALLOC_USER_SPACE=$COMPAT_ALLOC_USER_SPACE $def_smp $def_modversions" \
PAGE_ATTR_FIX=$PAGE_ATTR_FIX COMPAT_ALLOC_USER_SPACE=$COMPAT_ALLOC_USER_SPACE modules || return 1
}
package() {
cd "${srcdir}/archive_files/common/lib/modules/fglrx/build_mod"
install -m755 -d "${pkgdir}/lib/modules/${_kernver}/video/" || return 1
install -m644 fglrx.ko "${pkgdir}/lib/modules/${_kernver}/video/" || return 1
install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
## License
install -m644 "${srcdir}/archive_files/ATI_LICENSE.TXT" "${pkgdir}/usr/share/licenses/${pkgname}/" || return 1
sed -i -e "s/KERNEL_VERSION=.*/KERNEL_VERSION=${_kernver}/" $startdir/*.install
}