3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/development/libraries/libxml2/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

134 lines
3.7 KiB
Nix
Raw Normal View History

2022-02-20 14:26:51 +00:00
{ stdenv
, lib
, fetchurl
, zlib
, pkg-config
, autoreconfHook
2022-02-20 14:26:51 +00:00
, xz
, libintl
, python
, gettext
, ncurses
, findXMLCatalogs
, libiconv
, pythonSupport ? enableShared && stdenv.buildPlatform == stdenv.hostPlatform
2022-02-20 14:26:51 +00:00
, icuSupport ? false
2022-02-20 15:32:14 +00:00
, icu
2021-08-07 13:00:00 +01:00
, enableShared ? stdenv.hostPlatform.libc != "msvcrt" && !stdenv.hostPlatform.isStatic
, enableStatic ? !enableShared
, gnome
2017-02-11 04:48:28 +00:00
}:
stdenv.mkDerivation rec {
pname = "libxml2";
version = "2.9.14";
2022-02-20 14:26:51 +00:00
outputs = [ "bin" "dev" "out" "man" "doc" ]
++ lib.optional pythonSupport "py"
++ lib.optional (enableStatic && enableShared) "static";
src = fetchurl {
url = "mirror://gnome/sources/${pname}/${lib.versions.majorMinor version}/${pname}-${version}.tar.xz";
sha256 = "1vnzk33wfms348lgz9pvkq9li7jm44pvm73lbr3w1khwgljlmmv0";
};
2022-02-20 14:26:51 +00:00
patches = [
# Upstream bugs:
# https://bugzilla.gnome.org/show_bug.cgi?id=789714
# https://gitlab.gnome.org/GNOME/libxml2/issues/64
# Patch from https://bugzilla.opensuse.org/show_bug.cgi?id=1065270 ,
# but only the UTF-8 part.
# Can also be mitigated by fixing malformed XML inputs, such as in
# https://gitlab.gnome.org/GNOME/gnumeric/merge_requests/3 .
# Other discussion:
# https://github.com/itstool/itstool/issues/22
# https://github.com/NixOS/nixpkgs/pull/63174
# https://github.com/NixOS/nixpkgs/pull/72342
./utf8-xmlErrorFuncHandler.patch
];
2021-08-11 13:00:00 +01:00
strictDeps = true;
nativeBuildInputs = [
pkg-config
autoreconfHook
];
2022-02-20 14:26:51 +00:00
buildInputs = lib.optionals pythonSupport [
python
] ++ lib.optionals (pythonSupport && python?isPy2 && python.isPy2) [
gettext
] ++ lib.optionals (pythonSupport && python?isPy3 && python.isPy3) [
ncurses
] ++ lib.optionals (stdenv.isDarwin && pythonSupport && python?isPy2 && python.isPy2) [
libintl
] ++ lib.optionals stdenv.isFreeBSD [
# Libxml2 has an optional dependency on liblzma. However, on impure
# platforms, it may end up using that from /usr/lib, and thus lack a
# RUNPATH for that, leading to undefined references for its users.
2022-02-20 14:26:51 +00:00
xz
];
2022-02-20 14:26:51 +00:00
propagatedBuildInputs = [
zlib
findXMLCatalogs
] ++ lib.optionals stdenv.isDarwin [
libiconv
] ++ lib.optionals icuSupport [
icu
];
2018-07-25 01:13:43 +01:00
configureFlags = [
"--exec-prefix=${placeholder "dev"}"
2018-07-25 01:13:43 +01:00
(lib.enableFeature enableStatic "static")
(lib.enableFeature enableShared "shared")
(lib.withFeature icuSupport "icu")
(lib.withFeatureAs pythonSupport "python" python)
];
2022-02-20 14:26:51 +00:00
installFlags = lib.optionals pythonSupport [
2022-02-20 15:32:14 +00:00
"pythondir=\"${placeholder "py"}/${python.sitePackages}\""
2022-02-20 14:26:51 +00:00
];
enableParallelBuilding = true;
doCheck =
(stdenv.hostPlatform == stdenv.buildPlatform) &&
!stdenv.isDarwin &&
stdenv.hostPlatform.libc != "musl";
preConfigure = lib.optionalString (lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11") ''
MACOSX_DEPLOYMENT_TARGET=10.16
'';
2022-02-20 15:32:14 +00:00
preInstall = lib.optionalString pythonSupport ''
substituteInPlace python/libxml2mod.la --replace "$dev/${python.sitePackages}" "$py/${python.sitePackages}"
2022-02-20 15:32:14 +00:00
'';
postFixup = ''
moveToOutput bin/xml2-config "$dev"
moveToOutput lib/xml2Conf.sh "$dev"
moveToOutput share/man/man1 "$bin"
'' + lib.optionalString (enableStatic && enableShared) ''
moveToOutput lib/libxml2.a "$static"
'';
2022-02-20 14:26:51 +00:00
passthru = {
inherit version;
pythonSupport = pythonSupport;
updateScript = gnome.updateScript {
packageName = pname;
versionPolicy = "none";
};
2022-02-20 14:26:51 +00:00
};
2022-02-20 14:26:51 +00:00
meta = with lib; {
2022-05-11 10:46:58 +01:00
homepage = "https://gitlab.gnome.org/GNOME/libxml2";
2022-02-20 14:26:51 +00:00
description = "XML parsing library for C";
license = licenses.mit;
platforms = platforms.all;
2022-02-20 14:38:00 +00:00
maintainers = with maintainers; [ eelco jtojnar ];
};
}