@@ -0,0 +1,55 @@
1+{ stdenv, lib, fetchFromGitHub, cmake, libetpan, icu, cyrus_sasl, libctemplate
2+, libuchardet, pkgconfig, glib, libtidy, libxml2, libuuid, openssl
3+}:
4+
5+stdenv.mkDerivation rec {
6+ name = "mailcore2-${version}";
7+
8+ version = "0.5";
9+
10+ src = fetchFromGitHub {
11+ owner = "MailCore";
12+ repo = "mailcore2";
13+ rev = version;
14+ sha256 = "1f2kpw8ha4j43jlimw0my9b7x1gbik7yyg1m87q6nhbbsci78qly";
15+ };
16+
17+ buildInputs = [
18+ libetpan cmake icu cyrus_sasl libctemplate libuchardet pkgconfig glib
19+ libtidy libxml2 libuuid openssl
20+ ];
21+
22+ postPatch = ''
23+ substituteInPlace CMakeLists.txt \
24+ --replace "tidy/tidy.h" "tidy.h" \
25+ --replace "/usr/include/tidy" "${libtidy}/include" \
26+ --replace "/usr/include/libxml2" "${libxml2}/include/libxml2" \
27+ '';
28+
29+ cmakeFlags = [
30+ "-DBUILD_SHARED_LIBS=ON"
31+ ];
32+
33+ installPhase = ''
34+ mkdir $out
35+ cp -r src/include $out
36+
37+ mkdir $out/lib
38+ cp src/libMailCore.so $out/lib
39+ '';
40+
41+ doCheck = true;
42+ checkPhase = ''
43+ (
44+ cd unittest
45+ LD_LIBRARY_PATH="$(cd ../src; pwd)" TZ=PST8PDT ./unittestcpp ../../unittest/data
46+ )
47+ '';
48+
49+ meta = with lib; {
50+ description = "A simple and asynchronous API to work with e-mail protocols IMAP, POP and SMTP";
51+ homepage = http://libmailcore.com;
52+ license = licenses.bsd3;
53+ maintainers = with maintainers; [ cstrahan ];
54+ };
55+}