pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

add libjxl version 0.6 to pkgsrc-wip



Module Name:	pkgsrc-wip
Committed By:	Niclas Rosenvik <nros%NetBSD.org@localhost>
Pushed By:	nros
Date:		Thu Oct 14 21:00:02 2021 +0000
Changeset:	9e5efbd9c558b0ee9595e3319d08af94a8a7296e

Modified Files:
	Makefile
Added Files:
	libjxl/DESCR
	libjxl/Makefile
	libjxl/Makefile.common
	libjxl/PLIST
	libjxl/buildlink3.mk
	libjxl/distinfo
	libjxl/patches/patch-CMakeLists.txt
	libjxl/patches/patch-deps.sh
	libjxl/patches/patch-lib_jxl_base_os__macros.h
	libjxl/patches/patch-tools_cpu_os__specific.cc

Log Message:
add libjxl version 0.6 to pkgsrc-wip

Library for reading and writing JPEG XL images.
JPEG XL (.jxl) is the next generation , general-purpose
image compression codec by the JPEG committee.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=9e5efbd9c558b0ee9595e3319d08af94a8a7296e

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 Makefile                                       |   1 +
 libjxl/DESCR                                   |   3 +
 libjxl/Makefile                                |  35 ++++++
 libjxl/Makefile.common                         |  13 +++
 libjxl/PLIST                                   |  34 ++++++
 libjxl/buildlink3.mk                           |  15 +++
 libjxl/distinfo                                |   9 ++
 libjxl/patches/patch-CMakeLists.txt            |  15 +++
 libjxl/patches/patch-deps.sh                   |  23 ++++
 libjxl/patches/patch-lib_jxl_base_os__macros.h |  17 +++
 libjxl/patches/patch-tools_cpu_os__specific.cc | 145 +++++++++++++++++++++++++
 11 files changed, 310 insertions(+)

diffs:
diff --git a/Makefile b/Makefile
index 3aa82cc34a..8468d0895b 100644
--- a/Makefile
+++ b/Makefile
@@ -2100,6 +2100,7 @@ SUBDIR+=	libircclient
 SUBDIR+=	libitl
 SUBDIR+=	libjdksmidi
 SUBDIR+=	libjingle
+SUBDIR+=	libjxl
 SUBDIR+=	libkdepim
 SUBDIR+=	libkgapi
 SUBDIR+=	libkleo
