From 33afdcd1adccd19ebd9f4ec9cc6d23a37975d135 Mon Sep 17 00:00:00 2001 From: malosek Date: Thu, 24 Sep 2009 12:43:35 +0200 Subject: added --with-pgm2 into build system --- configure.in | 116 +++++++++++++++++++++++++++++++++++++++++---------- src/Makefile.am | 89 +++++++++++++++++++++++++++++++++++++-- src/pgm_receiver.cpp | 2 +- src/pgm_receiver.hpp | 2 +- src/pgm_sender.cpp | 2 +- src/pgm_sender.hpp | 2 +- src/pgm_socket.cpp | 2 +- src/pgm_socket.hpp | 2 +- src/platform.hpp.in | 8 +++- src/socket_base.cpp | 4 +- 10 files changed, 196 insertions(+), 33 deletions(-) diff --git a/configure.in b/configure.in index 8483dae..03adbe1 100644 --- a/configure.in +++ b/configure.in @@ -134,11 +134,6 @@ if test "x$pedantic" = "xyes"; then LIBZMQ_EXTRA_CXXFLAGS="${LIBZMQ_EXTRA_CXXFLAGS} -pedantic" fi -# If not on QNX nor --with-pgm add -Werror into LIBZMQ_EXTRA_CXXFLAGS. -if test "x$werror" = "xyes" -a "x$pgm_ext" = "xno"; then - LIBZMQ_EXTRA_CXXFLAGS="${LIBZMQ_EXTRA_CXXFLAGS} -Werror" -fi - # Check if we are running at sparc harware AC_MSG_CHECKING([wheter __sparc__ is defined]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM( @@ -363,14 +358,26 @@ else fi # PGM extension -pgm_ext="no" -pgm_name="" -pgm_basename="libpgm-1.2.14" -AC_SUBST(pgm_basename) +pgm1_ext="no" +pgm2_ext="no" + +pgm_basename="" + AC_ARG_WITH([pgm], [AS_HELP_STRING([--with-pgm], - [build libzmq with PGM extension [default=no]])], - [with_pgm_ext=yes], [with_pgm_ext=no]) -if test "x$with_pgm_ext" != "xno"; then + [build libzmq with PGM v1 extension [default=no]])], + [with_pgm1_ext=yes], [with_pgm1_ext=no]) + +AC_ARG_WITH([pgm2], [AS_HELP_STRING([--with-pgm2], + [build libzmq with PGM v2 extension [default=no]])], + [with_pgm2_ext=yes], [with_pgm2_ext=no]) + +if test "x$with_pgm1_ext" != "xno" -a "x$with_pgm2_ext" != "xno"; then + AC_MSG_ERROR([Can not configure --with-pgm and --with-pgm2.]); +fi + +if test "x$with_pgm1_ext" != "xno"; then + + pgm_basename="libpgm-1.2.14" # Test if we have pkg-config if test "x$have_pkg_config" != "xyes"; then @@ -391,7 +398,7 @@ if test "x$with_pgm_ext" != "xno"; then AC_CHECK_HEADERS(openssl/md5.h, [] , [AC_MSG_ERROR([To run configure with --with-pgm option, openssl/md5.h has to be usable.])]) - AC_CHECK_LIB(ssl, MD5_Init, , [AC_MSG_ERROR([Could not link with libuuid, install develop version.])]) + AC_CHECK_LIB(ssl, MD5_Init, , [AC_MSG_ERROR([Could not link with libssl, install develop version.])]) AC_CHECK_PROG(have_tar, tar, yes, no) if test "x$have_tar" != "xyes"; then @@ -454,9 +461,70 @@ if test "x$with_pgm_ext" != "xno"; then LIBZMQ_EXTRA_LDFLAFS="${LIBZMQ_EXTRA_LDFLAFS} ${GLIB_LIBS}" - AC_DEFINE(ZMQ_HAVE_OPENPGM, 1, [Have OpenPGM extension.]) - pgm_name="$pgm_basename" - pgm_ext="yes" + AC_DEFINE(ZMQ_HAVE_OPENPGM, 1, [Have OpenPGM v1 or v2 extension.]) + AC_DEFINE(ZMQ_HAVE_OPENPGM1, 1, [Have OpenPGM v1 extension.]) + pgm1_ext="yes" +fi + +if test "x$with_pgm2_ext" != "xno"; then + + pgm_basename="libpgm-dev" + + # Test if we have pkg-config + if test "x$have_pkg_config" != "xyes"; then + AC_MSG_ERROR([To run configure with --with-pgm2 option, pkg-config has to be installed.]); + fi + + case "${host_os}" in + *linux*) + LIBZMQ_EXTRA_CXXFLAGS="${LIBZMQ_EXTRA_CXXFLAGS} -Wno-variadic-macros -Wno-long-long " + ;; + *solaris*) + ;; + *) + AC_MSG_ERROR([PGM extesion is not supported on this platform $host.]) + ;; + esac + + AC_CHECK_HEADERS(openssl/md5.h, [] , + [AC_MSG_ERROR([To run configure with --with-pgm2 option, openssl/md5.h has to be usable.])]) + + AC_CHECK_LIB(ssl, MD5_Init, , [AC_MSG_ERROR([Could not link with libssl, install develop version.])]) + + if test "x$pyzmq" != "xyes"; then + AC_CHECK_PROG(have_python, python, yes, no) + if test "x$have_python" != "xyes"; then + AC_MSG_ERROR([Could not find python.]) + fi + fi + + # Generate galois_tables.c + AC_CONFIG_COMMANDS([galois_tables2.c], + [perl foreign/openpgm/libpgm-dev/openpgm/pgm/galois_generator.pl > \ + foreign/openpgm/libpgm-dev/openpgm/pgm/galois_tables.c]) + + # Generate version.c + AC_CONFIG_COMMANDS([version2.c], + [python foreign/openpgm/libpgm-dev/openpgm/pgm/version_generator.py > \ + foreign/openpgm/libpgm-dev/openpgm/pgm/version.c]) + + # Check for OpenPGM nedded libraries. + PKG_CHECK_MODULES([GLIB], [glib-2.0 gthread-2.0]) + + LIBZMQ_EXTRA_CXXFLAGS="${LIBZMQ_EXTRA_CXXFLAGS} ${GLIB_CFLAGS} " + + LIBZMQ_EXTRA_LDFLAFS="${LIBZMQ_EXTRA_LDFLAFS} ${GLIB_LIBS}" + + AC_DEFINE(ZMQ_HAVE_OPENPGM, 1, [Have OpenPGM v1 or v2 extension.]) + AC_DEFINE(ZMQ_HAVE_OPENPGM2, 1, [Have OpenPGM v2 extension.]) + pgm2_ext="yes" +fi + +AC_SUBST(pgm_basename) + +# If not on QNX nor --with-pgm/2add -Werror into LIBZMQ_EXTRA_CXXFLAGS. +if test "x$werror" = "xyes" -a "x$pgm1_ext" = "xno" -a "x$pgm2_ext" = "xno"; then + LIBZMQ_EXTRA_CXXFLAGS="${LIBZMQ_EXTRA_CXXFLAGS} -Werror" fi # forwarder device @@ -489,7 +557,9 @@ AM_CONDITIONAL(BUILD_PYTHON, test "x$pyzmq" = "xyes") AM_CONDITIONAL(BUILD_RUBY, test "x$rbzmq" = "xyes") AM_CONDITIONAL(BUILD_C, test "x$czmq" = "xyes") AM_CONDITIONAL(BUILD_CPP, test "x$cppzmq" = "xyes") -AM_CONDITIONAL(BUILD_PGM, test "x$pgm_ext" = "xyes") +AM_CONDITIONAL(BUILD_PGM1, test "x$pgm1_ext" = "xyes") +AM_CONDITIONAL(BUILD_PGM2, test "x$pgm2_ext" = "xyes") +AM_CONDITIONAL(BUILD_NO_PGM, test "x$pgm2_ext" = "xno" -a "x$pgm1_ext" = "xno") AM_CONDITIONAL(BUILD_FORWARDER, test "x$forwarder" = "xyes") AM_CONDITIONAL(BUILD_PERF, test "x$perf" = "xyes") @@ -534,10 +604,14 @@ AC_MSG_RESULT([ Ruby library install dir: $rubydir]) fi AC_MSG_RESULT([ Network protocols:]) AC_MSG_RESULT([ TCP: yes]) -if test "x$pgm_ext" = "xyes"; then -AC_MSG_RESULT([ PGM: $pgm_ext ($pgm_name)]) -else -AC_MSG_RESULT([ PGM: $pgm_ext]) +if test "x$pgm1_ext" = "xyes"; then +AC_MSG_RESULT([ PGM: $pgm1_ext ($pgm_basename)]) +fi +if test "x$pgm2_ext" = "xyes"; then +AC_MSG_RESULT([ PGM: $pgm2_ext ($pgm_basename)]) +fi +if test "x$pgm1_ext" = "xno" -a "x$pgm2_ext" = "xno"; then +AC_MSG_RESULT([ PGM: no]) fi AC_MSG_RESULT([ Devices:]) AC_MSG_RESULT([ forwarder: $forwarder]) diff --git a/src/Makefile.am b/src/Makefile.am index f75c3a1..e2f28e2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,7 +15,7 @@ include_HEADERS = ../bindings/c/zmq.h endif endif -if BUILD_PGM +if BUILD_PGM1 pgm_sources = ../foreign/openpgm/@pgm_basename@/openpgm/pgm/packet.c \ ../foreign/openpgm/@pgm_basename@/openpgm/pgm/timer.c \ ../foreign/openpgm/@pgm_basename@/openpgm/pgm/if.c \ @@ -32,6 +32,38 @@ pgm_sources = ../foreign/openpgm/@pgm_basename@/openpgm/pgm/packet.c \ ../foreign/openpgm/@pgm_basename@/openpgm/pgm/galois_tables.c endif +if BUILD_PGM2 +pgm_sources = ../foreign/openpgm/@pgm_basename@/openpgm/pgm/packet.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/time.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/if.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/getifaddrs.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/getnodeaddr.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/indextoaddr.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/indextoname.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/nametoindex.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/inet_network.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/md5.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/gsi.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/tsi.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/signal.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/txwi.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/rxwi.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/transport.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/source.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/receiver.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/recv.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/pgm.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/timer.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/net.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/rate_control.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/async.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/checksum.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/reed_solomon.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/galois_tables.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/wsastrerror.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/glib-compat.c +endif + libzmq_la_SOURCES = $(pgm_sources) \ app_thread.hpp \ atomic_bitmap.hpp \ @@ -140,7 +172,7 @@ libzmq_la_SOURCES = $(pgm_sources) \ libzmq_la_LDFLAGS = -version-info @LTVER@ @LIBZMQ_EXTRA_LDFLAFS@ -if BUILD_PGM +if BUILD_PGM1 libzmq_la_CXXFLAGS = -I$(top_srcdir)/foreign/openpgm/@pgm_basename@/openpgm/pgm/include/ -Wall @LIBZMQ_EXTRA_CXXFLAGS@ libzmq_la_CFLAGS = -I$(top_srcdir)/foreign/openpgm/@pgm_basename@/openpgm/pgm/include/ @LIBZMQ_EXTRA_CXXFLAGS@ \ -pipe \ @@ -180,7 +212,58 @@ libzmq_la_CFLAGS = -I$(top_srcdir)/foreign/openpgm/@pgm_basename@/openpgm/pgm/in -DCONFIG_HAVE_SIGHANDLER_T \ -DCONFIG_BIND_INADDR_ANY \ -DCONFIG_GALOIS_MUL_LUT -else +endif + +if BUILD_PGM2 +libzmq_la_CXXFLAGS = -I$(top_srcdir)/foreign/openpgm/@pgm_basename@/openpgm/pgm/include/ -Wall @LIBZMQ_EXTRA_CXXFLAGS@ +libzmq_la_CFLAGS = -I$(top_srcdir)/foreign/openpgm/@pgm_basename@/openpgm/pgm/include/ @LIBZMQ_EXTRA_CXXFLAGS@ \ + -pipe \ + -Wall \ + -Wextra \ + -Wfloat-equal \ + -Wshadow \ + -Wunsafe-loop-optimizations \ + -Wpointer-arith \ + -Wbad-function-cast \ + -Wcast-qual \ + -Wcast-align \ + -Wwrite-strings \ + -Waggregate-return \ + -Wstrict-prototypes \ + -Wold-style-definition \ + -Wmissing-prototypes \ + -Wmissing-declarations \ + -Wmissing-noreturn \ + -Wmissing-format-attribute \ + -Wredundant-decls \ + -Wnested-externs \ + -Winline \ + -pedantic \ + -std=gnu99 \ + --param max-inline-insns-single=600 \ + -D_REENTRANT \ + -D_GNU_SOURCE \ + -D__need_IOV_MAX \ + -DCONFIG_HAVE_PSELECT \ + -DCONFIG_HAVE_POLL \ + -DCONFIG_HAVE_PPOLL \ + -DCONFIG_HAVE_EPOLL \ + -DCONFIG_HAVE_CLOCK_GETTIME \ + -DCONFIG_HAVE_CLOCK_NANOSLEEP \ + -DCONFIG_HAVE_NANOSLEEP \ + -DCONFIG_HAVE_USLEEP \ + -DCONFIG_HAVE_RTC \ + -DCONFIG_HAVE_TSC \ + -DCONFIG_HAVE_IFR_NETMASK \ + -DCONFIG_HAVE_GETIFADDRS \ + -DCONFIG_HAVE_GETHOSTBYNAME2 \ + -DCONFIG_HAVE_GETPROTOBYNAME_R \ + -DCONFIG_BIND_INADDR_ANY \ + -DCONFIG_GALOIS_MUL_LUT \ + -DGETTEXT_PACKAGE=\'"pgm"\' +endif + +if BUILD_NO_PGM libzmq_la_CXXFLAGS = -Wall @LIBZMQ_EXTRA_CXXFLAGS@ endif diff --git a/src/pgm_receiver.cpp b/src/pgm_receiver.cpp index 50a8ff9..998becb 100644 --- a/src/pgm_receiver.cpp +++ b/src/pgm_receiver.cpp @@ -19,7 +19,7 @@ #include "platform.hpp" -#if defined ZMQ_HAVE_OPENPGM +#if defined ZMQ_HAVE_OPENPGM1 #include diff --git a/src/pgm_receiver.hpp b/src/pgm_receiver.hpp index b573081..3471324 100644 --- a/src/pgm_receiver.hpp +++ b/src/pgm_receiver.hpp @@ -22,7 +22,7 @@ #include "platform.hpp" -#if defined ZMQ_HAVE_OPENPGM +#if defined ZMQ_HAVE_OPENPGM1 #include "io_object.hpp" #include "i_engine.hpp" diff --git a/src/pgm_sender.cpp b/src/pgm_sender.cpp index 423865b..d5f62ab 100644 --- a/src/pgm_sender.cpp +++ b/src/pgm_sender.cpp @@ -19,7 +19,7 @@ #include "platform.hpp" -#if defined ZMQ_HAVE_OPENPGM +#if defined ZMQ_HAVE_OPENPGM1 #include diff --git a/src/pgm_sender.hpp b/src/pgm_sender.hpp index 8fdda6c..32e97f6 100644 --- a/src/pgm_sender.hpp +++ b/src/pgm_sender.hpp @@ -22,7 +22,7 @@ #include "platform.hpp" -#if defined ZMQ_HAVE_OPENPGM +#if defined ZMQ_HAVE_OPENPGM1 #include "stdint.hpp" #include "io_object.hpp" diff --git a/src/pgm_socket.cpp b/src/pgm_socket.cpp index 88ef68e..0d7a3e2 100644 --- a/src/pgm_socket.cpp +++ b/src/pgm_socket.cpp @@ -19,7 +19,7 @@ #include "platform.hpp" -#if defined ZMQ_HAVE_OPENPGM +#if defined ZMQ_HAVE_OPENPGM1 #ifdef ZMQ_HAVE_LINUX #include diff --git a/src/pgm_socket.hpp b/src/pgm_socket.hpp index c9d0feb..fc7a0a3 100644 --- a/src/pgm_socket.hpp +++ b/src/pgm_socket.hpp @@ -22,7 +22,7 @@ #include "platform.hpp" -#if defined ZMQ_HAVE_OPENPGM +#if defined ZMQ_HAVE_OPENPGM1 #ifdef ZMQ_HAVE_LINUX #include diff --git a/src/platform.hpp.in b/src/platform.hpp.in index e6bb10c..3c28737 100644 --- a/src/platform.hpp.in +++ b/src/platform.hpp.in @@ -178,9 +178,15 @@ /* Have OpenBSD OS */ #undef ZMQ_HAVE_OPENBSD -/* Have OpenPGM extension. */ +/* Have OpenPGM v1 or v2 extension. */ #undef ZMQ_HAVE_OPENPGM +/* Have OpenPGM v1 extension. */ +#undef ZMQ_HAVE_OPENPGM1 + +/* Have OpenPGM v2 extension. */ +#undef ZMQ_HAVE_OPENPGM2 + /* Have DarwinOSX OS */ #undef ZMQ_HAVE_OSX diff --git a/src/socket_base.cpp b/src/socket_base.cpp index 6763167..b466b8c 100644 --- a/src/socket_base.cpp +++ b/src/socket_base.cpp @@ -93,7 +93,7 @@ int zmq::socket_base_t::bind (const char *addr_) return 0; } -#if defined ZMQ_HAVE_OPENPGM +#if defined ZMQ_HAVE_OPENPGM1 if (addr_type == "pgm" || addr_type == "udp") { // In the case of PGM bind behaves the same like connect. return connect (addr_); @@ -179,7 +179,7 @@ int zmq::socket_base_t::connect (const char *addr_) return 0; } -#if defined ZMQ_HAVE_OPENPGM +#if defined ZMQ_HAVE_OPENPGM1 if (addr_type == "pgm" || addr_type == "udp") { // If the socket type requires bi-directional communication -- cgit v1.2.3