lol
1{ stdenv, fetchurl, m4, cxx ? true, withStatic ? true }:
2
3let inherit (stdenv.lib) optional optionalString; in
4
5let self = stdenv.mkDerivation rec {
6 name = "gmp-5.1.3";
7
8 src = fetchurl { # we need to use bz2, others aren't in bootstrapping stdenv
9 urls = [ "mirror://gnu/gmp/${name}.tar.bz2" "ftp://ftp.gmplib.org/pub/${name}/${name}.tar.bz2" ];
10 sha256 = "0q5i39pxrasgn9qdxzpfbwhh11ph80p57x6hf48m74261d97j83m";
11 };
12
13 #outputs TODO: split $cxx due to libstdc++ dependency
14 # maybe let ghc use a version with *.so shared with rest of nixpkgs and *.a added
15 # - see #5855 for related discussion
16 outputs = [ "out" "dev" "info" ];
17 passthru.static = self.out;
18
19 nativeBuildInputs = [ m4 ];
20
21 patches = if stdenv.isDarwin then [ ./need-size-t.patch ] else null;
22
23 configureFlags =
24 # Build a "fat binary", with routines for several sub-architectures
25 # (x86), except on Solaris where some tests crash with "Memory fault".
26 # See <http://hydra.nixos.org/build/2760931>, for instance.
27 #
28 # no darwin because gmp uses ASM that clang doesn't like
29 optional (!stdenv.isSunOS) "--enable-fat"
30 ++ (if cxx then [ "--enable-cxx" ]
31 else [ "--disable-cxx" ])
32 ++ optional (cxx && stdenv.isDarwin) "CPPFLAGS=-fexceptions"
33 ++ optional stdenv.isDarwin "ABI=64"
34 ++ optional stdenv.is64bit "--with-pic"
35 ;
36
37 # The config.guess in GMP tries to runtime-detect various
38 # ARM optimization flags via /proc/cpuinfo (and is also
39 # broken on multicore CPUs). Avoid this impurity.
40 preConfigure = optionalString stdenv.isArm ''
41 configureFlagsArray+=("--build=$(./configfsf.guess)")
42 '';
43
44 doCheck = true;
45
46 dontDisableStatic = withStatic;
47
48 enableParallelBuilding = true;
49
50 meta = with stdenv.lib; {
51 homepage = https://gmplib.org/;
52 description = "GNU multiple precision arithmetic library";
53 license = licenses.gpl3Plus;
54
55 longDescription =
56 '' GMP is a free library for arbitrary precision arithmetic, operating
57 on signed integers, rational numbers, and floating point numbers.
58 There is no practical limit to the precision except the ones implied
59 by the available memory in the machine GMP runs on. GMP has a rich
60 set of functions, and the functions have a regular interface.
61
62 The main target applications for GMP are cryptography applications
63 and research, Internet security applications, algebra systems,
64 computational algebra research, etc.
65
66 GMP is carefully designed to be as fast as possible, both for small
67 operands and for huge operands. The speed is achieved by using
68 fullwords as the basic arithmetic type, by using fast algorithms,
69 with highly optimised assembly code for the most common inner loops
70 for a lot of CPUs, and by a general emphasis on speed.
71
72 GMP is faster than any other bignum library. The advantage for GMP
73 increases with the operand sizes for many operations, since GMP uses
74 asymptotically faster algorithms.
75 '';
76
77 platforms = platforms.all;
78 maintainers = [ maintainers.peti ];
79 };
80};
81 in self