From 36f2ccd665e739583cc6aab20d4bfade9dba6516 Mon Sep 17 00:00:00 2001 From: Daniel Kempkens Date: Wed, 3 May 2023 17:16:35 +0200 Subject: [PATCH] Add liblpeg-darwin --- packages.nix | 2 ++ packages/liblpeg-darwin.nix | 23 +++++++++++++++ patches/liblpeg-makefile.patch | 51 ++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 packages/liblpeg-darwin.nix create mode 100644 patches/liblpeg-makefile.patch diff --git a/packages.nix b/packages.nix index ca71cef..04f3cfd 100644 --- a/packages.nix +++ b/packages.nix @@ -10,4 +10,6 @@ q = import ./packages/q.nix { inherit system lib pkgs; }; rimgo = import ./packages/rimgo.nix { inherit system lib pkgs; }; website-docs-nifoc-pw = import ./packages/website-docs-nifoc-pw.nix { inherit system lib pkgs; }; + + liblpeg-darwin = import ./packages/liblpeg-darwin.nix { inherit system lib pkgs; }; } diff --git a/packages/liblpeg-darwin.nix b/packages/liblpeg-darwin.nix new file mode 100644 index 0000000..00123f9 --- /dev/null +++ b/packages/liblpeg-darwin.nix @@ -0,0 +1,23 @@ +{ system, lib, pkgs }: + +pkgs.stdenv.mkDerivation { + pname = "liblpeg"; + inherit (pkgs.luajitPackages.lpeg) version src; + + nativeBuildInputs = [ pkgs.fixDarwinDylibNames ]; + buildInputs = [ pkgs.luajit ]; + + patches = [ ../patches/liblpeg-makefile.patch ]; + + installPhase = '' + mkdir -p $out/lib + install -D lpeg.dylib $out/lib/lpeg.dylib + ''; + + meta = { + homepage = "http://www.inf.puc-rio.br/~roberto/lpeg.html"; + description = "Parsing Expression Grammars For Lua"; + license.fullName = "MIT/X11"; + platforms = [ "x86_64-darwin" "aarch64-darwin" ]; + }; +} diff --git a/patches/liblpeg-makefile.patch b/patches/liblpeg-makefile.patch new file mode 100644 index 0000000..0bf2e78 --- /dev/null +++ b/patches/liblpeg-makefile.patch @@ -0,0 +1,51 @@ +--- a/makefile 2019-03-11 15:08:29 ++++ b/makefile 2023-05-03 17:12:18 +@@ -1,30 +1,7 @@ ++.DEFAULT_GOAL := macosx ++ + LIBNAME = lpeg +-LUADIR = ../lua/ + +-COPT = -O2 -DNDEBUG +-# COPT = -g +- +-CWARNS = -Wall -Wextra -pedantic \ +- -Waggregate-return \ +- -Wcast-align \ +- -Wcast-qual \ +- -Wdisabled-optimization \ +- -Wpointer-arith \ +- -Wshadow \ +- -Wsign-compare \ +- -Wundef \ +- -Wwrite-strings \ +- -Wbad-function-cast \ +- -Wdeclaration-after-statement \ +- -Wmissing-prototypes \ +- -Wnested-externs \ +- -Wstrict-prototypes \ +-# -Wunreachable-code \ +- +- +-CFLAGS = $(CWARNS) $(COPT) -std=c99 -I$(LUADIR) -fPIC +-CC = gcc +- + FILES = lpvm.o lpcap.o lptree.o lpcode.o lpprint.o + + # For Linux +@@ -33,11 +10,14 @@ macosx: + + # For Mac OS + macosx: +- $(MAKE) lpeg.so "DLLFLAGS = -bundle -undefined dynamic_lookup" ++ $(MAKE) lpeg.dylib "DLLFLAGS = -dynamiclib -undefined dynamic_lookup" + + lpeg.so: $(FILES) + env $(CC) $(DLLFLAGS) $(FILES) -o lpeg.so + ++lpeg.dylib: $(FILES) ++ env $(CC) $(DLLFLAGS) $(FILES) -o lpeg.dylib ++ + $(FILES): makefile + + test: test.lua re.lua lpeg.so