1{ stdenv, cmake, fetchurl, libcxx, libunwind, llvm }:
2
3let
4 version = "3.5.2";
5 cmakeLists = fetchurl {
6 name = "CMakeLists.txt";
7 url = "http://llvm.org/svn/llvm-project/libcxxabi/trunk/CMakeLists.txt?p=217324";
8 sha256 = "10idgcbs4pcx6mjsbq1vjm8hzqqdk2p7k86cw9f473jmfyfwgf5j";
9 };
10in stdenv.mkDerivation {
11 name = "libc++abi-${version}";
12
13 src = fetchurl {
14 url = "http://llvm.org/releases/${version}/libcxxabi-${version}.src.tar.xz";
15 sha256 = "1c6rv0zx0na1w4hdmdfq2f6nj7limb7d1krrknwajxxkcn4yws92";
16 };
17
18 buildInputs = [ cmake ] ++ stdenv.lib.optional (!stdenv.isDarwin) libunwind;
19
20 postUnpack = ''
21 unpackFile ${libcxx.src}
22 unpackFile ${llvm.src}
23 echo cp ${cmakeLists} libcxxabi-*/CMakeLists.txt
24 cp ${cmakeLists} libcxxabi-*/CMakeLists.txt
25 export NIX_CFLAGS_COMPILE+=" -I$PWD/include"
26 export cmakeFlags="-DLLVM_PATH=$PWD/$(ls -d llvm-*) -DLIBCXXABI_LIBCXX_INCLUDES=$PWD/$(ls -d libcxx-*)/include"
27 '' + stdenv.lib.optionalString stdenv.isDarwin ''
28 export TRIPLE=x86_64-apple-darwin
29 '';
30
31 installPhase = if stdenv.isDarwin
32 then ''
33 for file in lib/*; do
34 # this should be done in CMake, but having trouble figuring out
35 # the magic combination of necessary CMake variables
36 # if you fancy a try, take a look at
37 # http://www.cmake.org/Wiki/CMake_RPATH_handling
38 install_name_tool -id $out/$file $file
39 done
40 make install
41 install -d 755 $out/include
42 install -m 644 ../include/cxxabi.h $out/include
43 ''
44 else ''
45 install -d -m 755 $out/include $out/lib
46 install -m 644 lib/libc++abi.so.1.0 $out/lib
47 install -m 644 $src/include/cxxabi.h $out/include
48 ln -s libc++abi.so.1.0 $out/lib/libc++abi.so
49 ln -s libc++abi.so.1.0 $out/lib/libc++abi.so.1
50 '';
51
52 meta = {
53 homepage = http://libcxxabi.llvm.org/;
54 description = "A new implementation of low level support for a standard C++ library";
55 license = with stdenv.lib.licenses; [ ncsa mit ];
56 maintainers = with stdenv.lib.maintainers; [ vlstill ];
57 platforms = stdenv.lib.platforms.unix;
58 };
59}