configure.in 12.6 KB
Newer Older
Martin Sustrik's avatar
Martin Sustrik committed
1 2 3
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
4
#
5 6
# The 0MQ version number is extracted from include/zmq.h using
# the version.sh script. Hence, it should be updated there.
7 8
# The version in git should reflect the *next* version planned.
#
9
AC_INIT([zeromq],[m4_esyscmd([./version.sh | tr -d '\n'])],[zeromq-dev@lists.zeromq.org])
10

Martin Sustrik's avatar
Martin Sustrik committed
11
AC_CONFIG_AUX_DIR(config)
12
AC_CONFIG_MACRO_DIR(config)
Martin Sustrik's avatar
Martin Sustrik committed
13
AM_CONFIG_HEADER(src/platform.hpp)
14
AM_INIT_AUTOMAKE(tar-ustar dist-zip foreign)
Martin Sustrik's avatar
Martin Sustrik committed
15

16 17 18
# This lets us use PACKAGE_VERSION in Makefiles
AC_SUBST(PACKAGE_VERSION)

19 20
# Libtool -version-info (ABI version)
#
21 22
# Don't change this unless you know exactly what you're doing and have read and
# understand:
23 24
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
#
25 26 27 28 29 30 31
# Changes:
#
# ZeroMQ versions prior to 2.1.0 use 0.0.0 ("unstable")
# ZeroMQ version 2.1.0: 1:0:0
#
# libzmq -version-info current:revision:age
LTVER="1:0:0"
malosek's avatar
malosek committed
32 33
AC_SUBST(LTVER)

Martin Sustrik's avatar
Martin Sustrik committed
34
# Checks for programs.
35
AC_PROG_CC
Mikko Koppanen's avatar
Mikko Koppanen committed
36
AC_PROG_CC_C99
Martin Sustrik's avatar
Martin Sustrik committed
37
AC_PROG_CXX
38
AM_PROG_CC_C_O
malosek's avatar
malosek committed
39 40
AC_PROG_SED
AC_PROG_AWK
Martin Sustrik's avatar
Martin Sustrik committed
41

Mikko Koppanen's avatar
Mikko Koppanen committed
42
# Libtool configuration for different targets. See acinclude.m4
43
AC_ZMQ_CONFIG_LIBTOOL
44 45
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
Mikko Koppanen's avatar
Mikko Koppanen committed
46

47 48
# Check whether to build a with debug symbols
AC_ZMQ_CHECK_ENABLE_DEBUG
49

Martin Sustrik's avatar
Martin Sustrik committed
50
# Checks for libraries.
51
AC_CHECK_LIB([pthread], [pthread_create])
Martin Sustrik's avatar
Martin Sustrik committed
52

53 54
# Set pedantic
ac_zmq_pedantic="yes"
55

Mikko Koppanen's avatar
Mikko Koppanen committed
56
# By default compiling with -Werror except OSX.
57
ac_zmq_werror="yes"
58

Mikko Koppanen's avatar
Mikko Koppanen committed
59 60 61
# By default use DSO visibility
ac_zmq_dso_visibility="yes"

Mikko Koppanen's avatar
Mikko Koppanen committed
62
# Whether we are on mingw or not.
63
ac_zmq_on_mingw32="no"
64

65
# Set some default features required by 0MQ code.
66
CPPFLAGS="-D_REENTRANT -D_THREAD_SAFE $CPPFLAGS"
67

68 69 70
# For host type checks
AC_CANONICAL_HOST

71
# OS-specific tests
Martin Sustrik's avatar
Martin Sustrik committed
72 73
case "${host_os}" in
    *linux*)
74
        # Define on Linux to enable all library features. Define if using a gnu compiler
75
        if test "x$GXX" = "xyes"; then
76 77
            CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS"
        fi
Martin Sustrik's avatar
Martin Sustrik committed
78
        AC_DEFINE(ZMQ_HAVE_LINUX, 1, [Have Linux OS])
