From 8c969f8383c1f1d16a4eb2cb60374dc08c460236 Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jeremy@system76.com>
Date: Tue, 16 Jul 2019 17:18:06 -0600
Subject: [PATCH] Add fontconfig

---
 recipes/fontconfig/recipe.sh   | 46 ++++++++++++++++++++++++++++++++++
 recipes/fontconfig/redox.patch | 21 ++++++++++++++++
 2 files changed, 67 insertions(+)
 create mode 100755 recipes/fontconfig/recipe.sh
 create mode 100644 recipes/fontconfig/redox.patch

diff --git a/recipes/fontconfig/recipe.sh b/recipes/fontconfig/recipe.sh
new file mode 100755
index 000000000..8f29e0fb6
--- /dev/null
+++ b/recipes/fontconfig/recipe.sh
@@ -0,0 +1,46 @@
+VERSION="2.13.91"
+TAR="https://www.freedesktop.org/software/fontconfig/release/fontconfig-${VERSION}.tar.xz"
+BUILD_DEPENDS=(expat freetype libpng zlib)
+
+function recipe_version {
+	echo "$VERSION"
+	skip=1
+}
+
+function recipe_update {
+	echo "skipping update"
+	skip=1
+}
+
+function recipe_build {
+	wget -O config.sub http://git.savannah.gnu.org/cgit/config.git/plain/config.sub
+	sysroot="$(realpath ../sysroot)"
+	export CFLAGS="-I$sysroot/include"
+	export LDFLAGS="-L$sysroot/lib --static"
+	./configure \
+	    --build=${BUILD} \
+	    --host=${HOST} \
+	    --prefix=/ \
+	    --disable-shared \
+	    --enable-static \
+	    ac_cv_func_XML_SetDoctypeDeclHandler=yes
+	make -j"$(nproc)"
+    	skip=1
+}
+
+function recipe_test {
+	echo "skipping test"
+	skip=1
+}
+
+function recipe_clean {
+	make clean
+	skip=1
+}
+
+function recipe_stage {
+	echo "skipping stage"
+	dest="$(realpath $1)"
+	make DESTDIR="$dest" install
+	skip=1
+}
diff --git a/recipes/fontconfig/redox.patch b/recipes/fontconfig/redox.patch
new file mode 100644
index 000000000..7e9e74724
--- /dev/null
+++ b/recipes/fontconfig/redox.patch
@@ -0,0 +1,21 @@
+diff -ruwN source/src/fccache.c source-new/src/fccache.c
+--- source/src/fccache.c	2019-06-10 05:36:37.000000000 -0600
++++ source-new/src/fccache.c	2019-07-16 17:13:18.730013599 -0600
+@@ -1526,7 +1526,7 @@
+ #if defined(_WIN32)
+ 	    if (_locking (fd, _LK_LOCK, 1) == -1)
+ 		goto bail;
+-#else
++#elif !defined(__redox__)
+ 	    struct flock fl;
+ 
+ 	    fl.l_type = F_WRLCK;
+@@ -1556,7 +1556,7 @@
+     {
+ #if defined(_WIN32)
+ 	_locking (fd, _LK_UNLCK, 1);
+-#else
++#elif !defined(__redox__)
+ 	struct flock fl;
+ 
+ 	fl.l_type = F_UNLCK;
-- 
GitLab