[zeromq-dev] [patch] 0001-Added-support-for-latest-OpenPGM-5.1.99-on-OSX10.6.patch

Scott alcoholiday at gmail.com
Tue Dec 21 09:26:05 CET 2010


Hey folks... I added support for OpenPGM on OS X 10.6 (Snow Leopard),
here's what it involved:

1) latest openpgm -- configure.in conditionally pulls it out of
openpgm's svn repo

2) configure.in -- added --with-pgm-trunk option to pull openpgm from svn

3) src/Makefile.am -- Added appropriate OSX conditional -Defines to
src/Makefile.am
   Conditionally including two new source files that are part of the
latest openpgm lib.
   While I was at it, I also stuck some "endif reminders"

4) src/pgm_socket.cpp -- Added conditional include of pgm/in.h if
   building on OSX to fix a forward reference issue.

I feel like this is on the edge of wanting to be a branch, so I'll
leave it up to you who've been working on this project eons more than
me.

And to set expectations correctly, this builds, and doesn't
immediately crash, but I've yet to do much (any) in the way of
testing. But I'd rather get your feedback sooner than later, so I can
do this in a way that is most compatible w/ the awesome zeromq ethos!

-Scott

--patch follows inline below--


>From 167544fb9e3622781e89d05fead5754e147710f8 Mon Sep 17 00:00:00 2001
From: Scott Watson <scott at disney.com>
Date: Tue, 21 Dec 2010 00:20:40 -0800
Subject: [PATCH] Added support for latest OpenPGM (5.1.99) on OSX10.6

Configure.in modified to pull latest openpgm from svn when seeing
--with-pgm-trunk Added new AM Conditionals ON_DARWIN and PGM_TRUNK

src/Makefile.am modified to include new pgm source files and use
appropriate CFLAGS for OSX10.6

src/pgm_socket.cpp added OSX conditional source of pgm/in.h to address
forward reference error in pgm

Signed-off-by: Scott Watson <scott at disney.com>
---
 configure.in       |   32 +++++++++++++++++++++++++++++---
 src/Makefile.am    |   49 +++++++++++++++++++++++++++++++++++++++++--------
 src/pgm_socket.cpp |    7 ++++++-
 3 files changed, 76 insertions(+), 12 deletions(-)

diff --git a/configure.in b/configure.in
index 9c03518..df65b2e 100644
--- a/configure.in
+++ b/configure.in
@@ -118,6 +118,7 @@ case "${host_os}" in
         CPPFLAGS="-D_DARWIN_C_SOURCE $CPPFLAGS"
         ac_zmq_pedantic="no"
         ac_zmq_werror="no"
+        ac_zmq_on_darwin="yes"
         AC_DEFINE(ZMQ_HAVE_OSX, 1, [Have DarwinOSX OS])
         AC_LANG_PUSH([C++])
         AC_ZMQ_CHECK_LANG_FLAG_PREPEND([-Wno-uninitialized])
@@ -268,12 +269,14 @@ ac_zmq_pgm_ext="no"

 pgm_basename="libpgm-5.0.92~dfsg"

-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])

+AC_ARG_WITH([pgm-trunk], [AS_HELP_STRING([--with-pgm-trunk],
+    [build libzmq with OPEN PGM TRUNK [default=no]])],
+    [with_pgm_trunk=yes], [with_pgm_trunk=no])
+
 if test "x$with_pgm_ext" != "xno"; then

     if test "x$ac_cv_prog_cc_c99" = "xno"; then
@@ -329,17 +332,38 @@ if test "x$with_pgm_ext" != "xno"; then
         AC_MSG_ERROR([python is required for building the PGM extension.])
     fi

+    # remember where we are
+    ac_zmq_pwd=`pwd`
+
+    if test "x$with_pgm_trunk" != "xyes"; then
+
     #  Unpack libpgm
     AC_MSG_NOTICE([Unpacking ${pgm_basename}.tar.gz])
-    ac_zmq_pwd=`pwd`
     cd foreign/openpgm

     if ! (gzip -dc "${pgm_basename}.tar.gz" || echo "failed") |
${am__untar}; then
         AC_MSG_ERROR([cannot unpack the
foreign/openpgm/${pgm_basename}.tar.gz file])
     fi
