zeromq plugin: Fix the build system.
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 18 Oct 2010 09:19:04 +0000 (11:19 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Mon, 18 Oct 2010 09:19:04 +0000 (11:19 +0200)
configure.in
src/Makefile.am
src/zeromq.c

index b2347c7..b34dceb 100644 (file)
@@ -2640,12 +2640,15 @@ fi
 # }}}
 
 # --with-libzmq {{{
+with_zmq_cppflags=""
+with_zmq_ldflags=""
+with_zmq_libs="-lzmq"
 AC_ARG_WITH(libzmq, [AS_HELP_STRING([--with-libzmq@<:@=PREFIX@:>@], [Path to libzmq.])],
 [
        if test "x$withval" != "xno" && test "x$withval" != "xyes"
        then
-               LDFLAGS="$LDFLAGS -L$withval/lib"
-               CPPFLAGS="$CPPFLAGS -I$withval/include"
+               with_zmq_cppflags="-I$withval/include"
+               with_zmq_ldflags="-L$withval/lib"
                with_libzmq="yes"
        else
                with_libzmq="$withval"
@@ -2654,6 +2657,12 @@ AC_ARG_WITH(libzmq, [AS_HELP_STRING([--with-libzmq@<:@=PREFIX@:>@], [Path to lib
 [
        with_libzmq="yes"
 ])
+
+SAVE_CPPFLAGS="$CPPFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+CPPFLAGS="$SAVE_CPPFLAGS $with_zmq_cppflags"
+LDFLAGS="$SAVE_LDFLAGS $with_zmq_ldflags"
+
 if test "x$with_libzmq" = "xyes"
 then
        AC_CHECK_LIB(zmq, zmq_init,
@@ -2668,16 +2677,21 @@ then
                AC_DEFINE(HAVE_ZMQ_H, 1, [Define to 1 if you have the <zmq.h> header file.])
        ], [with_libzmq="no (zmq.h not found)"])
 fi
+
+CPPFLAGS="$SAVE_CPPFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+
 if test "x$with_libzmq" = "xyes"
 then
-       collect_libzmq=1
-else
-       collect_libzmq=0
+       BUILD_WITH_LIBZMQ_CPPFLAGS="$with_zmq_cppflags"
+       BUILD_WITH_LIBZMQ_LDFLAGS="$with_zmq_ldflags"
+       BUILD_WITH_LIBZMQ_LIBS="$with_zmq_libs"
+       AC_SUBST(BUILD_WITH_LIBZMQ_CPPFLAGS)
+       AC_SUBST(BUILD_WITH_LIBZMQ_LDFLAGS)
+       AC_SUBST(BUILD_WITH_LIBZMQ_LIBS)
 fi
-AC_DEFINE_UNQUOTED(COLLECT_LIBZMQ, [$collect_libzmq],
-       [Wether or not to use the ZeroMQ library])
 AM_CONDITIONAL(BUILD_WITH_LIBZMQ, test "x$with_libzmq" = "xyes")
-# }}}
+# }}} --with-libzmq
 
 # --with-libpcap {{{
 AC_ARG_WITH(libpcap, [AS_HELP_STRING([--with-libpcap@<:@=PREFIX@:>@], [Path to libpcap.])],
index 9962062..2288f14 100644 (file)
@@ -1245,10 +1245,10 @@ endif
 
 if BUILD_PLUGIN_ZEROMQ
 pkglib_LTLIBRARIES += zeromq.la
-zeromq_la_SOURCES = zeromq.c
-zeromq_la_CFLAGS = $(AM_CFLAGS) $(BUILD_WITH_LIBZMQ_CFLAGS)
-zeromq_la_LDFLAGS = -module -avoid-version
-zeromq_la_LIBADD = $(BUILD_WITH_ZEROMQ_LIBS)
+zeromq_la_SOURCES = zeromq.c zeromq.h
+zeromq_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBZMQ_CPPFLAGS)
+zeromq_la_LDFLAGS = -module -avoid-version $(BUILD_WITH_LIBZMQ_LDFLAGS)
+zeromq_la_LIBADD = $(BUILD_WITH_LIBZMQ_LIBS)
 collectd_LDADD += "-dlopen" zeromq.la
 collectd_DEPENDENCIES += zeromq.la
 endif
index e03fdc5..730ecc1 100644 (file)
@@ -1,4 +1,3 @@
-#ifdef HAVE_LIBZMQ
 /**
  * collectd - src/zeromq.c
  * Copyright (C) 20010  Julien Ammous
@@ -1030,6 +1029,3 @@ void module_register (void)
       /* user_data = */ NULL);
   plugin_register_shutdown ("zeromq", my_shutdown);
 }
-
-
-#endif // HAVE_LIBZMQ