From bf12749acbeeb3ef507c9ee049ce3f197bd9bbaf Mon Sep 17 00:00:00 2001
From: Albert Graef <aggraef@gmail.com>
Date: Mon, 17 Nov 2014 12:05:41 +0100
Subject: [PATCH] Work around quirks in the Debian build system of Precise and
 earlier.

---
 debuild/Makefile                |  9 ++++
 debuild/precise-configure.patch | 96 +++++++++++++++++++++++++++++++++
 2 files changed, 105 insertions(+)
 create mode 100644 debuild/precise-configure.patch

diff --git a/debuild/Makefile b/debuild/Makefile
index d4bcc0137..a75111779 100644
--- a/debuild/Makefile
+++ b/debuild/Makefile
@@ -63,11 +63,20 @@ debclean:
 	rm -f pd-l2ork_$(version)+git* pd-l2ork-*.tar.bz2
 
 deb: $(debsrc) $(gemdebsrc) $(pidebsrc)
+# Unpack the primary source into our temporary build directory.
 	rm -rf $(debdist)
 	tar xfz $(debsrc)
+# This works around some problems compiling externals on Precise and earlier
+# (patch from pd-extended by Hans-Christoph Steiner, modified for pd-l2ork).
+# This can be removed once Ubuntu 12.04 finally goes the way of the dodo.
+	cd $(debdist) && patch -p1 < ../precise-configure.patch
+# Unpack the secondary sources.
 	cd $(debdist) && rm -Rf Gem && tar xfz ../$(gemdebsrc)
 	cd $(debdist) && rm -Rf wiringPi && tar xfz ../$(pidebsrc)
+# Make sure to copy the Debian files which may have uncommitted changes.
+# Then run debuild to create the package.
 	cd $(debdist) && cp -R ../debian . && debuild $(DEBUILD_FLAGS)
+# Get rid of the temporary build directory.
 	rm -rf $(debdist)
 
 debsrc:
