Description: took fixes for HURD and kFreeBSD from upstream
Author: Hans-Christoph Steiner <hans@eds.org>
Forwarded: not-needed
Last-Update: <2011-12-31>

--- pd-cyclone-0.1~alpha55.orig/Makefile.common
+++ pd-cyclone-0.1~alpha55/Makefile.common
@@ -2,6 +2,15 @@
 PD_DIR ?= $(ROOT_DIR)/../../pd/src
 
 OS_NAME = $(shell uname -s)
+
+# Debian has options for the GNU HURD and kFreeBSD kernels
+ifeq ($(OS_NAME),GNU)
+  OS_NAME=Linux
+endif
+ifeq ($(OS_NAME),GNU/kFreeBSD)
+  OS_NAME=Linux
+endif
+
 ifneq ($(OS_NAME),Linux)
 ifneq ($(OS_NAME),Darwin)
 ifeq (,$(findstring MinGW,$(OS_NAME)))
--- pd-cyclone-0.1~alpha55/shared/unstable/loader.c	2012/01/01 19:37:29	15861
+++ pd-cyclone-0.1~alpha55/shared/unstable/loader.c	2012/01/02 06:34:02	15862
@@ -5,7 +5,8 @@
 /* This is just a not-yet-in-the-API-sys_load_lib() duplication
    (modulo differentiating the error return codes).  LATER use the original. */
 
-#ifdef __linux__
+/* this is for GNU/Linux and also Debian GNU/Hurd and GNU/kFreeBSD */
+#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__GNU__) || defined(__GLIBC__)
 #include <dlfcn.h>
 #endif
 #ifdef UNIX
@@ -39,7 +40,8 @@
     ".pd_irix5";
 #endif
 #endif
-#ifdef __linux__
+/* this is for GNU/Linux and also Debian GNU/Hurd and GNU/kFreeBSD */
+#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__GNU__) || defined(__GLIBC__)
     ".pd_linux";
 #endif
 #ifdef MACOSX
@@ -76,7 +78,8 @@
 	strcpy(symname + (strlen(symname) - 1), "_tilde");
     /* and append _setup to form the C setup function name */
     strcat(symname, "_setup");
-#ifdef __linux__
+/* this is for GNU/Linux and also Debian GNU/Hurd and GNU/kFreeBSD */
+#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__GNU__) || defined(__GLIBC__)
     dlobj = dlopen(filename, RTLD_NOW | RTLD_GLOBAL);
     if (!dlobj)
     {
--- pd-cyclone-0.1~alpha55/shared/common/mifi.c	2012/01/01 19:37:29	15861
+++ pd-cyclone-0.1~alpha55/shared/common/mifi.c	2012/01/02 06:34:02	15862
@@ -15,7 +15,8 @@
 #include "m_pd.h"
 #include "mifi.h"
 
-#ifdef __linux__
+/* this is for GNU/Linux and also Debian GNU/Hurd and GNU/kFreeBSD */
+#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__GNU__) || defined(__GLIBC__)
 #include <sys/types.h>
 #ifndef uint32
 typedef u_int32_t uint32;
--- pd-cyclone-0.1~alpha55/shared/shared.h	2012/01/01 19:37:29	15861
+++ pd-cyclone-0.1~alpha55/shared/shared.h	2012/01/02 06:34:02	15862
@@ -25,7 +25,8 @@
 
 typedef unsigned long shared_t_bitmask;
 
-#ifdef __linux__
+/* this is for GNU/Linux and also Debian GNU/Hurd and GNU/kFreeBSD */
+#if defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__GNU__) || defined(__GLIBC__)
 #include <sys/types.h>
 #ifndef int32
 typedef int32_t int32;
--- pd-cyclone-0.1~alpha55.orig/cyclone/Makefile.libdir
+++ pd-cyclone-0.1~alpha55/cyclone/Makefile.libdir
@@ -41,7 +41,7 @@ ifeq ($(UNAME),Darwin)
     else
       FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4
     endif
-    CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include
+    CFLAGS += -DUNIX $(FAT_FLAGS) -fPIC -I/sw/include
     LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib
     # if the 'pd' binary exists, check the linking against it to aid with stripping
     LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd)
@@ -57,24 +57,50 @@ ifeq ($(UNAME),Linux)
   OS = linux
   PD_PATH = /usr
   OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
-  CFLAGS += -fPIC
-  LDFLAGS += -Wl,--export-dynamic  -shared -fPIC
+  CFLAGS += -DUNIX -fPIC
+  LDFLAGS += -rdynamic -shared -fPIC
+  LIBS += -lc
+  STRIP = strip --strip-unneeded -R .note -R .comment
+endif
+ifeq ($(UNAME),GNU)
+  # GNU/Hurd, should work like GNU/Linux for basically all externals
+  CPU := $(shell uname -m)
+  EXTENSION = pd_linux
+  OS = linux
+  PD_PATH = /usr
+  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
+  CFLAGS += -DUNIX -fPIC
+  LDFLAGS += -rdynamic -shared -fPIC
+  LIBS += -lc
+  STRIP = strip --strip-unneeded -R .note -R .comment
+endif
+ifeq ($(UNAME),GNU/kFreeBSD)
+  # Debian GNU/kFreeBSD, should work like GNU/Linux for basically all externals
+  CPU := $(shell uname -m)
+  EXTENSION = pd_linux
+  OS = linux
+  PD_PATH = /usr
+  OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
+  CFLAGS += -DUNIX -fPIC
+  LDFLAGS += -rdynamic -shared -fPIC
   LIBS += -lc
   STRIP = strip --strip-unneeded -R .note -R .comment
 endif
 ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME)))
   CPU := $(shell uname -m)
