git: b16f47812788 - main - devel/libac: Add libac g20190308

From: Po-Chuan Hsieh <sunpoet_at_FreeBSD.org>
Date: Mon, 07 Mar 2022 18:15:52 UTC
The branch main has been updated by sunpoet:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b16f478127888cd34bf49b4db4537015432cef48

commit b16f478127888cd34bf49b4db4537015432cef48
Author:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
AuthorDate: 2022-03-07 17:46:36 +0000
Commit:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
CommitDate: 2022-03-07 18:10:49 +0000

    devel/libac: Add libac g20190308
    
    This port is the C++ implementation of the Aho-Corasick (AC) string matching
    algorithm.
    
    The upstream began with pure Lua implementation and realize the performance is
    not satisfactory. So they switch to C/C++ implementation.
    
    There are two shared objects provided by this package: libac.so and
    ahocorasick.so The former is a regular shared object which can be directly used
    by C/C++ application, or by Lua via FFI; and the later is a Lua module.
    
    WWW: https://github.com/cloudflare/lua-aho-corasick
---
 devel/Makefile                   |  1 +
 devel/libac/Makefile             | 27 +++++++++++++
 devel/libac/distinfo             |  3 ++
 devel/libac/files/patch-Makefile | 84 ++++++++++++++++++++++++++++++++++++++++
 devel/libac/pkg-descr            | 11 ++++++
 5 files changed, 126 insertions(+)

diff --git a/devel/Makefile b/devel/Makefile
index 4c82798904cb..9425dafd70f5 100644
--- a/devel/Makefile
+++ b/devel/Makefile
@@ -1142,6 +1142,7 @@
     SUBDIR += libIDL
     SUBDIR += libPropList
     SUBDIR += libabigail
+    SUBDIR += libac
     SUBDIR += libafterbase
     SUBDIR += liballium
     SUBDIR += libantlr3c
