diff options
author | Tobias Christiansen <tobyase@serenityos.org> | 2022-03-24 15:41:48 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-25 22:49:06 +0100 |
commit | acdb0860b1469a0d8f7cb464c97850abbacd7330 (patch) | |
tree | 0dddbfb4055a561d5afe50835f084f5959673a94 | |
parent | 7ab62ecd16fe7bb86676d9d56a66d919e48cf685 (diff) | |
download | serenity-acdb0860b1469a0d8f7cb464c97850abbacd7330.zip |
Ports: Add cfunge
This adds the `cfunge` Befunge interpreter. An interpreter for the
esoteric programming language Befunge written in C.
-rw-r--r-- | Ports/AvailablePorts.md | 1 | ||||
-rwxr-xr-x | Ports/cfunge/package.sh | 31 | ||||
-rw-r--r-- | Ports/cfunge/patches/ReadMe.md | 19 | ||||
-rw-r--r-- | Ports/cfunge/patches/arc4random_buf.patch | 10 | ||||
-rw-r--r-- | Ports/cfunge/patches/define-max.patch | 11 | ||||
-rw-r--r-- | Ports/cfunge/patches/posix-mapped-files.patch | 10 | ||||
-rw-r--r-- | Ports/cfunge/patches/posix-regexp.patch | 10 |
7 files changed, 92 insertions, 0 deletions
diff --git a/Ports/AvailablePorts.md b/Ports/AvailablePorts.md index 4c4843525f..845b65bd36 100644 --- a/Ports/AvailablePorts.md +++ b/Ports/AvailablePorts.md @@ -25,6 +25,7 @@ Please make sure to keep this list up to date when adding and updating ports. :^ | [`cmake`](cmake/) | CMake | 3.22.1 | https://cmake.org/ | | [`cmatrix`](cmatrix/) | cmatrix | 3112b12 | https://github.com/abishekvashok/cmatrix | | [`composer`](composer/) | Composer | 2.1.3 | https://getcomposer.org/ | +| [`cfunge`](cfunge/) | cfunge | 2bc4fb2 | https://github.com/VorpalBlade/cfunge/ | | [`curl`](curl/) | curl | 7.82.0 | https://curl.se/ | | [`dash`](dash/) | DASH | 0.5.10.2 | http://gondor.apana.org.au/~herbert/dash | | [`dialog`](dialog/) | Dialog | 1.3-20210324 | https://invisible-island.net/dialog/ | 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 |