forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / development / libraries / pcre / default.nix
blob58873ae875570f0b29fdeb0f201dc9330955efd1
1 { lib, stdenv, fetchurl, fetchpatch, updateAutotoolsGnuConfigScriptsHook
2 , pcre, windows ? null
3   # Disable jit on Apple Silicon, https://github.com/zherczeg/sljit/issues/51
4 , enableJit ? !(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)
5 , variant ? null
6 }:
8 assert lib.elem variant [ null "cpp" "pcre16" "pcre32" ];
10 stdenv.mkDerivation rec {
11   pname = "pcre"
12     + lib.optionalString (variant == "cpp") "-cpp"
13     + lib.optionalString (variant != "cpp" && variant != null) variant;
14   version = "8.45";
16   src = fetchurl {
17     url = "mirror://sourceforge/project/pcre/pcre/${version}/pcre-${version}.tar.bz2";
18     sha256 = "sha256-Ta5v3NK7C7bDe1+Xwzwr6VTadDmFNpzdrDVG4yGL/7g=";
19   };
21   outputs = [ "bin" "dev" "out" "doc" "man" ];
23   hardeningDisable = lib.optional enableJit "shadowstack";
25   configureFlags = [
26     "--enable-unicode-properties"
27     "--disable-cpp"
28   ] ++ lib.optional enableJit "--enable-jit=auto"
29     ++ lib.optional (variant != null) "--enable-${variant}";
31   patches = [
32     # https://bugs.exim.org/show_bug.cgi?id=2173
33     ./stacksize-detection.patch
35     # Fix segfaults & tests on powerpc64
36     (fetchpatch {
37       name = "sljit-ppc-icache-flush.patch";
38       url = "https://github.com/void-linux/void-packages/raw/d286e231ee680875ad8e80f90ea62e46f5edd812/srcpkgs/pcre/patches/ppc-icache-flush.patch";
39       hash = "sha256-pttmKwihLzKrAV6O4qVLp2pu4NwNJEFS/9Id8/b3nAU=";
40     })
41   ];
43   # necessary to build on FreeBSD native pending inclusion of
44   # https://git.savannah.gnu.org/cgit/config.git/commit/?id=e4786449e1c26716e3f9ea182caf472e4dbc96e0
45   nativeBuildInputs = [ updateAutotoolsGnuConfigScriptsHook ];
47   preCheck = ''
48     patchShebangs RunGrepTest
49   '';
51   doCheck = !(with stdenv.hostPlatform; isCygwin || isFreeBSD) && stdenv.hostPlatform == stdenv.buildPlatform;
52     # XXX: test failure on Cygwin
53     # we are running out of stack on both freeBSDs on Hydra
55   postFixup = ''
56     moveToOutput bin/pcre-config "$dev"
57   '' + lib.optionalString (variant != null) ''
58     ln -sf -t "$out/lib/" '${pcre.out}'/lib/libpcre{,posix}.{so.*.*.*,*dylib,*a}
59   '';
61   meta = {
62     homepage = "http://www.pcre.org/";
63     description = "Library for Perl Compatible Regular Expressions";
64     license = lib.licenses.bsd3;
66     longDescription = ''
67       The PCRE library is a set of functions that implement regular
68       expression pattern matching using the same syntax and semantics as
69       Perl 5. PCRE has its own native API, as well as a set of wrapper
70       functions that correspond to the POSIX regular expression API. The
71       PCRE library is free, even for building proprietary software.
72     '';
74     platforms = lib.platforms.all;
75     maintainers = [ ];
76     pkgConfigModules = [
77       "libpcre"
78       "libpcreposix"
79     ];
80   };