aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-12-10 04:41:35 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-12-10 04:46:28 +0100
commit18b531675ea16d7b4adbe3bd1caf05dca60ec5a2 (patch)
tree1dd63c9be174241074f4d44c23614533b11a1aed
parent9fcf1ee52a100dd3eae07fcc88acb9e2554cd519 (diff)
downloaddabmux-18b531675ea16d7b4adbe3bd1caf05dca60ec5a2.tar.gz
dabmux-18b531675ea16d7b4adbe3bd1caf05dca60ec5a2.tar.bz2
dabmux-18b531675ea16d7b4adbe3bd1caf05dca60ec5a2.zip
Improve check for ZMQ
-rw-r--r--configure.ac2
-rw-r--r--m4/ax_zmq.m486
-rw-r--r--src/Makefile.am16
3 files changed, 94 insertions, 10 deletions
diff --git a/configure.ac b/configure.ac
index 61b5bff..8fd4572 100644
--- a/configure.ac
+++ b/configure.ac
@@ -186,7 +186,7 @@ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[
AC_LANG_POP([C++])
# ZeroMQ
-AC_CHECK_LIB(zmq, zmq_init, [] , AC_MSG_ERROR(ZeroMQ libzmq is required))
+AX_ZMQ([4.0.0], [], AC_MSG_ERROR(ZeroMQ 4.0.0 is required))
AC_DEFINE([HAVE_INPUT_ZEROMQ], [1], [Define if ZeroMQ input is enabled])
AC_DEFINE([HAVE_OUTPUT_ZEROMQ], [1], [Define if ZeroMQ output is enabled])
diff --git a/m4/ax_zmq.m4 b/m4/ax_zmq.m4
new file mode 100644
index 0000000..752dc54
--- /dev/null
+++ b/m4/ax_zmq.m4
@@ -0,0 +1,86 @@
+# ===========================================================================
+# https://www.gnu.org/software/autoconf-archive/ax_zmq.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_ZMQ([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# DESCRIPTION
+#
+# Test for the ZMQ libraries of a particular version (or newer). The
+# default version tested for is 4.0.0.
+#
+# The macro tests for ZMQ libraries in the library/include path, and, when
+# provided, also in the path given by --with-zmq.
+#
+# This macro calls:
+#
+# AC_SUBST(ZMQ_CPPFLAGS) / AC_SUBST(ZMQ_LDFLAGS) / AC_SUBST(ZMQ_LIBS)
+#
+# And sets:
+#
+# HAVE_ZMQ
+#
+# LICENSE
+#
+# Copyright (c) 2016 Jeroen Meijer <jjgmeijer@gmail.com>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 2
+
+AC_DEFUN([AX_ZMQ], [
+ AC_ARG_WITH([zmq], [AS_HELP_STRING([--with-zmq=<prefix>],[ZMQ prefix directory])], [
+ ZMQ_LDFLAGS="-L${with_zmq}/lib"
+ ZMQ_CPPFLAGS="-I${with_zmq}/include"
+ ])
+
+ HAVE_ZMQ=0
+ if test "$with_zmq" != "no"; then
+
+ LD_FLAGS="$LDFLAGS $ZMQ_LDFLAGS"
+ CPPFLAGS="$CPPFLAGS $ZMQ_CPPFLAGS"
+
+ AC_LANG_SAVE
+ AC_LANG_C
+ AC_CHECK_HEADER(zmq.h, [zmq_h=yes], [zmq_h=no])
+ AC_LANG_RESTORE
+
+ if test "$zmq_h" = "yes"; then
+ version=ifelse([$1], ,4.0.0,$1)
+ AC_MSG_CHECKING([for ZMQ version >= $version])
+ version=$(echo $version | tr '.' ',')
+ AC_EGREP_CPP([version_ok], [
+#include <zmq.h>
+#if defined(ZMQ_VERSION) && ZMQ_VERSION >= ZMQ_MAKE_VERSION($version)
+ version_ok
+#endif
+ ],[
+ AC_MSG_RESULT(yes)
+ HAVE_ZMQ=1
+ ZMQ_LIBS="-lzmq"
+ AC_SUBST(ZMQ_LDFLAGS)
+ AC_SUBST(ZMQ_CPPFLAGS)
+ AC_SUBST(ZMQ_LIBS)
+ ], AC_MSG_RESULT([no valid ZMQ version was found]))
+ else
+ AC_MSG_WARN([no valid ZMQ installation was found])
+ fi
+
+ if test $HAVE_ZMQ = 1; then
+ # execute ACTION-IF-FOUND (if present):
+ ifelse([$2], , :, [$2])
+ else
+ # execute ACTION-IF-NOT-FOUND (if present):
+ ifelse([$3], , :, [$3])
+ fi
+ else
+ AC_MSG_NOTICE([not checking for ZMQ])
+ fi
+
+ AC_DEFINE(HAVE_ZMQ,,[define if the ZMQ library is available])
+])
diff --git a/src/Makefile.am b/src/Makefile.am
index ff0d21b..2bcd879 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -32,8 +32,6 @@ if HAVE_OUTPUT_RAW_TEST
bin_PROGRAMS+=odr-zmq2farsync
endif
-ZMQ_LIBS =-lzmq
-
if HAVE_EDI_TEST
bin_PROGRAMS+=odr-zmq2edi
CURL_LIBS =-lcurl
@@ -42,7 +40,7 @@ CURL_LIBS =
endif
odr_dabmux_CFLAGS =-Wall -I$(FARSYNC_DIR) $(GITVERSION_FLAGS)
-odr_dabmux_CXXFLAGS =-Wall -std=c++11 -I$(FARSYNC_DIR) $(GITVERSION_FLAGS) $(BOOST_CPPFLAGS)
+odr_dabmux_CXXFLAGS =-Wall -std=c++11 -I$(FARSYNC_DIR) $(GITVERSION_FLAGS) $(BOOST_CPPFLAGS) $(ZMQ_CPPFLAGS)
odr_dabmux_LDADD =$(ZMQ_LIBS) $(CURL_LIBS) $(BOOST_LDFLAGS) \
-lpthread $(BOOST_SYSTEM_LIB) $(BOOST_THREAD_LIB) $(BOOST_REGEX_LIB) $(BOOST_ASIO_LIB)
@@ -114,7 +112,7 @@ odr_dabmux_SOURCES =DabMux.cpp DabMux.h \
zmqinput_keygen_SOURCES = zmqinput-keygen.c
zmqinput_keygen_LDADD = $(ZMQ_LIBS)
-zmqinput_keygen_CFLAGS = -Wall $(GITVERSION_FLAGS)
+zmqinput_keygen_CFLAGS = -Wall $(GITVERSION_FLAGS) $(ZMQ_CPPFLAGS)
odr_zmq2farsync_SOURCES = zmq2farsync/zmq2farsync.cpp \
dabOutput/dabOutput.h \
@@ -122,8 +120,8 @@ odr_zmq2farsync_SOURCES = zmq2farsync/zmq2farsync.cpp \
Log.h Log.cpp \
zmq.hpp
odr_zmq2farsync_LDADD = $(ZMQ_LIBS)
-odr_zmq2farsync_CFLAGS = -Wall $(GITVERSION_FLAGS) -I$(FARSYNC_DIR)
-odr_zmq2farsync_CXXFLAGS = -Wall -std=c++11 $(GITVERSION_FLAGS) -I$(FARSYNC_DIR)
+odr_zmq2farsync_CFLAGS = -Wall $(ZMQ_CPPFLAGS) $(GITVERSION_FLAGS) -I$(FARSYNC_DIR)
+odr_zmq2farsync_CXXFLAGS = -Wall -std=c++11 $(ZMQ_CPPFLAGS) $(GITVERSION_FLAGS) -I$(FARSYNC_DIR)
odr_zmq2edi_SOURCES = zmq2edi/zmq2edi.cpp \
zmq2edi/EDISender.h zmq2edi/EDISender.cpp \
@@ -146,9 +144,9 @@ odr_zmq2edi_SOURCES = zmq2edi/zmq2edi.cpp \
crc.h crc.c \
zmq.hpp
odr_zmq2edi_LDADD = $(ZMQ_LIBS) \
- -lpthread -lboost_thread -lboost_system
-odr_zmq2edi_CFLAGS = -Wall $(GITVERSION_FLAGS)
-odr_zmq2edi_CXXFLAGS = -Wall -std=c++11 $(GITVERSION_FLAGS)
+ -lpthread -lboost_thread -lboost_system
+odr_zmq2edi_CFLAGS = -Wall $(ZMQ_CPPFLAGS) $(GITVERSION_FLAGS)
+odr_zmq2edi_CXXFLAGS = -Wall -std=c++11 $(ZMQ_CPPFLAGS) $(GITVERSION_FLAGS)
EXTRA_DIST = fec/README.md \
fec/LICENSE