@@ -0,0 +1,90 @@
1+{ stdenv, fetchurl, pkgconfig, perl
2+, http2Support ? true, nghttp2
3+, idnSupport ? false, libidn ? null
4+, ldapSupport ? false, openldap ? null
5+, zlibSupport ? false, zlib ? null
6+, sslSupport ? false, openssl ? null
7+, scpSupport ? false, libssh2 ? null
8+, gssSupport ? false, gss ? null
9+, c-aresSupport ? false, c-ares ? null
10+}:
11+
12+assert http2Support -> nghttp2 != null;
13+assert idnSupport -> libidn != null;
14+assert ldapSupport -> openldap != null;
15+assert zlibSupport -> zlib != null;
16+assert sslSupport -> openssl != null;
17+assert scpSupport -> libssh2 != null;
18+assert c-aresSupport -> c-ares != null;
19+
20+stdenv.mkDerivation rec {
21+ name = "curl-7.48.0";
22+
23+ src = fetchurl {
24+ url = "http://curl.haxx.se/download/${name}.tar.bz2";
25+ sha256 = "0ly7fbysxrdbclswcr6s7n5sfxfffzazv8blqr16sn0b44cphkl6";
26+ };
27+
28+ outputs = [ "dev" "out" "bin" "man" "docdev" ];
29+
30+ nativeBuildInputs = [ pkgconfig perl ];
31+
32+ # Zlib and OpenSSL must be propagated because `libcurl.la' contains
33+ # "-lz -lssl", which aren't necessary direct build inputs of
34+ # applications that use Curl.
35+ propagatedBuildInputs = with stdenv.lib;
36+ optional http2Support nghttp2 ++
37+ optional idnSupport libidn ++
38+ optional ldapSupport openldap ++
39+ optional zlibSupport zlib ++
40+ optional gssSupport gss ++
41+ optional c-aresSupport c-ares ++
42+ optional sslSupport openssl ++
43+ optional scpSupport libssh2;
44+
45+ # for the second line see http://curl.haxx.se/mail/tracker-2014-03/0087.html
46+ preConfigure = ''
47+ sed -e 's|/usr/bin|/no-such-path|g' -i.bak configure
48+ rm src/tool_hugehelp.c
49+ '';
50+
51+ configureFlags = [
52+ "--with-ca-bundle=/etc/ssl/certs/ca-certificates.crt"
53+ "--disable-manual"
54+ ( if sslSupport then "--with-ssl=${openssl.dev}" else "--without-ssl" )
55+ ( if scpSupport then "--with-libssh2=${libssh2.dev}" else "--without-libssh2" )
56+ ( if ldapSupport then "--enable-ldap" else "--disable-ldap" )
57+ ( if ldapSupport then "--enable-ldaps" else "--disable-ldaps" )
58+ ( if idnSupport then "--with-libidn=${libidn.dev}" else "--without-libidn" )
59+ ]
60+ ++ stdenv.lib.optional c-aresSupport "--enable-ares=${c-ares}"
61+ ++ stdenv.lib.optional gssSupport "--with-gssapi=${gss}";
62+
63+ CXX = "g++";
64+ CXXCPP = "g++ -E";
65+
66+ postInstall = ''
67+ moveToOutput bin/curl-config "$dev"
68+ sed '/^dependency_libs/s|${libssh2.dev}|${libssh2.out}|' -i "$out"/lib/*.la
69+ '';
70+
71+ crossAttrs = {
72+ # We should refer to the cross built openssl
73+ # For the 'urandom', maybe it should be a cross-system option
74+ configureFlags = [
75+ ( if sslSupport then "--with-ssl=${openssl.crossDrv}" else "--without-ssl" )
76+ "--with-random /dev/urandom"
77+ ];
78+ };
79+
80+ passthru = {
81+ inherit sslSupport openssl;
82+ };
83+
84+ meta = with stdenv.lib; {
85+ description = "A command line tool for transferring files with URL syntax";
86+ homepage = http://curl.haxx.se/;
87+ maintainers = with maintainers; [ lovek323 ];
88+ platforms = platforms.all;
89+ };
90+}