at 18.03-beta 107 lines 3.9 kB view raw
1{ stdenv, fetchurl, makeWrapper, perl, libGLU_combined, xorg, 2 version? "2.8", # What version 3 samples? false # Should samples be installed 4}: 5 6let 7 8 bits = if stdenv.system == "x86_64-linux" then "64" 9 else "32"; 10 11 arch = if stdenv.system == "x86_64-linux" then "x86_64" 12 else "x86"; 13 14 src_info = { 15 "2.6" = { 16 url = "http://download2-developer.amd.com/amd/APPSDK/AMD-APP-SDK-v2.6-lnx${bits}.tgz"; 17 x86 = "03vyvqp44f96036zsyy8n21ymbzy2bx09hlbd6ci3ikj8g7ic1dm"; 18 x86_64 = "1fj55358s4blxq9bp77k07gqi22n5nfkzwjkbdc62gmy1zxxlhih"; 19 }; 20 21 "2.7" = { 22 url = "http://download2-developer.amd.com/amd/APPSDK/AMD-APP-SDK-v2.7-lnx${bits}.tgz"; 23 x86 = "1v26n7g1xvlg5ralbfk3qiy34gj8fascpnjzm3120b6sgykfp16b"; 24 x86_64 = "08bi43bgnsxb47vbirh09qy02w7zxymqlqr8iikk9aavfxjlmch1"; 25 patches = [ ./gcc-5.patch]; 26 }; 27 28 "2.8" = { 29 url = "http://developer.amd.com/wordpress/media/2012/11/AMD-APP-SDK-v2.8-lnx${bits}.tgz"; 30 x86 = "99610737f21b2f035e0eac4c9e776446cc4378a614c7667de03a82904ab2d356"; 31 x86_64 = "d9c120367225bb1cd21abbcf77cb0a69cfb4bb6932d0572990104c566aab9681"; 32 33 # TODO: Add support for aparapi, java parallel api 34 patches = [ ./01-remove-aparapi-samples.patch ./gcc-5.patch]; 35 }; 36 }; 37 38in stdenv.mkDerivation rec { 39 name = "amdapp-sdk-${version}"; 40 41 src = fetchurl { 42 url = stdenv.lib.getAttrFromPath [version "url"] src_info; 43 sha256 = stdenv.lib.getAttrFromPath [version arch] src_info; 44 }; 45 46 patches = stdenv.lib.attrByPath [version "patches"] [] src_info; 47 48 patchFlags = "-p0"; 49 buildInputs = [ makeWrapper perl libGLU_combined xorg.libX11 xorg.libXext xorg.libXaw xorg.libXi xorg.libXxf86vm ]; 50 propagatedBuildInputs = [ stdenv.cc ]; 51 NIX_LDFLAGS = "-lX11 -lXext -lXmu -lXi -lXxf86vm"; 52 doCheck = false; 53 54 unpackPhase = '' 55 tar xvzf $src 56 tar xf AMD-APP-SDK-v${version}-*-lnx${bits}.tgz 57 cd AMD-APP-SDK-v${version}-*-lnx${bits} 58 ''; 59 60 buildPhase = if !samples then ''echo "nothing to build"'' else null; 61 62 installPhase = '' 63 # Install SDK 64 mkdir -p $out 65 cp -r {docs,include} "$out/" 66 mkdir -p "$out/"{bin,lib,samples/opencl/bin} 67 cp -r "./bin/${arch}/clinfo" "$out/bin/clinfo" 68 cp -r "./lib/${arch}/"* "$out/lib/" 69 70 # Register ICD 71 mkdir -p "$out/etc/OpenCL/vendors" 72 echo "$out/lib/libamdocl${bits}.so" > "$out/etc/OpenCL/vendors/amd.icd" 73 # The OpenCL ICD specifications: http://www.khronos.org/registry/cl/extensions/khr/cl_khr_icd.txt 74 75 # Install includes 76 mkdir -p "$out/usr/include/"{CAL,OpenVideo} 77 install -m644 './include/OpenVideo/'{OVDecode.h,OVDecodeTypes.h} "$out/usr/include/OpenVideo/" 78 79 ${ if samples then '' 80 # Install samples 81 find ./samples/opencl/ -mindepth 1 -maxdepth 1 -type d -not -name bin -exec cp -r {} "$out/samples/opencl" \; 82 cp -r "./samples/opencl/bin/${arch}/"* "$out/samples/opencl/bin" 83 for f in $(find "$out/samples/opencl/bin/" -type f -not -name "*.*"); 84 do 85 wrapProgram "$f" --prefix PATH ":" "${stdenv.cc}/bin" 86 done'' else "" 87 } 88 89 # Create wrappers 90 patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/bin/clinfo 91 patchelf --set-rpath ${stdenv.cc.cc.lib}/lib64:${stdenv.cc.cc.lib}/lib $out/bin/clinfo 92 93 # Fix modes 94 find "$out/" -type f -exec chmod 644 {} \; 95 chmod -R 755 "$out/bin/" 96 find "$out/samples/opencl/bin/" -type f -name ".*" -exec chmod 755 {} \; 97 find "$out/samples/opencl/bin/" -type f -not -name "*.*" -exec chmod 755 {} \; 98 ''; 99 100 meta = with stdenv.lib; { 101 description = "AMD Accelerated Parallel Processing (APP) SDK, with OpenCL 1.2 support"; 102 homepage = http://developer.amd.com/amd-accelerated-parallel-processing-app-sdk/; 103 license = licenses.amd; 104 maintainers = [ maintainers.offline ]; 105 platforms = [ "i686-linux" "x86_64-linux" ]; 106 }; 107}