From 5acef9fc96280df934176b02de724eb904e4bba3 Mon Sep 17 00:00:00 2001 From: malosek Date: Thu, 10 Sep 2009 11:21:05 +0200 Subject: added --with-pgm option, libpgm-1.2.14 build within 0mq build system --- Makefile.am | 3 + configure.in | 119 ++++++++++++++++++++++++++++++++-- foreign/openpgm/libpgm-1.2.14.tar.bz2 | Bin 0 -> 280029 bytes src/Makefile.am | 64 +++++++++++++++++- src/platform.hpp.in | 3 + 5 files changed, 183 insertions(+), 6 deletions(-) create mode 100644 foreign/openpgm/libpgm-1.2.14.tar.bz2 diff --git a/Makefile.am b/Makefile.am index 66cbc3d..335d988 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,3 +16,6 @@ endif SUBDIRS = src $(DIR_P) $(DIR_R) $(DIR_J) $(DIR_PERF) DIST_SUBDIRS = src python ruby java perf + +dist-hook: + -rm -rf $(distdir)/third-party/openpgm/$pgm_basename diff --git a/configure.in b/configure.in index 4457d0b..1cde153 100644 --- a/configure.in +++ b/configure.in @@ -30,6 +30,18 @@ AC_PROG_AWK AC_CHECK_LIB(pthread, pthread_create) AC_CHECK_LIB(stdc++, malloc) +# Extra CXXFLAGS are appended at the end of CXXFLAGS for libzmq. +LIBZMQ_EXTRA_CXXFLAGS="" + +# Extra LDFLAGS are appended at the end of LDFLAGS for libzmq. +LIBZMQ_EXTRA_LDFLAFS="" + +# By default compiling with -pedantic except QNX and OSX. +pedantic="yes" + +#By default compiling with -Werror except OSX. +werror="yes" + # Host speciffic checks AC_CANONICAL_HOST @@ -70,9 +82,11 @@ case "${host_os}" in LIBS="-pthread" ;; *darwin*) + pedantic="no" + werror="no" AC_DEFINE(ZMQ_HAVE_OSX, 1, [Have DarwinOSX OS]) LIBS="-pthread" - ZMQ_EXTRA_CXXFLAGS+="-Wno-uninitialized" + LIBZMQ_EXTRA_CXXFLAGS+="-Wno-uninitialized" ;; *openbsd*) AC_DEFINE(ZMQ_HAVE_OPENBSD, 1, [Have OpenBSD OS]) @@ -80,6 +94,7 @@ case "${host_os}" in LIBS="-pthread" ;; *nto-qnx*) + pedantic="no" AC_DEFINE(ZMQ_HAVE_QNXNTO, 1, [Have QNX Neutrino OS]) CPPFLAGS="-D_THREAD_SAFE $CPPFLAGS" AC_CHECK_LIB(socket,main) @@ -102,18 +117,28 @@ case "${host_os}" in chmod 755 libtool ;; *mingw32*) + pedantic="no" AC_DEFINE(ZMQ_HAVE_WINDOWS, 1, [Have Windows OS]) AC_DEFINE(ZMQ_HAVE_MINGW32, 1, [Have MinGW32]) AC_CHECK_HEADERS(windows.h) LIBS="-lwsock32 -lws2_32 -no-undefined" CFLAGS="-std=c99" - install_man="no" ;; *) AC_MSG_ERROR([Not supported os: $host.]) ;; esac +# If not on QNX nor OSX add -pedantic into LIBZMQ_EXTRA_CXXFLAGS. +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( @@ -337,6 +362,85 @@ else JAR=true fi +# PGM extension +pgm_ext="no" +pgm_name="" +pgm_basename="libpgm-1.2.14" +AC_SUBST(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 + + # Test if we have pkg-config + if test "x$have_pkg_config" != "xyes"; then + AC_MSG_ERROR([To run configure with --with-pgm 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_PROG(have_tar, tar, yes, no) + if test "x$have_tar" != "xyes"; then + AC_MSG_ERROR([Could not find tar.]) + fi + + AC_CHECK_PROG(have_bunzip2, bunzip2, yes, no) + if test "x$have_bunzip2" != "xyes"; then + AC_MSG_ERROR([Could not find bunzip2.]) + fi + + AC_CHECK_PROG(have_perl, perl, yes, no) + if test "x$have_perl" != "xyes"; then + AC_MSG_ERROR([Could not find perl.]) + fi + + 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 + + # Unpack libpgm-1.0.0rc8.tar.bz2 + AC_MSG_CHECKING([Unpacking ${pgm_basename}.tar.bz2]) + + if tar -xjf foreign/openpgm/${pgm_basename}.tar.bz2 -C foreign/openpgm/; then + AC_MSG_RESULT([yes]) + else + AC_MSG_ERROR([Could not unpack foreign/openpgm/${pgm_basename}.tar.bz2 file]) + fi + + # Generate galois_tables.c + AC_CONFIG_COMMANDS([galois_tables.c], + [perl foreign/openpgm/libpgm-1.2.14/openpgm/pgm/galois_generator.pl > \ + foreign/openpgm/libpgm-1.2.14/openpgm/pgm/galois_tables.c]) + + # Generate version.c + AC_CONFIG_COMMANDS([version.c], + [python foreign/openpgm/libpgm-1.2.14/openpgm/pgm/version_generator.py > \ + foreign/openpgm/libpgm-1.2.14/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 extension.]) + pgm_name="$pgm_basename" + pgm_ext="yes" +fi + # Perf perf="no" AC_ARG_WITH([perf], [AS_HELP_STRING([--with-perf], @@ -357,13 +461,15 @@ 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_PERF, test "x$perf" = "xyes") AC_SUBST(stdint) AC_SUBST(inttypes) -# Subst ZMQ_EXTRA_CXXFLAGS -AC_SUBST(ZMQ_EXTRA_CXXFLAGS) +# Subst LIBZMQ_EXTRA_CXXFLAGS & LDFLAGS +AC_SUBST(LIBZMQ_EXTRA_CXXFLAGS) +AC_SUBST(LIBZMQ_EXTRA_LDFLAFS) # Checks for library functions. @@ -394,6 +500,11 @@ if test "x$rbzmq" = "xyes"; then AC_MSG_RESULT([ Ruby library install dir: $rubydir]) fi AC_MSG_RESULT([ Java language binding: $jzmq]) +if test "x$pgm_ext" = "xyes"; then +AC_MSG_RESULT([ PGM extension: $pgm_ext ($pgm_name)]) +else +AC_MSG_RESULT([ PGM extension: $pgm_ext]) +fi AC_MSG_RESULT([ performance tests: $perf]) AC_MSG_RESULT([]) diff --git a/foreign/openpgm/libpgm-1.2.14.tar.bz2 b/foreign/openpgm/libpgm-1.2.14.tar.bz2 new file mode 100644 index 0000000..718465d Binary files /dev/null and b/foreign/openpgm/libpgm-1.2.14.tar.bz2 differ diff --git a/src/Makefile.am b/src/Makefile.am index 83670f2..98934e7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,7 +15,24 @@ include_HEADERS = ../c/zmq.h endif endif -libzmq_la_SOURCES = \ +if BUILD_PGM +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 \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/gsi.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/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/version.c \ + ../foreign/openpgm/@pgm_basename@/openpgm/pgm/galois_tables.c +endif + +libzmq_la_SOURCES = $(pgm_sources) \ app_thread.hpp \ atomic_bitmap.hpp \ atomic_counter.hpp \ @@ -104,7 +121,50 @@ libzmq_la_SOURCES = \ zmq_listener_init.cpp libzmq_la_LDFLAGS = -version-info @LTVER@ -libzmq_la_CXXFLAGS = -Wall -pedantic -Werror @ZMQ_EXTRA_CXXFLAGS@ + +if BUILD_PGM +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_EPOLL \ + -DCONFIG_HAVE_RTC \ + -DCONFIG_HAVE_TSC \ + -DCONFIG_HAVE_IFR_NETMASK \ + -DCONFIG_HAVE_GETIFADDRS \ + -DCONFIG_HAVE_GETHOSTBYNAME2 \ + -DCONFIG_HAVE_GETPROTOBYNAME_R \ + -DCONFIG_HAVE_SIGHANDLER_T \ + -DCONFIG_BIND_INADDR_ANY \ + -DCONFIG_GALOIS_MUL_LUT +else +libzmq_la_CXXFLAGS = -Wall @LIBZMQ_EXTRA_CXXFLAGS@ +endif dist-hook: -rm $(distdir)/src/platform.hpp diff --git a/src/platform.hpp.in b/src/platform.hpp.in index 5feeed4..8e345fc 100644 --- a/src/platform.hpp.in +++ b/src/platform.hpp.in @@ -172,6 +172,9 @@ /* Have OpenBSD OS */ #undef ZMQ_HAVE_OPENBSD +/* Have OpenPGM extension. */ +#undef ZMQ_HAVE_OPENPGM + /* Have DarwinOSX OS */ #undef ZMQ_HAVE_OSX -- cgit v1.2.3