git: 87fb42bf34ef - main - audio/xwax: New port: Open-source vinyl emulation software

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Tue, 25 Jun 2024 09:26:14 UTC
The branch main has been updated by yuri:

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

commit 87fb42bf34ef1709b6cec889e40af2af69900a0d
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2024-06-25 08:54:09 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2024-06-25 09:26:07 +0000

    audio/xwax: New port: Open-source vinyl emulation software
---
 audio/Makefile                     |  1 +
 audio/xwax/Makefile                | 39 ++++++++++++++++++++++++++++++++++++++
 audio/xwax/distinfo                |  3 +++
 audio/xwax/files/patch-Makefile    | 23 ++++++++++++++++++++++
 audio/xwax/files/patch-excrate.c   | 10 ++++++++++
 audio/xwax/files/patch-interface.c | 34 +++++++++++++++++++++++++++++++++
 audio/xwax/files/patch-library.c   | 31 ++++++++++++++++++++++++++++++
 audio/xwax/files/patch-track.c     | 10 ++++++++++
 audio/xwax/pkg-descr               |  1 +
 9 files changed, 152 insertions(+)

diff --git a/audio/Makefile b/audio/Makefile
index 75013e342992..9246dc455a42 100644
--- a/audio/Makefile
+++ b/audio/Makefile
@@ -889,6 +889,7 @@
     SUBDIR += xsynth-dssi
     SUBDIR += xuidesigner
     SUBDIR += xwave
+    SUBDIR += xwax
     SUBDIR += yell
     SUBDIR += ympd
     SUBDIR += yoshimi
diff --git a/audio/xwax/Makefile b/audio/xwax/Makefile
new file mode 100644
index 000000000000..713d225c7396
--- /dev/null
+++ b/audio/xwax/Makefile
@@ -0,0 +1,39 @@
+PORTNAME=	xwax
+DISTVERSION=	1.9
+CATEGORIES=	audio
+MASTER_SITES=	https://www.xwax.co.uk/releases/
+
+MAINTAINER=	yuri@FreeBSD.org
+COMMENT=	Open-source vinyl emulation software
+WWW=		https://wiki.xwax.org/
+
+LICENSE=	GPLv3
+LICENSE_FILE=	${WRKSRC}/COPYING
+
+LIB_DEPENDS=	libjack.so:audio/jack
+RUN_DEPENDS=	bash:shells/bash \
+		${LOCALBASE}/share/fonts/dejavu/DejaVuSans.ttf:x11-fonts/dejavu
+
+USES=		compiler:c++11-lang gmake iconv localbase:ldflags sdl shebangfix
+USE_SDL=	sdl ttf
+
+SHEBANG_FILES=	scan
+
+GNU_CONFIGURE=	yes
+CONFIGURE_ARGS=	--enable-jack \
+		--enable-oss
+
+LDFLAGS+=	-liconv -lm
+
+PLIST_FILES=	bin/xwax \
+		libexec/xwax-import \
+		libexec/xwax-scan \
+		share/man/man1/xwax.1.gz
+
+post-patch:
+	@${REINPLACE_CMD} -e 's|/usr/|${LOCALBASE}/|' ${WRKSRC}/interface.c
+
+post-install:
+	@${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/xwax
+
+.include <bsd.port.mk>
diff --git a/audio/xwax/distinfo b/audio/xwax/distinfo
new file mode 100644
index 000000000000..d6aa3c2f402f
--- /dev/null
+++ b/audio/xwax/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1719277040
+SHA256 (xwax-1.9.tar.gz) = 9bed8fa143182818650361f49257755bf891f143161066aaa7bca8c6cce9f632
+SIZE (xwax-1.9.tar.gz) = 87599
diff --git a/audio/xwax/files/patch-Makefile b/audio/xwax/files/patch-Makefile
new file mode 100644
index 000000000000..3efb05915114
--- /dev/null
+++ b/audio/xwax/files/patch-Makefile
@@ -0,0 +1,23 @@
+--- Makefile.orig	2024-06-25 02:10:13 UTC
++++ Makefile
+@@ -137,13 +137,13 @@ install:
+ 
+ .PHONY:		install
+ install:
+-		$(INSTALL) -D xwax $(DESTDIR)$(BINDIR)/xwax
+-		$(INSTALL) -D scan $(DESTDIR)$(EXECDIR)/xwax-scan
+-		$(INSTALL) -D import $(DESTDIR)$(EXECDIR)/xwax-import
+-		$(INSTALL) -D -m 0644 xwax.1 $(DESTDIR)$(MANDIR)/man1/xwax.1
+-		$(INSTALL) -D -m 0644 CHANGES $(DESTDIR)$(DOCDIR)/xwax/CHANGES
+-		$(INSTALL) -D -m 0644 COPYING $(DESTDIR)$(DOCDIR)/xwax/COPYING
+-		$(INSTALL) -D -m 0644 README $(DESTDIR)$(DOCDIR)/xwax/README
++		$(INSTALL) xwax $(DESTDIR)$(BINDIR)/xwax
++		$(INSTALL) scan $(DESTDIR)$(EXECDIR)/xwax-scan
++		$(INSTALL) import $(DESTDIR)$(EXECDIR)/xwax-import
++		$(INSTALL) -m 0644 xwax.1 $(DESTDIR)$(MANDIR)/man1/xwax.1
++		#$(INSTALL) -m 0644 CHANGES $(DESTDIR)$(DOCDIR)/xwax/CHANGES
++		#$(INSTALL) -m 0644 COPYING $(DESTDIR)$(DOCDIR)/xwax/COPYING
++		#$(INSTALL) -m 0644 README $(DESTDIR)$(DOCDIR)/xwax/README
+ 
+ # Distribution archive from Git source code
+ 
diff --git a/audio/xwax/files/patch-excrate.c b/audio/xwax/files/patch-excrate.c
new file mode 100644
index 000000000000..548ddc56ceca
--- /dev/null
+++ b/audio/xwax/files/patch-excrate.c
@@ -0,0 +1,10 @@
+--- excrate.c.orig	2024-06-25 01:52:31 UTC
++++ excrate.c
+@@ -28,6 +28,7 @@
+ #include <errno.h>
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <sys/signal.h>
+ #include <sys/wait.h>
+ 
+ #include "debug.h"
diff --git a/audio/xwax/files/patch-interface.c b/audio/xwax/files/patch-interface.c
new file mode 100644
index 000000000000..6ad03dd92504
--- /dev/null
+++ b/audio/xwax/files/patch-interface.c
@@ -0,0 +1,34 @@
+--- interface.c.orig	2023-05-12 17:27:59 UTC
++++ interface.c
+@@ -414,11 +414,12 @@ static int do_draw_text(SDL_Surface *sf, const struct 
+         src.h = 0;
+ 
+     } else {
++        char *in = NULL;
+         if (!locale) {
+             rendered = TTF_RenderText_Shaded(font, buf, fg, bg);
+         } else {
+             char ubuf[256], /* fixed buffer is reasonable for rendering */
+-                *in, *out;
++                *out;
+             size_t len, fill;
+ 
+             out = ubuf;
+@@ -427,7 +428,7 @@ static int do_draw_text(SDL_Surface *sf, const struct 
+             if (iconv(utf, NULL, NULL, &out, &fill) == -1)
+                 abort();
+ 
+-            in = strdupa(buf);
++            in = strdup(buf);
+             len = strlen(in);
+ 
+             (void)iconv(utf, &in, &len, &out, &fill);
+@@ -446,6 +447,8 @@ static int do_draw_text(SDL_Surface *sf, const struct 
+ 
+         SDL_BlitSurface(rendered, &src, sf, &dst);
+         SDL_FreeSurface(rendered);
++
++        //free(in); // this crashes with free() enabled for unknown reason, it's better to just lose the memory here
+     }
+ 
+     /* Complete the remaining space with a blank rectangle */
diff --git a/audio/xwax/files/patch-library.c b/audio/xwax/files/patch-library.c
new file mode 100644
index 000000000000..ddd573314804
--- /dev/null
+++ b/audio/xwax/files/patch-library.c
@@ -0,0 +1,31 @@
+--- library.c.orig	2024-06-25 01:59:59 UTC
++++ library.c
+@@ -603,12 +603,13 @@ int library_import(struct library *li, const char *sca
+     char *cratename, *pathname;
+     struct crate *crate;
+ 
+-    pathname = strdupa(path);
++    pathname = strdup(path);
+     cratename = basename(pathname); /* POSIX version, see basename(3) */
+     assert(cratename != NULL);
+ 
+     crate = malloc(sizeof *crate);
+     if (crate == NULL) {
++        free(pathname);
+         perror("malloc");
+         return -1;
+     }
+@@ -619,11 +620,13 @@ int library_import(struct library *li, const char *sca
+     if (add_crate(li, crate) == -1)
+         goto fail_crate;
+ 
++    free(pathname);
+     return 0;
+ 
+ fail_crate:
+     crate_clear(crate);
+ fail:
++    free(pathname);
+     free(crate);
+     return -1;
+ 
diff --git a/audio/xwax/files/patch-track.c b/audio/xwax/files/patch-track.c
new file mode 100644
index 000000000000..b65a7ba4a76d
--- /dev/null
+++ b/audio/xwax/files/patch-track.c
@@ -0,0 +1,10 @@
+--- track.c.orig	2024-06-25 02:02:16 UTC
++++ track.c
+@@ -22,6 +22,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <sys/types.h>
++#include <sys/signal.h>
+ #include <sys/wait.h>
+ #include <sys/mman.h> /* mlock() */
+ 
diff --git a/audio/xwax/pkg-descr b/audio/xwax/pkg-descr
new file mode 100644
index 000000000000..08eed90ea22e
--- /dev/null
+++ b/audio/xwax/pkg-descr
@@ -0,0 +1 @@
+xwax is an open source vinyl emulation software project.