Fix: Only close valid fds in is_valid_debug_file
[babeltrace.git] / configure.ac
CommitLineData
43047f21 1AC_PREREQ([2.50])
e61344cb 2AC_INIT([babeltrace],[1.4.0-rc1],[jeremie.galarneau@efficios.com],[],[https://diamon.org/babeltrace])
3fbccce7
MD
3AC_SUBST([BABELTRACE_LIBRARY_VERSION], [1:0:0])
4
9d5a2885 5AC_CONFIG_HEADERS([config.h])
ac65e355 6AC_CONFIG_AUX_DIR([config])
9d5a2885
MJ
7AC_CONFIG_MACRO_DIR([m4])
8
ac65e355
MD
9AC_CANONICAL_TARGET
10AC_CANONICAL_HOST
ac65e355 11
2413cbd9 12AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip tar-ustar])
9d5a2885 13AM_MAINTAINER_MODE([enable])
ac65e355 14
9d5a2885
MJ
15# Enable silent rules if available (Introduced in AM 1.11)
16m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
ac65e355 17
022dd2b4
MJ
18AC_REQUIRE_AUX_FILE([tap-driver.sh])
19
9d5a2885
MJ
20# Checks for C compiler
21AC_USE_SYSTEM_EXTENSIONS
217108a9 22AC_SYS_LARGEFILE
9d5a2885
MJ
23AC_PROG_CC
24AC_PROG_CC_STDC
217108a9 25
ac65e355 26# Checks for programs.
ac65e355 27AC_PROG_MAKE_SET
aa225880 28LT_INIT
8b9d5b5e
MD
29AC_PROG_YACC
30AC_PROG_LEX
9d5a2885
MJ
31AC_PROG_MKDIR_P
32AC_PROG_LN_S
ac65e355 33
58cb7c63
MJ
34AX_C___ATTRIBUTE__
35AS_IF([test "x$ax_cv___attribute__" = "xyes"],
36 [:],
37 [AC_MSG_ERROR([The compiler does not support __attribute__ extensions])])
38
909d3caa
MJ
39AX_PTHREAD(,[AC_MSG_ERROR([Could not configure pthreads support])])
40LIBS="$PTHREAD_LIBS $LIBS"
41CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
42CC="$PTHREAD_CC"
43
203d6b31
AM
44# Check linker option
45AX_APPEND_LINK_FLAGS([-Wl,--no-as-needed], [LD_NO_AS_NEEDED])
46AC_SUBST([LD_NO_AS_NEEDED])
47
22d7cb55
MJ
48AC_HEADER_STDBOOL
49AC_CHECK_HEADERS([ \
50 fcntl.h \
51 float.h \
52 libintl.h \
53 limits.h \
54 malloc.h \
55 netdb.h \
56 netinet/in.h \
57 stddef.h \
58 sys/socket.h \
59])
9d5a2885 60
331d78f5 61if test ! -f "$srcdir/formats/ctf/metadata/ctf-parser.h"; then
671c16a5 62 if test x"$(basename "$YACC")" != "xbison -y"; then
331d78f5
YB
63 AC_MSG_ERROR([[bison not found and is required when building from git.
64 Please install bison]])
65 fi
a66b40cc
JR
66 AC_PATH_PROG([BISON],[bison])
67 AX_PROG_BISON_VERSION([2.4], [],[
68 AC_MSG_ERROR([[Bison >= 2.4 is required when building from git]])
69 ])
331d78f5
YB
70fi
71
72if test ! -f "$srcdir/formats/ctf/metadata/ctf-lexer.c"; then
73 if test x"$LEX" != "xflex"; then
74 AC_MSG_ERROR([[flex not found and is required when building from git.
75 Please install flex]])
76 fi
fe709541
JR
77 AC_PATH_PROG([FLEX],[flex])
78 AX_PROG_FLEX_VERSION([2.5.35], [],[
79 AC_MSG_ERROR([[Flex >= 2.5.35 is required when building from git]])
80 ])
331d78f5
YB
81fi
82
a6947cca 83AM_PATH_GLIB_2_0(2.22.0, ,AC_MSG_ERROR([glib is required in order to compile BabelTrace - download it from ftp://ftp.gtk.org/pub/gtk]) , gmodule)
ac65e355 84
0692ec69
MJ
85# Check what libraries are required on this platform to link sockets programs.
86AX_LIB_SOCKET_NSL
87
ac65e355
MD
88# Checks for typedefs, structures, and compiler characteristics.
89AC_C_INLINE
90AC_TYPE_PID_T
91AC_TYPE_SIZE_T
92
93# Checks for library functions.
22d7cb55
MJ
94AC_FUNC_ALLOCA
95AC_FUNC_FORK
ac65e355 96AC_FUNC_MALLOC
22d7cb55 97AC_FUNC_MKTIME
ac65e355 98AC_FUNC_MMAP
22d7cb55
MJ
99AC_FUNC_REALLOC
100AC_FUNC_STRERROR_R
101AC_CHECK_FUNCS([ \
102 atexit \
103 dirfd \
104 dup2 \
105 ftruncate \
106 gethostbyname \
107 gethostname \
108 gettimeofday \
109 localtime_r \
110 memchr \
111 memset \
112 mkdir \
113 mkdtemp \
114 munmap \
115 rmdir \
116 setenv \
117 socket \
118 strchr \
119 strdup \
120 strerror \
121 strndup \
122 strnlen \
123 strrchr \
124 strtoul \
125 strtoull \
126 tzset \
127 uname \
128])
ac65e355 129
58819898 130MINGW32=no
eb75a494 131DEFAULT_ENABLE_DEBUG_INFO=yes
d2a7e852
MJ
132AS_CASE([$host_os],
133 [solaris*|darwin*],
134 [
eb75a494 135 DEFAULT_ENABLE_DEBUG_INFO=no
d2a7e852
MJ
136 ],
137 [mingw*],
138 [
139 MINGW32=yes
140 ]
141)
58819898
JI
142
143AM_CONDITIONAL([BABELTRACE_BUILD_WITH_MINGW], [test "x$MINGW32" = "xyes"])
144
27cdb685
MJ
145# Check what libraries are required on this platform to link sockets programs.
146AX_LIB_SOCKET_NSL
147
148# Check for uuid in system libs
149AC_CHECK_FUNCS([uuid_generate],
a4dfa07b 150[
27cdb685
MJ
151 AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_LIBUUID], 1, [Has libuuid support.])
152 link_with_libuuid=no
a4dfa07b
MD
153],
154[
27cdb685
MJ
155 # Check for libuuid
156 AC_CHECK_LIB([uuid], [uuid_generate],
157 [
158 AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_LIBUUID], 1, [Has libuuid support.])
159 link_with_libuuid=yes
160 ],
161 [
162 # libuuid not found, check for uuid_create in libc.
163 AC_CHECK_LIB([c], [uuid_create],
164 [
165 AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_LIBC_UUID], 1, [Has libc uuid support.])
166 link_with_libc_uuid=yes
167 ],
168 [
169 # for MinGW32 we have our own internal implemenation of uuid using Windows functions.
170 if test "x$MINGW32" = xno; then
171 AC_MSG_ERROR([Cannot find libuuid uuid_generate nor libc uuid_create. Use [LDFLAGS]=-Ldir to specify their location.])
172 fi
173 ])
174 ])
175])
176
177AM_CONDITIONAL([BABELTRACE_BUILD_WITH_LIBUUID], [test "x$link_with_libuuid" = "xyes"])
178AM_CONDITIONAL([BABELTRACE_BUILD_WITH_LIBC_UUID], [test "x$link_with_libc_uuid" = "xyes"])
fd55fc57 179
f8370579
MD
180# Check for fmemopen
181AC_CHECK_LIB([c], [fmemopen],
182[
183 AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_FMEMOPEN], 1, [Has fmemopen support.])
184]
185)
186
187# Check for open_memstream
188AC_CHECK_LIB([c], [open_memstream],
189[
190 AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_OPEN_MEMSTREAM], 1, [Has open_memstream support.])
191]
192)
193
edcad9c1
JG
194# Check for posix_fallocate
195AC_CHECK_LIB([c], [posix_fallocate],
196[
197 AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_POSIX_FALLOCATE], 1, [Has posix_fallocate support.])
198]
199)
200
ff48c2b0
MD
201# Check for faccessat
202AC_CHECK_LIB([c], [faccessat],
203[
204 AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_FACCESSAT], 1, [Has faccessat support.])
205]
206)
207
0f536a74
TP
208AC_CHECK_LIB([popt], [poptGetContext], [],
209 [AC_MSG_ERROR([Cannot find popt.])]
210)
211
24a3136a
DS
212# For Python
213# SWIG version needed or newer:
214swig_version=2.0.0
215
94a6cea3
JG
216AC_ARG_ENABLE([python-bindings],
217 [AC_HELP_STRING([--enable-python-bindings],
218 [generate Python bindings])],
219 [enable_python=yes], [enable_python=no])
24a3136a
DS
220
221AM_CONDITIONAL([USE_PYTHON], [test "x${enable_python:-yes}" = xyes])
222
223if test "x${enable_python:-yes}" = xyes; then
24a3136a
DS
224 AX_PKG_SWIG($swig_version, [], [ AC_MSG_ERROR([SWIG $swig_version or newer is needed]) ])
225 AM_PATH_PYTHON
226
33287b16
JG
227 AM_PATH_PYTHON_MODULES([PYTHON])
228 # pythondir is the path where extra modules are to be installed
229 pythondir=$PYTHON_PREFIX/$PYTHON_MODULES_PATH
230 # pyexecdir is the path that contains shared objects used by the extra modules
231 pyexecdir=$PYTHON_EXEC_PREFIX/$PYTHON_MODULES_PATH
24a3136a
DS
232 AC_ARG_VAR([PYTHON_INCLUDE], [Include flags for python, bypassing python-config])
233 AC_ARG_VAR([PYTHON_CONFIG], [Path to python-config])
234 AS_IF([test -z "$PYTHON_INCLUDE"], [
235 AS_IF([test -z "$PYTHON_CONFIG"], [
236 AC_PATH_PROGS([PYTHON_CONFIG],
237 [python$PYTHON_VERSION-config python-config],
238 [no],
239 [`dirname $PYTHON`])
94a6cea3 240 AS_IF([test "$PYTHON_CONFIG" = no], [AC_MSG_ERROR([cannot find python-config for $PYTHON. Do you have python-dev installed?])])
24a3136a
DS
241 ])
242 AC_MSG_CHECKING([python include flags])
243 PYTHON_INCLUDE=`$PYTHON_CONFIG --includes`
244 AC_MSG_RESULT([$PYTHON_INCLUDE])
245 ])
94a6cea3
JG
246
247else
248 AC_MSG_NOTICE([You may configure with --enable-python-bindings ]dnl
249[if you want Python bindings.])
250
24a3136a
DS
251fi
252
eb75a494
AB
253# Set default enable state for debug info.
254# The _enable_debug_info variable is prepended with an underscore to
255# avoid clashing with the one generated by AC_ARG_ENABLE.
256AS_IF([test "x$DEFAULT_ENABLE_DEBUG_INFO" = xyes], [_enable_debug_info=yes], [_enable_debug_info=no])
0e798524 257
eb75a494 258# Optional debug info feature
0e798524
MD
259# Do _not_ indent the help string below (appears in the configure --help
260# output).
261AC_ARG_ENABLE([debug-info],
eb75a494
AB
262[AC_HELP_STRING([--enable-debug-info], [enable the debug info feature (default on Linux)])]
263[AC_HELP_STRING([--disable-debug-info], [disable the debug info feature (default on OS X and Solaris)])],
264 [AS_IF([test "x$enableval" = xyes], [_enable_debug_info=yes], [_enable_debug_info=no])], [])
b5a8598f 265
eb75a494
AB
266AM_CONDITIONAL([ENABLE_DEBUG_INFO], [test "x$_enable_debug_info" = xyes])
267AS_IF([test "x$_enable_debug_info" = xyes], [
97e67ce6 268 # Check if libelf and libdw are present
eb75a494
AB
269 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.)])
270 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.)])
271 AX_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.)])
272 AC_DEFINE([ENABLE_DEBUG_INFO], [1], [Define to 1 if you enable the 'debug info' feature])
b5a8598f
AB
273], [])
274
12471830 275PKG_CHECK_MODULES(GMODULE, [gmodule-2.0 >= 2.0.0])
ac65e355
MD
276AC_SUBST(PACKAGE_LIBS)
277
34d3acc4 278LIBS="$LIBS $GMODULE_LIBS"
37566b71 279PACKAGE_CFLAGS="$GMODULE_CFLAGS -Wall -Wformat"
ac65e355
MD
280AC_SUBST(PACKAGE_CFLAGS)
281
37566b71
MJ
282DEFAULT_INCLUDES="-I\$(top_srcdir) -I\$(top_builddir) -I\$(top_builddir)/include -include config.h"
283AC_SUBST(DEFAULT_INCLUDES)
284
e4d70dc3 285babeltraceincludedir="${includedir}/babeltrace"
70bd0a12
JD
286AC_SUBST(babeltraceincludedir)
287
64a35d1b
JD
288babeltracectfincludedir="${includedir}/babeltrace/ctf"
289AC_SUBST(babeltracectfincludedir)
290
273b65be
JG
291babeltracectfwriterincludedir="${includedir}/babeltrace/ctf-writer"
292AC_SUBST(babeltracectfwriterincludedir)
293
ac65e355
MD
294AC_CONFIG_FILES([
295 Makefile
296 types/Makefile
9d1e7de0 297 compat/Makefile
ac65e355
MD
298 formats/Makefile
299 formats/ctf/Makefile
300 formats/ctf/types/Makefile
1ae19169
MD
301 formats/ctf-text/Makefile
302 formats/ctf-text/types/Makefile
5d93a76e 303 formats/ctf-metadata/Makefile
22133895 304 formats/bt-dummy/Makefile
4a744367 305 formats/lttng-live/Makefile
8b9d5b5e 306 formats/ctf/metadata/Makefile
273b65be 307 formats/ctf/writer/Makefile
4c8bfb7e 308 converter/Makefile
d2c0553c 309 doc/Makefile
1eb0c69c 310 lib/Makefile
74f21e2d 311 lib/prio_heap/Makefile
e92927d1 312 include/Makefile
24a3136a
DS
313 bindings/Makefile
314 bindings/python/Makefile
4c3a0a3c 315 bindings/python/babeltrace/Makefile
ac65e355 316 tests/Makefile
19badea8 317 tests/bin/Makefile
3b888428 318 tests/bin/intersection/Makefile
aa968dde 319 tests/lib/Makefile
1833a3d1
CB
320 tests/utils/Makefile
321 tests/utils/tap/Makefile
6aa249b5
MD
322 extras/Makefile
323 extras/valgrind/Makefile
d0acc96d 324 babeltrace.pc
e7a7efdb 325 babeltrace-ctf.pc
ac65e355 326])
fcacebd5 327
4369fbb4 328AC_CONFIG_FILES([tests/lib/test_ctf_writer_complete], [chmod +x tests/lib/test_ctf_writer_complete])
84be346b
JG
329AC_CONFIG_FILES([tests/lib/test_seek_big_trace], [chmod +x tests/lib/test_seek_big_trace])
330AC_CONFIG_FILES([tests/lib/test_seek_empty_packet], [chmod +x tests/lib/test_seek_empty_packet])
05d31afb
SM
331AC_CONFIG_FILES([tests/lib/test_dwarf_complete], [chmod +x tests/lib/test_dwarf_complete])
332AC_CONFIG_FILES([tests/lib/test_bin_info_complete], [chmod +x tests/lib/test_bin_info_complete])
4369fbb4 333
fcacebd5 334AC_CONFIG_FILES([tests/bin/test_trace_read], [chmod +x tests/bin/test_trace_read])
3b888428
JG
335AC_CONFIG_FILES([tests/bin/intersection/test_intersection], [chmod +x tests/bin/intersection/test_intersection])
336AC_CONFIG_FILES([tests/bin/intersection/bt_python_helper.py])
fcacebd5 337AC_CONFIG_FILES([tests/bin/test_packet_seq_num], [chmod +x tests/bin/test_packet_seq_num])
3b888428 338AC_CONFIG_FILES([tests/bin/intersection/test_multi_trace_intersection.py:tests/bin/intersection/test_multi_trace_intersection.py], [chmod +x tests/bin/intersection/test_multi_trace_intersection.py])
fcacebd5 339
ac65e355 340AC_OUTPUT
1e3c16c7
MJ
341
342#
343# Mini-report on what will be built.
344#
345
346PPRINT_INIT
347PPRINT_SET_INDENT(1)
348PPRINT_SET_TS(38)
349
350AS_ECHO
351AS_ECHO("${PPRINT_COLOR_BLDBLU}Babeltrace $PACKAGE_VERSION$PPRINT_COLOR_RST")
352AS_ECHO
353
354PPRINT_SUBTITLE([Features])
355
356# Target architecture we're building for.
357target_arch=$host_cpu
358[
359for f in $CFLAGS; do
360 if test $f = "-m32"; then
361 target_arch="32-bit"
362 elif test $f = "-m64"; then
363 target_arch="64-bit"
364 fi
365done
366]
367PPRINT_PROP_STRING([Target architecture], $target_arch)
368
369# python bindings enabled/disabled
370test "x$enable_python" = "xyes" && value=1 || value=0
371PPRINT_PROP_BOOL([Python bindings], $value)
372
373# python bindings doc enabled/disabled
374test "x$enable_python_bindings_doc" = "xyes" && value=1 || value=0
375PPRINT_PROP_BOOL([Python bindings doc], $value)
376
eb75a494
AB
377# debug info enabled/disabled
378test "x$_enable_debug_info" = "xyes" && value=1 || value=0
1e3c16c7
MJ
379PPRINT_PROP_BOOL([Debug information output], $value)
380
381
382report_bindir="`eval eval echo $bindir`"
383report_libdir="`eval eval echo $libdir`"
384
385# Print the bindir and libdir this `make install' will install into.
386AS_ECHO
387PPRINT_SUBTITLE([Install directories])
388PPRINT_PROP_STRING([Binaries], [$report_bindir])
389PPRINT_PROP_STRING([Libraries], [$report_libdir])
This page took 0.04898 seconds and 4 git commands to generate.