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