about summary refs log tree commit diff
path: root/pkgs/development/mobile/androidenv/androidndk.nix
blob: 1144826557518754d1c0db53c59ce78654543d98 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{ stdenv, fetchurl, zlib, ncurses
}:

stdenv.mkDerivation rec {
  name = "android-ndk-r9d";

  src = if stdenv.system == "i686-linux"
    then fetchurl {
      url = "http://dl.google.com/android/ndk/${name}-linux-x86.tar.bz2";
      sha256 = "0lrxx8rclmda72dynh0qjr6xpcnv5vs3gc96jcia37h8mmn2xv6m";
    }
    else if stdenv.system == "x86_64-linux" then fetchurl {
      url = "http://dl.google.com/android/ndk/${name}-linux-x86_64.tar.bz2";
      sha256 = "16miwrnf3c7x7rlpmssmjx9kybmapsjyamjyivhabb2wm21x3q8l";
    }
    else throw "platform not ${stdenv.system} supported!";

  phases = "installPhase";

  installPhase = ''
    set -x
    mkdir -pv $out
    tar xf $src
    mv */* $out

    # so that it doesn't fail because of read-only permissions set
    patch -p1 -d $out < ${ ./make-standalone-toolchain.patch }

    find $out \( \
        \( -type f -a -name "*.so*" \) -o \
        \( -type f -a -perm +0100 \) \
        \) -exec patchelf --set-interpreter ${stdenv.gcc.libc}/lib/ld-*so.? \
        --set-rpath ${zlib}/lib:${ncurses}/lib {} \;
  '';
}