--- /dev/null
+From 23591404610b1eeffb69712d93c77c2327b9ef7a Mon Sep 17 00:00:00 2001
+From: Phillip Mienk <mienkphi@gmail.com>
+Date: Fri, 31 Oct 2014 00:55:35 -0700
+Subject: [PATCH] Simply configure.ac to prevent contradictory discovery of
+ libzmq.
+
+[Romain: rebase on top of 3.0.0]
+Signed-off-by: Romain Naour <romain.naour@openwide.fr>
+---
+ Makefile.am | 3 ++-
+ addons/Makefile.am.supplement | 3 ++-
+ configure.ac | 46 ++-----------------------------------------
+ model/build-autoconf.gsl | 28 ++++++++++++++++++++++++++
+ model/project.xml | 3 +++
+ src/Makefile.am.supplement | 12 ++++++++++-
+ 6 files changed, 48 insertions(+), 47 deletions(-)
+
+diff --git a/Makefile.am b/Makefile.am
+index 10f21fb..187c62b 100644
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -1,7 +1,8 @@
+ ACLOCAL_AMFLAGS = -I config
+
+ AM_CPPFLAGS = \
+- -I$(srcdir)/include
++ ${zmq_CFLAGS} \
++ -I$(srcdir)/include
+
+ EXTRA_DIST = \
+ version.sh \
+diff --git a/addons/Makefile.am.supplement b/addons/Makefile.am.supplement
+index 8800db4..74f0c60 100644
+--- a/addons/Makefile.am.supplement
++++ b/addons/Makefile.am.supplement
+@@ -4,7 +4,8 @@ EXTRA_DIST += \
+ bin_PROGRAMS += makecert
+
+ makecert_LDADD = \
+- libczmq.la
++ libczmq.la \
++ ${zmq_LIBS}
+
+ makecert_SOURCES = \
+ addons/makecert.c
+diff --git a/configure.ac b/configure.ac
+index 1a4667e..1ccae06 100755
+--- a/configure.ac
++++ b/configure.ac
+@@ -74,50 +74,8 @@ if test "x${CZMQ_GCOV}" == "xyes"; then
+ fi
+ fi
+
+-# Check for libzmq library
+-libzmq_prefix=detect
+-AC_ARG_WITH([libzmq],
+- [AS_HELP_STRING([--with-libzmq=PREFIX],
+- [build with ZeroMQ library installed in PREFIX [default=autodetect]])],
+- [case "x$withval" in
+- xno)
+- AC_MSG_ERROR([CZMQ requires the ZeroMQ library])
+- ;;
+- xyes|x)
+- ;;
+- *)
+- CPPFLAGS="$CPPFLAGS -I${withval}/include"
+- LDFLAGS="$LDFLAGS -L${withval}/lib"
+- zeromq_prefix=${withval}
+- ;;
+- esac ]
+-)
+-if test "x$libzmq_prefix" = "xdetect"; then
+- PKG_CHECK_MODULES(
+- [ZeroMQ], [libzmq], [libzmq_prefix=pkgconfig], [libzmq_prefix=])
+- if test "x$libzmq_prefix" = "xpkgconfig"; then
+- CPPFLAGS="$CPPFLAGS ${ZeroMQ_CFLAGS}"
+- LDFLAGS="$LDFLAGS ${ZeroMQ_LIBS}"
+- fi
+-fi
+-
+-if test "x$czmq_search_libzmq" = "xyes"; then
+- if test -r "${with_libzmq}/include/zmq.h"; then
+- CFLAGS="-I${with_libzmq}/include ${CFLAGS}"
+- LDFLAGS="-L${with_libzmq}/lib ${LDFLAGS}"
+- fi
+-fi
+-
+-AC_CHECK_HEADER([zmq.h], [], [AC_MSG_ERROR([cannot find zmq.h])])
+-
+-AC_CHECK_LIB(zmq, zmq_init, ,[AC_MSG_ERROR([cannot link with -lzmq, install libzmq.])])
+-
+-AC_MSG_CHECKING([whether libzmq installation works])
+-AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <zmq.h>],
+- [zmq_init(1);])
+- ],
+- [AC_MSG_RESULT([yes])],
+- [AC_MSG_ERROR([no. Please specify libzmq installation prefix using --with-libzmq])])
++# Check for libzmq
++PKG_CHECK_MODULES([zmq], [libzmq])
+
+ # Platform specific checks
+ czmq_on_mingw32="no"
+diff --git a/model/build-autoconf.gsl b/model/build-autoconf.gsl
+index d012a3c..30aff14 100644
+--- a/model/build-autoconf.gsl
++++ b/model/build-autoconf.gsl
+@@ -46,12 +46,39 @@ lib$(project.name)_la_SOURCES = \\
+
+ bin_PROGRAMS = $(project.name)_selftest
+
++$(project.name)_selftest_CPPFLAGS = \\
++.for package_dependency where defined (package_dependency.for_test)
++ \${$(package_dependency.name)_CFLAGS} \\
++.endfor
++ \${lib$(project.name)_la_CFLAGS}
++
+ $(project.name)_selftest_LDADD = \\
++.if count (package_dependency, defined (count.for_lib) | defined (count.for_test) | defined (count.for_all)) > 0
++ lib$(project.name).la \\
++.else
+ lib$(project.name).la
++.endif
++.for package_dependency where defined (package_dependency.for_lib) | defined (package_dependency.for_test) | defined (package_dependency.for_all)
++. if last()
++ \${$(package_dependency.name)_LIBS}
++. else
++ \${$(package_dependency.name)_LIBS} \\
++.endif
++.endfor
+
+ $(project.name)_selftest_SOURCES = \\
+ src/$(project.name)_selftest.c
+
++lib$(project.name)_la_CPPFLAGS = \\
++.for package_dependency where defined (package_dependency.for_lib)
++. if last()
++ \${$(package_dependency.name)_CFLAGS}
++. else
++ \${$(package_dependency.name)_CFLAGS} \\
++. endif
++.endfor
++ ${AM_CPPFLAGS}
++
+ lib$(project.name)_la_LDFLAGS = \\
+ -version-info @LTVER@
+
+@@ -62,6 +89,7 @@ lib$(project.name)_la_LDFLAGS += \\
+ endif
+
+ TESTS = $(project.name)_selftest
++
+ .for model
+ . if first ()
+
+diff --git a/model/project.xml b/model/project.xml
+index 91306cf..b7bab4a 100644
+--- a/model/project.xml
++++ b/model/project.xml
+@@ -2,6 +2,9 @@
+ name = "czmq"
+ script = "project.gsl"
+ >
++
++ <package_dependency name="zmq" pkg_name="libzmq" for_all="1" />
++
+ <header name = "czmq" />
+ <header name = "czmq_prelude" />
+
+diff --git a/src/Makefile.am.supplement b/src/Makefile.am.supplement
+index 91e5b62..929aa07 100644
+--- a/src/Makefile.am.supplement
++++ b/src/Makefile.am.supplement
+@@ -95,12 +95,19 @@ libczmq_la_SOURCES = \
+
+ bin_PROGRAMS = czmq_selftest
+
++czmq_selftest_CPPFLAGS = \
++ ${src_libczmq_la_CFLAGS}
++
+ czmq_selftest_LDADD = \
+- libczmq.la
++ libczmq.la \
++ ${zmq_LIBS}
+
+ czmq_selftest_SOURCES = \
+ src/czmq_selftest.c
+
++libczmq_la_CPPFLAGS = \
++ ${AM_CPPFLAGS}
++
+ libczmq_la_LDFLAGS = \
+ -version-info @LTVER@
+
+@@ -112,6 +119,9 @@ endif
+
+ TESTS = czmq_selftest
+
++# define custom target for all products of /src
++src: src/libczmq.la src/czmq_selftest
++
+ # Produce generated models; do this manually in src directory
+ code:
+ gsl -q src/sockopts.xml
+--
+1.9.3
+