Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at gcc-offload 144 lines 3.8 kB view raw
1{ 2 stdenv, 3 lib, 4 fetchurl, 5 pkg-config, 6 autoreconfHook, 7 libintl, 8 python, 9 gettext, 10 ncurses, 11 findXMLCatalogs, 12 libiconv, 13 # Python limits cross-compilation to an allowlist of host OSes. 14 # https://github.com/python/cpython/blob/dfad678d7024ab86d265d84ed45999e031a03691/configure.ac#L534-L562 15 pythonSupport ? 16 enableShared 17 && ( 18 stdenv.hostPlatform == stdenv.buildPlatform 19 || stdenv.hostPlatform.isCygwin 20 || stdenv.hostPlatform.isLinux 21 || stdenv.hostPlatform.isWasi 22 ), 23 icuSupport ? false, 24 icu, 25 enableShared ? !stdenv.hostPlatform.isMinGW && !stdenv.hostPlatform.isStatic, 26 enableStatic ? !enableShared, 27 gnome, 28 testers, 29 enableHttp ? false, 30}: 31 32stdenv.mkDerivation (finalAttrs: { 33 pname = "libxml2"; 34 version = "2.13.4"; 35 36 outputs = 37 [ 38 "bin" 39 "dev" 40 "out" 41 "devdoc" 42 ] 43 ++ lib.optional pythonSupport "py" 44 ++ lib.optional (enableStatic && enableShared) "static"; 45 outputMan = "bin"; 46 47 src = fetchurl { 48 url = "mirror://gnome/sources/libxml2/${lib.versions.majorMinor finalAttrs.version}/libxml2-${finalAttrs.version}.tar.xz"; 49 hash = "sha256-ZdBC4cgBAkPmF++wKv2iC4XCFgrNv7y1smuAzsZRVlA="; 50 }; 51 52 strictDeps = true; 53 54 nativeBuildInputs = [ 55 pkg-config 56 autoreconfHook 57 ]; 58 59 buildInputs = 60 lib.optionals pythonSupport [ 61 python 62 ] 63 ++ lib.optionals (pythonSupport && python ? isPy2 && python.isPy2) [ 64 gettext 65 ] 66 ++ lib.optionals (pythonSupport && python ? isPy3 && python.isPy3) [ 67 ncurses 68 ] 69 ++ lib.optionals (stdenv.hostPlatform.isDarwin && pythonSupport && python ? isPy2 && python.isPy2) [ 70 libintl 71 ]; 72 73 propagatedBuildInputs = 74 [ 75 findXMLCatalogs 76 ] 77 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 78 libiconv 79 ] 80 ++ lib.optionals icuSupport [ 81 icu 82 ]; 83 84 configureFlags = [ 85 "--exec-prefix=${placeholder "dev"}" 86 (lib.enableFeature enableStatic "static") 87 (lib.enableFeature enableShared "shared") 88 (lib.withFeature icuSupport "icu") 89 (lib.withFeature pythonSupport "python") 90 (lib.optionalString pythonSupport "PYTHON=${python.pythonOnBuildForHost.interpreter}") 91 ] ++ lib.optional enableHttp "--with-http"; 92 93 installFlags = lib.optionals pythonSupport [ 94 "pythondir=\"${placeholder "py"}/${python.sitePackages}\"" 95 "pyexecdir=\"${placeholder "py"}/${python.sitePackages}\"" 96 ]; 97 98 enableParallelBuilding = true; 99 100 doCheck = (stdenv.hostPlatform == stdenv.buildPlatform) && stdenv.hostPlatform.libc != "musl"; 101 preCheck = lib.optional stdenv.hostPlatform.isDarwin '' 102 export DYLD_LIBRARY_PATH="$PWD/.libs:$DYLD_LIBRARY_PATH" 103 ''; 104 105 preConfigure = lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") '' 106 MACOSX_DEPLOYMENT_TARGET=10.16 107 ''; 108 109 preInstall = lib.optionalString pythonSupport '' 110 substituteInPlace python/libxml2mod.la --replace-fail "$dev/${python.sitePackages}" "$py/${python.sitePackages}" 111 ''; 112 113 postFixup = 114 '' 115 moveToOutput bin/xml2-config "$dev" 116 moveToOutput lib/xml2Conf.sh "$dev" 117 '' 118 + lib.optionalString (enableStatic && enableShared) '' 119 moveToOutput lib/libxml2.a "$static" 120 ''; 121 122 passthru = { 123 inherit pythonSupport; 124 125 updateScript = gnome.updateScript { 126 packageName = "libxml2"; 127 versionPolicy = "none"; 128 }; 129 tests = { 130 pkg-config = testers.hasPkgConfigModules { 131 package = finalAttrs.finalPackage; 132 }; 133 }; 134 }; 135 136 meta = with lib; { 137 homepage = "https://gitlab.gnome.org/GNOME/libxml2"; 138 description = "XML parsing library for C"; 139 license = licenses.mit; 140 platforms = platforms.all; 141 maintainers = with maintainers; [ jtojnar ]; 142 pkgConfigModules = [ "libxml-2.0" ]; 143 }; 144})