fix: handle EINTR correctly in get_cpu_mask_from_sysfs
[librseq.git] / configure.ac
1 dnl SPDX-License-Identifier: MIT
2 dnl
3 dnl SPDX-FileCopyrightText: 2021 EfficiOS, Inc.
4 dnl
5 dnl Process this file with autoconf to produce a configure script.
6
7 # Project version information
8 m4_define([rseq_version_major], [0])
9 m4_define([rseq_version_minor], [1])
10 m4_define([rseq_version_patch], [0])
11 m4_define([rseq_version_dev_stage], [-pre])
12 m4_define([rseq_version], rseq_version_major[.]rseq_version_minor[.]rseq_version_patch[]rseq_version_dev_stage)
13
14 # Library version information of "librseq"
15 # Following the numbering scheme proposed by libtool for the library version
16 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
17 m4_define([rseq_lib_version_current], [0])
18 m4_define([rseq_lib_version_revision], [0])
19 m4_define([rseq_lib_version_age], [0])
20 m4_define([rseq_lib_version], rseq_lib_version_current[:]rseq_lib_version_revision[:]rseq_lib_version_age)
21
22
23 ## ##
24 ## Autoconf base setup ##
25 ## ##
26
27 AC_PREREQ([2.69])
28 AC_INIT([librseq],[rseq_version],[mathieu dot desnoyers at efficios dot com],[],[https://github.com/compudj/librseq/])
29
30 AC_CONFIG_HEADERS([include/config.h])
31 AC_CONFIG_AUX_DIR([config])
32 AC_CONFIG_MACRO_DIR([m4])
33
34 AC_CANONICAL_TARGET
35 AC_CANONICAL_HOST
36
37
38 ## ##
39 ## Automake base setup ##
40 ## ##
41
42 AM_INIT_AUTOMAKE([1.12 foreign dist-bzip2 no-dist-gzip nostdinc -Wall -Werror])
43 AM_MAINTAINER_MODE([enable])
44
45 # Enable silent rules by default
46 AM_SILENT_RULES([yes])
47
48
49 ## ##
50 ## C compiler checks ##
51 ## ##
52
53 # Choose the C compiler
54 AC_PROG_CC
55 # AC_PROG_CC_STDC was merged in AC_PROG_CC in autoconf 2.70
56 m4_version_prereq([2.70], [], [AC_PROG_CC_STDC])
57
58 # Make sure the C compiler supports C99
59 AS_IF([test "$ac_cv_prog_cc_c99" = "no"], [AC_MSG_ERROR([The compiler does not support C99])])
60
61 # Enable available system extensions and LFS support
62 AC_USE_SYSTEM_EXTENSIONS
63 AC_SYS_LARGEFILE
64
65 # Make sure the C compiler supports __attribute__
66 AX_C___ATTRIBUTE__
67 AS_IF([test "x$ax_cv___attribute__" != "xyes"],
68 [AC_MSG_ERROR([The compiler does not support __attribute__ extensions])])
69
70 # Make sure we have pthread support
71 AX_PTHREAD([], [AC_MSG_ERROR([Could not configure pthread support])])
72
73 # Checks for typedefs, structures, and compiler characteristics.
74 AC_C_INLINE
75 AC_C_TYPEOF
76 AC_TYPE_INT32_T
77 AC_TYPE_INT64_T
78 AC_TYPE_OFF_T
79 AC_TYPE_SIZE_T
80 AC_TYPE_UINT32_T
81 AC_TYPE_UINT64_T
82
83 # Detect warning flags supported by the C compiler and append them to
84 # WARN_CFLAGS.
85 m4_define([WARN_FLAGS_LIST], [ dnl
86 -Wall dnl
87 -Wextra dnl
88 -Wmissing-prototypes dnl
89 -Wmissing-declarations dnl
90 -Wnull-dereference dnl
91 -Wundef dnl
92 -Wshadow dnl
93 -Wjump-misses-init dnl
94 -Wsuggest-attribute=format dnl
95 -Wtautological-constant-out-of-range-compare dnl
96 -Wnested-externs dnl
97 -Wwrite-strings dnl
98 -Wformat=2 dnl
99 -Wstrict-aliasing dnl
100 -Wmissing-noreturn dnl
101 -Winit-self dnl
102 -Wduplicated-cond dnl
103 -Wduplicated-branches dnl
104 -Wlogical-op dnl
105 -Wredundant-decls dnl
106 ])
107
108 # Pass -Werror as an extra flag during the test: this is needed to make the
109 # -Wunknown-warning-option diagnostic fatal with clang.
110 AC_LANG_PUSH([C])
111 AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CFLAGS], [-Werror])
112 AC_LANG_POP([C])
113
114 AC_LANG_PUSH([C++])
115 AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CXXFLAGS], [-Werror])
116 AC_LANG_POP([C++])
117
118 AE_IF_FEATURE_ENABLED([Werror], [WARN_CFLAGS="${WARN_CFLAGS} -Werror"])
119 AE_IF_FEATURE_ENABLED([Werror], [WARN_CXXFLAGS="${WARN_CXXFLAGS} -Werror"])
120
121
122 ## ##
123 ## C++ compiler checks ##
124 ## ##
125
126 # Require a C++11 compiler without GNU extensions (-std=c++11)
127 AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
128
129
130 ## ##
131 ## Header checks ##
132 ## ##
133
134 AC_HEADER_STDBOOL
135 AC_CHECK_HEADERS([ \
136 limits.h \
137 stddef.h \
138 sys/time.h \
139 ])
140
141
142 ## ##
143 ## Programs checks ##
144 ## ##
145
146 AM_PROG_AR
147 AC_PROG_AWK
148 AC_PROG_MAKE_SET
149
150 # Initialize and configure libtool
151 LT_INIT
152
153
154 ## ##
155 ## Library checks ##
156 ## ##
157
158 # Checks for library functions.
159 AC_FUNC_MMAP
160 AC_FUNC_FORK
161 AC_CHECK_FUNCS([ \
162 atexit \
163 memset \
164 strerror \
165 ])
166
167 # AC_FUNC_MALLOC causes problems when cross-compiling.
168 #AC_FUNC_MALLOC
169
170 # Check dor dlopen() in -ldl or -lc
171 AC_CHECK_LIB([dl], [dlopen], [
172 libdl_name=dl
173 DL_LIBS="-ldl"
174 ], [
175 # dlopen not found in libdl, check in libc
176 AC_CHECK_LIB([c], [dlopen], [
177 libdl_name=c
178 DL_LIBS="-lc"
179 ], [
180 AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.])
181 ])
182 ])
183 AC_SUBST(DL_LIBS)
184
185 PKG_CHECK_MODULES([SECCOMP], [libseccomp],
186 [
187 dnl PKG_CHECK_MODULES defines SECCOMP_LIBS
188 have_seccomp=yes
189 ],
190 [
191 have_seccomp=no
192 ])
193
194
195 ## ##
196 ## Optional features selection ##
197 ## ##
198
199 # Enabled by default
200 AE_FEATURE_DEFAULT_ENABLE
201 AE_FEATURE([numa],[disable NUMA support])
202
203 # When given, add -Werror to WARN_CFLAGS and WARN_CXXFLAGS.
204 # Disabled by default
205 AE_FEATURE_DEFAULT_DISABLE
206 AE_FEATURE([Werror], [Treat compiler warnings as errors.])
207
208 ## ##
209 ## Check for optional features dependencies ##
210 ## ##
211
212 # The numa integration requires libnuma
213 AE_IF_FEATURE_ENABLED([numa], [
214 AC_CHECK_LIB([numa], [numa_available], [
215 AC_DEFINE([HAVE_LIBNUMA], [1], [Define to 1 if libnuma is available.])
216 ], [
217 AC_MSG_ERROR([dnl
218 libnuma is not available. Please either install it (e.g. libnuma-dev) or use
219 [LDFLAGS]=-Ldir to specify the right location, or use --disable-numa configure
220 argument to disable NUMA support.
221 ])
222 ])
223 ])
224
225
226 ## ##
227 ## Set automake variables for optional feature conditionnals in Makefile.am ##
228 ## ##
229
230 AM_CONDITIONAL([ENABLE_SHARED], [test "x${enable_shared}" = "xyes"])
231 AM_CONDITIONAL([ENABLE_SECCOMP], [test "x${have_seccomp}" = "xyes"])
232 AM_CONDITIONAL([ENABLE_NUMA], AE_IS_FEATURE_ENABLED([numa]))
233
234 ## ##
235 ## Substitute variables for use in Makefile.am ##
236 ## ##
237
238 # Library versions for libtool
239 AC_SUBST([RSEQ_LIBRARY_VERSION], [rseq_lib_version])
240
241 # The order in which the include folders are searched is important.
242 # The top_builddir should always be searched first in the event that a build
243 # time generated file is included.
244 AM_CPPFLAGS="-I\$(top_builddir)/include -I\$(top_srcdir)/include -include config.h"
245 AC_SUBST(AM_CPPFLAGS)
246
247 AM_CFLAGS="$WARN_CFLAGS $PTHREAD_CFLAGS"
248 AC_SUBST(AM_CFLAGS)
249
250 AM_CXXFLAGS="$WARN_CXXFLAGS $PTHREAD_CFLAGS"
251 AC_SUBST(AM_CXXFLAGS)
252
253
254 ## ##
255 ## Output files generated by configure ##
256 ## ##
257
258 AC_CONFIG_FILES([
259 Makefile
260 doc/Makefile
261 doc/man/Makefile
262 include/Makefile
263 src/Makefile
264 src/librseq.pc
265 tests/Makefile
266 tests/utils/Makefile
267 tests/unit/Makefile
268 ])
269
270 AC_OUTPUT
271
272
273 #
274 # Mini-report on what will be built.
275 #
276
277 PPRINT_INIT
278 PPRINT_SET_INDENT(1)
279 PPRINT_SET_TS(38)
280
281 AS_ECHO
282 AS_ECHO("${PPRINT_COLOR_BLDBLU}librseq $PACKAGE_VERSION${PPRINT_COLOR_RST}")
283 AS_ECHO
284
285 PPRINT_SUBTITLE([Features])
286
287 PPRINT_PROP_STRING([Target architecture], $host_cpu)
288 AE_IS_FEATURE_ENABLED([numa]) && value=1 || value=0
289 PPRINT_PROP_BOOL([NUMA], $value)
290
291 report_bindir="`eval eval echo $bindir`"
292 report_libdir="`eval eval echo $libdir`"
293
294 # Print the bindir and libdir this `make install' will install into.
295 AS_ECHO
296 PPRINT_SUBTITLE([Install directories])
297 PPRINT_PROP_STRING([Binaries], [$report_bindir])
298 PPRINT_PROP_STRING([Libraries], [$report_libdir])
This page took 0.036483 seconds and 4 git commands to generate.