diff --git a/libjxl/DESCR b/libjxl/DESCR
new file mode 100644
index 0000000000..45fd816801
--- /dev/null
+++ b/libjxl/DESCR
@@ -0,0 +1,3 @@
+Library for reading and writing JPEG XL images.
+JPEG XL (.jxl) is the next generation , general-purpose
+image compression codec by the JPEG committee.
diff --git a/libjxl/Makefile b/libjxl/Makefile
new file mode 100644
index 0000000000..768f8727e1
--- /dev/null
+++ b/libjxl/Makefile
@@ -0,0 +1,35 @@
+# $NetBSD$
+
+.include "../../wip/libjxl/Makefile.common"
+COMMENT=	JpegXL reference codec
+
+USE_TOOLS+=	bash pkg-config
+USE_LANGUAGES=	c c++
+USE_CMAKE=	yes
+
+CMAKE_ARGS+=	-DJPEGXL_VERSION=${PKGVERSION_NOREV}
+CMAKE_ARGS+=	-DJPEGXL_FORCE_SYSTEM_BROTLI=ON
+CMAKE_ARGS+=	-DJPEGXL_FORCE_SYSTEM_GTEST=ON
+CMAKE_ARGS+=	-DJPEGXL_FORCE_SYSTEM_HWY=ON
+CMAKE_ARGS+=	-DJPEGXL_ENABLE_SJPEG=OFF
+
+REPLACE_BASH=	deps.sh
+
+PKGCONFIG_OVERRIDE+=	lib/jxl/libjxl.pc.in
+PKGCONFIG_OVERRIDE+=	lib/threads/libjxl_threads.pc.in
+
+pre-configure:
+	cd ${WRKSRC} && ./deps.sh
+
+TOOL_DEPENDS+=	asciidoc-[0-9]*:../../textproc/asciidoc
+TOOL_DEPENDS+=	realpath-[0-9]*:../../wip/realpath
+
+.include "../../archivers/brotli/buildlink3.mk"
+.include "../../devel/googletest/buildlink3.mk"
+.include "../../graphics/giflib/buildlink3.mk"
+.include "../../graphics/openexr/buildlink3.mk"
+.include "../../graphics/libwebp/buildlink3.mk"
+.include "../../graphics/png/buildlink3.mk"
+.include "../../wip/libhighway/buildlink3.mk"
+.include "../../mk/jpeg.buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/libjxl/Makefile.common b/libjxl/Makefile.common
new file mode 100644
index 0000000000..e7ad50404d
--- /dev/null
+++ b/libjxl/Makefile.common
@@ -0,0 +1,13 @@
+# $NetBSD$
+
+DISTNAME=	libjxl-0.6
+CATEGORIES=	graphics
+MASTER_SITES=	${MASTER_SITE_GITHUB:=libjxl/}
+GITHUB_TAG=	v${PKGVERSION_NOREV}
+
+MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE=	https://jpegxl.info/
+LICENSE=	modified-bsd
+
+PATCHDIR?=	${.CURDIR}/../../wip/libjxl/patches
+DISTINFO_FILE?=	${.CURDIR}/../../wip/libjxl/distinfo
diff --git a/libjxl/PLIST b/libjxl/PLIST
new file mode 100644
index 0000000000..8e12578b42
--- /dev/null
+++ b/libjxl/PLIST
@@ -0,0 +1,34 @@
+@comment $NetBSD$
+bin/benchmark_xl
+bin/cjxl
+bin/djxl
+include/jxl/butteraugli.h
+include/jxl/butteraugli_cxx.h
+include/jxl/codestream_header.h
+include/jxl/color_encoding.h
+include/jxl/decode.h
+include/jxl/decode_cxx.h
+include/jxl/encode.h
+include/jxl/encode_cxx.h
+include/jxl/jxl_export.h
+include/jxl/jxl_threads_export.h
+include/jxl/memory_manager.h
+include/jxl/parallel_runner.h
+include/jxl/resizable_parallel_runner.h
+include/jxl/resizable_parallel_runner_cxx.h
+include/jxl/thread_parallel_runner.h
+include/jxl/thread_parallel_runner_cxx.h
+include/jxl/types.h
+lib/libjxl.a
+lib/libjxl.so
+lib/libjxl.so.${PKGVERSION}
+lib/libjxl.so.${PKGVERSION}.0
+lib/libjxl_dec.a
+lib/libjxl_threads.a
+lib/libjxl_threads.so
+lib/libjxl_threads.so.${PKGVERSION}
+lib/libjxl_threads.so.${PKGVERSION}.0
+lib/pkgconfig/libjxl.pc
+lib/pkgconfig/libjxl_threads.pc
+man/man1/cjxl.1
+man/man1/djxl.1
diff --git a/libjxl/buildlink3.mk b/libjxl/buildlink3.mk
new file mode 100644
index 0000000000..dd9da5439a
--- /dev/null
+++ b/libjxl/buildlink3.mk
@@ -0,0 +1,15 @@
+# $NetBSD$
+
+BUILDLINK_TREE+=	libjxl
+
+.if !defined(LIBJXL_BUILDLINK3_MK)
+LIBJXL_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.libjxl+=	libjxl>=0.6
+BUILDLINK_PKGSRCDIR.libjxl?=	../../wip/libjxl
+
+.include "../../archivers/brotli/buildlink3.mk"
+.include "../../wip/libhighway/buildlink3.mk"
+.endif	# LIBJXL_BUILDLINK3_MK
+
+BUILDLINK_TREE+=	-libjxl
diff --git a/libjxl/distinfo b/libjxl/distinfo
new file mode 100644
index 0000000000..dfb4e0ee51
--- /dev/null
+++ b/libjxl/distinfo
@@ -0,0 +1,9 @@
+$NetBSD$
+
+RMD160 (libjxl-0.6.tar.gz) = c24c9b2b0e2a5a24a030c6be11f392e989047b9b
+SHA512 (libjxl-0.6.tar.gz) = 934c86d079c7a1f5382fad158efac225b9d1b27e551ea85ea7ec43e7ffd5cba85ddbfa35658b242a9f9c9589decf245568349abfa8a4fe12898af78d51608852
+Size (libjxl-0.6.tar.gz) = 16953410 bytes
+SHA1 (patch-CMakeLists.txt) = 037a77f2c258424fcc75f7eff2b75ae4cc150b19
+SHA1 (patch-deps.sh) = 7886018fe8f79f692865c852b2755e4b16a3ee72
+SHA1 (patch-lib_jxl_base_os__macros.h) = 083d97beeec362271fa1ce515204332f1d8938e6
+SHA1 (patch-tools_cpu_os__specific.cc) = 8cdd77ae04ad80e09c4e46ef1de29ba71cebc0b7
diff --git a/libjxl/patches/patch-CMakeLists.txt b/libjxl/patches/patch-CMakeLists.txt
new file mode 100644
index 0000000000..09d4146891
--- /dev/null
+++ b/libjxl/patches/patch-CMakeLists.txt
@@ -0,0 +1,15 @@
+$NetBSD$
+
+* install manpages to PKGMANDIR
+
+--- CMakeLists.txt.orig	2021-10-04 18:02:44.000000000 +0000
++++ CMakeLists.txt
+@@ -364,7 +364,7 @@ if (ASCIIDOC_PY_FOUND)
+     list(APPEND MANPAGES "${PAGE}.1")
+   endforeach()
+   add_custom_target(manpages ALL DEPENDS ${MANPAGES})
+-  install(FILES ${MANPAGE_FILES} DESTINATION share/man/man1)
++  install(FILES ${MANPAGE_FILES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
+ endif()  # ASCIIDOC_PY_FOUND
+ else()
+   message(WARNING "asciidoc was not found, the man pages will not be installed.")
diff --git a/libjxl/patches/patch-deps.sh b/libjxl/patches/patch-deps.sh
new file mode 100644
index 0000000000..8a1953d6d9
--- /dev/null
+++ b/libjxl/patches/patch-deps.sh
@@ -0,0 +1,23 @@
+$NetBSD$
+
+* don't require git
+
+--- deps.sh.orig	2021-10-04 18:02:44.000000000 +0000
++++ deps.sh
+@@ -57,16 +57,6 @@ download_github() {
+ 
+ 
+ main() {
+-  if git -C "${MYDIR}" rev-parse; then
+-    cat >&2 <<EOF
+-Current directory is a git repository, downloading dependencies via git:
+-
+-  git submodule update --init --recursive
+-
+-EOF
+-    git -C "${MYDIR}" submodule update --init --recursive
+-    return 0
+-  fi
+ 
+   # Sources downloaded from a tarball.
+   download_github third_party/highway google/highway
diff --git a/libjxl/patches/patch-lib_jxl_base_os__macros.h b/libjxl/patches/patch-lib_jxl_base_os__macros.h
new file mode 100644
index 0000000000..d503405b0f
--- /dev/null
+++ b/libjxl/patches/patch-lib_jxl_base_os__macros.h
@@ -0,0 +1,17 @@
+$NetBSD$
+
+* add NetBSD support
+
+--- lib/jxl/base/os_macros.h.orig	2021-10-04 18:02:44.000000000 +0000
++++ lib/jxl/base/os_macros.h
+@@ -47,4 +47,10 @@
+ #define JXL_OS_HAIKU 0
+ #endif
+ 
++#ifdef __NetBSD__
++#define JXL_OS_NETBSD 1
++#else
++#define JXL_OS_NETBSD 0
++#endif
++
+ #endif  // LIB_JXL_BASE_OS_MACROS_H_
diff --git a/libjxl/patches/patch-tools_cpu_os__specific.cc b/libjxl/patches/patch-tools_cpu_os__specific.cc
new file mode 100644
index 0000000000..df269bdf04
--- /dev/null
+++ b/libjxl/patches/patch-tools_cpu_os__specific.cc
@@ -0,0 +1,145 @@
+$NetBSD$
+
+* add NetBSD support
+
+--- tools/cpu/os_specific.cc.orig	2021-10-04 18:02:44.000000000 +0000
++++ tools/cpu/os_specific.cc
+@@ -59,6 +59,15 @@
+ #include <OS.h>
+ #endif  // JXL_OS_HAIKU
+ 
++#if JXL_OS_NETBSD
++#include <pthread.h>
++#include <sched.h>
++#include <sys/param.h>
++#include <sys/sysctl.h>
++#include <sys/types.h>
++#include <unistd.h>
++#endif //JXL_OS_NETBSD
++
+ using jxl::Status;
+ 
+ namespace jpegxl {
+@@ -82,10 +91,14 @@ static inline void CPU_SET(int cpu, cpu_
+ #endif
+ 
+ struct ThreadAffinity {
++#if JXL_OS_NETBSD
++  cpuset_t *set;
++#else
+   cpu_set_t set;
++#endif
+ };
+ 
+-#if JXL_OS_MAC
++#if JXL_OS_MAC || JXL_OS_NETBSD 
+ namespace {
+ Status GetSystemValue(const char* name, size_t* value) {
+   int64_t value_i64 = 0;
+@@ -96,7 +109,9 @@ Status GetSystemValue(const char* name, 
+   *value = static_cast<size_t>(value_i64);
+   return true;
+ }
+-
++} // namespace
++#endif
++#if JXL_OS_MAC
+ // Returns mask with the lowest N bits set, one per logical processor.
+ cpu_set_t SetOfAllLogicalProcessors() {
+   size_t logical;
+@@ -153,7 +168,14 @@ Status GetProcessorTopologyFromOS(Proces
+   pt->logical_per_core = 1;
+ 
+   return true;
++#elif JXL_OS_NETBSD
++  size_t cores;
++  JXL_RETURN_IF_ERROR(GetSystemValue("hw.ncpuonline", &cores));
++  pt->packages = 1;
++  pt->cores_per_package = cores;
++  pt->logical_per_core = 1;
+ 
++  return true;
+ #else
+   // Not needed on X64 if the affinity APIs work (DetectProcessorTopology will
+   // succeed)
+@@ -164,6 +186,19 @@ Status GetProcessorTopologyFromOS(Proces
+ ThreadAffinity* GetThreadAffinity() {
+   ThreadAffinity* affinity =
+       static_cast<ThreadAffinity*>(malloc(sizeof(ThreadAffinity)));
++#if JXL_OS_NETBSD
++  if (affinity != NULL) {
++    affinity->set = cpuset_create();
++    if (affinity->set == NULL) {
++      free(affinity);
++      affinity = NULL;
++    } else {
++      cpuset_zero(affinity->set);
++      const int err = pthread_getaffinity_np(pthread_self(), cpuset_size(affinity->set), affinity->set);
++      JXL_CHECK(err == 0);
++    }
++  }
++#endif
+ #if JXL_OS_WIN
+   DWORD_PTR process_affinity, system_affinity;
+   const BOOL ok = GetProcessAffinityMask(GetCurrentProcess(), &process_affinity,
+@@ -195,6 +230,19 @@ ThreadAffinity* OriginalThreadAffinity()
+ 
+ }  // namespace
+ 
++#if JXL_OS_NETBSD
++bool set_affinity_allowed()
++{
++  if (geteuid() == 0)
++    return true;
++
++  size_t len = 4;
++  int *val =(int*)asysctlbyname("security.models.extensions.user_set_cpu_affinity", &len);
++
++  return (*val == 1);
++}
++#endif
++
+ Status SetThreadAffinity(ThreadAffinity* affinity) {
+   // Ensure original is initialized before changing.
+   const ThreadAffinity* const original = OriginalThreadAffinity();
+@@ -224,6 +272,14 @@ Status SetThreadAffinity(ThreadAffinity*
+   // As of 2020-06 Haiku does not support pinning threads to cores.
+   (void)affinity;
+   return false;
++#elif JXL_OS_NETBSD
++  if (!set_affinity_allowed()) 
++     return false;
++
++  const int err = pthread_setaffinity_np(pthread_self(), cpuset_size(affinity->set),
++                                        affinity->set);
++  if (err != 0) return JXL_FAILURE("cpuset_setaffinity_np failed");
++  return true;  
+ #else
+   printf("Don't know how to SetThreadAffinity on this platform.\n");
+   return false;
+@@ -255,6 +311,16 @@ Status PinThreadToCPU(const int cpu) {
+   CPU_ZERO(&affinity.set);
+   CPU_SET(cpu, &affinity.set);
+   return SetThreadAffinity(&affinity);
++#elif JXL_OS_NETBSD
++  ThreadAffinity affinity;
++  affinity.set = cpuset_create();
++  if (affinity.set == nullptr)
++    return false;
++  cpuset_zero(affinity.set);
++  cpuset_set(cpu, affinity.set);
++  bool st = SetThreadAffinity(&affinity);
++  cpuset_destroy(affinity.set);
++  return st;
+ #else
+   return false;
+ #endif
+@@ -280,7 +346,7 @@ Status PinThreadToRandomCPU() {
+ namespace {
+ 
+ size_t DetectTotalMemoryMiB() {
+-#if JXL_OS_LINUX || JXL_OS_FREEBSD || JXL_OS_MAC
++#if JXL_OS_LINUX || JXL_OS_FREEBSD || JXL_OS_MAC || JXL_OS_NETBSD
+   const long page_size = sysconf(_SC_PAGESIZE);
+   const long num_pages = sysconf(_SC_PHYS_PAGES);
+   if (page_size == -1 || num_pages == -1) {


Home | Main Index | Thread Index | Old Index