git: 62072792a60d - main - math/libdivsufsort: New port: Lightweight suffix-sorting library
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 21 Jul 2023 19:00:00 UTC
The branch main has been updated by yuri: URL: https://cgit.FreeBSD.org/ports/commit/?id=62072792a60d0c11a8d4fa07d9b93c13976c56b7 commit 62072792a60d0c11a8d4fa07d9b93c13976c56b7 Author: Yuri Victorovich <yuri@FreeBSD.org> AuthorDate: 2023-07-21 18:59:23 +0000 Commit: Yuri Victorovich <yuri@FreeBSD.org> CommitDate: 2023-07-21 18:59:57 +0000 math/libdivsufsort: New port: Lightweight suffix-sorting library --- math/Makefile | 1 + math/libdivsufsort/Makefile | 32 ++++++++++++++++++++++++++++++++ math/libdivsufsort/distinfo | 3 +++ math/libdivsufsort/files/test.c | 34 ++++++++++++++++++++++++++++++++++ math/libdivsufsort/pkg-descr | 7 +++++++ 5 files changed, 77 insertions(+) diff --git a/math/Makefile b/math/Makefile index 0d8c393b4db6..7fea1dcd2f10 100644 --- a/math/Makefile +++ b/math/Makefile @@ -444,6 +444,7 @@ SUBDIR += libccd SUBDIR += libcerf SUBDIR += libdivide + SUBDIR += libdivsufsort SUBDIR += libfixmath SUBDIR += libflame SUBDIR += libformfactor diff --git a/math/libdivsufsort/Makefile b/math/libdivsufsort/Makefile new file mode 100644 index 000000000000..220c8accbb85 --- /dev/null +++ b/math/libdivsufsort/Makefile @@ -0,0 +1,32 @@ +PORTNAME= libdivsufsort +DISTVERSIONPREFIX= v +DISTVERSION= 2.0.1-14 +DISTVERSIONSUFFIX= -g5f60d6f +CATEGORIES= math + +MAINTAINER= yuri@FreeBSD.org +COMMENT= Lightweight suffix-sorting library +WWW= https://github.com/y-256/libdivsufsort + +LICENSE= MIT +LICENSE_FILE= ${WRKSRC}/LICENSE + +USES= cmake pathfix +USE_LDCONFIG= yes + +USE_GITHUB= yes +GH_ACCOUNT= y-256 + +PLIST_FILES= include/divsufsort.h \ + lib/libdivsufsort.so \ + lib/libdivsufsort.so.3 \ + lib/libdivsufsort.so.3.0.1 \ + libdata/pkgconfig/libdivsufsort.pc + +do-test: + @cd ${TEST_WRKSRC} && \ + ${SETENV} ${TEST_ENV} ${CC} ${FILESDIR}/test.c -I${STAGEDIR}${PREFIX}/include -L${STAGEDIR}${PREFIX}/lib -ldivsufsort && \ + ${ECHO} "==> running the test program:" && \ + LD_PRELOAD=${STAGEDIR}${PREFIX}/lib/libdivsufsort.so ${TEST_WRKSRC}/a.out + +.include <bsd.port.mk> diff --git a/math/libdivsufsort/distinfo b/math/libdivsufsort/distinfo new file mode 100644 index 000000000000..63ebe645c508 --- /dev/null +++ b/math/libdivsufsort/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1689965360 +SHA256 (y-256-libdivsufsort-v2.0.1-14-g5f60d6f_GH0.tar.gz) = 9de40c9a343a3776c4a9ebc2dac93d0f1cd8ce021cd095b5d9ecc381c2207eab +SIZE (y-256-libdivsufsort-v2.0.1-14-g5f60d6f_GH0.tar.gz) = 25900 diff --git a/math/libdivsufsort/files/test.c b/math/libdivsufsort/files/test.c new file mode 100644 index 000000000000..f001733d9254 --- /dev/null +++ b/math/libdivsufsort/files/test.c @@ -0,0 +1,34 @@ +// simple example from README + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <divsufsort.h> + +int main() { + // intput data + char *Text = "abracadabra"; + int n = strlen(Text); + int i, j; + + // allocate + int *SA = (int *)malloc(n * sizeof(int)); + + // sort + divsufsort((unsigned char *)Text, SA, n); + + // output + for(i = 0; i < n; ++i) { + printf("SA[%2d] = %2d: ", i, SA[i]); + for(j = SA[i]; j < n; ++j) { + printf("%c", Text[j]); + } + printf("$\n"); + } + + // deallocate + free(SA); + + return 0; +} diff --git a/math/libdivsufsort/pkg-descr b/math/libdivsufsort/pkg-descr new file mode 100644 index 000000000000..0024aaeafae3 --- /dev/null +++ b/math/libdivsufsort/pkg-descr @@ -0,0 +1,7 @@ +libdivsufsort is a software library that implements a lightweight suffix array +construction algorithm. + +This library provides a simple and an efficient C API to construct a suffix +array and a Burrows-Wheeler transformed string from a given string over a +constant-size alphabet. The algorithm runs in O(n log n) worst-case time using +only 5n+O(1) bytes of memory space, where n is the length of the string.