Add C++11 support to the build system
[babeltrace.git] / configure.ac
1 dnl SPDX-License-Identifier: MIT
2 dnl
3 dnl Copyright (C) 2017 EfficiOS, Inc.
4 dnl
5 dnl Process this file with autoconf to produce a configure script.
6
7 ## ##
8 ## Autoconf base setup ##
9 ## ##
10
11 AC_PREREQ([2.69])
12
13 m4_define([bt_version_major], [2])
14 m4_define([bt_version_minor], [1])
15 m4_define([bt_version_patch], [0])
16 m4_define([bt_version_dev_stage], [-rc1])
17 m4_define([bt_version], bt_version_major[.]bt_version_minor[.]bt_version_patch[]bt_version_dev_stage)
18 m4_define([bt_version_name], [])
19
20 AC_INIT([babeltrace2],[bt_version],[jeremie dot galarneau at efficios dot com],[],[https://efficios.com/babeltrace/])
21
22 # Following the numbering scheme proposed by libtool for the library version
23 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
24 m4_define([bt_lib_version_current], [0])
25 m4_define([bt_lib_version_revision], [0])
26 m4_define([bt_lib_version_age], [0])
27 m4_define([bt_lib_version], bt_lib_version_current[:]bt_lib_version_revision[:]bt_lib_version_age)
28 m4_define([bt_version_description], [])
29 m4_define([bt_version_description_c_safe], AS_ESCAPE(bt_version_description))
30
31 AC_SUBST([BABELTRACE_LIBRARY_VERSION], bt_lib_version)
32
33 AC_CONFIG_HEADERS([src/common/config.h])
34 AC_CONFIG_AUX_DIR([config])
35 AC_CONFIG_MACRO_DIR([m4])
36
37 AC_DEFINE([BT_VERSION_MAJOR], bt_version_major, [Babeltrace major version])
38 AC_DEFINE([BT_VERSION_MINOR], bt_version_minor, [Babeltrace minor version])
39 AC_DEFINE([BT_VERSION_PATCH], bt_version_patch, [Babeltrace patch version])
40 AC_DEFINE([BT_VERSION_DEV_STAGE], ["]bt_version_dev_stage["], [Babeltrace version development stage (can be empty)])
41 AC_DEFINE([BT_VERSION_NAME], ["]bt_version_name["], [Babeltrace version name])
42 AC_DEFINE([BT_VERSION_DESCRIPTION], ["]bt_version_description_c_safe["], [Babeltrace version description])
43
44 AC_CANONICAL_TARGET
45 AC_CANONICAL_HOST
46
47
48 ## ##
49 ## Automake base setup ##
50 ## ##
51
52 AM_INIT_AUTOMAKE([1.12 foreign dist-bzip2 no-dist-gzip tar-ustar nostdinc -Wall -Wno-portability -Werror])
53 AM_MAINTAINER_MODE([enable])
54
55 # Enable silent rules by default
56 AM_SILENT_RULES([yes])
57
58
59 ## ##
60 ## OS specific defaults ##
61 ## ##
62
63 MINGW32=no
64 LT_NO_UNDEFINED=""
65 AS_CASE([$host_os],
66 [solaris*|darwin*],
67 [
68 AE_FEATURE_DISABLE([debug-info])
69 ],
70 [freebsd*],
71 [
72 AE_FEATURE_DISABLE([debug-info])
73 ],
74 [cygwin*],
75 [
76 AE_FEATURE_DISABLE([debug-info])
77 LT_NO_UNDEFINED="-no-undefined"
78 ],
79 [mingw*],
80 [
81 MINGW32=yes
82 AE_FEATURE_DISABLE([debug-info])
83 LT_NO_UNDEFINED="-no-undefined"
84 ]
85 )
86
87 AM_CONDITIONAL([BABELTRACE_BUILD_WITH_MINGW], [test "x$MINGW32" = "xyes"])
88 AC_SUBST(LT_NO_UNDEFINED)
89
90
91 ## ##
92 ## C compiler checks ##
93 ## ##
94
95 # Choose the c compiler
96 AC_PROG_CC_STDC
97
98 # Make sure the c compiler supports C99
99 AS_IF([test "$ac_cv_prog_cc_c99" = "no"], [AC_MSG_ERROR([The compiler does not support C99])])
100
101 # Enable available system extensions and LFS support
102 AC_USE_SYSTEM_EXTENSIONS
103 AC_SYS_LARGEFILE
104
105 # Make sure the c compiler supports __attributes__
106 AX_C___ATTRIBUTE__
107 AS_IF([test "x$ax_cv___attribute__" != "xyes"],
108 [AC_MSG_ERROR([The compiler does not support __attribute__ extensions])])
109
110 # Make sur we have pthread support
111 AX_PTHREAD([], [AC_MSG_ERROR([Could not configure pthread support])])
112
113 # Checks for typedefs, structures, and compiler characteristics.
114 AC_C_INLINE
115 AC_C_TYPEOF
116 AC_TYPE_PID_T
117 AC_TYPE_SIZE_T
118 AC_TYPE_INT16_T
119 AC_TYPE_INT32_T
120 AC_TYPE_INT64_T
121 AC_TYPE_INT8_T
122 AC_TYPE_OFF_T
123 AC_TYPE_SSIZE_T
124 AC_TYPE_UINT16_T
125 AC_TYPE_UINT32_T
126 AC_TYPE_UINT64_T
127 AC_TYPE_UINT8_T
128 AC_CHECK_TYPES([ptrdiff_t])
129
130
131 ## ##
132 ## C++ compiler checks ##
133 ## ##
134
135 # Require a C++11 compiler without GNU extensions (-std=c++11)
136 AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
137
138
139 ## ##
140 ## Header checks ##
141 ## ##
142
143 AC_HEADER_STDBOOL
144 AC_CHECK_HEADERS([ \
145 fcntl.h \
146 float.h \
147 ftw.h \
148 libintl.h \
149 limits.h \
150 malloc.h \
151 netdb.h \
152 netinet/in.h \
153 stddef.h \
154 sys/socket.h \
155 sys/time.h
156 ])
157
158
159 ## ##
160 ## Linker checks ##
161 ## ##
162
163 # Check if the linker supports no-as-needed
164 AX_APPEND_LINK_FLAGS([-Wl,--no-as-needed], [LD_NO_AS_NEEDED])
165 AC_SUBST([LD_NO_AS_NEEDED])
166
167 # Check if the linker supports whole-archive
168 AX_CHECK_LINK_FLAG([-Wl,--whole-archive,--no-whole-archive],
169 [
170 AC_SUBST([LD_WHOLE_ARCHIVE], [-Wl,--whole-archive,])
171 AC_SUBST([LD_NO_WHOLE_ARCHIVE], [,--no-whole-archive])
172 ],[
173 # Fallback to force_load for the macOS linker
174 AX_CHECK_LINK_FLAG([-Wl,-force_load],
175 [
176 AC_SUBST([LD_WHOLE_ARCHIVE], [-Wl,-force_load,])
177 AC_SUBST([LD_NO_WHOLE_ARCHIVE], [])
178 ],[
179 AC_MSG_WARN([Can't find a linker option to force the inclusion of the static plugin archive objects.])
180 ]
181 )
182 ]
183 )
184
185 # Check if the linker supports the "notext" keyword
186 AX_CHECK_LINK_FLAG([-Wl,-z,notext],[
187 AC_SUBST([LD_NOTEXT], [-Wl,-z,notext])
188 ])
189
190
191 ## ##
192 ## Programs checks ##
193 ## ##
194
195 AM_PROG_AR
196 AC_PROG_MAKE_SET
197 AC_PROG_MKDIR_P
198 AC_PROG_LN_S
199 AC_PROG_SED
200 AC_PATH_PROG([report_fold], [fold])
201
202 # set $IN_GIT_REPO if we're in the Git repository; the `bootstrap` file
203 # is not distributed in tarballs
204 AS_IF([test -f "$srcdir/bootstrap"], [in_git_repo=yes], [in_git_repo=no])
205 AM_CONDITIONAL([IN_GIT_REPO], [test "x$in_git_repo" = "xyes"])
206
207 # check for bison
208 AC_PROG_YACC
209 AX_PROG_BISON_VERSION([2.5], [have_bison=yes])
210
211 AS_IF([test "x$have_bison" != "xyes"], [
212 AS_IF([test "x$in_git_repo" = "xyes"], [
213 AC_MSG_FAILURE([dnl
214 Bison >= 2.4 is required when building from the Git repository. You can
215 set the YACC variable to override automatic detection.
216 ])
217 ], [
218 AC_MSG_WARN([dnl
219 Missing Bison >= 2.4. Note that the parser files are already built in
220 this distribution tarball, so Bison is only needed if you intend to
221 modify their sources. You can set the YACC variable to override automatic
222 detection.
223 ])
224 ])
225 ])
226 AM_CONDITIONAL([HAVE_BISON], [test "x$have_bison" = "xyes"])
227
228 # check for flex
229 AC_PROG_LEX
230 AX_PROG_FLEX_VERSION([2.5.35], [have_flex=yes])
231
232 AS_IF([test "x$have_flex" != "xyes"], [
233 AS_IF([test "x$in_git_repo" = "xyes"], [
234 AC_MSG_FAILURE([dnl
235 Flex >= 2.5.35 is required when building from the Git repository. You can
236 set the LEX variable to override automatic detection.
237 ])
238 ], [
239 AC_MSG_WARN([dnl
240 Missing Flex >= 2.5.35. Note that the lexer files are already built in
241 this distribution tarball, so Flex is only needed if you intend to
242 modify their sources. You can set the LEX variable to override automatic
243 detection.
244 ])
245 ])
246 ])
247 AM_CONDITIONAL([HAVE_FLEX], [test "x$have_flex" = "xyes"])
248
249 # Initialize and configure libtool
250 LT_INIT([win32-dll])
251
252
253 ## ##
254 ## Library checks ##
255 ## ##
256
257 # Check what libraries are required on this platform to link sockets programs.
258 AX_LIB_SOCKET_NSL
259
260 # Check for glib >= 2.28 with gmodule support
261 AM_PATH_GLIB_2_0([2.28.0], [],
262 AC_MSG_ERROR([glib >= 2.28 is required - download it from ftp://ftp.gtk.org/pub/gtk]),
263 [gmodule-no-export]
264 )
265
266 # Checks for library functions.
267 AC_FUNC_ALLOCA
268 AC_FUNC_FORK
269 AC_FUNC_MKTIME
270 AC_FUNC_MMAP
271 AC_FUNC_STRERROR_R
272 AC_FUNC_STRNLEN
273 AC_CHECK_FUNCS([ \
274 atexit \
275 dup2 \
276 ftruncate \
277 gethostbyname \
278 gettimeofday \
279 localtime_r \
280 memchr \
281 memset \
282 mkdir \
283 mkdtemp \
284 munmap \
285 rmdir \
286 setenv \
287 socket \
288 strchr \
289 strdup \
290 strerror \
291 strndup \
292 strnlen \
293 strrchr \
294 strstr \
295 strtoul \
296 strtoull \
297 tzset \
298 ])
299
300 # AC_FUNC_MALLOC causes problems when cross-compiling.
301 #AC_FUNC_MALLOC
302 #AC_FUNC_REALLOC
303
304 # Check for fmemopen
305 AC_CHECK_LIB([c], [fmemopen],
306 [AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_FMEMOPEN], 1, [Has fmemopen support.])]
307 )
308
309 # Check for open_memstream
310 AC_CHECK_LIB([c], [open_memstream],
311 [AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_OPEN_MEMSTREAM], 1, [Has open_memstream support.])]
312 )
313
314 # Check for posix_fallocate
315 AC_CHECK_LIB([c], [posix_fallocate],
316 [AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_POSIX_FALLOCATE], 1, [Has posix_fallocate support.])]
317 )
318
319
320 ## ##
321 ## User variables ##
322 ## ##
323
324 AC_ARG_VAR([PYTHON_INCLUDE], [Include flags for Python, bypassing python-config])
325 AC_ARG_VAR([PYTHON_LDFLAGS], [Linker flags for Python, bypassing python-config])
326 AC_ARG_VAR([PYTHON_CONFIG], [Path to python-config])
327
328 # BABELTRACE_PLUGINS_DIR: Plugins directory
329 AC_ARG_VAR([BABELTRACE_PLUGINS_DIR], [built-in plugins install directory [LIBDIR/babeltrace2/plugins]])
330 AS_IF([test "x$BABELTRACE_PLUGINS_DIR" = x], [BABELTRACE_PLUGINS_DIR='${libdir}/babeltrace2/plugins'])
331
332 # BABELTRACE_PLUGIN_PROVIDERS_DIR: Plugin providers directory
333 AC_ARG_VAR([BABELTRACE_PLUGIN_PROVIDERS_DIR], [built-in plugin providers install directory [LIBDIR/babeltrace2/plugin-providers]])
334 AS_IF([test "x$BABELTRACE_PLUGIN_PROVIDERS_DIR" = x], [BABELTRACE_PLUGIN_PROVIDERS_DIR='${libdir}/babeltrace2/plugin-providers'])
335
336 # BABELTRACE_MINIMAL_LOG_LEVEL:
337 AC_ARG_VAR([BABELTRACE_MINIMAL_LOG_LEVEL], [Minimal log level for Babeltrace program, library, and plugins (TRACE, DEBUG (default), or INFO)])
338 AS_IF([test "x$BABELTRACE_MINIMAL_LOG_LEVEL" = x], [BABELTRACE_MINIMAL_LOG_LEVEL="DEBUG"])
339 AS_IF([test "$BABELTRACE_MINIMAL_LOG_LEVEL" != "TRACE" && \
340 test "$BABELTRACE_MINIMAL_LOG_LEVEL" != "DEBUG" && \
341 test "$BABELTRACE_MINIMAL_LOG_LEVEL" != "INFO"],
342 [AC_MSG_ERROR([Invalid BABELTRACE_MINIMAL_LOG_LEVEL value ($BABELTRACE_MINIMAL_LOG_LEVEL): use TRACE, DEBUG, or INFO.])]
343 )
344 AC_DEFINE_UNQUOTED([BT_MINIMAL_LOG_LEVEL], [BT_LOG_$BABELTRACE_MINIMAL_LOG_LEVEL], [Minimal log level])
345
346 # BABELTRACE_DEV_MODE:
347 AC_ARG_VAR([BABELTRACE_DEV_MODE], [Set to 1 to enable the Babeltrace developer mode (enables run-time checks for plugin developers)])
348 AS_IF([test "x$BABELTRACE_DEV_MODE" = x1], [
349 AC_DEFINE([BT_DEV_MODE], 1, [Babeltrace developer mode])
350 ], [BABELTRACE_DEV_MODE=0])
351 AM_CONDITIONAL([DEV_MODE], [test "x$BABELTRACE_DEV_MODE" = x1])
352
353 # BABELTRACE_DEBUG_MODE:
354 AC_ARG_VAR([BABELTRACE_DEBUG_MODE], [Set to 1 to enable the Babeltrace debug mode (enables internal assertions for Babeltrace maintainers)])
355 AS_IF([test "x$BABELTRACE_DEBUG_MODE" = x1], [
356 AC_DEFINE([BT_DEBUG_MODE], 1, [Babeltrace debug mode])
357 ], [BABELTRACE_DEBUG_MODE=0])
358
359
360 ## ##
361 ## Optionnal features selection ##
362 ## ##
363
364 # Python bindings
365 # Disabled by default
366 AE_FEATURE_DEFAULT_DISABLE
367 AE_FEATURE([python-bindings],[build the Python bindings])
368
369 # Python bindings documentation
370 # Disabled by default
371 AE_FEATURE_DEFAULT_DISABLE
372 AE_FEATURE([python-bindings-doc],[build the Python bindings documentation])
373
374 # Python plugins
375 # Disabled by default
376 AE_FEATURE_DEFAULT_DISABLE
377 AE_FEATURE([python-plugins],[enable the Python plugins support for the library and converter])
378
379 # Debug info
380 # Enabled by default, except on some platforms
381 AE_FEATURE_DEFAULT_ENABLE
382 AE_FEATURE([debug-info],[disable the debug info support (default on macOS, Solaris and Windows)])
383
384 # API documentation
385 # Disabled by default
386 AE_FEATURE_DEFAULT_DISABLE
387 AE_FEATURE([api-doc],[build the HTML API documentation])
388
389 # Built-in plugins
390 # Disabled by default
391 AE_FEATURE_DEFAULT_DISABLE
392 AE_FEATURE([built-in-plugins],[Statically-link in-tree plug-ins into the babeltrace2 executable])
393
394 # Built-in python plugin support
395 # Disabled by default
396 AE_FEATURE_DEFAULT_DISABLE
397 AE_FEATURE([built-in-python-plugin-support],[Statically-link Python plugin support into the babeltrace library])
398
399 # Man pages
400 # Enabled by default
401 AE_FEATURE_DEFAULT_ENABLE
402 AE_FEATURE([man-pages],[Do not build and install man pages (already built in a distributed tarball])
403
404 # When given, add -Werror to WARN_CFLAGS and WARN_CXXFLAGS.
405 # Disabled by default
406 AE_FEATURE_DEFAULT_DISABLE
407 AE_FEATURE([Werror],[Treat compiler warnings as errors.])
408
409
410 ## ##
411 ## Check for conflicting features selection ##
412 ## ##
413
414 # Check for conflicting Python related features user choices.
415 AE_IF_FEATURE_ENABLED([python-plugins], [
416 AE_IF_FEATURE_UNDEF([python-bindings], [
417 # --enable-python-plugins was provided but --enable-python-bindings was
418 # omitted. Turn the Python bindings ON anyway because it's needed to
419 # use the Python plugins.
420 AE_FEATURE_ENABLE([python-bindings])
421 ], [
422 AE_IF_FEATURE_DISABLED([python-bindings], [
423 # --enable-python-plugins _and_ --disable-python-bindings were
424 # used. This is invalid because Python plugins need the Python
425 # bindings to be useful.
426 AC_MSG_ERROR(--enable-python-bindings must be used to support Python plugins)
427 ])
428 ])
429 ])
430
431 # Check for conflicting optional features user choices
432 AE_IF_FEATURE_ENABLED([built-in-plugins], [
433 # Built-in plug-ins are only available when the --disable-shared --enable-static options are used.
434 AE_IF_FEATURE_NOT_ENABLED([static], [AC_MSG_ERROR(--enable-static must be used to bundle plug-ins in the babeltrace2 executable)])
435 AE_IF_FEATURE_ENABLED([shared], [AC_MSG_ERROR(--disable-shared must be used to bundle plug-ins in the babeltrace2 executable)])
436 ])
437
438 AE_IF_FEATURE_ENABLED([built-in-python-plugin-support], [
439 AE_IF_FEATURE_NOT_ENABLED([python-plugins], [AC_MSG_ERROR([--enable-python-plugins must be used to bundle Python plugin support in the babeltrace2 executable])])
440 # Built-in plug-ins are only available when the --disable-shared --enable-static options are used.
441 AE_IF_FEATURE_NOT_ENABLED([static], [AC_MSG_ERROR(--enable-static must be used to bundle Python plugin support in the babeltrace2 executable)])
442 AE_IF_FEATURE_ENABLED([shared], [AC_MSG_ERROR(--disable-shared must be used to bundle Python plugin support in the babeltrace2 executable)])
443 ])
444
445
446 ## ##
447 ## Set automake variables for optionnal feature conditionnals in Makefile.am ##
448 ## ##
449
450 AM_CONDITIONAL([ENABLE_PYTHON_BINDINGS], AE_IS_FEATURE_ENABLED([python-bindings]))
451 AM_CONDITIONAL([ENABLE_PYTHON_BINDINGS_DOC], AE_IS_FEATURE_ENABLED([python-bindings-doc]))
452 AM_CONDITIONAL([ENABLE_PYTHON_PLUGINS], AE_IS_FEATURE_ENABLED([python-plugins]))
453 AM_CONDITIONAL([ENABLE_DEBUG_INFO], AE_IS_FEATURE_ENABLED([debug-info]))
454 AM_CONDITIONAL([ENABLE_API_DOC], AE_IS_FEATURE_ENABLED([api-doc]))
455 AM_CONDITIONAL([ENABLE_BUILT_IN_PLUGINS], AE_IS_FEATURE_ENABLED([built-in-plugins]))
456 AM_CONDITIONAL([ENABLE_BUILT_IN_PYTHON_PLUGIN_SUPPORT], AE_IS_FEATURE_ENABLED([built-in-python-plugin-support]))
457 AM_CONDITIONAL([ENABLE_MAN_PAGES], AE_IS_FEATURE_ENABLED([man-pages]))
458 AM_CONDITIONAL([ENABLE_PYTHON_COMMON_DEPS], AE_IS_FEATURE_ENABLED([python-bindings]) || AE_IS_FEATURE_ENABLED([python-plugins]))
459
460
461 ## ##
462 ## Set defines for optionnal features conditionnals in the source code ##
463 ## ##
464
465 AE_IF_FEATURE_ENABLED([built-in-plugins],
466 [AC_DEFINE([BT_BUILT_IN_PLUGINS], [1], [Define to 1 to register plug-in attributes in static executable sections])]
467 )
468
469 AE_IF_FEATURE_ENABLED([built-in-python-plugin-support],
470 [AC_DEFINE([BT_BUILT_IN_PYTHON_PLUGIN_SUPPORT], [1], [Define to 1 to register plug-in attributes in static executable sections])]
471 )
472
473 AE_IF_FEATURE_ENABLED([debug-info], [ENABLE_DEBUG_INFO_VAL=1], [ENABLE_DEBUG_INFO_VAL=0])
474 AC_SUBST([ENABLE_DEBUG_INFO_VAL])
475
476
477 ## ##
478 ## Check for optionnal features dependencies ##
479 ## ##
480
481 # The Python bindings require SWIG
482 AE_IF_FEATURE_ENABLED([python-plugins],
483 [AX_PKG_SWIG(2.0.0, [], [AC_MSG_ERROR([SWIG 2.0.0 or newer is required to build the python bindings])])]
484 )
485
486 # Always check for python, we will fail later if some features require it and
487 # it's unavailable.
488 AM_PATH_PYTHON([3.0], [
489 AE_PATH_PYTHON_MODULES([PYTHON])
490
491 # pythondir is the path where extra modules are to be installed
492 pythondir=$PYTHON_PREFIX/$PYTHON_MODULES_PATH
493
494 # pyexecdir is the path that contains shared objects used by the extra modules
495 pyexecdir=$PYTHON_EXEC_PREFIX/$PYTHON_MODULES_PATH
496
497 AS_IF([test -z "$PYTHON_CONFIG"], [
498 AC_PATH_PROGS([PYTHON_CONFIG],
499 [python$PYTHON_VERSION-config python-config],
500 [],
501 [`dirname $PYTHON`])
502 ])
503
504 AS_IF([test -n "$PYTHON_CONFIG"], [
505 AS_IF([test -z "$PYTHON_INCLUDE"], [
506 AC_MSG_CHECKING([Python include flags])
507 PYTHON_INCLUDE=`$PYTHON_CONFIG --includes`
508 AC_MSG_RESULT([$PYTHON_INCLUDE])
509 ])
510
511 AS_IF([test -z "$PYTHON_LDFLAGS"], [
512 AC_MSG_CHECKING([Python library flags])
513 # Python 3.8+ requires that we pass --embed to get the -lpython3.x flag.
514 AS_IF([! PYTHON_LDFLAGS=`$PYTHON_CONFIG --ldflags --embed`], [
515 PYTHON_LDFLAGS=`$PYTHON_CONFIG --ldflags`
516 ])
517 AC_MSG_RESULT([$PYTHON_LDFLAGS])
518 ])
519 ])
520 ], [:])
521
522 AS_IF([test "$PYTHON" != :], [have_python=yes], [have_python=no])
523 AS_IF([test -n "$PYTHON_CONFIG"], [have_python_dev=yes], [have_python_dev=no])
524
525 AM_CONDITIONAL([HAVE_PYTHON], [test "x$have_python" = xyes])
526 AM_CONDITIONAL([HAVE_PYTHON_DEV], [test "x$have_python_dev" = xyes])
527
528 AS_IF([AE_IS_FEATURE_ENABLED([python-bindings]) || AE_IS_FEATURE_ENABLED([python-plugins])], [
529 AS_IF([test "x$have_python_dev" = xno], [
530 AC_MSG_ERROR([Cannot find a suitable python-config. You can override the python-config path with the PYTHON_CONFIG environment variable.])
531 ])
532 ])
533
534 AE_IF_FEATURE_ENABLED([python-bindings-doc],
535 [
536 AE_CHECK_PYTHON_SPHINX([PYTHON])
537 AS_IF([test "x$PYTHON_SPHINX_EXISTS" = xno], [
538 AC_MSG_ERROR([The Sphinx package for Python 3 is required to build the Python bindings documentation])
539 ])
540
541 AE_IF_FEATURE_NOT_ENABLED([python-bindings], [
542 AC_MSG_ERROR([The Python bindings are required to build their documentation])
543 ])
544 ]
545 )
546
547 AE_IF_FEATURE_ENABLED([debug-info], [
548 # Check if libelf and libdw are present
549 PKG_CHECK_MODULES([ELFUTILS], [libelf >= 0.154 libdw >= 0.154],
550 [
551 dnl PKG_CHECK_MODULES defines ELFUTILS_LIBS
552 ],
553 [
554 AC_MSG_WARN([pkg-config was unable to find a valid .pc for libelf/libdw. Set PKG_CONFIG_PATH to specify the pkg-config configuration file location.])
555
556 # Turns out SLES12 doesn't bother shipping .pc file for libelf
557 AC_MSG_WARN([Finding libelf without pkg-config.])
558 AC_CHECK_LIB([elf], [elf_version], [], [AC_MSG_ERROR(Missing libelf (from elfutils >= 0.154) which is required by debug info. You can disable this feature using --disable-debug-info.)])
559 AC_CHECK_LIB([dw], [dwarf_begin], [], [AC_MSG_ERROR(Missing libdw (from elfutils >= 0.154) which is required by debug info. You can disable this feature using --disable-debug-info.)])
560 AE_LIB_ELFUTILS([0], [154], [], [AC_MSG_ERROR(elfutils >= 0.154 is required to use the debug info feature. You can disable this feature using --disable-debug-info.)])
561 ELFUTILS_LIBS="-lelf -ldw"
562 ])
563 ])
564 AC_SUBST([ELFUTILS_LIBS])
565
566 AE_IF_FEATURE_ENABLED([api-doc],
567 [
568 DX_DOXYGEN_FEATURE(ON)
569 DX_DOT_FEATURE(OFF)
570 DX_HTML_FEATURE(ON)
571 DX_CHM_FEATURE(OFF)
572 DX_CHI_FEATURE(OFF)
573 DX_MAN_FEATURE(OFF)
574 DX_RTF_FEATURE(OFF)
575 DX_XML_FEATURE(OFF)
576 DX_PDF_FEATURE(OFF)
577 DX_PS_FEATURE(OFF)
578 DX_INIT_DOXYGEN([Babeltrace 2], [$(builddir)/Doxyfile], [output])
579 AS_IF([test -z "$DX_DOXYGEN"],
580 [AC_MSG_ERROR([You need doxygen to enable the API documentation])]
581 )
582 ]
583 )
584
585 have_asciidoc_xmlto=no
586 warn_prebuilt_man_pages=no
587
588 AC_PATH_PROG([ASCIIDOC], [asciidoc], [no])
589 AC_PATH_PROG([XMLTO], [xmlto], [no])
590
591 AE_IF_FEATURE_ENABLED([man-pages], [
592 AS_IF([test "x$ASCIIDOC" = "xno" || test "x$XMLTO" = "xno"], [
593 AS_IF([test "x$in_git_repo" = "xyes"], [
594 # this is an error because we're in the Git repo, which
595 # means the man pages are not already generated for us,
596 # thus asciixmlto are required because we were asked
597 # to build the man pages
598 AC_MSG_ERROR([
599 You need asciidoc and xmlto to build the Babeltrace man pages. Use
600 --disable-man-pages to disable building the man pages, in which case
601 they will not be installed.
602 ])
603 ], [
604 # only warn here: since we're in the tarball, the man
605 # pages should already be generated at this point, thus
606 # asciidoc/xmlto are not strictly required
607 warn_prebuilt_man_pages=yes
608 ])
609 ], [
610 have_asciidoc_xmlto=yes
611 ])
612 ])
613
614 # export AsciiDoc and xmlto existence
615 AM_CONDITIONAL([HAVE_ASCIIDOC_XMLTO], [test "x$have_asciidoc_xmlto" = "xyes"])
616
617 # a wonderful hack that seems necessary because $libdir is
618 # literally `${exec_prefix}/lib`, and $exec_prefix is set to `NONE`
619 # by autoconf when it's not specified by the user
620 AS_IF([test "x$exec_prefix" = xNONE], [
621 AS_IF([test "x$prefix" = xNONE], [
622 PREFIX="$ac_default_prefix"
623 ], [
624 PREFIX="$prefix"
625 ])
626
627 LIBDIR="$PREFIX/lib"
628 ], [
629 LIBDIR="$libdir"
630 ])
631
632 AC_SUBST(LIBDIR)
633
634
635
636
637 # CFLAGS from libraries (the glib ones are needed for the following sizeof
638 # test).
639 AM_CFLAGS="${PTHREAD_CFLAGS} ${GLIB_CFLAGS}"
640 AM_CXXFLAGS="${PTHREAD_CFLAGS} ${GLIB_CFLAGS}"
641
642 # Check that the current size_t matches the size that glib thinks it should
643 # be. This catches problems on multi-arch where people try to do a 32-bit
644 # build while pointing at 64-bit glib headers. This is a common error because
645 # glib.h is not platform specific but it includes glibconfig.h which is and
646 # is usually installed in a non-standard path.
647
648 # Do this before enabling all the warning flags, as the
649 # AC_LANG_PROGRAM-generated program may generate some warning, which makes this
650 # test fail unnecessarily.
651
652 # Older versions of the pkg-config macros disallows PKG_* in the autoconf
653 # output. Specifically allow pkg_config_libdir to be able to print the
654 # error message.
655 m4_pattern_allow([PKG_CONFIG_LIBDIR])
656
657 save_CFLAGS=${CFLAGS}
658 CFLAGS="${CFLAGS} ${AM_CFLAGS}"
659 AC_COMPILE_IFELSE([
660 AC_LANG_PROGRAM([dnl
661 #include <glib.h>
662 #include <unistd.h>
663 ], [dnl
664 G_STATIC_ASSERT(sizeof(size_t) == GLIB_SIZEOF_SIZE_T);
665 ])
666 ],[:],[
667 AC_MSG_ERROR([dnl
668 sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T. You probably need to set
669 PKG_CONFIG_LIBDIR to point to the right pkg-config files for your build
670 target.
671 ])
672 ])
673 CFLAGS=${save_CFLAGS}
674
675 # Detect C and LD warning flags supported by the compiler.
676
677 # Detect warning flags supported by the C and C++ compilers and append them to
678 # WARN_CFLAGS and WARN_CXXFLAGS.
679 #
680 m4_define([WARN_FLAGS_LIST], [ dnl
681 -Wall dnl
682 -Wextra dnl
683 -Wmissing-prototypes dnl
684 -Wmissing-declarations dnl
685 -Wnull-dereference dnl
686 -Wundef dnl
687 -Wredundant-decls dnl
688 -Wshadow dnl
689 -Wjump-misses-init dnl
690 -Wsuggest-attribute=format dnl
691 -Wtautological-constant-out-of-range-compare dnl
692 -Wnested-externs dnl
693 -Wwrite-strings dnl
694 -Wformat=2 dnl
695 -Wstrict-aliasing dnl
696 -Wmissing-noreturn dnl
697 -Winit-self dnl
698 -Wduplicated-cond dnl
699 -Wduplicated-branches dnl
700 -Wlogical-op dnl
701 -Wno-unused-parameter dnl
702 -Wno-sign-compare dnl
703 dnl
704 dnl Some versions of SWIG (like 3.0.12) generate code that produces
705 dnl -Wcast-function-type warnings. This warning is present in gcc >= 8. This
706 dnl combo happens on RHEL/Centos 8, for example. Later versions of SWIG (like
707 dnl 4.0.1) have the correct function signatures to not produce this warning.
708 dnl It's simpler to just disable the warning globally.
709 dnl
710 dnl Note that the Debian/Ubuntu SWIG package 3.0.12-2 contains a local patch to
711 dnl fix this (python-fix-function-cast-warnings.patch), so you won't be able to
712 dnl reproduce the warning using that package.
713 dnl
714 dnl Ref: https://github.com/swig/swig/issues/1259
715 -Wno-cast-function-type dnl
716 -Wno-missing-field-initializers dnl
717 ])
718
719 # Pass -Werror as an extra flag during the test: this is needed to make the
720 # -Wunknown-warning-option diagnostic fatal with clang.
721 AC_LANG([C++])
722 AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CXXFLAGS], [-Werror])
723 AC_LANG([C])
724 AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CFLAGS], [-Werror])
725
726 AE_IF_FEATURE_ENABLED([Werror], [WARN_CXXFLAGS="${WARN_CXXFLAGS} -Werror"])
727 AE_IF_FEATURE_ENABLED([Werror], [WARN_CFLAGS="${WARN_CFLAGS} -Werror"])
728
729 # The test used in AX_APPEND_COMPILE_FLAGS, generated using AC_LANG_PROGRAM, is
730 # written in such a way that it triggers warnings with the following warning
731 # flags. So they would always end up disabled if we put them there, because
732 # the test program would not build.
733 #
734 # Enable them here unconditionally. They are supported by GCC >= 4.8 and by
735 # Clang >= 3.3 (required by the project) and are only valid for C code.
736 WARN_CFLAGS="${WARN_CFLAGS} -Wold-style-definition -Wstrict-prototypes"
737
738 # CFLAGS from AX_APPEND_COMPILE_FLAGS.
739 AM_CXXFLAGS="${AM_CXXFLAGS} ${WARN_CXXFLAGS}"
740 AM_CFLAGS="${AM_CFLAGS} ${WARN_CFLAGS}"
741
742 # Done for AM_CXXFLAGS and AM_CFLAGS.
743 AC_SUBST(AM_CXXFLAGS)
744 AC_SUBST(AM_CFLAGS)
745
746 # Set global CPPFLAGS in AM_CPPFLAGS
747 AM_CPPFLAGS="-I\$(top_srcdir)/include -I\$(top_builddir)/src -I\$(top_srcdir)/src -include common/config.h"
748 AC_SUBST(AM_CPPFLAGS)
749
750 # Add glib to global link libs
751 LIBS="$LIBS $GLIB_LIBS"
752
753 # Abuse autoconf's AC_ARG_PROGRAM output variable 'program_transform_name'
754 # to rename babeltrace2.bin to babeltrace2 at install time.
755 program_transform_name="s&babeltrace2\.bin&babeltrace2&;$program_transform_name"
756 AC_SUBST(program_transform_name)
757
758 AC_CONFIG_FILES([
759 doc/api/Makefile
760 doc/api/libbabeltrace2/Doxyfile
761 doc/api/libbabeltrace2/Makefile
762 doc/bindings/Makefile
763 doc/bindings/python/Makefile
764 doc/contributing-images/Makefile
765 doc/Makefile
766 doc/man/asciidoc-attrs.conf
767 doc/man/Makefile
768 include/Makefile
769 Makefile
770 src/argpar/Makefile
771 src/autodisc/Makefile
772 src/babeltrace2-ctf-writer.pc
773 src/babeltrace2.pc
774 src/bindings/Makefile
775 src/bindings/python/bt2/bt2/version.py
776 src/bindings/python/bt2/Makefile
777 src/bindings/python/bt2/setup.py
778 src/bindings/python/Makefile
779 src/cli/Makefile
780 src/common/Makefile
781 src/compat/Makefile
782 src/ctfser/Makefile
783 src/ctf-writer/Makefile
784 src/fd-cache/Makefile
785 src/lib/graph/Makefile
786 src/lib/graph/message/Makefile
787 src/lib/Makefile
788 src/lib/plugin/Makefile
789 src/lib/prio-heap/Makefile
790 src/lib/trace-ir/Makefile
791 src/logging/Makefile
792 src/Makefile
793 src/plugins/common/Makefile
794 src/plugins/common/muxing/Makefile
795 src/plugins/common/param-validation/Makefile
796 src/plugins/ctf/common/bfcr/Makefile
797 src/plugins/ctf/common/Makefile
798 src/plugins/ctf/common/metadata/Makefile
799 src/plugins/ctf/common/msg-iter/Makefile
800 src/plugins/ctf/fs-sink/Makefile
801 src/plugins/ctf/fs-src/Makefile
802 src/plugins/ctf/lttng-live/Makefile
803 src/plugins/ctf/Makefile
804 src/plugins/lttng-utils/debug-info/Makefile
805 src/plugins/lttng-utils/Makefile
806 src/plugins/Makefile
807 src/plugins/text/dmesg/Makefile
808 src/plugins/text/Makefile
809 src/plugins/text/pretty/Makefile
810 src/plugins/text/details/Makefile
811 src/plugins/utils/counter/Makefile
812 src/plugins/utils/dummy/Makefile
813 src/plugins/utils/Makefile
814 src/plugins/utils/muxer/Makefile
815 src/plugins/utils/trimmer/Makefile
816 src/py-common/Makefile
817 src/python-plugin-provider/Makefile
818 src/param-parse/Makefile
819 src/string-format/Makefile
820 tests/bitfield/Makefile
821 tests/ctf-writer/Makefile
822 tests/lib/Makefile
823 tests/lib/test-plugin-plugins/Makefile
824 tests/lib/conds/Makefile
825 tests/Makefile
826 tests/param-validation/Makefile
827 tests/plugins/Makefile
828 tests/plugins/src.ctf.fs/Makefile
829 tests/plugins/src.ctf.fs/succeed/Makefile
830 tests/plugins/sink.ctf.fs/Makefile
831 tests/plugins/sink.ctf.fs/succeed/Makefile
832 tests/plugins/flt.lttng-utils.debug-info/Makefile
833 tests/plugins/flt.utils.muxer/Makefile
834 tests/plugins/flt.utils.muxer/succeed/Makefile
835 tests/plugins/flt.utils.trimmer/Makefile
836 tests/plugins/sink.text.pretty/Makefile
837 tests/utils/Makefile
838 tests/utils/tap/Makefile
839 ])
840
841 AC_OUTPUT
842
843 #
844 # Mini-report on what will be built.
845 #
846
847 PPRINT_INIT
848 PPRINT_SET_INDENT(1)
849 PPRINT_SET_TS(38)
850
851 AS_ECHO
852
853 AS_IF([test -n "bt_version_name"], [
854 AS_ECHO("${PPRINT_COLOR_BLDBLU}Babeltrace $PACKAGE_VERSION \"bt_version_name\"$PPRINT_COLOR_RST")
855 ], [
856 AS_ECHO("${PPRINT_COLOR_BLDBLU}Babeltrace $PACKAGE_VERSION")
857 ])
858
859 AS_ECHO
860
861 AS_IF([test -n "bt_version_description"], [
862 AS_IF([test -n "$report_fold"], [
863 AS_ECHO("`AS_ECHO("bt_version_description") | $report_fold -s`")
864 ], [
865 AS_ECHO("bt_version_description")
866 ])
867
868 AS_ECHO
869 ])
870
871 PPRINT_SUBTITLE([System])
872
873 # Target architecture we're building for.
874 target_arch=$host_cpu
875 [
876 for f in $CFLAGS; do
877 if test $f = "-m32"; then
878 target_arch="32-bit"
879 elif test $f = "-m64"; then
880 target_arch="64-bit"
881 fi
882 done
883 ]
884
885 PPRINT_PROP_STRING([Target architecture], $target_arch)
886
887 AS_ECHO
888 PPRINT_SUBTITLE([Python 3 language support])
889 test "x$have_python" = "xyes" && value=1 || value=0
890 PPRINT_PROP_BOOL([Have Python interpreter], $value)
891 test "x$have_python_dev" = "xyes" && value=1 || value=0
892 PPRINT_PROP_BOOL([Have Python development libraries], $value)
893 test "x$enable_python_bindings" = "xyes" && value=1 || value=0
894 PPRINT_PROP_BOOL_CUSTOM([Python bindings], $value, [To enable, use --enable-python-bindings])
895 test "x$enable_python_plugins" = "xyes" && value=1 || value=0
896 PPRINT_PROP_BOOL_CUSTOM([Python plugin support], $value, [To enable, use --enable-python-plugins])
897 AS_IF([test "x$have_python" = "xyes"], [
898 PPRINT_PROP_STRING([Python interpreter path], [$PYTHON])
899 ])
900 AS_IF([test "x$have_python_dev" = "xyes"], [
901 PPRINT_PROP_STRING([python-config path], [$PYTHON_CONFIG])
902 PPRINT_PROP_STRING([Python include paths], [$PYTHON_INCLUDE])
903 PPRINT_PROP_STRING([Python linker flags], [$PYTHON_LDFLAGS])
904 ])
905 AE_IF_FEATURE_ENABLED([python-bindings], [
906 PPRINT_PROP_STRING([SWIG executable], [$SWIG])
907 PPRINT_PROP_STRING([SWIG library], [$SWIG_LIB])
908 ])
909
910 AS_ECHO
911 PPRINT_SUBTITLE([Plugins])
912 PPRINT_PROP_BOOL(['ctf' plugin], 1)
913 test "x$enable_debug_info" = "xyes" && value=1 || value=0
914 PPRINT_PROP_BOOL_CUSTOM(['lttng-utils' plugin], $value, [To enable, use --enable-debug-info])
915 PPRINT_PROP_BOOL(['text' plugin], 1)
916 PPRINT_PROP_BOOL(['utils' plugin], 1)
917
918 AS_ECHO
919 PPRINT_SUBTITLE([Built-in features])
920 test "x$enable_built_in_plugins" = "xyes" && value=1 || value=0
921 PPRINT_PROP_BOOL_CUSTOM([Built-in plugins], $value, [To enable, use --enable-built-in-plugins])
922 test "x$enable_built_in_python_plugin_support" = "xyes" && value=1 || value=0
923 PPRINT_PROP_BOOL_CUSTOM([Built-in Python plugin support], $value, [To enable, use --enable-built-in-python-plugin-support])
924
925 AS_ECHO
926 PPRINT_SUBTITLE([Documentation])
927
928 # man pages build enabled/disabled
929 m4_pushdef([build_man_pages_msg], [Build and install man pages])
930
931 AS_IF([test "x$enable_man_pages" != "xno"], [
932 AS_IF([test "x$in_git_repo" = "xyes"], [
933 PPRINT_PROP_BOOL([build_man_pages_msg], 1)
934 ], [
935 AS_IF([test "x$have_asciidoc_xmlto" = "xyes"], [
936 PPRINT_PROP_BOOL([build_man_pages_msg], 1)
937 ], [
938 PPRINT_PROP_STRING([build_man_pages_msg],
939 [${PPRINT_COLOR_BLDGRN}yes (already built)],
940 $PPRINT_COLOR_SUBTITLE)
941 ])
942 ])
943 ], [
944 PPRINT_PROP_BOOL_CUSTOM([build_man_pages_msg], 0, [To build man pages, use --enable-man-pages])
945 ])
946
947 m4_popdef([build_man_pages_msg])
948
949 test "x$enable_api_doc" = "xyes" && value=1 || value=0
950 PPRINT_PROP_BOOL_CUSTOM([HTML API documentation], $value, [To build documentation, use --enable-api-doc])
951 test "x$enable_python_bindings_doc" = "xyes" && value=1 || value=0
952 PPRINT_PROP_BOOL_CUSTOM([Python bindings documentation], $value, [To build the Python bindings documentation, use --enable-python-bindings-doc])
953
954 AS_ECHO
955 PPRINT_SUBTITLE([Logging])
956 PPRINT_PROP_STRING([Minimal log level], $BABELTRACE_MINIMAL_LOG_LEVEL)
957
958 AS_ECHO
959 PPRINT_SUBTITLE([Special build modes])
960 PPRINT_PROP_BOOL_CUSTOM([Debug mode], $BABELTRACE_DEBUG_MODE, [To enable, set the BABELTRACE_DEBUG_MODE environment variable to 1])
961 PPRINT_PROP_BOOL_CUSTOM([Developer mode], $BABELTRACE_DEV_MODE, [To enable, set the BABELTRACE_DEV_MODE environment variable to 1])
962
963 report_bindir="`eval eval echo $bindir`"
964 report_libdir="`eval eval echo $libdir`"
965 report_sysconfdif="`eval eval echo $sysconfdir`"
966 report_pluginsdir="`eval eval eval echo $BABELTRACE_PLUGINS_DIR`"
967 report_pluginprovidersdir="`eval eval eval echo $BABELTRACE_PLUGIN_PROVIDERS_DIR`"
968
969 # Print the bindir and libdir this `make install' will install into.
970 AS_ECHO
971 PPRINT_SUBTITLE([Install directories])
972 PPRINT_PROP_STRING([Binaries], [$report_bindir])
973 PPRINT_PROP_STRING([Libraries], [$report_libdir])
974 PPRINT_PROP_STRING([Plugins], [$report_pluginsdir])
975 PPRINT_PROP_STRING([Plugin providers], [$report_pluginprovidersdir])
976 PPRINT_PROP_STRING([Configuration], [$report_sysconfdif])
This page took 0.047487 seconds and 5 git commands to generate.