about summary refs log tree commit diff
path: root/pkgs/development/libraries/pcre
diff options
context:
space:
mode:
authorNikolay Amiantov <ab@fmap.me>2016-03-28 13:26:46 +0300
committerNikolay Amiantov <ab@fmap.me>2016-03-30 22:22:51 +0300
commitc091e61a098c5cab1f5b6b850d8fc05741cb112e (patch)
treeef397943a6b5ed5ccc4fbae7b99850f14fd71fb5 /pkgs/development/libraries/pcre
parent3d1523ebe2b7433cfc4a9d3c5f0552647285403b (diff)
pcre: add 16- and 32-bit character size versions
Diffstat (limited to 'pkgs/development/libraries/pcre')
-rw-r--r--pkgs/development/libraries/pcre/default.nix25
1 files changed, 18 insertions, 7 deletions
diff --git a/pkgs/development/libraries/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix
index 92f53b067204d..afeffae3e5fa9 100644
--- a/pkgs/development/libraries/pcre/default.nix
+++ b/pkgs/development/libraries/pcre/default.nix
@@ -1,14 +1,24 @@
-{ stdenv, fetchurl, unicodeSupport ? true, cplusplusSupport ? true
+{ stdenv, lib, fetchurl, unicodeSupport ? true, cplusplusSupport ? true
 , windows ? null
+, withCharSize ? 8
 }:
 
 with stdenv.lib;
 
-stdenv.mkDerivation rec {
-  name = "pcre-8.38";
+assert withCharSize != 8 -> !cplusplusSupport;
+
+let
+  charFlags = if withCharSize == 8 then [ ]
+              else if withCharSize == 16 then [ "--enable-pcre16" "--disable-pcre8" ]
+              else if withCharSize == 32 then [ "--enable-pcre32" "--disable-pcre8" ]
+              else abort "Invalid character size";
+
+in stdenv.mkDerivation rec {
+  name = "pcre${lib.optionalString (withCharSize != 8) (toString withCharSize)}-8.38";
+  # FIXME: add "version" attribute and use it in URL
 
   src = fetchurl {
-    url = "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/${name}.tar.bz2";
+    url = "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.bz2";
     sha256 = "1pvra19ljkr5ky35y2iywjnsckrs9ch2anrf5b0dc91hw8v2vq5r";
   };
 
@@ -17,11 +27,12 @@ stdenv.mkDerivation rec {
 
   outputs = [ "out" "doc" "man" ];
 
+  # FIXME: Refactor into list!
   configureFlags = ''
     --enable-jit
-    ${if unicodeSupport then "--enable-unicode-properties" else ""}
-    ${if !cplusplusSupport then "--disable-cpp" else ""}
-  '';
+    ${lib.optionalString unicodeSupport "--enable-unicode-properties"}
+    ${lib.optionalString (!cplusplusSupport) "--disable-cpp"}
+  '' + lib.optionalString (charFlags != []) " ${toString charFlags}";
 
   doCheck = with stdenv; !(isCygwin || isFreeBSD);
     # XXX: test failure on Cygwin