Mikko Koppanen's avatar
Mikko Koppanen committed
79 80
        AC_CHECK_LIB(rt, sem_init)
        AC_CHECK_LIB(uuid, uuid_generate, , 
81
            [AC_MSG_ERROR([cannot link with -luuid, install uuid-dev.])])
Martin Sustrik's avatar
Martin Sustrik committed
82 83
        ;;
    *solaris*)
84
        # Define on Solaris to enable all library features
85
        CPPFLAGS="-D_PTHREADS $CPPFLAGS"
Martin Sustrik's avatar
Martin Sustrik committed
86
        AC_DEFINE(ZMQ_HAVE_SOLARIS, 1, [Have Solaris OS])
Mikko Koppanen's avatar
Mikko Koppanen committed
87 88 89 90
        AC_CHECK_LIB(socket, socket)
        AC_CHECK_LIB(nsl, gethostbyname)
        AC_CHECK_LIB(rt, sem_init)
        AC_CHECK_LIB(uuid, uuid_generate, ,
91
            [AC_MSG_ERROR([cannot link with -luuid, install uuid-dev.])])
Martin Lucina's avatar
Martin Lucina committed
92
        AC_MSG_CHECKING([whether atomic operations can be used])
Martin Sustrik's avatar
Martin Sustrik committed
93 94 95 96 97 98 99 100 101 102
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
            [[#include <atomic.h>]],
            [[uint32_t value;
              atomic_cas_32 (&value, 0, 0);
              return 0;]])],
            [solaris_has_atomic=yes],
            [solaris_has_atomic=no])
        AC_MSG_RESULT([$solaris_has_atomic])
        # Solaris 8 does not have atomic operations exported to user space.
        if test "x$solaris_has_atomic" = "xno"; then
Martin Sustrik's avatar
Martin Sustrik committed
103
            AC_DEFINE(ZMQ_FORCE_MUTEXES, 1, [Force to use mutexes])
Martin Sustrik's avatar
Martin Sustrik committed
104 105 106
        fi
        ;;
    *freebsd*)
107 108
        # Define on FreeBSD to enable all library features
        CPPFLAGS="-D__BSD_VISIBLE $CPPFLAGS"
Martin Sustrik's avatar
Martin Sustrik committed
109
        AC_DEFINE(ZMQ_HAVE_FREEBSD, 1, [Have FreeBSD OS])
Martin Sustrik's avatar
Martin Sustrik committed
110 111
        ;;
    *darwin*)
112 113
        # Define on Darwin to enable all library features
        CPPFLAGS="-D_DARWIN_C_SOURCE $CPPFLAGS"
114 115
        ac_zmq_pedantic="no"
        ac_zmq_werror="no"
Martin Sustrik's avatar
Martin Sustrik committed
116
        AC_DEFINE(ZMQ_HAVE_OSX, 1, [Have DarwinOSX OS])
117 118 119
        AC_LANG_PUSH([C++])
        AC_ZMQ_CHECK_LANG_FLAG_PREPEND([-Wno-uninitialized])
        AC_LANG_POP([C++])
Martin Sustrik's avatar
Martin Sustrik committed
120
        ;;
Martin Lucina's avatar
Martin Lucina committed
121 122 123 124
    *netbsd*)
        # Define on NetBSD to enable all library features
        CPPFLAGS="-D_NETBSD_SOURCE $CPPFLAGS"
        AC_DEFINE(ZMQ_HAVE_NETBSD, 1, [Have NetBSD OS])
125 126 127
        # NetBSD 5.0 and newer provides atomic operations but we can
        # only use these on systems where PR #42842 has been fixed so
        # we must try and link a test program using C++.
128
        ac_zmq_netbsd_has_atomic=no
