Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at release-19.03 96 lines 4.0 kB view raw
1{ stdenv, fetchurl, fetchpatch 2, autoreconfHook 3 4# libffi is used in darwin stdenv 5# we cannot run checks within it 6, doCheck ? !stdenv.isDarwin, dejagnu 7}: 8 9stdenv.mkDerivation rec { 10 name = "libffi-3.2.1"; 11 12 src = fetchurl { 13 url = "https://sourceware.org/pub/libffi/${name}.tar.gz"; 14 sha256 = "0dya49bnhianl0r65m65xndz6ls2jn1xngyn72gd28ls3n7bnvnh"; 15 }; 16 17 patches = stdenv.lib.optional stdenv.isCygwin ./3.2.1-cygwin.patch 18 ++ stdenv.lib.optional stdenv.isAarch64 (fetchpatch { 19 url = https://src.fedoraproject.org/rpms/libffi/raw/ccffc1700abfadb0969495a6e51b964117fc03f6/f/libffi-aarch64-rhbz1174037.patch; 20 sha256 = "1vpirrgny43hp0885rswgv3xski8hg7791vskpbg3wdjdpb20wbc"; 21 }) 22 ++ stdenv.lib.optional stdenv.hostPlatform.isMusl (fetchpatch { 23 name = "gnu-linux-define.patch"; 24 url = "https://git.alpinelinux.org/cgit/aports/plain/main/libffi/gnu-linux-define.patch?id=bb024fd8ec6f27a76d88396c9f7c5c4b5800d580"; 25 sha256 = "11pvy3xkhyvnjfyy293v51f1xjy3x0azrahv1nw9y9mw8bifa2j2"; 26 }) 27 ++ stdenv.lib.optional stdenv.hostPlatform.isRiscV (fetchpatch { 28 name = "riscv-support.patch"; 29 url = https://github.com/sorear/libffi-riscv/commit/e46492e8bb1695a19bc1053ed869e6c2bab02ff2.patch; 30 sha256 = "1vl1vbvdkigs617kckxvj8j4m2cwg62kxm1clav1w5rnw9afxg0y"; 31 }) 32 ++ stdenv.lib.optionals stdenv.isMips [ 33 (fetchpatch { 34 name = "0001-mips-Use-compiler-internal-define-for-linux.patch"; 35 url = "http://cgit.openembedded.org/openembedded-core/plain/meta/recipes-support/libffi/libffi/0001-mips-Use-compiler-internal-define-for-linux.patch?id=318e33a708378652edcf61ce7d9d7f3a07743000"; 36 sha256 = "1gc53lw90p6hc0cmhj3csrwincfz7va5ss995ksw5gm0yrr9mrvb"; 37 }) 38 (fetchpatch { 39 name = "0001-mips-fix-MIPS-softfloat-build-issue.patch"; 40 url = "http://cgit.openembedded.org/openembedded-core/plain/meta/recipes-support/libffi/libffi/0001-mips-fix-MIPS-softfloat-build-issue.patch?id=318e33a708378652edcf61ce7d9d7f3a07743000"; 41 sha256 = "0l8xgdciqalg4z9rcwyk87h8fdxpfv4hfqxwsy2agpnpszl5jjdq"; 42 }) 43 ]; 44 45 outputs = [ "out" "dev" "man" "info" ]; 46 47 nativeBuildInputs = stdenv.lib.optional stdenv.hostPlatform.isRiscV autoreconfHook; 48 49 configureFlags = [ 50 "--with-gcc-arch=generic" # no detection of -march= or -mtune= 51 "--enable-pax_emutramp" 52 ]; 53 54 preCheck = '' 55 # The tests use -O0 which is not compatible with -D_FORTIFY_SOURCE. 56 NIX_HARDENING_ENABLE=''${NIX_HARDENING_ENABLE/fortify/} 57 ''; 58 59 checkInputs = [ dejagnu ]; 60 61 inherit doCheck; 62 63 dontStrip = stdenv.hostPlatform != stdenv.buildPlatform; # Don't run the native `strip' when cross-compiling. 64 65 # Install headers and libs in the right places. 66 postFixup = '' 67 mkdir -p "$dev/" 68 mv "$out/lib/${name}/include" "$dev/include" 69 rmdir "$out/lib/${name}" 70 substituteInPlace "$dev/lib/pkgconfig/libffi.pc" \ 71 --replace 'includedir=''${libdir}/libffi-3.2.1' "includedir=$dev" 72 ''; 73 74 meta = with stdenv.lib; { 75 description = "A foreign function call interface library"; 76 longDescription = '' 77 The libffi library provides a portable, high level programming 78 interface to various calling conventions. This allows a 79 programmer to call any function specified by a call interface 80 description at run-time. 81 82 FFI stands for Foreign Function Interface. A foreign function 83 interface is the popular name for the interface that allows code 84 written in one language to call code written in another 85 language. The libffi library really only provides the lowest, 86 machine dependent layer of a fully featured foreign function 87 interface. A layer must exist above libffi that handles type 88 conversions for values passed between the two languages. 89 ''; 90 homepage = http://sourceware.org/libffi/; 91 # See http://github.com/atgreen/libffi/blob/master/LICENSE . 92 license = licenses.free; 93 maintainers = [ ]; 94 platforms = platforms.all; 95 }; 96}