1 { lib, stdenv, fetchurl, fetchpatch, updateAutotoolsGnuConfigScriptsHook
3 # Disable jit on Apple Silicon, https://github.com/zherczeg/sljit/issues/51
4 , enableJit ? !(stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64)
8 assert lib.elem variant [ null "cpp" "pcre16" "pcre32" ];
10 stdenv.mkDerivation rec {
12 + lib.optionalString (variant == "cpp") "-cpp"
13 + lib.optionalString (variant != "cpp" && variant != null) variant;
17 url = "mirror://sourceforge/project/pcre/pcre/${version}/pcre-${version}.tar.bz2";
18 sha256 = "sha256-Ta5v3NK7C7bDe1+Xwzwr6VTadDmFNpzdrDVG4yGL/7g=";
21 outputs = [ "bin" "dev" "out" "doc" "man" ];
23 hardeningDisable = lib.optional enableJit "shadowstack";
26 "--enable-unicode-properties"
28 ] ++ lib.optional enableJit "--enable-jit=auto"
29 ++ lib.optional (variant != null) "--enable-${variant}";
32 # https://bugs.exim.org/show_bug.cgi?id=2173
33 ./stacksize-detection.patch
35 # Fix segfaults & tests on powerpc64
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=";
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 ];
48 patchShebangs RunGrepTest
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
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}
62 homepage = "http://www.pcre.org/";
63 description = "Library for Perl Compatible Regular Expressions";
64 license = lib.licenses.bsd3;
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.
74 platforms = lib.platforms.all;