1{ fetchurl, stdenv, unzip }:
2
3stdenv.mkDerivation rec {
4 name = "crypto++-5.6.2";
5
6 src = fetchurl {
7 url = "mirror://sourceforge/cryptopp/cryptopp562.zip";
8 sha256 = "0x1mqpz1v071cfrw4grbw7z734cxnpry1qh2b6rsmcx6nkyd5gsw";
9 };
10
11 patches = with stdenv;
12 lib.optional (system != "i686-cygwin") ./dll.patch
13 ++ lib.optional isDarwin ./GNUmakefile.patch;
14
15 buildInputs = [ unzip ];
16
17 sourceRoot = ".";
18
19 configurePhase = let
20 marchflags =
21 if stdenv.isi686 then "-march=i686" else
22 if stdenv.isx86_64 then "-march=nocona -mtune=generic" else
23 "";
24 in
25 ''
26 sed -i GNUmakefile \
27 -e 's|-march=native|${marchflags} -fPIC|g' \
28 -e 's|-mtune=native||g' \
29 -e '/^CXXFLAGS =/s|-g ||'
30 '';
31
32 enableParallelBuilding = true;
33
34 makeFlags = "PREFIX=$(out)";
35 buildFlags = "libcryptopp.so";
36
37 doCheck = true;
38 checkPhase = "LD_LIBRARY_PATH=`pwd` make test";
39
40 # prefer -fPIC and .so to .a; cryptotest.exe seems superfluous
41 postInstall = ''rm "$out"/lib/*.a -r "$out/bin" '';
42
43 meta = with stdenv.lib; {
44 description = "Crypto++, a free C++ class library of cryptographic schemes";
45 homepage = http://cryptopp.com/;
46 license = licenses.boost;
47 platforms = platforms.all;
48 maintainers = [ ];
49 };
50}
51