summaryrefslogtreecommitdiff
path: root/Ports/cfunge
diff options
context:
space:
mode:
authorTobias Christiansen <tobyase@serenityos.org>2022-03-24 15:41:48 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-25 22:49:06 +0100
commitacdb0860b1469a0d8f7cb464c97850abbacd7330 (patch)
tree0dddbfb4055a561d5afe50835f084f5959673a94 /Ports/cfunge
parent7ab62ecd16fe7bb86676d9d56a66d919e48cf685 (diff)
downloadserenity-acdb0860b1469a0d8f7cb464c97850abbacd7330.zip
Ports: Add cfunge
This adds the `cfunge` Befunge interpreter. An interpreter for the esoteric programming language Befunge written in C.
Diffstat (limited to 'Ports/cfunge')
-rwxr-xr-xPorts/cfunge/package.sh31
-rw-r--r--Ports/cfunge/patches/ReadMe.md19
-rw-r--r--Ports/cfunge/patches/arc4random_buf.patch10
-rw-r--r--Ports/cfunge/patches/define-max.patch11
-rw-r--r--Ports/cfunge/patches/posix-mapped-files.patch10
-rw-r--r--Ports/cfunge/patches/posix-regexp.patch10
6 files changed, 91 insertions, 0 deletions
diff --git a/Ports/cfunge/package.sh b/Ports/cfunge/package.sh
new file mode 100755
index 0000000000..104f5ad181
--- /dev/null
+++ b/Ports/cfunge/package.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env -S bash ../.port_include.sh
+
+port=cfunge
+version=2bc4fb27ade2a816ca9a90a6d9f6958111123fa9
+workdir=cfunge-${version}/build
+useconfigure=true
+files="https://codeload.github.com/VorpalBlade/cfunge/zip/${version} cfunge.zip 364994a890ed1083684956db576a2a5cfb94b3117bae868910d6a75111033f55"
+auth_type=sha256
+
+mkdir -p cfunge-${version}/build
+
+patch_internal() {
+ # patch if it was not yet patched (applying patches multiple times doesn't work!)
+ if [ -z "${IN_SERENITY_PORT_DEV:-}" ] && [ -d patches ]; then
+ for filepath in patches/*.patch; do
+ filename=$(basename $filepath)
+ if [ ! -f "$workdir"/.${filename}_applied ]; then
+ run patch -d .. -p"$patchlevel" < "$filepath"
+ run touch .${filename}_applied
+ fi
+ done
+ fi
+}
+
+configure() {
+ run cmake "${configopts[@]}" ..
+}
+
+install() {
+ run cp cfunge "${SERENITY_INSTALL_ROOT}/bin"
+}
diff --git a/Ports/cfunge/patches/ReadMe.md b/Ports/cfunge/patches/ReadMe.md
new file mode 100644
index 0000000000..0742d93762
--- /dev/null
+++ b/Ports/cfunge/patches/ReadMe.md
@@ -0,0 +1,19 @@
+# Patches for cfunge on SerenityOS
+
+## `arc4random_buf.patch`
+Somewhere on the way of configuring the variable `HAVE_arc4random_buf` was set which lead to the linker complaining about not knowing a certain `arc4random_stir()` function.
+This patch just negates the define and the linker is happy.
+
+
+## `define-max.patch`
+It is expected that `sys/param.h` defines a `MAX` macro. We don't. So here the needed macro is just inserted instead of the include.
+
+
+## `posix-mapped-files.patch`
+It is expected that `_POSIX_MAPPED_FILES` is defined as at least `1`, so we do that here.
+
+
+## `posix-regexp.patch`
+Same as before, just for `_POSIX_REGEXP`
+
+
diff --git a/Ports/cfunge/patches/arc4random_buf.patch b/Ports/cfunge/patches/arc4random_buf.patch
new file mode 100644
index 0000000000..b645bc4fc4
--- /dev/null
+++ b/Ports/cfunge/patches/arc4random_buf.patch
@@ -0,0 +1,10 @@
+--- ../src/prng.c
++++ ../src/prng.c
+@@ -29,6 +29,7 @@
+ # undef HAVE_arc4random_buf
+ #endif
+
++#undef HAVE_arc4random_buf
+ #ifdef HAVE_arc4random_buf
+ # define HAVE_ARC4RANDOM
+ # ifndef ARC4RANDOM_IN_BSD
diff --git a/Ports/cfunge/patches/define-max.patch b/Ports/cfunge/patches/define-max.patch
new file mode 100644
index 0000000000..b764bbc790
--- /dev/null
+++ b/Ports/cfunge/patches/define-max.patch
@@ -0,0 +1,11 @@
+--- ../lib/fungestring/funge_str-two-way.h
++++ ../lib/fungestring/funge_str-two-way.h
+@@ -53,7 +53,7 @@
+
+ #include <limits.h>
+ #include <stdint.h>
+-#include <sys/param.h> /* Defines MAX. */
++#define MAX(a,b) (((a)>(b))?(a):(b))
+
+ /* We use the Two-Way string matching algorithm, which guarantees
+ linear complexity with constant space. Additionally, for long
diff --git a/Ports/cfunge/patches/posix-mapped-files.patch b/Ports/cfunge/patches/posix-mapped-files.patch
new file mode 100644
index 0000000000..d771b31390
--- /dev/null
+++ b/Ports/cfunge/patches/posix-mapped-files.patch
@@ -0,0 +1,10 @@
+--- ../src/funge-space/funge-space.c
++++ ../src/funge-space/funge-space.c
+@@ -47,6 +47,7 @@
+ #include <sys/stat.h> /* fstat, open */
+ #include <fcntl.h> /* open, posix_fallocate */
+
++#define _POSIX_MAPPED_FILES 1
+ #if !defined(_POSIX_MAPPED_FILES) || (_POSIX_MAPPED_FILES < 1)
+ # error "cfunge needs a working mmap(), which this system claims it lacks."
+ #endif
diff --git a/Ports/cfunge/patches/posix-regexp.patch b/Ports/cfunge/patches/posix-regexp.patch
new file mode 100644
index 0000000000..a5bc5d7154
--- /dev/null
+++ b/Ports/cfunge/patches/posix-regexp.patch
@@ -0,0 +1,10 @@
+--- ../src/fingerprints/REXP/REXP.c
++++ ../src/fingerprints/REXP/REXP.c
+@@ -28,6 +28,7 @@
+ #include <unistd.h>
+ #include <string.h>
+
++#define _POSIX_REGEXP 1
+ #if !defined(_POSIX_REGEXP) || (_POSIX_REGEXP < 1)
+ # error "cfunge needs POSIX regular expressions, which this system claims it doesn't have."
+ #endif