git: c66fa584263e - main - devel/libchdr: New port: Standalone library for reading MAME CHDv1-v5 formats

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Thu, 14 Nov 2024 08:44:23 UTC
The branch main has been updated by fuz:

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

commit c66fa584263efe3b13cf9d2dee1a5c97448c4a26
Author:     Stefan Schlosser <bsdcode@disroot.org>
AuthorDate: 2024-11-09 20:51:33 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2024-11-14 08:43:26 +0000

    devel/libchdr: New port: Standalone library for reading MAME CHDv1-v5 formats
    
    libchdr is a standalone library for reading MAME's CHDv1-v5 formats.
    
    The code is based off of MAME's old C codebase which read up to CHDv4 with
    OS-dependent features removed, and CHDv5 support backported from MAME's current
    C++ codebase.
    
    WWW: https://github.com/rtissera/libchdr
    
    PR:             282692
---
 devel/Makefile                           |  1 +
 devel/libchdr/Makefile                   | 26 ++++++++++++++++++++++++++
 devel/libchdr/distinfo                   |  3 +++
 devel/libchdr/files/patch-CMakeLists.txt | 26 ++++++++++++++++++++++++++
 devel/libchdr/pkg-descr                  |  5 +++++
 devel/libchdr/pkg-plist                  | 13 +++++++++++++
 6 files changed, 74 insertions(+)

diff --git a/devel/Makefile b/devel/Makefile
index daf9f8cc8642..e64fa0f42543 100644
--- a/devel/Makefile
+++ b/devel/Makefile
@@ -1221,6 +1221,7 @@
     SUBDIR += libcdb
     SUBDIR += libcds
     SUBDIR += libcfu
+    SUBDIR += libchdr
     SUBDIR += libchipcard
     SUBDIR += libcidr
     SUBDIR += libcii
diff --git a/devel/libchdr/Makefile b/devel/libchdr/Makefile
new file mode 100644
index 000000000000..a5ca39c65376
--- /dev/null
+++ b/devel/libchdr/Makefile
@@ -0,0 +1,26 @@
+PORTNAME=	libchdr
+DISTVERSION=	g20241111
+CATEGORIES=	devel
+
+MAINTAINER=	bsdcode@disroot.org
+COMMENT=	Standalone library for reading MAME CHDv1-v5 formats
+WWW=		https://github.com/rtissera/libchdr
+
+LICENSE=	BSD3CLAUSE
+LICENSE_FILE=	${WRKSRC}/LICENSE.txt
+
+LIB_DEPENDS=	libzstd.so:archivers/zstd
+
+USES=		cmake pathfix pkgconfig
+USE_GITHUB=	yes
+GH_ACCOUNT=	rtissera
+GH_TAGNAME=	b3974651d869c2f804e9879b063c23280d2ae617
+USE_LDCONFIG=	yes
+
+CMAKE_ARGS=	-DBUILD_LTO=${defined(WITH_LTO):?ON:OFF}
+CMAKE_ON=	INSTALL_STATIC_LIBS WITH_SYSTEM_ZLIB WITH_SYSTEM_ZSTD
+
+post-install:
+	${RLN} ${STAGEDIR}${PREFIX}/lib/libchdr-static.a ${STAGEDIR}${PREFIX}/lib/libchdr.a
+
+.include <bsd.port.mk>
diff --git a/devel/libchdr/distinfo b/devel/libchdr/distinfo
new file mode 100644
index 000000000000..129e3d7d1f45
--- /dev/null
+++ b/devel/libchdr/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1731325563
+SHA256 (rtissera-libchdr-g20241111-b3974651d869c2f804e9879b063c23280d2ae617_GH0.tar.gz) = e17270412aaa7158073ec6d8e6287f80a64354ba2b4edbd5786f2d8571f9e787
+SIZE (rtissera-libchdr-g20241111-b3974651d869c2f804e9879b063c23280d2ae617_GH0.tar.gz) = 4222329
diff --git a/devel/libchdr/files/patch-CMakeLists.txt b/devel/libchdr/files/patch-CMakeLists.txt
new file mode 100644
index 000000000000..80417eff28fc
--- /dev/null
+++ b/devel/libchdr/files/patch-CMakeLists.txt
@@ -0,0 +1,26 @@
+--- CMakeLists.txt.orig	2024-11-12 19:29:11 UTC
++++ CMakeLists.txt
+@@ -51,8 +51,12 @@ if (WITH_SYSTEM_ZSTD)
+ 
+ # zstd
+ if (WITH_SYSTEM_ZSTD)
+-  find_package(zstd REQUIRED)
+-  list(APPEND PLATFORM_LIBS zstd::libzstd_shared)
++  # find_package(zstd) fails on i386 because of a known problem with the
++  # provided cmake module. Use pkg_check_modules instead.
++  find_package(PkgConfig REQUIRED)
++  pkg_check_modules(zstd REQUIRED libzstd)
++  list(APPEND CHDR_INCLUDES ${zstd_INCLUDE_DIRS})
++  list(APPEND PLATFORM_LIBS ${zstd_LINK_LIBRARIES})
+ else()
+   option(ZSTD_BUILD_SHARED "BUILD SHARED LIBRARIES" OFF)
+   option(ZSTD_BUILD_PROGRAMS "BUILD PROGRAMS" OFF)
+@@ -83,7 +87,7 @@ if (INSTALL_STATIC_LIBS)
+ endif()
+ 
+ if (INSTALL_STATIC_LIBS)
+-  install(TARGETS chdr-static ${CHDR_LIBS}
++  install(TARGETS chdr-static
+     ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+   )
+ endif()
diff --git a/devel/libchdr/pkg-descr b/devel/libchdr/pkg-descr
new file mode 100644
index 000000000000..b3e772f746ae
--- /dev/null
+++ b/devel/libchdr/pkg-descr
@@ -0,0 +1,5 @@
+libchdr is a standalone library for reading MAME's CHDv1-v5 formats.
+
+The code is based off of MAME's old C codebase which read up to CHDv4 with
+OS-dependent features removed, and CHDv5 support backported from MAME's current
+C++ codebase.
diff --git a/devel/libchdr/pkg-plist b/devel/libchdr/pkg-plist
new file mode 100644
index 000000000000..49bdddd8b05e
--- /dev/null
+++ b/devel/libchdr/pkg-plist
@@ -0,0 +1,13 @@
+include/libchdr/bitstream.h
+include/libchdr/cdrom.h
+include/libchdr/chd.h
+include/libchdr/chdconfig.h
+include/libchdr/coretypes.h
+include/libchdr/flac.h
+include/libchdr/huffman.h
+lib/libchdr-static.a
+lib/libchdr.a
+lib/libchdr.so
+lib/libchdr.so.0
+lib/libchdr.so.0.2
+libdata/pkgconfig/libchdr.pc