+
+    fi
+
+    if test "x$with_pgm_trunk" = "xyes"; then
+
+    pgm_basename="openpgm-read-only"
+    AC_MSG_NOTICE([Using latest Openpgm Trunk Snapshot -- FETCHING
OpenPGM TRUNK via: ])
+    AC_MSG_NOTICE([cd foreign/openpgm/; svn checkout
http://openpgm.googlecode.com/svn/trunk/ ${pgm_basename} ])
+
+    cd foreign/openpgm
+    if ! (svn checkout http://openpgm.googlecode.com/svn/trunk/
openpgm-read-only || echo "failed") ; then
+        AC_MSG_ERROR([cannot get latest version of openpgm from svn
checkout http://openpgm.googlecode.com/svn/trunk/ openpgm-read-only])
+    fi
+
+    fi
+
     cd "${ac_zmq_pwd}"

     #  Success!
+    AC_SUBST(pgm_basename)
     AC_DEFINE(ZMQ_HAVE_OPENPGM, 1, [Have OpenPGM extension])
     ac_zmq_pgm_ext="yes"

@@ -365,6 +389,8 @@ AC_LANG_POP([C++])

 AM_CONDITIONAL(BUILD_PGM, test "x$ac_zmq_pgm_ext" = "xyes")
 AM_CONDITIONAL(ON_MINGW, test "x$ac_zmq_on_mingw32" = "xyes")
+AM_CONDITIONAL(ON_DARWIN, test "x$ac_zmq_on_darwin" = "xyes" )
+AM_CONDITIONAL(PGM_TRUNK, test "x$with_pgm_trunk" = "xyes" )

 # Subst LIBZMQ_EXTRA_CFLAGS & CXXFLAGS & LDFLAGS
 AC_SUBST(LIBZMQ_EXTRA_CFLAGS)
diff --git a/src/Makefile.am b/src/Makefile.am
index 0b00f1c..a74723a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,6 +6,11 @@ pkgconfig_DATA = libzmq.pc
 include_HEADERS = ../include/zmq.h ../include/zmq.hpp ../include/zmq_utils.h

 if BUILD_PGM
+
+PGMEXTRASOURCE = \
+	../foreign/openpgm/@pgm_basename@/openpgm/pgm/getprotobyname.c \
+	../foreign/openpgm/@pgm_basename@/openpgm/pgm/getnetbyname.c
+
 noinst_LTLIBRARIES = libpgm.la

 nodist_libpgm_la_SOURCES =
../foreign/openpgm/@pgm_basename@/openpgm/pgm/thread.c \
@@ -49,7 +54,8 @@ nodist_libpgm_la_SOURCES =
../foreign/openpgm/@pgm_basename@/openpgm/pgm/thread.
     ../foreign/openpgm/@pgm_basename@/openpgm/pgm/galois_tables.c \
     ../foreign/openpgm/@pgm_basename@/openpgm/pgm/wsastrerror.c \
     ../foreign/openpgm/@pgm_basename@/openpgm/pgm/histogram.c \
-    ../foreign/openpgm/@pgm_basename@/openpgm/pgm/version.c
+    ../foreign/openpgm/@pgm_basename@/openpgm/pgm/version.c \
+    $(PGMEXTRASOURCE)

 ../foreign/openpgm/@pgm_basename@/openpgm/pgm/version.c:
../foreign/openpgm/@pgm_basename@/openpgm/pgm/version_generator.py
 	python ../foreign/openpgm/@pgm_basename@/openpgm/pgm/version_generator.py > $@
@@ -58,7 +64,9 @@ nodist_libpgm_la_SOURCES =
../foreign/openpgm/@pgm_basename@/openpgm/pgm/thread.
 	perl ../foreign/openpgm/@pgm_basename@/openpgm/pgm/galois_generator.pl > $@

 libpgm_la_LIBADD = @LTLIBOBJS@
-endif
+
+endif BUILD_PGM
+

 libzmq_la_SOURCES = \
     array.hpp \
@@ -189,6 +197,7 @@ libzmq_la_SOURCES = \
     zmq_init.cpp \
     zmq_listener.cpp

+
 if ON_MINGW
 libzmq_la_LDFLAGS = -no-undefined -avoid-version -version-info
@LTVER@ @LIBZMQ_EXTRA_LDFLAGS@
 else
@@ -203,9 +212,31 @@ libpgm_diff_flags = \
     -DCONFIG_HAVE_ISO_VARARGS \
     -DCONFIG_HAVE_TSC \
     -DCONFIG_HAVE_WSACMSGHDR \
-    -DCONFIG_BIND_INADDR_ANY
+    -DCONFIG_BIND_INADDR_ANY \
+    -DPGM_GNUC_INTERNAL=

 else
+
+if ON_DARWIN
+libpgm_diff_flags = \
+	-DCONFIG_BIND_INADDR_ANY \
+	-DCONFIG_HAVE_ALLOCA_H \
+	-DCONFIG_HAVE_BACKTRACE \
+	-DCONFIG_HAVE_DSO_VISIBILITY \
+	-DCONFIG_HAVE_GETIFADDRS \
+	-DCONFIG_HAVE_GETOPT \
+	-DCONFIG_HAVE_IFR_NETMASK \
+	-DCONFIG_HAVE_ISO_VARARGS \
+	-DCONFIG_HAVE_POLL \
+	-DCONFIG_HAVE_PROC \
+	-DCONFIG_HAVE_PSELECT \
+	-DCONFIG_HAVE_SPRINTF_GROUPING \
+	-DCONFIG_HAVE_VASPRINTF \
+	-DCONFIG_HOST_ORDER_IP_LEN \
+	-DCONFIG_HOST_ORDER_IP_OFF \
+	-D__PGM_IMPL_FEATURES_H__ -DCONFIG_HAVE_GETTIMEOFDAY=1 -DCONFIG_HAVE_FTIME
+
+else
 libpgm_diff_flags = \
     -DCONFIG_HAVE_GETPROTOBYNAME_R2 \
     -DCONFIG_HAVE_ISO_VARARGS \
@@ -225,8 +256,10 @@ libpgm_diff_flags = \
     -DCONFIG_HAVE_SPRINTF_GROUPING \
     -DCONFIG_HAVE_VASPRINTF \
     -DCONFIG_BIND_INADDR_ANY \
-    -DCONFIG_HAVE_GETOPT
-endif
+    -DCONFIG_HAVE_GETOPT \
+    -DPGM_GNUC_INTERNAL=
+endif !ON_DARWIN
+endif !ON_MINGW

 libpgm_la_CFLAGS =
-I$(top_srcdir)/foreign/openpgm/@pgm_basename@/openpgm/pgm/include/
@LIBZMQ_EXTRA_CFLAGS@ \
     -D_XOPEN_SOURCE=600 \
@@ -235,19 +268,19 @@ libpgm_la_CFLAGS =
-I$(top_srcdir)/foreign/openpgm/@pgm_basename@/openpgm/pgm/in
     -DCONFIG_16BIT_CHECKSUM \
     -DCONFIG_GALOIS_MUL_LUT \
     -DGETTEXT_PACKAGE='"pgm"' \
-    -DPGM_GNUC_INTERNAL= \
     ${libpgm_diff_flags}

 libzmq_la_CXXFLAGS =
-I$(top_srcdir)/foreign/openpgm/@pgm_basename@/openpgm/pgm/include/ \
     @LIBZMQ_EXTRA_CXXFLAGS@
-endif
+
+endif BUILD_PGM

 if !BUILD_PGM
 libzmq_la_CXXFLAGS = @LIBZMQ_EXTRA_CXXFLAGS@
 endif

 if BUILD_PGM
-libzmq_la_LIBADD = libpgm.la
+libzmq_la_LIBADD = libpgm.la
 endif

 dist-hook:
diff --git a/src/pgm_socket.cpp b/src/pgm_socket.cpp
index 4c92f97..d461c28 100644
--- a/src/pgm_socket.cpp
+++ b/src/pgm_socket.cpp
@@ -34,6 +34,11 @@
 #include <string>

 #include "options.hpp"
+
+#ifdef ZMQ_HAVE_OSX
+# include "pgm/in.h"
+#endif
+
 #include "pgm_socket.hpp"
 #include "config.hpp"
 #include "err.hpp"
@@ -325,7 +330,7 @@ int zmq::pgm_socket_t::init (bool
udp_encapsulation_, const char *network_)
     pgm_freeaddrinfo (res);
     res = NULL;

-    //  Set IP level parameters.
+    //  Set IP level parameters.
     {
         const int nonblocking      = 1,
                   multicast_loop   = options.use_multicast_loop ? 1 : 0,
-- 
1.7.3.2



More information about the zeromq-dev mailing list