129 130 131 132 133 134 135
        AC_MSG_CHECKING([whether atomic operations can be used])
        AC_LANG_PUSH([C++])
        AC_LINK_IFELSE([AC_LANG_PROGRAM(
            [[#include <atomic.h>]],
            [[uint32_t value;
              atomic_cas_32 (&value, 0, 0);
              return 0;]])],
136 137
            [ac_zmq_netbsd_has_atomic=yes],
            [ac_zmq_netbsd_has_atomic=no])
138
        AC_LANG_POP([C++])
139 140
        AC_MSG_RESULT([$ac_zmq_netbsd_has_atomic])
        if test "x$ac_zmq_netbsd_has_atomic" = "xno"; then
Martin Lucina's avatar
Martin Lucina committed
141 142 143
            AC_DEFINE(ZMQ_FORCE_MUTEXES, 1, [Force to use mutexes])
        fi
        ;;
Martin Sustrik's avatar
Martin Sustrik committed
144
    *openbsd*)
145 146
        # Define on OpenBSD to enable all library features
        CPPFLAGS="-D_BSD_SOURCE $CPPFLAGS"
Martin Sustrik's avatar
Martin Sustrik committed
147
        AC_DEFINE(ZMQ_HAVE_OPENBSD, 1, [Have OpenBSD OS])
Martin Sustrik's avatar
Martin Sustrik committed
148 149
        ;;
    *nto-qnx*)
150
        ac_zmq_pedantic="no"
Martin Sustrik's avatar
Martin Sustrik committed
151
        AC_DEFINE(ZMQ_HAVE_QNXNTO, 1, [Have QNX Neutrino OS])
Mikko Koppanen's avatar
Mikko Koppanen committed
152 153
        AC_CHECK_LIB(socket, socket)
        AC_CHECK_LIB(crypto, RAND_bytes)
Martin Sustrik's avatar
Martin Sustrik committed
154 155
        ;;
    *aix*)
Martin Sustrik's avatar
Martin Sustrik committed
156
        AC_DEFINE(ZMQ_HAVE_AIX, 1, [Have AIX OS])
157
        AC_CHECK_LIB(crypto,RAND_bytes)
Martin Sustrik's avatar
Martin Sustrik committed
158 159
        ;;
    *hpux*)
160
        # Define on HP-UX to enable all library features
161
        CPPFLAGS="-D_POSIX_C_SOURCE=200112L $CPPFLAGS"
Martin Sustrik's avatar
Martin Sustrik committed
162
        AC_DEFINE(ZMQ_HAVE_HPUX, 1, [Have HPUX OS])
Mikko Koppanen's avatar
Mikko Koppanen committed
163
        AC_CHECK_LIB(rt, sem_init)
164
        AC_CHECK_LIB(crypto, RAND_bytes)
Martin Sustrik's avatar
Martin Sustrik committed
165 166
        ;;
    *mingw32*)
Martin Sustrik's avatar
Martin Sustrik committed
167 168
        AC_DEFINE(ZMQ_HAVE_WINDOWS, 1, [Have Windows OS])
        AC_DEFINE(ZMQ_HAVE_MINGW32, 1, [Have MinGW32])
Martin Sustrik's avatar
Martin Sustrik committed
169
        AC_CHECK_HEADERS(windows.h)
170
        AC_CHECK_LIB(ws2_32, main, ,
171
            [AC_MSG_ERROR([cannot link with ws2_32.dll.])])
Martin Lucina's avatar
Martin Lucina committed
172 173 174 175
        AC_CHECK_LIB(rpcrt4, main, ,
            [AC_MSG_ERROR([cannot link with rpcrt4.dll.])])
        AC_CHECK_LIB(iphlpapi, main, ,
            [AC_MSG_ERROR([cannot link with iphlpapi.dll.])])
Mikko Koppanen's avatar
Mikko Koppanen committed
176
        # mingw32 defines __int64_t as long long
177 178 179 180
        AC_LANG_PUSH([C++])
        AC_ZMQ_CHECK_LANG_FLAG_PREPEND([-Wno-long-long])
        AC_LANG_POP([C++])
        ac_zmq_on_mingw32="yes"
Mikko Koppanen's avatar
Mikko Koppanen committed
181
        ac_zmq_dso_visibility="no"
Mikko Koppanen's avatar
Mikko Koppanen committed
182 183 184 185

        if test "x$enable_static" = "xyes"; then
            AC_MSG_ERROR([Building static libraries is not supported under MinGW32])
        fi
