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