+  EXE = .exe
   EXTENSION = dll
   OS = cygwin
   PD_PATH = $(cygpath $(PROGRAMFILES))/pd
   OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer
-  CFLAGS += 
+  CFLAGS += -DUNIX
   LDFLAGS += -Wl,--export-dynamic -shared -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin"
   LIBS += -lc -lpd
   STRIP = strip --strip-unneeded -R .note -R .comment
 endif
 ifeq (MINGW,$(findstring MINGW,$(UNAME)))
   CPU := $(shell uname -m)
+  EXE = .exe
   EXTENSION = dll
   OS = windows
   PD_PATH = $(shell cd "$(PROGRAMFILES)"/pd && pwd)
@@ -86,7 +112,7 @@ ifeq (MINGW,$(findstring MINGW,$(UNAME))
 endif
 
 cyclone:
-	$(MAKE) -j4 -f Makefile \
+	$(MAKE) -f Makefile \
 		OPT_CFLAGS="-O6 -funroll-loops -fomit-frame-pointer -fno-strict-aliasing -fPIC"
 
 install: cyclone
@@ -94,9 +120,12 @@ install: cyclone
 	$(INSTALL_DATA) cyclone-meta.pd $(DESTDIR)$(objectsdir)/cyclone
 	$(INSTALL_DATA) ../LICENSE.txt $(DESTDIR)$(objectsdir)/cyclone
 	$(INSTALL_DATA) README.txt $(DESTDIR)$(objectsdir)/cyclone
+	$(INSTALL_DIR) $(DESTDIR)$(objectsdir)/cyclone/manual
+	$(INSTALL_DATA) ../doc/help/cyclone/coll.txt hammer/pd-lib-notes.txt \
+		$(DESTDIR)$(objectsdir)/cyclone/manual
 # cyclone is compiled straight into $(OUT_DIR), yes a kludge, but the code of
 # this build system is impenetrable
-	$(MAKE) -j4 OUT_DIR=$(DESTDIR)$(objectsdir)/cyclone
+	$(MAKE) OUT_DIR=$(DESTDIR)$(objectsdir)/cyclone
 	$(STRIP) $(DESTDIR)$(objectsdir)/cyclone/*.$(EXTENSION)
 	chmod a-x $(DESTDIR)$(objectsdir)/cyclone/*.$(EXTENSION)
 # install "maxmode" libraries into subdir, so they don't override the libdir
@@ -115,14 +144,80 @@ install: cyclone
 # install "cyclist" command line app with pd
 	$(INSTALL_DIR) $(DESTDIR)$(bindir)
 	$(INSTALL_PROGRAM) ../bin/cyclist $(DESTDIR)$(bindir)
-	$(STRIP) $(DESTDIR)$(bindir)/cyclist
+	$(STRIP) $(DESTDIR)$(bindir)/cyclist$(EXE)
+ifeq ($(UNAME),Linux)
+# add links for the downcase versions, only on GNU/Linux since Windows
+# and Mac OS X almost always use case insensitive file systems, so
+# Borax.pd_darwin is the same file as borax.pd_darwin, etc.
+	ln -s -f Append.$(EXTENSION) $(DESTDIR)$(objectsdir)/cyclone/append.$(EXTENSION)
+	ln -s -f Append-help.pd $(DESTDIR)$(objectsdir)/cyclone/append-help.pd
+	ln -s -f Borax.$(EXTENSION) $(DESTDIR)$(objectsdir)/cyclone/borax.$(EXTENSION)
+	ln -s -f Borax-help.pd $(DESTDIR)$(objectsdir)/cyclone/borax-help.pd
+	ln -s -f Bucket.$(EXTENSION) $(DESTDIR)$(objectsdir)/cyclone/bucket.$(EXTENSION)
+	ln -s -f Bucket-help.pd $(DESTDIR)$(objectsdir)/cyclone/bucket-help.pd
+	ln -s -f Clip.$(EXTENSION) $(DESTDIR)$(objectsdir)/cyclone/clip.$(EXTENSION)
+	ln -s -f Clip-help.pd $(DESTDIR)$(objectsdir)/cyclone/clip-help.pd
+	ln -s -f Decode.$(EXTENSION) $(DESTDIR)$(objectsdir)/cyclone/decode.$(EXTENSION)
+	ln -s -f Decode-help.pd $(DESTDIR)$(objectsdir)/cyclone/decode-help.pd
+	ln -s -f Histo.$(EXTENSION) $(DESTDIR)$(objectsdir)/cyclone/histo.$(EXTENSION)
+	ln -s -f Histo-help.pd $(DESTDIR)$(objectsdir)/cyclone/histo-help.pd
+	ln -s -f MouseState.$(EXTENSION) $(DESTDIR)$(objectsdir)/cyclone/mousestate.$(EXTENSION)
+	ln -s -f MouseState-help.pd $(DESTDIR)$(objectsdir)/cyclone/mousestate-help.pd
+	ln -s -f Peak.$(EXTENSION) $(DESTDIR)$(objectsdir)/cyclone/peak.$(EXTENSION)
+	ln -s -f Peak-help.pd $(DESTDIR)$(objectsdir)/cyclone/peak-help.pd
+	ln -s -f Table.$(EXTENSION) $(DESTDIR)$(objectsdir)/cyclone/table.$(EXTENSION)
+	ln -s -f Table-help.pd $(DESTDIR)$(objectsdir)/cyclone/table-help.pd
+	ln -s -f TogEdge.$(EXTENSION) $(DESTDIR)$(objectsdir)/cyclone/togedge.$(EXTENSION)
+	ln -s -f TogEdge-help.pd $(DESTDIR)$(objectsdir)/cyclone/togedge-help.pd
+	ln -s -f Trough.$(EXTENSION) $(DESTDIR)$(objectsdir)/cyclone/trough.$(EXTENSION)
+	ln -s -f Trough-help.pd $(DESTDIR)$(objectsdir)/cyclone/trough-help.pd
+	ln -s -f Uzi.$(EXTENSION) $(DESTDIR)$(objectsdir)/cyclone/uzi.$(EXTENSION)
+	ln -s -f Uzi-help.pd $(DESTDIR)$(objectsdir)/cyclone/uzi-help.pd
+	ln -s -f Clip~.$(EXTENSION) $(DESTDIR)$(objectsdir)/cyclone/clip~.$(EXTENSION)
+	ln -s -f Clip~-help.pd $(DESTDIR)$(objectsdir)/cyclone/clip~-help.pd
+	ln -s -f Line~.$(EXTENSION) $(DESTDIR)$(objectsdir)/cyclone/line~.$(EXTENSION)
+	ln -s -f Line~-help.pd $(DESTDIR)$(objectsdir)/cyclone/line~-help.pd
+	ln -s -f Scope~.$(EXTENSION) $(DESTDIR)$(objectsdir)/cyclone/scope~.$(EXTENSION)
+	ln -s -f Scope~-help.pd $(DESTDIR)$(objectsdir)/cyclone/scope~-help.pd
+	ln -s -f Snapshot~.$(EXTENSION) $(DESTDIR)$(objectsdir)/cyclone/snapshot~.$(EXTENSION)
+	ln -s -f Snapshot~-help.pd $(DESTDIR)$(objectsdir)/cyclone/snapshot~-help.pd
+endif
 
 clean:
 	-$(MAKE) -f Makefile $(DEST_PATHS) clean
-	-rm -f ../bin/*.pd_linux
+	-rm -f ../bin/*.$(EXTENSION)
 	-rm -f ../bin/cyclist
 	-rm -f Makefile.deps
 	-rm -f shadow/Makefile.deps
 	-rm -f hammer/Makefile.deps
 	-rm -f sickle/Makefile.deps
+	-rm -f -- ../pddp/Makefile.deps
+	-rm -f -- ../toxy/setup.wiq
+	-rm -f -- ../toxy/Makefile.deps
+	-rm -f -- ../shared/Makefile.deps
+	-rm -f -- ../shared/toxy/Makefile.deps
+	-rm -f -- ../shared/common/Makefile.deps
+	-rm -f -- ../shared/hammer/Makefile.deps
+	-rm -f -- ../shared/sickle/Makefile.deps
+	-rm -f -- ../shared/unstable/Makefile.deps
 	-rm -f ../build-stamp
+	-rm -f -- ../shared/common/vefl.o
+	-rm -f -- ../shared/common/rand.o
+	-rm -f -- ../shared/common/port.o
+	-rm -f -- ../shared/common/os.o
+	-rm -f -- ../shared/common/mifi.o
+	-rm -f -- ../shared/common/loud.o
+	-rm -f -- ../shared/common/lex.o
+	-rm -f -- ../shared/common/grow.o
+	-rm -f -- ../shared/common/fitter.o
+	-rm -f -- ../shared/common/clc.o
+	-rm -f -- ../shared/common/binport.o
+	-rm -f -- ../shared/hammer/tree.o
+	-rm -f -- ../shared/hammer/gui.o
+	-rm -f -- ../shared/hammer/file.o
+	-rm -f -- ../shared/sickle/sic.o
+	-rm -f -- ../shared/sickle/arsic.o
+	-rm -f -- ../shared/unstable/loader.o
+	-rm -f -- ../shared/unstable/fringe.o
+	-rm -f -- ../shared/unstable/fragile.o
+	-rm -f -- ../shared/unstable/forky.o