Martin Sustrik's avatar
Martin Sustrik committed
186
        ;;
Martin Sustrik's avatar
Martin Sustrik committed
187
    *cygwin*)
Martin Lucina's avatar
Martin Lucina committed
188 189
        # Define on Cygwin to enable all library features
        CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS"
Martin Sustrik's avatar
Martin Sustrik committed
190
        AC_DEFINE(ZMQ_HAVE_CYGWIN, 1, [Have Cygwin])
Martin Lucina's avatar
Martin Lucina committed
191 192
        # Cygwin provides libuuid as part of the e2fsprogs package, and somewhat
        # uselessly installs the library in /usr/lib/e2fsprogs
193
        LDFLAGS="-L/usr/lib/e2fsprogs ${LDFLAGS}"
Martin Lucina's avatar
Martin Lucina committed
194 195
        AC_CHECK_LIB(uuid, uuid_generate, ,
            [AC_MSG_ERROR([cannot link with -luuid, install the e2fsprogs package.])])
Mikko Koppanen's avatar
Mikko Koppanen committed
196 197 198 199

        if test "x$enable_static" = "xyes"; then
            AC_MSG_ERROR([Building static libraries is not supported under Cygwin])
        fi
Martin Sustrik's avatar
Martin Sustrik committed
200
        ;;
Martin Sustrik's avatar
Martin Sustrik committed
201
    *)
202
        AC_MSG_ERROR([unsupported system: ${host_os}.])
Martin Sustrik's avatar
Martin Sustrik committed
203 204 205
        ;;
esac

206 207 208
#
# Check if the compiler supports -fvisibility=hidden flag. MinGW32 uses __declspec
#
Mikko Koppanen's avatar
Mikko Koppanen committed
209
if test "x$ac_zmq_dso_visibility" = "xyes"; then
210
    AC_LANG_PUSH([C])
Mikko Koppanen's avatar
Mikko Koppanen committed
211
    AC_ZMQ_CHECK_LANG_VISIBILITY([LIBZMQ_EXTRA_CFLAGS="$ac_zmq_cv_[]_AC_LANG_ABBREV[]_visibility_flag ${LIBZMQ_EXTRA_CFLAGS}"])
212 213 214
    AC_LANG_POP([C])

    AC_LANG_PUSH([C++])
Mikko Koppanen's avatar
Mikko Koppanen committed
215
    AC_ZMQ_CHECK_LANG_VISIBILITY([LIBZMQ_EXTRA_CXXFLAGS="$ac_zmq_cv_[]_AC_LANG_ABBREV[]_visibility_flag ${LIBZMQ_EXTRA_CXXFLAGS}"])
216
    AC_LANG_POP([C++])
217 218
fi

219 220 221
# CPU-specific optimizations
case "${host_cpu}" in
    *sparc*)
222 223 224
        AC_LANG_PUSH([C++])
        AC_ZMQ_CHECK_LANG_FLAG_PREPEND([-mcpu=v9])
        AC_LANG_POP([C++])
225 226 227 228
    ;;
    *)
    ;;
esac
Martin Sustrik's avatar
Martin Sustrik committed
229

Mikko Koppanen's avatar
Mikko Koppanen committed
230
# Check whether to build docs / install man pages
231
AC_ZMQ_CHECK_DOC_BUILD
Mikko Koppanen's avatar
Mikko Koppanen committed
232

Martin Sustrik's avatar
Martin Sustrik committed
233 234 235 236 237 238
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(errno.h arpa/inet.h netinet/tcp.h netinet/in.h stddef.h \
stdlib.h string.h sys/socket.h sys/time.h unistd.h limits.h)

# Check if we have ifaddrs.h header file.
Martin Sustrik's avatar
Martin Sustrik committed
239
AC_CHECK_HEADERS(ifaddrs.h, [AC_DEFINE(ZMQ_HAVE_IFADDRS, 1, [Have ifaddrs.h header.])])
Martin Sustrik's avatar
Martin Sustrik committed
240 241