diff --git a/devel/libac/Makefile b/devel/libac/Makefile
new file mode 100644
index 000000000000..4da94966dfa0
--- /dev/null
+++ b/devel/libac/Makefile
@@ -0,0 +1,27 @@
+# Created by: Po-Chuan Hsieh <sunpoet@FreeBSD.org>
+
+PORTNAME=	libac
+PORTVERSION=	g20190308
+CATEGORIES=	devel
+
+MAINTAINER=	sunpoet@FreeBSD.org
+COMMENT=	C++ implementation of the Aho-Corasick (AC) string matching algorithm
+
+LICENSE=	BSD3CLAUSE
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+USES=		gmake
+
+PLIST_FILES=	lib/libac.a \
+		lib/libac.so
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	cloudflare
+GH_PROJECT=	lua-aho-corasick
+GH_TAGNAME=	ca6043c
+
+do-install:
+	${INSTALL_DATA} ${WRKSRC}/libac.a ${STAGEDIR}${PREFIX}/lib/libac.a
+	${INSTALL_LIB} ${WRKSRC}/libac.so ${STAGEDIR}${PREFIX}/lib/libac.so
+
+.include <bsd.port.mk>
diff --git a/devel/libac/distinfo b/devel/libac/distinfo
new file mode 100644
index 000000000000..49c5e80f8000
--- /dev/null
+++ b/devel/libac/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1646057840
+SHA256 (cloudflare-lua-aho-corasick-g20190308-ca6043c_GH0.tar.gz) = 20d3238f1be3b3df866adf0c9943b82517130c1cde80cd6fb2ab3ffc1bc73265
+SIZE (cloudflare-lua-aho-corasick-g20190308-ca6043c_GH0.tar.gz) = 26262
diff --git a/devel/libac/files/patch-Makefile b/devel/libac/files/patch-Makefile
new file mode 100644
index 000000000000..7e93ed796a8c
--- /dev/null
+++ b/devel/libac/files/patch-Makefile
@@ -0,0 +1,84 @@
+--- Makefile.orig	2019-03-08 12:57:59 UTC
++++ Makefile
+@@ -13,7 +13,6 @@ endif
+ #############################################################################
+ #
+ C_SO_NAME = libac.$(SO_EXT)
+-LUA_SO_NAME = ahocorasick.$(SO_EXT)
+ AR_NAME = libac.a
+ 
+ #############################################################################
+@@ -22,10 +21,7 @@ AR_NAME = libac.a
+ #
+ #############################################################################
+ PREFIX ?= /usr/local
+-LUA_VERSION := 5.1
+-LUA_INCLUDE_DIR := $(PREFIX)/include/lua$(LUA_VERSION)
+-SO_TARGET_DIR := $(PREFIX)/lib/lua/$(LUA_VERSION)
+-LUA_TARGET_DIR := $(PREFIX)/share/lua/$(LUA_VERSION)
++SO_TARGET_DIR := $(PREFIX)/lib
+ 
+ # Available directives:
+ # -DDEBUG : Turn on debugging support
+@@ -57,7 +53,6 @@ AR_FLAGS = cru
+ #
+ SRC_COMMON := ac_fast.cxx ac_slow.cxx
+ LIBAC_SO_SRC := $(SRC_COMMON) ac.cxx    # source for libac.so
+-LUA_SO_SRC := $(SRC_COMMON) ac_lua.cxx  # source for ahocorasick.so
+ LIBAC_A_SRC := $(LIBAC_SO_SRC)          # source for libac.a
+ 
+ #############################################################################
+@@ -67,10 +62,9 @@ LIBAC_A_SRC := $(LIBAC_SO_SRC)          # source for l
+ #############################################################################
+ #
+ .PHONY = all clean test benchmark prepare
+-all : $(C_SO_NAME) $(LUA_SO_NAME) $(AR_NAME)
++all : $(C_SO_NAME) $(AR_NAME)
+ 
+ -include c_so_dep.txt
+--include lua_so_dep.txt
+ -include ar_dep.txt
+ 
+ BUILD_SO_DIR := build_so
+@@ -80,28 +74,19 @@ $(BUILD_SO_DIR) :; mkdir $@
+ $(BUILD_AR_DIR) :; mkdir $@
+ 
+ $(BUILD_SO_DIR)/%.o : %.cxx | $(BUILD_SO_DIR)
+-	$(CXX) $< -c $(SO_CXXFLAGS) -I$(LUA_INCLUDE_DIR) -MMD -o $@
++	$(CXX) $< -c $(SO_CXXFLAGS) -MMD -o $@
+ 
+ $(BUILD_AR_DIR)/%.o : %.cxx | $(BUILD_AR_DIR)
+-	$(CXX) $< -c $(AR_CXXFLAGS) -I$(LUA_INCLUDE_DIR) -MMD -o $@
++	$(CXX) $< -c $(AR_CXXFLAGS) -MMD -o $@
+ 
+ ifneq ($(OS), Darwin)
+ $(C_SO_NAME) : $(addprefix $(BUILD_SO_DIR)/, ${LIBAC_SO_SRC:.cxx=.o})
+ 	$(CXX) $+ -shared -Wl,-soname=$(C_SO_NAME) $(SO_LFLAGS) -o $@
+ 	cat $(addprefix $(BUILD_SO_DIR)/, ${LIBAC_SO_SRC:.cxx=.d}) > c_so_dep.txt
+-
+-$(LUA_SO_NAME) : $(addprefix $(BUILD_SO_DIR)/, ${LUA_SO_SRC:.cxx=.o})
+-	$(CXX) $+ -shared -Wl,-soname=$(LUA_SO_NAME) $(SO_LFLAGS) -o $@
+-	cat $(addprefix $(BUILD_SO_DIR)/, ${LUA_SO_SRC:.cxx=.d}) > lua_so_dep.txt
+-
+ else
+ $(C_SO_NAME) : $(addprefix $(BUILD_SO_DIR)/, ${LIBAC_SO_SRC:.cxx=.o})
+ 	$(CXX) $+ -shared $(SO_LFLAGS) -o $@
+ 	cat $(addprefix $(BUILD_SO_DIR)/, ${LIBAC_SO_SRC:.cxx=.d}) > c_so_dep.txt
+-
+-$(LUA_SO_NAME) : $(addprefix $(BUILD_SO_DIR)/, ${LUA_SO_SRC:.cxx=.o})
+-	$(CXX) $+ -shared $(SO_LFLAGS) -o $@ -Wl,-undefined,dynamic_lookup
+-	cat $(addprefix $(BUILD_SO_DIR)/, ${LUA_SO_SRC:.cxx=.d}) > lua_so_dep.txt
+ endif
+ 
+ $(AR_NAME) : $(addprefix $(BUILD_AR_DIR)/, ${LIBAC_A_SRC:.cxx=.o})
+@@ -115,9 +100,7 @@ $(AR_NAME) : $(addprefix $(BUILD_AR_DIR)/, ${LIBAC_A_S
+ #############################################################################
+ #
+ test : $(C_SO_NAME)
+-	$(MAKE) -C tests && \
+-	luajit tests/lua_test.lua && \
+-	luajit tests/load_ac_test.lua
++	$(MAKE) -C tests &&
+ 
+ benchmark: $(C_SO_NAME)
+ 	$(MAKE) benchmark -C tests
diff --git a/devel/libac/pkg-descr b/devel/libac/pkg-descr
new file mode 100644
index 000000000000..8384e6d377cf
--- /dev/null
+++ b/devel/libac/pkg-descr
@@ -0,0 +1,11 @@
+This port is the C++ implementation of the Aho-Corasick (AC) string matching
+algorithm.
+
+The upstream began with pure Lua implementation and realize the performance is
+not satisfactory. So they switch to C/C++ implementation.
+
+There are two shared objects provided by this package: libac.so and
+ahocorasick.so The former is a regular shared object which can be directly used
+by C/C++ application, or by Lua via FFI; and the later is a Lua module.
+
+WWW: https://github.com/cloudflare/lua-aho-corasick