1{ stdenv, lib, fetchFromGitHub, cmake, libetpan, icu, cyrus_sasl, libctemplate
2, libuchardet, pkg-config, glib, html-tidy, libxml2, libuuid, openssl
3, darwin
4}:
5
6stdenv.mkDerivation rec {
7 pname = "mailcore2";
8
9 version = "0.6.4";
10
11 src = fetchFromGitHub {
12 owner = "MailCore";
13 repo = "mailcore2";
14 rev = version;
15 sha256 = "0a69q11z194fdfwyazjyyylx57sqs9j4lz7jwh5qcws8syqgb23z";
16 };
17
18 nativeBuildInputs = [ cmake pkg-config ];
19 buildInputs = [
20 libetpan cyrus_sasl libctemplate libuchardet
21 html-tidy libxml2 openssl
22 ] ++ lib.optionals stdenv.isLinux [
23 glib
24 icu
25 libuuid
26 ] ++ lib.optionals stdenv.isDarwin [
27 darwin.apple_sdk.frameworks.Foundation
28 ];
29
30 postPatch = ''
31 substituteInPlace CMakeLists.txt \
32 --replace " icule iculx" "" \
33 --replace "tidy/tidy.h" "tidy.h" \
34 --replace "/usr/include/tidy" "${html-tidy}/include" \
35 --replace "/usr/include/libxml2" "${libxml2.dev}/include/libxml2"
36 substituteInPlace src/core/basetypes/MCHTMLCleaner.cpp \
37 --replace buffio.h tidybuffio.h
38 substituteInPlace src/core/basetypes/MCString.cpp \
39 --replace "xmlErrorPtr" "const xmlError *"
40 '' + lib.optionalString (!stdenv.isDarwin) ''
41 substituteInPlace src/core/basetypes/MCICUTypes.h \
42 --replace "__CHAR16_TYPE__ UChar" "char16_t UChar"
43 '';
44
45 cmakeFlags = lib.optionals (!stdenv.isDarwin) [
46 "-DBUILD_SHARED_LIBS=ON"
47 ];
48
49 installPhase = ''
50 mkdir $out
51 cp -r src/include $out
52
53 mkdir $out/lib
54 cp src/libMailCore.* $out/lib
55 '';
56
57 doCheck = !stdenv.isDarwin;
58 checkPhase = ''
59 (
60 cd unittest
61 TZ=PST8PDT ./unittestcpp ../../unittest/data
62 )
63 '';
64
65 meta = with lib; {
66 description = "Simple and asynchronous API to work with e-mail protocols IMAP, POP and SMTP";
67 homepage = "http://libmailcore.com";
68 license = licenses.bsd3;
69 maintainers = [ ];
70 platforms = platforms.unix;
71 };
72}