# Use c++ in subsequent tests
242
AC_LANG_PUSH(C++)
Martin Sustrik's avatar
Martin Sustrik committed
243 244 245 246

AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
247 248 249 250 251 252 253 254 255 256
# Checks for typedefs, structures, and compiler characteristics.
if test "x$ac_zmq_cv_[]_AC_LANG_ABBREV[]_intel_compiler" = "xyes"; then
    dnl 279: controlling expression is constant
    dnl Fixes build with ICC 12.x
    AC_ZMQ_CHECK_WITH_FLAG([-wd279], [AC_TYPE_SIZE_T])
    AC_ZMQ_CHECK_WITH_FLAG([-wd279], [AC_TYPE_SSIZE_T])
else
    AC_TYPE_SIZE_T
    AC_TYPE_SSIZE_T
fi
Martin Sustrik's avatar
Martin Sustrik committed
257 258 259 260
AC_HEADER_TIME
AC_TYPE_UINT32_T
AC_C_VOLATILE

261
#  PGM extension
262
ac_zmq_pgm_ext="no"
263

Steven McCoy's avatar
Steven McCoy committed
264
pgm_basename="libpgm-5.0.92~dfsg"
265

266
AC_SUBST(pgm_basename)
267

268
AC_ARG_WITH([pgm], [AS_HELP_STRING([--with-pgm], 
269
    [build libzmq with PGM extension [default=no]])], 
270
    [with_pgm_ext=yes], [with_pgm_ext=no])
271

272
if test "x$with_pgm_ext" != "xno"; then
273

Mikko Koppanen's avatar
Mikko Koppanen committed
274
    if test "x$ac_cv_prog_cc_c99" = "xno"; then
275
        AC_MSG_WARN([The C compiler is not set to C99 mode. The build will most likely fail])
Mikko Koppanen's avatar
Mikko Koppanen committed
276 277
    fi
    
278
    AC_MSG_CHECKING([if the PGM extension is supported on this platform])
Steven McCoy's avatar
Steven McCoy committed
279
    # OpenPGM is only supported by the vendor on x86, AMD64, and SPARC platforms...
280
    case "${host_cpu}" in
281
        i*86|x86_64|amd64|*sparc*)
282 283 284 285
            # Supported
        ;;
        *)
            AC_MSG_ERROR([the PGM extension is not supported on the ${host_cpu} platform.])
286
        ;;
287 288
    esac

Steven McCoy's avatar
Steven McCoy committed
289
    # ... and on Linux/Windows/Solaris/FreeBSD/OSX systems.
290
    case "${host_os}" in
Steven McCoy's avatar
Steven McCoy committed
291
        *linux*|*mingw32*|*solaris*|*freebsd*|*darwin*)
292 293 294 295 296 297 298 299 300 301 302 303 304
            AC_MSG_RESULT([yes])

            AC_LANG_PUSH([C++])
            AC_ZMQ_CHECK_LANG_FLAG([-Wno-variadic-macros], [LIBZMQ_EXTRA_CXXFLAGS="-Wno-variadic-macros $LIBZMQ_EXTRA_CXXFLAGS"])
            AC_ZMQ_CHECK_LANG_FLAG([-Wno-long-long], [LIBZMQ_EXTRA_CXXFLAGS="-Wno-long-long $LIBZMQ_EXTRA_CXXFLAGS"])
            AC_LANG_POP([C++])

            AC_LANG_PUSH([C])
            AC_ZMQ_LANG_STRICT([LIBZMQ_EXTRA_CFLAGS="$ac_zmq_cv_[]_AC_LANG_ABBREV[]_strict_flag $LIBZMQ_EXTRA_CFLAGS"])

            if test "x$ac_zmq_cv_[]_AC_LANG_ABBREV[]_intel_compiler" = "xyes" -o \
                    "x$ac_zmq_cv_[]_AC_LANG_ABBREV[]_sun_studio_compiler" = "xyes"; then
                LIBZMQ_EXTRA_CFLAGS="-Dasm=__asm__ $LIBZMQ_EXTRA_CFLAGS"
