1{ stdenv, fetchzip, libX11, libXScrnSaver, libXext, libXft, libXrender
2, freetype, zlib, fontconfig
3}:
4
5let
6 maybe64 = if stdenv.isx86_64 then "_64" else "";
7 libPath = stdenv.lib.makeLibraryPath
8 [ stdenv.cc.cc.lib libX11 libXScrnSaver libXext libXft libXrender freetype
9 zlib fontconfig
10 ];
11in
12stdenv.mkDerivation rec {
13 version = "2.16";
14 name = "sam-ba-${version}";
15
16 src = fetchzip {
17 url = "http://www.atmel.com/dyn/resources/prod_documents/sam-ba_${version}_linux.zip";
18 sha256 = "18lsi4747900cazq3bf0a87n3pc7751j5papj9sxarjymcz9vks4";
19 };
20
21 # Pre-built binary package. Install everything to /opt/sam-ba to not mess up
22 # the internal directory structure. Then create wrapper in /bin. Attemts to
23 # use "patchelf --set-rpath" instead of setting LD_PRELOAD_PATH failed.
24 installPhase = ''
25 mkdir -p "$out/bin/" \
26 "$out/opt/sam-ba/"
27 cp -a . "$out/opt/sam-ba/"
28 patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$out/opt/sam-ba/sam-ba${maybe64}"
29 cat > "$out/bin/sam-ba" << EOF
30 export LD_LIBRARY_PATH="${libPath}"
31 exec "$out/opt/sam-ba/sam-ba${maybe64}"
32 EOF
33 chmod +x "$out/bin/sam-ba"
34 '';
35
36 # Do our own thing
37 dontPatchELF = true;
38
39 meta = with stdenv.lib; {
40 description = "Programming tools for Atmel SAM3/7/9 ARM-based microcontrollers";
41 longDescription = ''
42 Atmel SAM-BA software provides an open set of tools for programming the
43 Atmel SAM3, SAM7 and SAM9 ARM-based microcontrollers.
44 '';
45 homepage = http://www.at91.com/linux4sam/bin/view/Linux4SAM/SoftwareTools;
46 # License in <source>/doc/readme.txt
47 license = "BSD-like (partly binary-only)"; # according to Buildroot
48 platforms = [ "x86_64-linux" ]; # patchelf fails on i686-linux
49 maintainers = [ maintainers.bjornfor ];
50 };
51}