2016-01-04 14:03:42 +00:00
|
|
|
{ stdenv, fetchurl, fetchpatch, runCommand, gcc, zlib }:
|
2008-02-12 13:32:37 +00:00
|
|
|
|
2016-01-25 19:08:34 +00:00
|
|
|
let ccache = stdenv.mkDerivation rec {
|
2015-05-11 13:56:41 +01:00
|
|
|
name = "ccache-${version}";
|
2016-04-17 17:24:11 +01:00
|
|
|
version = "3.2.5";
|
2015-05-11 13:56:41 +01:00
|
|
|
|
2008-02-12 13:32:37 +00:00
|
|
|
src = fetchurl {
|
2016-04-17 17:24:11 +01:00
|
|
|
sha256 = "11db1g109g0g5si0s50yd99ja5f8j4asxb081clvx78r9d9i2w0i";
|
2015-05-11 13:56:41 +01:00
|
|
|
url = "mirror://samba/ccache/${name}.tar.xz";
|
2012-01-21 00:25:30 +00:00
|
|
|
};
|
|
|
|
|
2015-07-01 16:43:04 +01:00
|
|
|
buildInputs = [ zlib ];
|
|
|
|
|
2015-08-25 04:03:05 +01:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace Makefile.in --replace 'objs) $(extra_libs)' 'objs)'
|
|
|
|
'';
|
|
|
|
|
2015-07-01 16:43:04 +01:00
|
|
|
doCheck = true;
|
2012-01-21 01:29:06 +00:00
|
|
|
|
2012-01-21 00:25:30 +00:00
|
|
|
passthru = {
|
|
|
|
# A derivation that provides gcc and g++ commands, but that
|
|
|
|
# will end up calling ccache for the given cacheDir
|
2016-05-11 05:45:41 +01:00
|
|
|
links = extraConfig: stdenv.mkDerivation rec {
|
|
|
|
name = "ccache-links";
|
|
|
|
passthru = {
|
|
|
|
inherit gcc;
|
|
|
|
isGNU = true;
|
|
|
|
};
|
|
|
|
inherit (gcc.cc) lib;
|
|
|
|
buildCommand = ''
|
2012-01-21 00:25:30 +00:00
|
|
|
mkdir -p $out/bin
|
2015-01-15 04:44:00 +00:00
|
|
|
if [ -x "${gcc.cc}/bin/gcc" ]; then
|
2012-01-21 00:25:30 +00:00
|
|
|
cat > $out/bin/gcc << EOF
|
|
|
|
#!/bin/sh
|
2012-01-21 01:29:06 +00:00
|
|
|
${extraConfig}
|
2015-01-15 04:44:00 +00:00
|
|
|
exec ${ccache}/bin/ccache ${gcc.cc}/bin/gcc "\$@"
|
2012-01-21 00:25:30 +00:00
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/gcc
|
|
|
|
fi
|
2015-01-15 04:44:00 +00:00
|
|
|
if [ -x "${gcc.cc}/bin/g++" ]; then
|
2012-01-21 00:25:30 +00:00
|
|
|
cat > $out/bin/g++ << EOF
|
|
|
|
#!/bin/sh
|
2012-01-21 01:29:06 +00:00
|
|
|
${extraConfig}
|
2015-01-15 04:44:00 +00:00
|
|
|
exec ${ccache}/bin/ccache ${gcc.cc}/bin/g++ "\$@"
|
2012-01-21 00:25:30 +00:00
|
|
|
EOF
|
|
|
|
chmod +x $out/bin/g++
|
|
|
|
fi
|
2015-07-29 10:03:39 +01:00
|
|
|
for executable in $(ls ${gcc.cc}/bin); do
|
|
|
|
if [ ! -x "$out/bin/$executable" ]; then
|
|
|
|
ln -s ${gcc.cc}/bin/$executable $out/bin/$executable
|
|
|
|
fi
|
|
|
|
done
|
2015-12-09 05:43:38 +00:00
|
|
|
for file in $(ls ${gcc.cc} | grep -vw bin); do
|
|
|
|
ln -s ${gcc.cc}/$file $out/$file
|
|
|
|
done
|
2016-05-11 05:45:41 +01:00
|
|
|
'';
|
|
|
|
};
|
2008-02-12 13:32:37 +00:00
|
|
|
};
|
|
|
|
|
2015-01-26 03:41:30 +00:00
|
|
|
meta = with stdenv.lib; {
|
2013-10-05 15:22:46 +01:00
|
|
|
description = "Compiler cache for fast recompilation of C/C++ code";
|
2008-02-12 13:32:37 +00:00
|
|
|
homepage = http://ccache.samba.org/;
|
2015-05-11 13:56:41 +01:00
|
|
|
downloadPage = https://ccache.samba.org/download.html;
|
2015-05-28 18:20:29 +01:00
|
|
|
license = licenses.gpl3Plus;
|
2015-01-26 03:41:30 +00:00
|
|
|
maintainers = with maintainers; [ nckx ];
|
2008-02-12 13:32:37 +00:00
|
|
|
};
|
2012-01-21 00:25:30 +00:00
|
|
|
};
|
2016-01-25 19:08:34 +00:00
|
|
|
in ccache
|