From acdb0860b1469a0d8f7cb464c97850abbacd7330 Mon Sep 17 00:00:00 2001 From: Tobias Christiansen Date: Thu, 24 Mar 2022 15:41:48 +0100 Subject: Ports: Add cfunge This adds the `cfunge` Befunge interpreter. An interpreter for the esoteric programming language Befunge written in C. --- Ports/cfunge/package.sh | 31 +++++++++++++++++++++++++++ Ports/cfunge/patches/ReadMe.md | 19 ++++++++++++++++ Ports/cfunge/patches/arc4random_buf.patch | 10 +++++++++ Ports/cfunge/patches/define-max.patch | 11 ++++++++++ Ports/cfunge/patches/posix-mapped-files.patch | 10 +++++++++ Ports/cfunge/patches/posix-regexp.patch | 10 +++++++++ 6 files changed, 91 insertions(+) create mode 100755 Ports/cfunge/package.sh create mode 100644 Ports/cfunge/patches/ReadMe.md create mode 100644 Ports/cfunge/patches/arc4random_buf.patch create mode 100644 Ports/cfunge/patches/define-max.patch create mode 100644 Ports/cfunge/patches/posix-mapped-files.patch create mode 100644 Ports/cfunge/patches/posix-regexp.patch (limited to 'Ports/cfunge') 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 + #include +-#include /* 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 /* fstat, open */ + #include /* 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 + #include + ++#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 -- cgit v1.2.3