diff --git a/debuild/precise-configure.patch b/debuild/precise-configure.patch
new file mode 100644
index 000000000..e4bb19126
--- /dev/null
+++ b/debuild/precise-configure.patch
@@ -0,0 +1,96 @@
+Fix up LDFLAGS for Precise and earlier (patch by Hans-Christoph Steiner,
+updated to pd-l2ork by Albert Graef).
+Description: fix ./configure dying thinking we're cross-compiling
+ When building using debuild on Debian/squeeze or Ubuntu < quantal,
+ ./configure somehow gets some LDFLAGS for shared libraries and uses them in
+ the gcc tests.  The executable then fails to run since its a shared library,
+ and ./configure thinks we're cross-compiling.  This patch forces no LDFLAGS.
+
+diff --git a/externals/Makefile b/externals/Makefile
+index 7b64f45..6b7c49b 100644
+--- a/externals/Makefile
++++ b/externals/Makefile
+@@ -611,6 +611,7 @@ $(gem_src)/Gem.pd_linux: $(gem_src)/configure
+ 	test -s $(gem_src)/Gem.pd_linux || \
+ 		cd $(gem_src) && ./configure \
+ 			CXXFLAGS="-DHAVE_S_STUFF_H" \
++			LDFLAGS= \
+ 			--prefix=$(prefix) \
+ 			--with-video=plugins \
+ 			--with-film=plugins \
+@@ -649,7 +650,7 @@ $(externals_src)/gem2pdp/configure: $(externals_src)/gem2pdp/configure.ac
+ 	cd $(externals_src)/gem2pdp && aclocal && autoconf
+ 
+ $(externals_src)/gem2pdp/Makefile: $(externals_src)/gem2pdp/Makefile.in
+-	cd $(externals_src)/gem2pdp && ./configure --with-pddir=$(pd_src) \
++	cd $(externals_src)/gem2pdp && ./configure LDFLAGS= --with-pddir=$(pd_src) \
+ 		--with-gemdir=$(gem_src)  --with-pdpdir=$(externals_src)/pdp
+ 
+ gem2pdp: $(externals_src)/gem2pdp/configure $(externals_src)/gem2pdp/Makefile
+@@ -885,7 +886,7 @@ $(IEM16_DIR)/configure: $(IEM16_DIR)/configure.ac $(IEM16_DIR)/aclocal.m4
+ 
+ $(IEM16_DIR)/Make.config: $(IEM16_DIR)/Make.config.in \
+ $(IEM16_DIR)/configure
+-	cd $(IEM16_DIR) && ./configure --disable-library \
++	cd $(IEM16_DIR) && ./configure LDFLAGS= --disable-library \
+ 		--with-pd=$(pd_src)
+ 
+ iem16: $(IEM16_DIR)/Make.config
+@@ -1269,11 +1270,11 @@ $(externals_src)/OSCx/configure: $(externals_src)/OSCx/configure.ac
+ 	cd $(externals_src)/OSCx && autoconf
+ 
+ $(externals_src)/OSCx/Makefile: $(externals_src)/OSCx/Makefile.in
+-	cd $(externals_src)/OSCx && ./configure
++	cd $(externals_src)/OSCx && ./configure LDFLAGS=
+ $(externals_src)/OSCx/libOSC/Makefile: $(externals_src)/OSCx/libOSC/Makefile.in
+-	cd $(externals_src)/OSCx && ./configure
++	cd $(externals_src)/OSCx && ./configure LDFLAGS=
+ $(externals_src)/OSCx/src/Makefile: $(externals_src)/OSCx/src/Makefile.in
+-	cd $(externals_src)/OSCx && ./configure
++	cd $(externals_src)/OSCx && ./configure LDFLAGS=
+ 
+ $(externals_src)/OSCx/src/OSCroute.$(EXTENSION):  $(externals_src)/OSCx/configure \
+ $(externals_src)/OSCx/Makefile
+@@ -1356,7 +1357,7 @@ $(externals_src)/pdp/configure: $(externals_src)/pdp/configure.ac
+ 	cd $(externals_src)/pdp && autoconf
+ 
+ $(externals_src)/pdp/Makefile.config: $(externals_src)/pdp/configure $(externals_src)/pdp/Makefile.config.in
+-	cd $(externals_src)/pdp && ./configure PD_CPPFLAGS="-I$(pd_src)/src" \
++	cd $(externals_src)/pdp && ./configure LDFLAGS= PD_CPPFLAGS="-I$(pd_src)/src" \
+ 		$(PDP_OPTIONS)
+ 
+ $(externals_src)/pdp/pdp.$(EXTENSION): $(externals_src)/pdp/Makefile.config 
+@@ -1770,6 +1771,7 @@ $(zexy_src)/configure: $(zexy_src)/configure.ac
+ 
+ $(zexy_src)/Makefile: $(zexy_src)/configure $(zexy_src)/Makefile.am $(zexy_src)/src/Makefile.am
+ 	cd $(zexy_src) && ./configure --disable-library \
++		LDFLAGS= \
+ 		--with-extension=$(EXTENSION) \
+ 		--prefix=$(prefix) \
+ 		--libdir=$(objectsdir) \
+diff --git a/externals/iem16/src/Makefile b/externals/iem16/src/Makefile
+index 25e5bbe..5be876d 100644
+--- a/externals/iem16/src/Makefile
++++ b/externals/iem16/src/Makefile
+@@ -22,7 +22,7 @@ aclocal.m4: acinclude.m4
+ 	aclocal
+ 
+ Make.config: Make.config.in configure
+-	./configure $(CONFIGUREFLAGS)
++	./configure $(CONFIGUREFLAGS) LDFLAGS=
+ 
+ -include $(SOURCES:.c=.d)
+ 
+diff --git a/externals/moocow/extended/Makefile b/externals/moocow/extended/Makefile
+index 2726d1a..9da4944 100644
+--- a/externals/moocow/extended/Makefile
++++ b/externals/moocow/extended/Makefile
+@@ -36,7 +36,7 @@ MOOCOW_BUILD_VERSION ?=2009-04-27.002
+ #	CFLAGS="$(shell echo $(CFLAGS))" ##-- works
+ CONFIGURE_ARGS=\
+ 	CFLAGS="$(CFLAGS) -I/sw/include" \
+-	LDFLAGS="$(LDFLAGS) -L$(pd_src)/src -L$(pd_src)/bin -L$(pd_src)/obj -L/sw/lib" \
++	LDFLAGS="-L$(pd_src)/src -L$(pd_src)/bin -L$(pd_src)/obj -L/sw/lib" \
+ 	--with-pd-include="$(pd_src)/src" \
+ 	--with-pd-dir="$(MOOCOW_BUILD)" \
+ 	--disable-dependency-tracking
-- 
GitLab