-
-
Save ottidmes/1597e644500af2f1258c5bf7dddfac71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ stdenv, fetchurl, kernel ? linuxPackages_latest.kernel, linuxPackages_latest | |
, autoPatchelfHook, libelf, patchelf, unzip | |
, fontconfig, freetype, libGLU_combined, xorg }: | |
with stdenv.lib; | |
let | |
pname = "radeon-${edition}"; | |
edition = "crimson"; | |
version = "15.12"; | |
build = "15.302"; | |
depsDRI = [ | |
xorg.libICE | |
xorg.libSM | |
xorg.libX11 | |
xorg.libXext | |
xorg.libXinerama | |
xorg.libXrandr | |
xorg.libXrender | |
]; | |
deps = [ | |
fontconfig | |
freetype | |
libGLU_combined | |
xorg.imake | |
xorg.libXxf86vm | |
xorg.xf86vidmodeproto | |
] ++ depsDRI; | |
in stdenv.mkDerivation rec { | |
name = "${pname}-${version}-${build}"; | |
hardeningDisable = [ "pic" "format" ]; | |
enableParallelBuilding = true; | |
src = fetchurl { | |
url = "https://www2.ati.com/drivers/linux/${name}-151217a-297685e.zip"; | |
sha256 = "0n0ynqmjkjp5dl5q07as7ps3rlyyn63hq4mlwgd7c7v82ky2skvh"; | |
curlOpts = "--referer https://www.amd.com/en/support/kb/release-notes/rn-rad-lin-15-12"; | |
}; | |
sourceRoot = "."; | |
postUnpack = '' | |
sh "fglrx-${build}/amd-driver-installer-${build}-x86.x86_64.run" --extract . | |
''; | |
# We removed 'grsec_arch.patch', since it did not succeed. | |
patches = let fromKernelVersion = version: optionals (versionAtLeast kernel.version version); in [ | |
./patches/makefile_compat.patch | |
./patches/lano1106_fglrx_intel_iommu.patch | |
./patches/lano1106_kcl_agp_13_4.patch | |
./patches/fglrx_gpl_symbol.patch | |
# ./patches/grsec_arch.patch | |
# ./patches/makesh-dont-check-gcc-version.patch | |
./patches/arch-fglrx-authatieventsd_new.patch | |
] ++ fromKernelVersion "4.4" [ | |
./patches/4.3-kolasa-seq_printf.patch | |
./patches/4.3-gentoo-mtrr.patch | |
./patches/4.4-manjaro-xstate.patch | |
] ++ fromKernelVersion "4.9" [ | |
./patches/4.6-arch-get_user_pages-page_cache_release.patch | |
./patches/4.7-arch-cpu_has_pge-v2.patch | |
./patches/4.9_over_4.6-arch-get_user_pages_remote.patch | |
] ++ fromKernelVersion "4.14" [ | |
./patches/4.10-arch-sling00-virtual_address-acpi_get_table_with_size.patch | |
./patches/4.11-npfeiler-signal_vmf.patch | |
./patches/4.12-npfeiler-PUD_OFFSET.patch | |
./patches/4.12-arch-remove_clts.patch | |
./patches/4.12-npfeiler-movsl_mask.patch | |
./patches/4.13-npfeiler-wait_queue_t.patch | |
./patches/4.14-npfeiler-task_struct-mm_segment_t.patch | |
./patches/4.14.21_4.15.5-npfeiler-flush_tlb_one_kernel.patch | |
] ++ fromKernelVersion "4.17" [ | |
./patches/4.17-npfeiler-pci_get_domain_bus_and_slot.patch | |
]; | |
postPatch = '' | |
cp -f ${./make.sh} common/lib/modules/fglrx/build_mod/make.sh | |
''; | |
buildInputs = [ | |
autoPatchelfHook | |
libelf | |
patchelf | |
unzip | |
] ++ deps; | |
kernelDev = kernel.dev; | |
kernelVersion = kernel.modDirVersion; | |
buildPhase = '' | |
( source common/lib/modules/fglrx/build_mod/make.sh ) | |
''; | |
installPhase = '' | |
mkdirp() { | |
mkdir -p "$@" | |
echo "$@" | |
} | |
cp -r common/etc $(mkdirp $out) | |
cp -r common/usr/{include,sbin,share,X11R6/bin} $out | |
cp -r xpic_64a/usr/X11R6/lib64/* $(mkdirp $out/lib/xorg) | |
cp common/lib/modules/fglrx/build_mod/2.6.x/fglrx.ko $(mkdirp $out/lib/modules/$kernelVersion/kernel/drivers/misc) | |
cp -r arch/x86_64/usr/X11R6/lib64/*.so* $out/lib | |
cp -r arch/x86_64/usr/X11R6/lib64/modules/dri $out/lib | |
ln -s $out/lib{/dri,}/fglrx_dri.so | |
cp arch/x86_64/usr/X11R6/lib64/fglrx/fglrx-libGL.so.1.2 $out/lib | |
# FIXME: This could be conciser. | |
ln -s $out/lib/{fglrx-libGL.so.1.2,libGL.so} | |
ln -s $out/lib/{fglrx-libGL.so.1.2,libGL.so.1} | |
cp -r arch/x86_64/usr/lib64/* $out/lib | |
ln -s $out/lib/libatiuki.so.1{.0,} | |
# Make xorg use the fglrx version. | |
ln -s $out/lib/xorg/modules/extensions/{fglrx/fglrx-libglx.so,libglx.so} | |
''; | |
preFixup = '' | |
# Based on: find . -name '*.so*' -type f -exec sh -c 'if strings {} | grep -q /usr/X11R6/lib/modules/dri; then echo {}; fi' \; | |
for lib in \ | |
fglrx-libGL.so.1.2 \ | |
dri/fglrx_dri.so \ | |
xorg/modules/extensions/fglrx/fglrx-libglx.so \ | |
xorg/modules/glesx.so | |
do | |
sed -i 's|/usr/X11R6/lib/modules/dri|/run/opengl-driver/lib/dri|' $out/lib/$lib | |
done | |
''; | |
extraLibsDRI = map (dep: dep.out) depsDRI; | |
postFixup = '' | |
for pkg in $extraLibsDRI; do | |
for lib in $pkg/lib/*.so*; do | |
ln -s $lib $out/lib | |
done | |
done | |
''; | |
meta = { | |
description = "AMD Radeon Software Crimson Edition 15.12 Proprietary Linux x86_64 Display Driver"; | |
homepage = https://www.amd.com/en/support; | |
license = licenses.unfree; | |
maintainers = with maintainers; [ msteen ]; | |
platforms = [ "x86_64-linux" ]; | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright 1999-2005 ATI Technologies Inc., Markham, Ontario, CANADA. | |
# All Rights Reserved. | |
# | |
# Your use and or redistribution of this software in source and \ or | |
# binary form, with or without modification, is subject to: (i) your | |
# ongoing acceptance of and compliance with the terms and conditions of | |
# the ATI Technologies Inc. software End User License Agreement; and (ii) | |
# your inclusion of this notice in any version of this software that you | |
# use or redistribute. A copy of the ATI Technologies Inc. software End | |
# User License Agreement is included with this software and is also | |
# available by contacting ATI Technologies Inc. at http://www.ati.com | |
# ============================================================== | |
# External environment variables | |
# | |
# FGLRX_DEBUG | |
# Set this variable to backup kernel module before stripping | |
# The nonstripped version will be names like fglrx_dbg.ko | |
# ============================================================== | |
# local variables and files | |
current_wd=`pwd` | |
MODULE=fglrx | |
LIBIP_PREFIX=$current_wd/arch/x86_64/lib/modules/fglrx/build_mod | |
CC=gcc | |
# ============================================================== | |
# assing default location of linux kernel headers | |
linuxbuild=$(echo $kernelDev/lib/modules/$kernelVersion/build) | |
linuxsources=$(echo $kernelDev/lib/modules/$kernelVersion/source) | |
linuxincludes=$linuxbuild/include | |
# ============================================================== | |
# locate and verify contents of kernel include file path | |
# verify match with respective line in linux/version.h | |
# sample: #define UTS_RELEASE "2.4.0-test7" | |
# Before kernel 3.7.0 version.h is normally located at linux/version.h | |
# For 3.7.0 and later version.h is in generated/uapi/linux/version.h | |
headerexist=0 | |
for src_file in \ | |
"$linuxincludes/linux/version.h" \ | |
"$linuxincludes/generated/uapi/linux/version.h"; | |
do | |
if [ -e $src_file ]; then | |
headerexist=1 | |
break | |
fi | |
done | |
if [ $headerexist -eq 0 ]; then | |
echo "kernel includes at $linuxincludes not found or incomplete" >&2 | |
exit 1 | |
fi | |
# ============================================================== | |
# resolve if we are running a SMP enabled kernel | |
autoconf_h=$linuxincludes/generated/autoconf.h | |
src_file=$autoconf_h | |
if [ ! -e $src_file ]; then | |
echo "file $src_file not found" >&2 | |
exit 1 | |
fi | |
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 | |
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 | |
# ============================================================== | |
# 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 [ `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 | |
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=$linuxsources/arch/x86/include/asm/compat.h | |
if [ ! -e $src_file ]; then | |
echo "Warning: x86 compat.h not found in kernel headers" >&2 | |
echo "file $src_file not found" >&2 | |
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 | |
# ============================================================== | |
# make kernel module and check results | |
kmod_extension=.ko | |
echo "doing Makefile based build for kernel 2.6.x and higher" | |
( | |
cd common/lib/modules/fglrx/build_mod/2.6.x | |
GCC_MAJOR="`gcc --version | grep -o -e ") ." | head -1 | cut -d " " -f 2`" | |
echo "This is a dummy file created to suppress this warning: could not find /lib/modules/fglrx/build_mod/2.6.x/.libfglrx_ip.a.cmd for /lib/modules/fglrx/build_mod/2.6.x/libfglrx_ip.a.GCC${GCC_MAJOR}" > lib${MODULE}_ip.a.GCC${GCC_MAJOR}.cmd | |
make CC=${CC} \ | |
LIBIP_PREFIX=$(echo "$LIBIP_PREFIX" | sed -e 's|^\([^/]\)|../\1|') \ | |
MODFLAGS="-DMODULE -DATI -DFGL -DPAGE_ATTR_FIX=$PAGE_ATTR_FIX -DCOMPAT_ALLOC_USER_SPACE=$COMPAT_ALLOC_USER_SPACE $def_smp $def_modversions" \ | |
KVER=$linuxversion \ | |
KDIR=$linuxbuild \ | |
PAGE_ATTR_FIX=$PAGE_ATTR_FIX | |
) | |
res=$? | |
if [ $res -eq 0 ]; then | |
echo "build succeeded with return value $res" | |
else | |
echo "build failed with return value $res" | |
exit 1 | |
fi | |
#EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment