[PD-dev] pd-0.43.0 port to NetBSD

Thomas Klausner tk at giga.or.at
Thu Sep 15 03:15:05 CEST 2011


Hi!

I've ported pd-0.43.0 to NetBSD.
It compiles fine and it does stuff.
I'm new to pd, so I can't evaluate yet if everything's fine.
I've imported the resulting package into pkgsrc as pkgsrc/audio/pd.
It will soon be visible at
	http://pkgsrc.se/audio/pd

The patches might need cleanup before they can be included into pd,
but even in their current state they show the issues I had to solve.

There are three more issues I fixed with sed:
1. hardcoded path to tclsh in tcl/pkg_mkIndex.tcl
2. path to audio device in src/s_audio_oss.c
3. paths to documentation, which I moved to ${PREFIX}/share/doc/pd to
follow pkgsrc conventions

Please let me know about the best way to get these or similar patches
integrated.

Thanks,
 Thomas
-------------- next part --------------
$NetBSD: patch-Makefile.am,v 1.1.1.1 2011/09/15 01:05:05 wiz Exp $

Fix path to documentation (installed following pksrc conventions).
Avoid creating unnecessary(?) empty directory.

--- Makefile.am.orig	2010-08-18 23:42:59.000000000 +0000
+++ Makefile.am
@@ -37,11 +37,7 @@ endif
 ## FIXXXME
 ## $(pkglibdir) is used throughout the other Makefile.amS
 ##       simply ignoring the special case for other OSs...
-if LINUX
-libpddir = $(pkglibdir)
-else
-libpddir = $(prefix)
-endif
+libpddir = $(prefix)/share/doc/pd
 
 # Symlinks don't work on Windows/MinGW but they do on Cygwin.
 bin:
@@ -51,6 +47,7 @@ locales:
 	make -C po all
 
 install-data-local:
+mingw-install-data-local:
 	$(INSTALL) -d $(DESTDIR)$(libpddir)/startup
 	$(INSTALL) -d $(DESTDIR)$(libpddir)/startup/disabled
 
-------------- next part --------------
$NetBSD: patch-extra_bonk~_bonk~.c,v 1.1.1.1 2011/09/15 01:05:05 wiz Exp $

alloca.h is not portable.

--- extra/bonk~/bonk~.c.orig	2010-08-19 01:37:00.000000000 +0000
+++ extra/bonk~/bonk~.c
@@ -82,11 +82,7 @@ void *bonk_class;
 static t_class *bonk_class;
 #endif
 
-#ifdef _WIN32
 #include <malloc.h>
-#elif ! defined(_MSC_VER)
-#include <alloca.h>
-#endif
 
 /* ------------------------ bonk~ ----------------------------- */
 
-------------- next part --------------
$NetBSD: patch-extra_pd~_pd~.c,v 1.1.1.1 2011/09/15 01:05:05 wiz Exp $

Add missing include (for SIGPIPE).
Define extensions for NetBSD.

--- extra/pd~/pd~.c.orig	2010-07-28 20:55:17.000000000 +0000
+++ extra/pd~/pd~.c
@@ -6,6 +6,7 @@
 */
 
 #include <stdio.h>
+#include <signal.h>
 #include <string.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -56,6 +57,15 @@ static char pd_tilde_dllextent[] = ".l_i
     pd_tilde_dllextent2[] = ".pd_linux";
 #endif
 #endif
+#if defined(__NetBSD__)
+#ifdef __x86_64__
+static char pd_tilde_dllextent[] = ".n_ia64",
+    pd_tilde_dllextent2[] = ".pd_netbsd";
+#else
+static char pd_tilde_dllextent[] = ".n_i386",
+    pd_tilde_dllextent2[] = ".pd_netbsd";
+#endif
+#endif
 #ifdef __APPLE__
 static char pd_tilde_dllextent[] = ".d_fat",
     pd_tilde_dllextent2[] = ".pd_darwin";
-------------- next part --------------
$NetBSD: patch-extra_sigmund~_sigmund~.c,v 1.1.1.1 2011/09/15 01:05:05 wiz Exp $

alloca.h is not portable.

--- extra/sigmund~/sigmund~.c.orig	2010-07-28 20:55:17.000000000 +0000
+++ extra/sigmund~/sigmund~.c
@@ -26,11 +26,7 @@ for example, defines this in the file d_
 #include <math.h>
 #include <stdio.h>
 #include <string.h>
-#ifdef _WIN32
 #include <malloc.h>
-#elif ! defined(_MSC_VER)
-#include <alloca.h>
-#endif
 #include <stdlib.h>
 #ifdef _MSC_VER
 #pragma warning( disable : 4244 )
-------------- next part --------------
$NetBSD: patch-src_Makefile.am,v 1.1.1.1 2011/09/15 01:05:05 wiz Exp $

Add missing libraries to linker line.

--- src/Makefile.am.orig	2011-02-27 03:22:57.000000000 +0000
+++ src/Makefile.am
@@ -6,7 +6,7 @@ pd_LDFLAGS =
 pdsend_CFLAGS = 
 pdreceive_CFLAGS = 
 pd_watchdog_CFLAGS = 
-LIBS = 
+LIBS = $(LIBOSSAUDIO) $(PTHREAD_LDFLAGS) $(PTHREAD_LIBS) -lm
 INCLUDES = @INCLUDES@
 
 SUFFIXES = . at EXTENSION@ . at SHARED_LIB@
-------------- next part --------------
$NetBSD: patch-src_configure,v 1.1.1.1 2011/09/15 01:05:05 wiz Exp $

Fix unportable test(1) construct.

--- src/configure.orig	2011-03-21 01:41:34.000000000 +0000
+++ src/configure
@@ -5407,7 +5407,7 @@ then
     then
         fat="no"
     fi
-    if test "x$fat" == "xyes";
+    if test "x$fat" = "xyes";
     then
         MORECFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
             -arch i386 -arch ppc -Wno-error"
-------------- next part --------------
$NetBSD: patch-src_d__array.c,v 1.1.1.1 2011/09/15 01:05:05 wiz Exp $

Detect endianness on NetBSD.

--- src/d_array.c.orig	2010-07-28 20:55:17.000000000 +0000
+++ src/d_array.c
@@ -502,7 +502,7 @@ static void tabread4_tilde_setup(void)
 #include <sys/endian.h>
 #endif
 
-#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__FreeBSD_kernel__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
 #include <machine/endian.h>
 #endif
 
-------------- next part --------------
$NetBSD: patch-src_d__osc.c,v 1.1.1.1 2011/09/15 01:05:05 wiz Exp $

Detect endianness on NetBSD.

--- src/d_osc.c.orig	2010-07-28 20:55:17.000000000 +0000
+++ src/d_osc.c
@@ -15,7 +15,7 @@
 #include <sys/endian.h>
 #endif
 
-#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__FreeBSD_kernel__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
 #include <machine/endian.h>
 #endif
 
-------------- next part --------------
$NetBSD: patch-src_m__binbuf.c,v 1.1.1.1 2011/09/15 01:05:05 wiz Exp $

alloca.h is not portable.

--- src/m_binbuf.c.orig	2011-03-10 06:02:41.000000000 +0000
+++ src/m_binbuf.c
@@ -530,11 +530,7 @@ done:
 
 #define SMALLMSG 5
 #define HUGEMSG 1000
-#ifdef MSW
 #include <malloc.h>
-#else
-#include <alloca.h>
-#endif
 #if HAVE_ALLOCA
 #define ATOMS_ALLOCA(x, n) ((x) = (t_atom *)((n) < HUGEMSG ?  \
         alloca((n) * sizeof(t_atom)) : getbytes((n) * sizeof(t_atom))))
-------------- next part --------------
$NetBSD: patch-src_s__audio__oss.c,v 1.1.1.1 2011/09/15 01:05:05 wiz Exp $

Use proper soundcard.h include on NetBSD and add missing argument
to ioctl().

--- src/s_audio_oss.c.orig	2011-03-07 01:33:39.000000000 +0000
+++ src/s_audio_oss.c
@@ -5,7 +5,7 @@
 
 /* this file inputs and outputs audio using the OSS API available on linux. */
 
-#if defined(__FreeBSD_kernel__)
+#if defined(__FreeBSD_kernel__) || defined(__NetBSD__)
 # include <sys/soundcard.h>
 #else
 # include <linux/soundcard.h>
@@ -120,7 +120,7 @@ typedef struct _multidev {
 
 int oss_reset(int fd) {
      int err;
-     if ((err = ioctl(fd,SNDCTL_DSP_RESET)) < 0)
+     if ((err = ioctl(fd,SNDCTL_DSP_RESET,0)) < 0)
           error("OSS: Could not reset");
      return err;
 }
-------------- next part --------------
$NetBSD: patch-src_s__file.c,v 1.1.1.1 2011/09/15 01:05:05 wiz Exp $

File handling under NetBSD is the same as under Linux.

--- src/s_file.c.orig	2011-03-19 22:22:27.000000000 +0000
+++ src/s_file.c
@@ -36,7 +36,7 @@ int sys_defeatrt;
 t_symbol *sys_flags = &s_;
 void sys_doflags( void);
 
-#if defined(__linux__) || defined(__CYGWIN__) || defined(__FreeBSD_kernel__) || defined(__GNU__) || defined(ANDROID)
+#if defined(__linux__) || defined(__CYGWIN__) || defined(__FreeBSD_kernel__) || defined(__GNU__) || defined(ANDROID) || defined(__NetBSD__)
 
 static char *sys_prefbuf;
 static int sys_prefbufsize;
-------------- next part --------------
$NetBSD: patch-src_s__loader.c,v 1.1.1.1 2011/09/15 01:05:05 wiz Exp $

Define extensions for NetBSD.

--- src/s_loader.c.orig	2010-07-29 03:50:34.000000000 +0000
+++ src/s_loader.c
@@ -38,6 +38,12 @@ a fat binary or an indication of the ins
 
 #ifdef __FreeBSD__
 static char sys_dllextent[] = ".b_i386", sys_dllextent2[] = ".pd_freebsd";
+#elif defined(__NetBSD__)
+# ifdef __x86_64__
+static char sys_dllextent[] = ".n_ia64", sys_dllextent2[] = ".pd_netbsd";
+# else
+static char sys_dllextent[] = ".n_i386", sys_dllextent2[] = ".pd_netbsd";
+# endif
 #elif defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__GNU__)
 # ifdef __x86_64__
 static char sys_dllextent[] = ".l_ia64", sys_dllextent2[] = ".pd_linux";
-------------- next part --------------
$NetBSD: patch-src_s__stuff.h,v 1.1.1.1 2011/09/15 01:05:05 wiz Exp $

Use OSS on NetBSD.

--- src/s_stuff.h.orig	2011-03-13 00:19:29.000000000 +0000
+++ src/s_stuff.h
@@ -204,7 +204,7 @@ void sys_setalarm(int microsec);
 #define API_DEFAULT API_DUMMY
 #define API_DEFSTRING "dummy audio"
 #else
-#if defined(__linux__) || defined(__FreeBSD_kernel__)
+#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
 # define API_DEFAULT API_OSS
 # define API_DEFSTRING "OSS"
 #endif
-------------- next part --------------
$NetBSD: patch-src_s__utf8.c,v 1.1.1.1 2011/09/15 01:05:05 wiz Exp $

alloca.h is not portable.

--- src/s_utf8.c.orig	2010-08-18 03:51:01.000000000 +0000
+++ src/s_utf8.c
@@ -18,11 +18,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
-#ifdef WIN32
 #include <malloc.h>
-#else
-#include <alloca.h>
-#endif
 
 #include "s_utf8.h"
 
-------------- next part --------------
$NetBSD: patch-src_x__list.c,v 1.1.1.1 2011/09/15 01:05:05 wiz Exp $

alloca.h is not portable.

--- src/x_list.c.orig	2010-07-21 18:37:47.000000000 +0000
+++ src/x_list.c
@@ -4,11 +4,7 @@
 
 #include "m_pd.h"
 /* #include <string.h> */
-#ifdef MSW
 #include <malloc.h>
-#else
-#include <alloca.h>
-#endif
 
 extern t_pd *newest;
 
-------------- next part --------------
$NetBSD: patch-src_x__misc.c,v 1.1.1.1 2011/09/15 01:05:05 wiz Exp $

Define missing symbol the same as on FreeBSD/Mac OS X.

--- src/x_misc.c.orig	2010-07-28 20:55:17.000000000 +0000
+++ src/x_misc.c
@@ -20,7 +20,7 @@
 #include <unistd.h>
 #endif /* _WIN32 */
 
-#if defined (__APPLE__) || defined (__FreeBSD__)
+#if defined (__APPLE__) || defined (__FreeBSD__) || defined(__NetBSD__)
 #define CLOCKHZ CLK_TCK
 #endif
 #if defined (__linux__) || defined (__CYGWIN__) || defined (ANDROID)


More information about the Pd-dev mailing list