From 5e0eb814166817b9cca1e05fba32fb7924e68635 Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jeremy@system76.com>
Date: Sat, 5 Jan 2019 11:06:12 -0700
Subject: [PATCH] Add pcre

---
 recipes/pcre/recipe.sh   | 44 ++++++++++++++++++++++++++++++++++++++++
 recipes/pcre/redox.patch | 17 ++++++++++++++++
 2 files changed, 61 insertions(+)
 create mode 100644 recipes/pcre/recipe.sh
 create mode 100644 recipes/pcre/redox.patch

diff --git a/recipes/pcre/recipe.sh b/recipes/pcre/recipe.sh
new file mode 100644
index 000000000..1cc309313
--- /dev/null
+++ b/recipes/pcre/recipe.sh
@@ -0,0 +1,44 @@
+VERSION=8.42
+TAR=https://ftp.pcre.org/pub/pcre/pcre-$VERSION.tar.bz2
+BUILD_DEPENDS=()
+
+function recipe_version {
+    echo "$VERSION"
+    skip=1
+}
+
+function recipe_update {
+    echo "skipping update"
+    skip=1
+}
+
+function recipe_build {
+    sysroot="$(realpath ../sysroot)"
+    export CFLAGS="-I$sysroot/include"
+    export LDFLAGS="-L$sysroot/lib"
+    export LIBS="-Wl,--whole-archive -lpthread -Wl,--no-whole-archive"
+    ./configure \
+        --host=${HOST} \
+        --prefix=/ \
+        --disable-shared \
+        --enable-static
+    make -j"$(nproc)"
+    skip=1
+}
+
+function recipe_test {
+    echo "skipping test"
+    skip=1
+}
+
+function recipe_clean {
+    make clean
+    skip=1
+}
+
+function recipe_stage {
+    dest="$(realpath $1)"
+    make DESTDIR="$dest" install
+    rm -f "$dest/lib/"*.la
+    skip=1
+}
diff --git a/recipes/pcre/redox.patch b/recipes/pcre/redox.patch
new file mode 100644
index 000000000..6e438bacc
--- /dev/null
+++ b/recipes/pcre/redox.patch
@@ -0,0 +1,17 @@
+diff -ruwN source/pcretest.c source-new/pcretest.c
+--- source/pcretest.c	2017-06-13 10:49:46.000000000 -0600
++++ source-new/pcretest.c	2019-01-05 11:04:15.198224299 -0700
+@@ -3168,7 +3168,7 @@
+       ((stack_size = get_value((pcre_uint8 *)argv[op+1], &endptr)),
+         *endptr == 0))
+     {
+-#if defined(_WIN32) || defined(WIN32) || defined(__minix) || defined(NATIVE_ZOS) || defined(__VMS)
++#if defined(_WIN32) || defined(WIN32) || defined(__minix) || defined(NATIVE_ZOS) || defined(__VMS) || defined(__redox__)
+     printf("PCRE: -S not supported on this OS\n");
+     exit(1);
+ #else
+@@ -5770,4 +5770,3 @@
+ }
+ 
+ /* End of pcretest.c */
+-
-- 
GitLab