erlang plugin: Add some proof-of-concept code for Erlang interoperability.
[collectd.git] / configure.in
index d21df3c..fa463dd 100644 (file)
@@ -1245,6 +1245,74 @@ fi
 AM_CONDITIONAL(BUILD_WITH_LIBDBI, test "x$with_libdbi" = "xyes")
 # }}}
 
+# --with-erlang {{{
+ERLANG_CPPFLAGS="$ERLANG_CPPFLAGS"
+ERLANG_LDFLAGS="$ERLANG_LDFLAGS"
+ERLANG_LIBS="$ERLANG_LIBS"
+AC_ARG_WITH(erlang, [AS_HELP_STRING([--with-erlang@<:@=PREFIX@:>@], [Path to Erlang / erl_interface.])],
+[
+       if test "x$withval" != "xno" && test "x$withval" != "xyes"
+       then
+               LDFLAGS="$LDFLAGS -L$withval/lib"
+               CPPFLAGS="$CPPFLAGS -I$withval/include -D_THREAD_SAFE"
+               with_erlang="yes"
+       else
+               with_erlang="$withval"
+       fi
+],
+[
+       with_erlang="yes"
+])
+if test "x$ERLANG_CPPFLAGS" = "x"
+then
+       ERLANG_CPPFLAGS="-D_REENTRANT"
+fi
+if test "x$ERLANG_LIBS" = "x"
+then
+       ERLANG_LIBS="-lei -lpthread"
+fi
+
+SAVE_CPPFLAGS="$CPPFLAGS"
+SAVE_LDFLAGS="$LDFLAGS"
+CPPFLAGS="$CPPFLAGS $ERLANG_CPPFLAGS"
+LDFLAGS="$LDFLAGS $ERLANG_LDFLAGS"
+
+if test "x$with_erlang" = "xyes"
+then
+       if test "x$ERLANG_CPPFLAGS" != "x"
+       then
+               AC_MSG_NOTICE([Erlang CPPFLAGS: $ERLANG_CPPFLAGS])
+       fi
+       AC_CHECK_HEADERS(erl_interface.h ei.h,
+                        [with_erlang="yes"],
+                        [with_erlang="no (Headers not found)"])
+fi
+if test "x$with_erlang" = "xyes"
+then
+       if test "x$ERLANG_LDFLAGS" != "x"
+       then
+               AC_MSG_NOTICE([Erlang LDFLAGS: $ERLANG_LDFLAGS])
+       fi
+       AC_CHECK_LIB(erl_interface, erl_connect_xinit,
+                    [with_erlang="yes"],
+                    [with_erlang="no (Symbol erl_connect_xinit not found)"],
+                    [$ERLANG_LIBS])
+fi
+if test "x$with_erlang" = "xyes"
+then
+       BUILD_WITH_ERLANG_CPPFLAGS="$ERLANG_CPPFLAGS"
+       BUILD_WITH_ERLANG_LDFLAGS="$ERLANG_LDFLAGS"
+       BUILD_WITH_ERLANG_LIBS="-lerl_interface $ERLANG_LIBS"
+       AC_SUBST(BUILD_WITH_ERLANG_CPPFLAGS)
+       AC_SUBST(BUILD_WITH_ERLANG_LDFLAGS)
+       AC_SUBST(BUILD_WITH_ERLANG_LIBS)
+fi
+AM_CONDITIONAL(BUILD_WITH_ERLANG, test "x$with_erlang" = "xyes")
+
+CPPFLAGS="$SAVE_CPPFLAGS"
+LDFLAGS="$SAVE_LDFLAGS"
+# }}}
+
 # --with-libesmtp {{{
 AC_ARG_WITH(libesmtp, [AS_HELP_STRING([--with-libesmtp@<:@=PREFIX@:>@], [Path to libesmtp.])],
 [
@@ -3853,6 +3921,7 @@ AC_PLUGIN([disk],        [$plugin_disk],       [Disk usage statistics])
 AC_PLUGIN([dns],         [$with_libpcap],      [DNS traffic analysis])
 AC_PLUGIN([email],       [yes],                [EMail statistics])
 AC_PLUGIN([entropy],     [$plugin_entropy],    [Entropy statistics])
+AC_PLUGIN([erlang],      [$with_erlang],       [Erlang interoperability])
 AC_PLUGIN([exec],        [yes],                [Execution of external programs])
 AC_PLUGIN([filecount],   [yes],                [Count files in directories])
 AC_PLUGIN([fscache],     [$plugin_fscache],    [fscache statistics])
@@ -4099,6 +4168,7 @@ Configuration:
   Libraries:
     libcurl . . . . . . . $with_libcurl
     libdbi  . . . . . . . $with_libdbi
+    liberl_interface  . . $with_erlang
     libesmtp  . . . . . . $with_libesmtp
     libganglia  . . . . . $with_libganglia
     libgcrypt . . . . . . $with_libgcrypt
@@ -4158,6 +4228,7 @@ Configuration:
     dns . . . . . . . . . $enable_dns
     email . . . . . . . . $enable_email
     entropy . . . . . . . $enable_entropy
+    erlang  . . . . . . . $enable_erlang
     exec  . . . . . . . . $enable_exec
     filecount . . . . . . $enable_filecount
     fscache . . . . . . . $enable_fscache