Mikko Koppanen's avatar
Mikko Koppanen committed
305
            fi
306
            AC_LANG_POP([C])
307 308
        ;;
        *)
309
            AC_MSG_ERROR([the PGM extension is not supported on system ${host_os}.])
310 311 312
        ;;
    esac

313
    #  Gzip, Perl and Python are required duing PGM build
314 315
    AC_CHECK_PROG(ac_zmq_have_gzip, gzip, yes, no)
    if test "x$ac_zmq_have_gzip" != "xyes"; then
316
        AC_MSG_ERROR([gzip is required for building the PGM extension.])
317
    fi
318 319
    AC_CHECK_PROG(ac_zmq_have_perl, perl, yes, no)
    if test "x$ac_zmq_have_perl" != "xyes"; then
320
        AC_MSG_ERROR([perl is required for building the PGM extension.])
321
    fi
322 323
    AC_CHECK_PROG(ac_zmq_have_python, python, yes, no)
    if test "x$ac_zmq_have_python" != "xyes"; then
Martin Sustrik's avatar
Martin Sustrik committed
324
        AC_MSG_ERROR([python is required for building the PGM extension.])
325 326
    fi

327
    #  Unpack libpgm
328
    AC_MSG_NOTICE([Unpacking ${pgm_basename}.tar.gz])
329 330 331 332 333
    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])
334
    fi
335
    cd "${ac_zmq_pwd}"
336 337 338

    #  Success!
    AC_DEFINE(ZMQ_HAVE_OPENPGM, 1, [Have OpenPGM extension])
339 340 341 342 343
    ac_zmq_pgm_ext="yes"

    # these break OpenPGM so don't specify them if we are building with it.
    ac_zmq_pedantic="no"
    ac_zmq_werror="no"
344 345
fi

346 347
# Set -Wall, -Werror and -pedantic
AC_LANG_PUSH([C++])
348

349 350
# Check how to enable -Wall
AC_ZMQ_LANG_WALL([CPPFLAGS="$ac_zmq_cv_[]_AC_LANG_ABBREV[]_wall_flag $CPPFLAGS"])
malosek's avatar
malosek committed
351

352 353 354 355 356 357
if test "x$ac_zmq_werror" = "xyes" -a "x$ac_zmq_cv_[]_AC_LANG_ABBREV[]_sun_studio_compiler" != "xyes"; then
    AC_ZMQ_LANG_WERROR([CPPFLAGS="$ac_zmq_cv_[]_AC_LANG_ABBREV[]_werror_flag $CPPFLAGS"])
fi

if test "x$ac_zmq_pedantic" = "xyes"; then
    AC_ZMQ_LANG_STRICT([CPPFLAGS="$ac_zmq_cv_[]_AC_LANG_ABBREV[]_strict_flag $CPPFLAGS"])
358
fi
359
AC_LANG_POP([C++])
360

361 362
AM_CONDITIONAL(BUILD_PGM, test "x$ac_zmq_pgm_ext" = "xyes")
AM_CONDITIONAL(ON_MINGW, test "x$ac_zmq_on_mingw32" = "xyes")
363

Mikko Koppanen's avatar
Mikko Koppanen committed
364 365
# Subst LIBZMQ_EXTRA_CFLAGS & CXXFLAGS & LDFLAGS
AC_SUBST(LIBZMQ_EXTRA_CFLAGS)
366
AC_SUBST(LIBZMQ_EXTRA_CXXFLAGS)
367
AC_SUBST(LIBZMQ_EXTRA_LDFLAGS)
Martin Sustrik's avatar
Martin Sustrik committed
368 369 370 371 372

# Checks for library functions.
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(perror gettimeofday memset socket getifaddrs freeifaddrs)

373
AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile
374
    perf/Makefile src/libzmq.pc \
375
    devices/Makefile devices/zmq_forwarder/Makefile \
376
    devices/zmq_streamer/Makefile devices/zmq_queue/Makefile \
377 378
    builds/msvc/Makefile tests/Makefile])
AC_OUTPUT
Martin Sustrik's avatar
Martin Sustrik committed
379