2011-10-19 22:57:18 +02:00
|
|
|
{ stdenv, fetchurl, perl, groff, llvm }:
|
|
|
|
|
|
|
|
assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";
|
|
|
|
let
|
2011-10-20 02:15:49 +02:00
|
|
|
triplet = if (stdenv.system == "i686-linux") then "i686-pc-linux-gnu"
|
2011-10-19 22:57:18 +02:00
|
|
|
else if (stdenv.system == "x86_64-linux") then "x86_64-unknown-linux-gnu"
|
|
|
|
else throw "System not supported";
|
|
|
|
|
|
|
|
version = "2.9";
|
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "clang-${version}";
|
|
|
|
|
|
|
|
src = llvm.src;
|
|
|
|
|
|
|
|
buildInputs = [ perl llvm groff ];
|
|
|
|
|
2011-10-20 01:49:22 +02:00
|
|
|
configureFlags = [ "--enable-optimized" "--enable-shared" "--disable-static" ]
|
|
|
|
++ stdenv.lib.optionals (stdenv.gcc ? clang) [
|
|
|
|
"--with-built-clang=yes"
|
|
|
|
"CXX=clang++"
|
|
|
|
];
|
|
|
|
|
2011-10-19 22:57:18 +02:00
|
|
|
srcClang = fetchurl {
|
|
|
|
url = "http://llvm.org/releases/${version}/clang-${version}.tgz";
|
|
|
|
sha256 = "1pq9g7qxw761dp6gx3amx39kl9p4zhlymmn8gfmcnw9ag0zizi3h";
|
|
|
|
};
|
|
|
|
|
|
|
|
prePatch = ''
|
|
|
|
pushd tools
|
|
|
|
unpackFile $srcClang
|
|
|
|
mv clang-${version} clang
|
|
|
|
popd
|
|
|
|
find
|
|
|
|
'';
|
|
|
|
|
|
|
|
patches = [ ./clang-include-paths.patch ./clang-ld-flags.patch ./clang-tblgen.patch ./clang-system-llvm-libs.patch ];
|
|
|
|
|
|
|
|
buildFlags = [ "TableGen=tblgen" "LLVM_CONFIG=llvm-config" ];
|
2011-10-19 23:47:28 +02:00
|
|
|
|
2011-10-19 22:57:18 +02:00
|
|
|
preBuild = ''
|
|
|
|
sed -i -e 's,C_INCLUDE_PATH,"${stdenv.gcc.libc}/include/",' \
|
|
|
|
-e 's,CPP_HOST,"${triplet}",' \
|
|
|
|
-e 's,CPP_INCLUDE_PATH,"${stdenv.gcc.gcc}/include/c++/${stdenv.gcc.gcc.version}",' \
|
|
|
|
tools/clang/lib/Frontend/InitHeaderSearch.cpp
|
|
|
|
|
|
|
|
pushd utils/unittest
|
|
|
|
make
|
|
|
|
popd
|
|
|
|
cd tools/clang
|
|
|
|
'';
|
|
|
|
|
2011-10-19 23:47:28 +02:00
|
|
|
postInstall = ''
|
|
|
|
install -v -m755 tools/scan-build/scan-build $out/bin
|
|
|
|
install -v -m755 tools/scan-view/scan-view $out/bin
|
|
|
|
'';
|
|
|
|
|
2011-10-19 22:57:18 +02:00
|
|
|
passthru = { gcc = stdenv.gcc.gcc; };
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
homepage = http://clang.llvm.org/;
|
|
|
|
description = "A C language family frontend for LLVM";
|
|
|
|
license = "BSD";
|
|
|
|
maintainers = with stdenv.lib.maintainers; [viric shlevy];
|
|
|
|
platforms = with stdenv.lib.platforms; linux;
|
|
|
|
};
|
|
|
|
}
|