forked from zeromq/zproject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
477 lines (424 loc) · 17.9 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
#
AC_INIT([zproject],[1.1.0],[zeromq-dev@lists.zeromq.org])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR(config)
AC_CONFIG_HEADERS([src/platform.h])
AM_INIT_AUTOMAKE([subdir-objects tar-ustar dist-zip foreign])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
# This defines PACKAGE_VERSION_... in src/platform.h
PV_MAJOR=`echo $PACKAGE_VERSION | cut -d . -f 1`
PV_MINOR=`echo $PACKAGE_VERSION | cut -d . -f 2`
PV_PATCH=`echo $PACKAGE_VERSION | cut -d . -f 3`
AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MAJOR],[$PV_MAJOR],
[ZPROJECT major version])
AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MINOR],[$PV_MINOR],
[ZPROJECT minor version])
AC_DEFINE_UNQUOTED([PACKAGE_VERSION_PATCH],[$PV_PATCH],
[ZPROJECT patchlevel])
# This lets us use PACKAGE_VERSION in Makefiles
AC_SUBST(PACKAGE_VERSION)
#
# Libtool -version-info (ABI version)
#
# Currently 0:0:0 ("stable"). Don't change this unless you
# know exactly what you're doing and have read and understand
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
#
# libzproject -version-info
LTVER="0:0:0"
AC_SUBST(LTVER)
# building in a subdirectory?
AM_CONDITIONAL([USING_VPATH], [test "x${srcdir}" != "x."])
# Capture c flags
ZPROJECT_ORIG_CFLAGS="${CFLAGS:-none}"
# Checks for programs
AC_PROG_CC
AC_PROG_CC_C99
AM_PROG_CC_C_O
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
AC_PROG_SED
AC_PROG_AWK
PKG_PROG_PKG_CONFIG
# Check endianess of the system
AC_C_BIGENDIAN
# See if cppcheck is in PATH; this variable unblocks the "cppcheck" recipe
# (note that "make cppcheck.xml" can be used - and perhaps fail - regardless)
AC_CHECK_PROG([WITH_CPPCHECK], [cppcheck], [true], [false])
AM_CONDITIONAL(WITH_CPPCHECK, $WITH_CPPCHECK)
# Code coverage
AC_MSG_CHECKING([whether to enable GCov])
AC_ARG_WITH(gcov, [AS_HELP_STRING([--with-gcov=yes/no],
[With GCC Code Coverage reporting])],
[ZPROJECT_GCOV="$withval"])
if test "x${ZPROJECT_GCOV}" == "xyes"; then
CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
if test "x${ZPROJECT_ORIG_CFLAGS}" != "xnone"; then
CFLAGS="${CFLAGS} ${ZPROJECT_ORIG_CFLAGS}"
fi
AM_CONDITIONAL(WITH_GCOV, true)
AC_MSG_RESULT([yes])
else
AM_CONDITIONAL(WITH_GCOV, false)
AC_MSG_RESULT([no])
fi
# Memory mis-use detection
AC_MSG_CHECKING([whether to enable ASan])
AC_ARG_ENABLE(address-sanitizer, [AS_HELP_STRING([--enable-address-sanitizer=yes/no],
[Build with GCC Address Sanitizer instrumentation])],
[ZPROJECT_ASAN="$enableval"])
if test "x${ZPROJECT_ASAN}" == "xyes"; then
CFLAGS="${CFLAGS} -fsanitize=address"
CXXFLAGS="${CXXFLAGS} -fsanitize=address"
AM_CONDITIONAL(ENABLE_ASAN, true)
AC_MSG_RESULT([yes])
else
AM_CONDITIONAL(ENABLE_ASAN, false)
AC_MSG_RESULT([no])
fi
# See if clang-format is in PATH; the result unblocks the relevant recipes
WITH_CLANG_FORMAT=""
AS_IF([test x"$CLANG_FORMAT" = x],
[AC_PATH_PROG([CLANG_FORMAT], [clang-format], [])],
[AC_CHECK_PROG([WITH_CLANG_FORMAT], [$CLANG_FORMAT], [true], [fail])])
AS_IF([test x"$CLANG_FORMAT" != x && test x"$WITH_CLANG_FORMAT" = x],
[AS_IF([test -x "$CLANG_FORMAT"],
[WITH_CLANG_FORMAT=true],
[AC_CHECK_PROG([WITH_CLANG_FORMAT], [$CLANG_FORMAT], [true], [false])])])
AS_IF([test "$WITH_CLANG_FORMAT" = fail],
[AC_MSG_ERROR([Caller explicitly referenced CLANG_FORMAT=$CLANG_FORMAT which was not found])])
AM_CONDITIONAL([WITH_CLANG_FORMAT], [$WITH_CLANG_FORMAT])
# Set pkgconfigdir
AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=PATH],
[Path to the pkgconfig directory [[LIBDIR/pkgconfig]]]),
[pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig'])
AC_SUBST([pkgconfigdir])
# Use the provided pkgconfigdir not only to write our pkg-config data,
# but also as an additional location to look for other packages metadata.
AS_IF([test -n "${pkgconfigdir}" -a -d "${pkgconfigdir}"],
[AS_IF([test -z "${PKG_CONFIG_PATH}"],
[PKG_CONFIG_PATH="${pkgconfigdir}"],
[PKG_CONFIG_PATH="${pkgconfigdir}:${PKG_CONFIG_PATH}"])
export PKG_CONFIG_PATH
])
# Will be used to add flags to pkg-config useful when apps want to statically link
PKGCFG_LIBS_PRIVATE=""
# Archive user supplied flags
PREVIOUS_CFLAGS="${CFLAGS}"
PREVIOUS_LIBS="${LIBS}"
AC_CHECK_PROG(HAVE_GSL, gsl, yes)
if test x"$HAVE_GSL" != x"yes" ; then
AC_MSG_ERROR([Cannot find gsl])
fi
CFLAGS="${PREVIOUS_CFLAGS}"
LIBS="${PREVIOUS_LIBS}"
AC_SUBST(pkg_config_libs_private, $PKGCFG_LIBS_PRIVATE)
# Platform specific checks
zproject_on_mingw32="no"
zproject_on_cygwin="no"
zproject_on_android="no"
zproject_on_linux="no"
zproject_on_gnu="no"
# Host specific checks
AC_CANONICAL_HOST
# Man pages are built/installed if asciidoc and xmlto are present
# --with-docs=no overrides this
AC_ARG_WITH([docs],
AS_HELP_STRING([--with-docs],
[Build and install man pages [default=yes]]),
[with_docs=$withval])
if test "x$with_docs" = "xno"; then
zproject_build_doc="no"
zproject_install_man="no"
else
# Determine whether or not documentation should be built and installed.
zproject_build_doc="yes"
zproject_install_man="yes"
# Check for asciidoc and xmlto and don't build the docs if these are not installed.
AC_CHECK_PROG(zproject_have_asciidoc, asciidoc, yes, no)
AC_CHECK_PROG(zproject_have_xmlto, xmlto, yes, no)
if test "x$zproject_have_asciidoc" = "xno" -o "x$zproject_have_xmlto" = "xno"; then
if test "x$with_docs" = "xyes" ; then
AC_MSG_ERROR([Build with docs was explicitly requested, but tools are not available])
fi
zproject_build_doc="no"
# Tarballs built with 'make dist' ship with prebuilt documentation.
if ! test -f doc/zproject.7; then
zproject_install_man="no"
AC_MSG_WARN([You are building an unreleased version of ZPROJECT and asciidoc or xmlto are not installed.])
AC_MSG_WARN([Documentation will not be built and manual pages will not be installed.])
fi
fi
fi
AC_MSG_CHECKING([whether to build documentation])
AC_MSG_RESULT([$zproject_build_doc])
AC_MSG_CHECKING([whether to install manpages])
AC_MSG_RESULT([$zproject_install_man])
# Set some default features required by libzproject code.
CPPFLAGS="-DZPROJECT_INTERNAL_BUILD -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 -DLINUX $CPPFLAGS"
AC_DEFINE(ZPROJECT_HAVE_LINUX, 1, [Have Linux OS])
zproject_on_linux="yes"
case "${host_os}" in
*android*)
AC_DEFINE(ZPROJECT_HAVE_ANDROID, 1, [Have Android OS])
zproject_on_android="yes"
;;
esac
;;
*solaris*)
# Define on Solaris to enable all library features
CPPFLAGS="-D_PTHREADS $CPPFLAGS"
# Allow definitions of common OS-provided functions that are not in old standards
CPPFLAGS="-D__EXTENSIONS__ $CPPFLAGS"
AC_DEFINE(ZPROJECT_HAVE_SOLARIS, 1, [Have Solaris OS])
CFLAGS="${CFLAGS} -lsocket -lssp"
;;
*freebsd*)
# Define on FreeBSD to enable all library features
CPPFLAGS="-D__BSD_VISIBLE $CPPFLAGS"
AC_DEFINE(ZPROJECT_HAVE_FREEBSD, 1, [Have FreeBSD OS])
;;
*darwin*)
# Define on Darwin to enable all library features
CPPFLAGS="-D_DARWIN_C_SOURCE $CPPFLAGS"
AC_DEFINE(ZPROJECT_HAVE_OSX, 1, [Have DarwinOSX OS])
;;
*netbsd*)
# Define on NetBSD to enable all library features
CPPFLAGS="-D_NETBSD_SOURCE $CPPFLAGS"
AC_DEFINE(ZPROJECT_HAVE_NETBSD, 1, [Have NetBSD OS])
;;
*openbsd*)
# Define on OpenBSD to enable all library features
CPPFLAGS="-D_BSD_SOURCE $CPPFLAGS"
AC_DEFINE(ZPROJECT_HAVE_OPENBSD, 1, [Have OpenBSD OS])
;;
*nto-qnx*)
AC_DEFINE(ZPROJECT_HAVE_QNXNTO, 1, [Have QNX Neutrino OS])
;;
*aix*)
AC_DEFINE(ZPROJECT_HAVE_AIX, 1, [Have AIX OS])
;;
*hpux*)
# Define on HP-UX to enable all library features
CPPFLAGS="-D_POSIX_C_SOURCE=200112L"
AC_DEFINE(ZPROJECT_HAVE_HPUX, 1, [Have HPUX OS])
;;
*mingw32*)
# Disable format error due to incomplete ANSI C
CFLAGS="-Wno-error=format -Wno-unused-function -Wno-unused-variable -D_XOPEN_SOURCE $CFLAGS"
CPPFLAGS="-Wno-error=format -Wno-unused-function -Wno-unused-variable -D_XOPEN_SOURCE $CPPFLAGS"
AC_DEFINE(ZPROJECT_HAVE_WINDOWS, 1, [Have Windows OS])
AC_DEFINE(ZPROJECT_HAVE_MINGW32, 1, [Have MinGW32])
AC_CHECK_HEADERS(windows.h)
zproject_on_mingw32="yes"
zproject_install_man="no"
;;
*mingw64*)
# Define on MINGW64 to enable all libeary features
# Disable format error due to incomplete ANSI C
CFLAGS="-Wno-error=format -Wno-unused-function -Wno-unused-variable -D_XOPEN_SOURCE $CFLAGS"
CPPFLAGS="-Wno-error=format -Wno-unused-function -Wno-unused-variable -D_XOPEN_SOURCE $CPPFLAGS"
AC_DEFINE(ZPROJECT_HAVE_WINDOWS, 1, [Have Windows OS])
AC_DEFINE(ZPROJECT_HAVE_MINGW32, 1, [Have MinGW32])
AC_CHECK_HEADERS(windows.h)
zproject_on_mingw32="yes"
zproject_install_man="no"
;;
*cygwin*)
# Define on Cygwin to enable all library features
CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS"
AC_DEFINE(ZPROJECT_HAVE_CYGWIN, 1, [Have Cygwin])
zproject_on_cygwin="yes"
;;
gnu*)
# Define on GNU/Hurd to enable all library features
if test "x$GXX" = "xyes"; then
CPPFLAGS="-D_GNU_SOURCE $CPPFLAGS"
fi
AC_DEFINE(ZPROJECT_HAVE_GNU, 1, [Have GNU/Hurd OS])
zproject_on_gnu="yes"
;;
*)
AC_MSG_ERROR([unsupported system: ${host_os}])
;;
esac
# 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 ifaddrs.h)
AC_CHECK_HEADERS([net/if.h net/if_media.h linux/wireless.h], [], [],
[
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#include <stdint.h>
])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_HEADER_TIME
AC_TYPE_UINT32_T
AC_C_VOLATILE
AC_C_BIGENDIAN
# These options are GNU compiler specific.
if test "x$GCC" = "xyes"; then
CPPFLAGS="-pedantic -Werror -Wall -Wc++-compat ${CPPFLAGS}"
fi
AM_CONDITIONAL(ENABLE_SHARED, test "x$enable_shared" = "xyes")
AM_CONDITIONAL(ON_MINGW, test "x$zproject_on_mingw32" = "xyes")
AM_CONDITIONAL(ON_CYGWIN, test "x$zproject_on_cygwin" = "xyes")
AM_CONDITIONAL(ON_ANDROID, test "x$zproject_on_android" = "xyes")
AM_CONDITIONAL(ON_LINUX, test "x$zproject_on_linux" = "xyes")
AM_CONDITIONAL(ON_GNU, test "x$zproject_on_gnu" = "xyes")
AM_CONDITIONAL(INSTALL_MAN, test "x$zproject_install_man" = "xyes")
AM_CONDITIONAL(BUILD_DOC, test "x$zproject_build_doc" = "xyes")
AC_ARG_ENABLE([dist_cmakefiles],
AS_HELP_STRING([--enable-dist_cmakefiles],
[Distribute CMakeLists.txt and related files [default depends: on if present and not cross compiling]]),
[enable_dist_cmakefiles=$enableval],
[AC_MSG_CHECKING([for presence of CMake recipes])
if test "x$cross_compiling" = "xyes"; then
enable_dist_cmakefiles=no
else
AC_CHECK_FILE($srcdir/CMakeLists.txt, [enable_dist_cmakefiles=yes], [enable_dist_cmakefiles=no])
fi
AC_MSG_RESULT([$enable_dist_cmakefiles])])
AM_CONDITIONAL(ENABLE_DIST_CMAKEFILES, test "x$enable_dist_cmakefiles" = "xyes")
# Checks for library functions.
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(perror gettimeofday memset getifaddrs)
# enable specific system integration features
# Project has no stable classes so enable draft API by default
enable_drafts=yes
AM_CONDITIONAL([ENABLE_DRAFTS], [test x$enable_drafts != xno])
if test "x$enable_drafts" = "xyes"; then
AC_MSG_NOTICE([Building stable and legacy API + draft API])
AC_DEFINE(ZPROJECT_BUILD_DRAFT_API, 1, [Provide draft classes and methods])
AC_SUBST(pkg_config_defines, "-DZPROJECT_BUILD_DRAFT_API=1")
else
AC_MSG_NOTICE([Building stable and legacy API (no draft API)])
AC_SUBST(pkg_config_defines, "")
fi
AC_ARG_ENABLE([Werror],
AS_HELP_STRING([--enable-Werror],
[Add -Wall -Werror to GCC/GXX arguments [default=no; default=auto if nothing specified]]),
[AS_IF([test -n "$enableval"], [enable_Werror=$enableval], [enable_Werror=auto])],
[enable_Werror=no])
AS_IF([test "x$enable_Werror" = "xyes" || test "x$enable_Werror" = "xauto"],
[AS_IF([test -n "$CC"],[AS_IF([$CC --version 2>&1 | grep 'Free Software Foundation' > /dev/null],
[AC_MSG_NOTICE([Enabling pedantic errors for GNU C])
CFLAGS="$CFLAGS -Wall -Werror"],
[AC_MSG_NOTICE([Not enabling pedantic errors: compiler not supported by this recipe (not GNU C)])
AS_IF([test "x$enable_Werror" = "xyes"], [AC_MSG_ERROR([--enable-Werror=yes was requested and can not be satisfied for C: $CC])])
])])
AS_IF([test -n "$CXX"],[AS_IF([$CXX --version 2>&1 | grep 'Free Software Foundation' > /dev/null],
[AC_MSG_NOTICE([Enabling pedantic errors for GNU C++])
CXXFLAGS="$CXXFLAGS -Wall -Werror"],
[AC_MSG_NOTICE([Not enabling pedantic errors: compiler not supported by this recipe (not GNU C++)])
AS_IF([test "x$enable_Werror" = "xyes"], [AC_MSG_ERROR([--enable-Werror=yes was requested and can not be satisfied for C++: $CXX])])
])])
AS_IF([test -n "$CPP"],[AS_IF([$CPP --version 2>&1 | grep 'Free Software Foundation' > /dev/null],
[AC_MSG_NOTICE([Enabling pedantic errors for GNU CPP preprocessor])
CPPFLAGS="$CPPFLAGS -Wall -Werror"],
[AC_MSG_NOTICE([Not enabling pedantic errors: preprocessor not supported by this recipe (not GNU CPP)])
AS_IF([test "x$enable_Werror" = "xyes"], [AC_MSG_ERROR([--enable-Werror=yes was requested and can not be satisfied for CPP: $CPP])])
])])
])
# Specify output files
AC_CONFIG_FILES([Makefile
])
AC_OUTPUT
# Print configure summary and list make options
AC_DEFUN([AX_SUMMARIZE_ENV],
[
BUILD_USER=${USER}
BUILD_ARCH=${host}
BUILD_HOST=${ac_hostname}
BUILD_DATE=$(date +'%F %H:%M')
AC_DEFINE_UNQUOTED([BUILD_USER], "${BUILD_USER}", [The fine user who built the package])
AC_DEFINE_UNQUOTED([BUILD_ARCH], "${BUILD_ARCH}", [Architecture of the build host])
AC_DEFINE_UNQUOTED([BUILD_HOST], "${BUILD_HOST}", [Build host name])
AC_DEFINE_UNQUOTED([BUILD_DATE], "${BUILD_DATE}", [Build date])
AC_SUBST(BUILD_USER)
AC_SUBST(BUILD_ARCH)
AC_SUBST(BUILD_HOST)
AC_SUBST(BUILD_DATE)
AC_SUBST(BUILD_VERSION)
])
AC_DEFUN([AX_SUMMARIZE_CONFIG],
[
echo
echo '##########################################################################'
echo '# SUMMARY #'
echo '##########################################################################'
echo
echo Package version............... : $PACKAGE-$VERSION
echo
echo C compiler.................... : $CC
echo C compiler flags.............. : $CFLAGS
echo C++ compiler.................. : $CXX
echo C++ compiler flags............ : $CXXFLAGS
echo Configure date................ : $BUILD_DATE
echo Build architecture............ : $BUILD_ARCH
echo Build docs.................... : $zproject_build_doc
echo Build host.................... : $BUILD_HOST
echo Build user.................... : $USER
echo Draft API..................... : $enable_drafts
echo Install dir................... : $prefix
echo Install man pages............. : $zproject_install_man
echo
echo Help:
echo Use the Draft API \(default = yes\):
echo --enable-drafts=\(yes\|no\)
echo
echo Build the docs and install the man pages \(default = yes\):
echo --with-docs=\(yes\|no\) *requires asciidoc and xmlto
echo
echo '##########################################################################'
echo
echo Configure complete! Now proceed with:
echo " - 'make' compile the project"
echo " - 'make check' run the project's selftest"
echo " - 'make install' install the project to $prefix"
echo
echo Further options are:
echo " - 'make callcheck' run the project's selftest with valgrind to"
echo " check for performance leaks"
echo " - 'make check-verbose' run the project's selftest in verbose mode"
echo " - 'make code' generate code from models in src directory"
echo " (requires zproject and zproto)"
echo " - 'make debug' run the project's selftest under gdb"
echo " - 'make memcheck' run the project's selftest with valgrind to"
echo " check for memory leaks"
echo " - 'make coverage' generate project's selftest coverage report"
echo " expects --with-gcov option for configure"
echo " - 'make clang-format-check' check if project sources conform"
echo " to style requirements"
echo " - 'make clang-format' modify project sources to conform"
echo " to style requirements"
echo " - 'make clang-format-diff' modify as above and print 'git diff'"
echo
])
AX_SUMMARIZE_ENV
AX_SUMMARIZE_CONFIG
################################################################################
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Read the zproject/README.md for information about making permanent changes. #
################################################################################