From f745c96a9bcf930d10fe31de5f7b3e772cccfa83 Mon Sep 17 00:00:00 2001 From: Martin Lucina Date: Wed, 17 Feb 2010 15:40:26 +0100 Subject: Add POSIX and GNU Feature Test Macros This should fix more exotic POSIX platforms such as HPUX which insist on having _POSIX_C_SOURCE defined to get proper threading behaviour. We also define _GNU_SOURCE so that we get any extensions on systems with glibc, e.g. eventfd. --- configure.in | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'configure.in') diff --git a/configure.in b/configure.in index 49266c7..a031458 100644 --- a/configure.in +++ b/configure.in @@ -91,10 +91,13 @@ if test ! -f "doc/zmq.html"; then fi fi +# Set some default features required by 0MQ code. +CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_GNU_SOURCE -D_POSIX_C_SOURCE=200112L $CPPFLAGS" + +# OS-specific tests case "${host_os}" in *linux*) AC_DEFINE(ZMQ_HAVE_LINUX, 1, [Have Linux OS]) - CPPFLAGS="-D_REENTRANT $CPPFLAGS" AC_CHECK_LIB(uuid, main, , [AC_MSG_ERROR([cannot link with -luuid, install uuid-dev.])]) ;; @@ -105,7 +108,7 @@ case "${host_os}" in AC_CHECK_LIB(rt, main) AC_CHECK_LIB(uuid, main, , [AC_MSG_ERROR([cannot link with -luuid, install uuid-dev.])]) - CPPFLAGS="-D_REENTRANT -D_PTHREADS $CPPFLAGS" + CPPFLAGS="-D_PTHREADS $CPPFLAGS" AC_MSG_CHECKING([wheter atomic operations can be used]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[#include ]], @@ -122,7 +125,6 @@ case "${host_os}" in ;; *freebsd*) AC_DEFINE(ZMQ_HAVE_FREEBSD, 1, [Have FreeBSD OS]) - CPPFLAGS="-D_THREAD_SAFE $CPPFLAGS" LIBS="-pthread" ;; *darwin*) @@ -134,26 +136,18 @@ case "${host_os}" in ;; *openbsd*) AC_DEFINE(ZMQ_HAVE_OPENBSD, 1, [Have OpenBSD OS]) - CPPFLAGS="-pthread $CPPFLAGS" 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) ;; *aix*) AC_DEFINE(ZMQ_HAVE_AIX, 1, [Have AIX OS]) - if test "x$GXX" = "xyes"; then - CPPFLAGS="-D_THREAD_SAFE $CPPFLAGS" - fi ;; *hpux*) AC_DEFINE(ZMQ_HAVE_HPUX, 1, [Have HPUX OS]) - if test "x$GXX" = "xyes"; then - CPPFLAGS="-D_THREAD_SAFE $CPPFLAGS" - fi AC_CHECK_LIB(rt, main) ;; *mingw32*) -- cgit v1.2.3 From 8be491b7bdb8525eb37cebf355697c566a482e2d Mon Sep 17 00:00:00 2001 From: Martin Lucina Date: Thu, 18 Feb 2010 13:46:00 +0100 Subject: Use feature test macros more conservatively It turns out that feature test macros are a complete mess, and defining _GNU_SOURCE and _POSIX_C_SOURCE together breaks some systems. So we try and define the appropriate "make everything visible" combination specific to each system instead. This may still break something, so people should test their platforms and speak up if so. --- configure.in | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'configure.in') diff --git a/configure.in b/configure.in index a031458..d43f941 100644 --- a/configure.in +++ b/configure.in @@ -92,23 +92,26 @@ if test ! -f "doc/zmq.html"; then fi # Set some default features required by 0MQ code. -CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE -D_GNU_SOURCE -D_POSIX_C_SOURCE=200112L $CPPFLAGS" +CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE $CPPFLAGS" # OS-specific tests case "${host_os}" in *linux*) + # Define on Linux to enable all library features + CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS" AC_DEFINE(ZMQ_HAVE_LINUX, 1, [Have Linux OS]) AC_CHECK_LIB(uuid, main, , [AC_MSG_ERROR([cannot link with -luuid, install uuid-dev.])]) ;; *solaris*) + # Define on Solaris to enable all library features + CPPFLAGS="-D_POSIX_C_SOURCE=200112L -D_PTHREADS $CPPFLAGS" AC_DEFINE(ZMQ_HAVE_SOLARIS, 1, [Have Solaris OS]) AC_CHECK_LIB(socket, main) AC_CHECK_LIB(nsl, main) AC_CHECK_LIB(rt, main) AC_CHECK_LIB(uuid, main, , [AC_MSG_ERROR([cannot link with -luuid, install uuid-dev.])]) - CPPFLAGS="-D_PTHREADS $CPPFLAGS" AC_MSG_CHECKING([wheter atomic operations can be used]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[#include ]], @@ -124,10 +127,14 @@ case "${host_os}" in fi ;; *freebsd*) + # Define on FreeBSD to enable all library features + CPPFLAGS="-D__BSD_VISIBLE $CPPFLAGS" AC_DEFINE(ZMQ_HAVE_FREEBSD, 1, [Have FreeBSD OS]) LIBS="-pthread" ;; *darwin*) + # Define on Darwin to enable all library features + CPPFLAGS="-D_DARWIN_C_SOURCE $CPPFLAGS" pedantic="no" werror="no" AC_DEFINE(ZMQ_HAVE_OSX, 1, [Have DarwinOSX OS]) @@ -135,6 +142,8 @@ case "${host_os}" in LIBZMQ_EXTRA_CXXFLAGS+="-Wno-uninitialized" ;; *openbsd*) + # Define on OpenBSD to enable all library features + CPPFLAGS="-D_BSD_SOURCE $CPPFLAGS" AC_DEFINE(ZMQ_HAVE_OPENBSD, 1, [Have OpenBSD OS]) LIBS="-pthread" ;; @@ -147,6 +156,8 @@ case "${host_os}" in AC_DEFINE(ZMQ_HAVE_AIX, 1, [Have AIX OS]) ;; *hpux*) + # Define on HP-UX to enable all library features + CPPFLAGS="-D_POSIX_C_SOURCE=200112L" AC_DEFINE(ZMQ_HAVE_HPUX, 1, [Have HPUX OS]) AC_CHECK_LIB(rt, main) ;; -- cgit v1.2.3 From 46824abeb2b016c51f406401d965816f71189aed Mon Sep 17 00:00:00 2001 From: Martin Lucina Date: Thu, 18 Feb 2010 17:25:49 +0100 Subject: Never build docs from tarball releases This fixes the build_doc logic to work as advertised and never try to (re)build documentation when working with a tarball release. --- configure.in | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'configure.in') diff --git a/configure.in b/configure.in index d43f941..45def38 100644 --- a/configure.in +++ b/configure.in @@ -77,9 +77,9 @@ on_mingw32="no" AC_CANONICAL_HOST # Determine whether or not documentation should be built. -build_doc="yes" +build_doc="no" install_man="yes" -if test ! -f "doc/zmq.html"; then +if test -d ".git"; then # We are building from git. # Check for asciidoc and xmlto and don't build the docs if these are not installed. AC_CHECK_PROG(have_asciidoc, asciidoc, yes, no) @@ -88,8 +88,17 @@ if test ! -f "doc/zmq.html"; then build_doc="no" install_man="no" AC_MSG_WARN([You are building from git and asciidoc is not installed. Documentation will not be built or installed.]) + else + build_doc="yes" fi fi +AC_MSG_CHECKING([whether to build documentation]) +AC_MSG_RESULT([$build_doc]) +AC_MSG_CHECKING([whether to install manpages]) +if test ! -f "./doc/zmq.7"; then + AC_MSG_ERROR([configure thinks we want to install manpages but they're not present. Help!]) +fi +AC_MSG_RESULT([$install_man]) # Set some default features required by 0MQ code. CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE $CPPFLAGS" @@ -639,7 +648,6 @@ AC_MSG_RESULT([ Queue: $queue]) AC_MSG_RESULT([ Performance tests: $perf]) AC_MSG_RESULT([ Examples:]) AC_MSG_RESULT([ Chat: $chat]) -AC_MSG_RESULT([ Documentation: $build_doc]) AC_MSG_RESULT([]) AC_MSG_RESULT([ ******************************************************** ]) AC_MSG_RESULT([]) -- cgit v1.2.3 From 495f0d105f809a265c34aa9a0eb20af0dcdcf283 Mon Sep 17 00:00:00 2001 From: Martin Lucina Date: Thu, 18 Feb 2010 17:29:14 +0100 Subject: Fix detection of libstdc++ We only care about libstdc++ when using GNU C++. Further, libstdc++ depends on libm on some platforms, fix this. --- configure.in | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'configure.in') diff --git a/configure.in b/configure.in index 45def38..7fbc2cf 100644 --- a/configure.in +++ b/configure.in @@ -55,8 +55,12 @@ AC_PROG_SED AC_PROG_AWK # Checks for libraries. -AC_CHECK_LIB(pthread, pthread_create) -AC_CHECK_LIB(stdc++, malloc) +AC_CHECK_LIB([pthread], [pthread_create]) +# If using GNU C++, libstdc++ must be available. +if test "x$GXX" = "xyes"; then + AC_CHECK_LIB([stdc++], [main], , + [AC_MSG_ERROR([cannot link with -lstdc++])], [-lm]) +fi # Extra CXXFLAGS are appended at the end of CXXFLAGS for libzmq. LIBZMQ_EXTRA_CXXFLAGS="" @@ -139,7 +143,6 @@ case "${host_os}" in # Define on FreeBSD to enable all library features CPPFLAGS="-D__BSD_VISIBLE $CPPFLAGS" AC_DEFINE(ZMQ_HAVE_FREEBSD, 1, [Have FreeBSD OS]) - LIBS="-pthread" ;; *darwin*) # Define on Darwin to enable all library features @@ -147,14 +150,12 @@ case "${host_os}" in pedantic="no" werror="no" AC_DEFINE(ZMQ_HAVE_OSX, 1, [Have DarwinOSX OS]) - LIBS="-pthread" LIBZMQ_EXTRA_CXXFLAGS+="-Wno-uninitialized" ;; *openbsd*) # Define on OpenBSD to enable all library features CPPFLAGS="-D_BSD_SOURCE $CPPFLAGS" AC_DEFINE(ZMQ_HAVE_OPENBSD, 1, [Have OpenBSD OS]) - LIBS="-pthread" ;; *nto-qnx*) pedantic="no" -- cgit v1.2.3 From ab27f84b14a317d78a9dd145ef5c82e0ef88f583 Mon Sep 17 00:00:00 2001 From: Martin Lucina Date: Thu, 18 Feb 2010 19:27:15 +0100 Subject: libstdc++ depends on libm on some platforms --- configure.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'configure.in') diff --git a/configure.in b/configure.in index 7fbc2cf..da7f0b1 100644 --- a/configure.in +++ b/configure.in @@ -58,8 +58,10 @@ AC_PROG_AWK AC_CHECK_LIB([pthread], [pthread_create]) # If using GNU C++, libstdc++ must be available. if test "x$GXX" = "xyes"; then + # libstdc++ depends on libm on some platforms + AC_CHECK_LIB([m], [main]) AC_CHECK_LIB([stdc++], [main], , - [AC_MSG_ERROR([cannot link with -lstdc++])], [-lm]) + [AC_MSG_ERROR([cannot link with -lstdc++])]) fi # Extra CXXFLAGS are appended at the end of CXXFLAGS for libzmq. -- cgit v1.2.3 From 776b12633981fd95050e138daeeba00a65d9532b Mon Sep 17 00:00:00 2001 From: Martin Lucina Date: Thu, 18 Feb 2010 19:27:35 +0100 Subject: Fix typo --- configure.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'configure.in') diff --git a/configure.in b/configure.in index da7f0b1..314372a 100644 --- a/configure.in +++ b/configure.in @@ -127,7 +127,7 @@ case "${host_os}" in AC_CHECK_LIB(rt, main) AC_CHECK_LIB(uuid, main, , [AC_MSG_ERROR([cannot link with -luuid, install uuid-dev.])]) - AC_MSG_CHECKING([wheter atomic operations can be used]) + AC_MSG_CHECKING([whether atomic operations can be used]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [[#include ]], [[uint32_t value; -- cgit v1.2.3 From 2a79a943de417679c562cd4a917e1d1bc19b0d25 Mon Sep 17 00:00:00 2001 From: Martin Lucina Date: Thu, 18 Feb 2010 19:38:15 +0100 Subject: Add NetBSD support --- configure.in | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'configure.in') diff --git a/configure.in b/configure.in index 314372a..20cd8c5 100644 --- a/configure.in +++ b/configure.in @@ -154,6 +154,19 @@ case "${host_os}" in AC_DEFINE(ZMQ_HAVE_OSX, 1, [Have DarwinOSX OS]) LIBZMQ_EXTRA_CXXFLAGS+="-Wno-uninitialized" ;; + *netbsd*) + # Define on NetBSD to enable all library features + CPPFLAGS="-D_NETBSD_SOURCE $CPPFLAGS" + AC_DEFINE(ZMQ_HAVE_NETBSD, 1, [Have NetBSD OS]) + # NetBSD 5.0 and newer provides atomic operations + netbsd_has_atomic=no + # XXX As of 5.0.1 the functions declared in atomic.h are + # missing "extern C", disable this until upstream fixes it. + # AC_CHECK_HEADERS(atomic.h, [netbsd_has_atomic=yes]) + if test "x$netbsd_has_atomic" = "xno"; then + AC_DEFINE(ZMQ_FORCE_MUTEXES, 1, [Force to use mutexes]) + fi + ;; *openbsd*) # Define on OpenBSD to enable all library features CPPFLAGS="-D_BSD_SOURCE $CPPFLAGS" -- cgit v1.2.3