fix: handle EINTR correctly in get_cpu_mask_from_sysfs
[librseq.git] / configure.ac
CommitLineData
4a97c059
MJ
1dnl SPDX-License-Identifier: MIT
2dnl
f2d7b530 3dnl SPDX-FileCopyrightText: 2021 EfficiOS, Inc.
4a97c059
MJ
4dnl
5dnl Process this file with autoconf to produce a configure script.
6
7# Project version information
8m4_define([rseq_version_major], [0])
9m4_define([rseq_version_minor], [1])
10m4_define([rseq_version_patch], [0])
11m4_define([rseq_version_dev_stage], [-pre])
12m4_define([rseq_version], rseq_version_major[.]rseq_version_minor[.]rseq_version_patch[]rseq_version_dev_stage)
13
14# Library version information of "librseq"
2cbca301
MJ
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
4a97c059
MJ
17m4_define([rseq_lib_version_current], [0])
18m4_define([rseq_lib_version_revision], [0])
19m4_define([rseq_lib_version_age], [0])
20m4_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
27AC_PREREQ([2.69])
28AC_INIT([librseq],[rseq_version],[mathieu dot desnoyers at efficios dot com],[],[https://github.com/compudj/librseq/])
2cbca301
MJ
29
30AC_CONFIG_HEADERS([include/config.h])
31AC_CONFIG_AUX_DIR([config])
32AC_CONFIG_MACRO_DIR([m4])
33
34AC_CANONICAL_TARGET
35AC_CANONICAL_HOST
36
4a97c059
MJ
37
38## ##
39## Automake base setup ##
40## ##
41
42AM_INIT_AUTOMAKE([1.12 foreign dist-bzip2 no-dist-gzip nostdinc -Wall -Werror])
2cbca301
MJ
43AM_MAINTAINER_MODE([enable])
44
4a97c059
MJ
45# Enable silent rules by default
46AM_SILENT_RULES([yes])
2cbca301 47
4a97c059
MJ
48
49## ##
50## C compiler checks ##
51## ##
52
53# Choose the C compiler
2cbca301 54AC_PROG_CC
4a97c059
MJ
55# AC_PROG_CC_STDC was merged in AC_PROG_CC in autoconf 2.70
56m4_version_prereq([2.70], [], [AC_PROG_CC_STDC])
2cbca301 57
4a97c059
MJ
58# Make sure the C compiler supports C99
59AS_IF([test "$ac_cv_prog_cc_c99" = "no"], [AC_MSG_ERROR([The compiler does not support C99])])
2cbca301 60
4a97c059
MJ
61# Enable available system extensions and LFS support
62AC_USE_SYSTEM_EXTENSIONS
63AC_SYS_LARGEFILE
64
65# Make sure the C compiler supports __attribute__
66AX_C___ATTRIBUTE__
67AS_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
71AX_PTHREAD([], [AC_MSG_ERROR([Could not configure pthread support])])
2cbca301
MJ
72
73# Checks for typedefs, structures, and compiler characteristics.
74AC_C_INLINE
4a97c059 75AC_C_TYPEOF
2cbca301
MJ
76AC_TYPE_INT32_T
77AC_TYPE_INT64_T
78AC_TYPE_OFF_T
79AC_TYPE_SIZE_T
80AC_TYPE_UINT32_T
81AC_TYPE_UINT64_T
82
6e284b80
MJ
83# Detect warning flags supported by the C compiler and append them to
84# WARN_CFLAGS.
85m4_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.
110AC_LANG_PUSH([C])
111AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CFLAGS], [-Werror])
112AC_LANG_POP([C])
113
114AC_LANG_PUSH([C++])
115AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CXXFLAGS], [-Werror])
116AC_LANG_POP([C++])
117
118AE_IF_FEATURE_ENABLED([Werror], [WARN_CFLAGS="${WARN_CFLAGS} -Werror"])
119AE_IF_FEATURE_ENABLED([Werror], [WARN_CXXFLAGS="${WARN_CXXFLAGS} -Werror"])
120
2cbca301 121
d268885a
MJ
122## ##
123## C++ compiler checks ##
124## ##
125
126# Require a C++11 compiler without GNU extensions (-std=c++11)
127AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
128
129
4a97c059
MJ
130## ##
131## Header checks ##
132## ##
133
134AC_HEADER_STDBOOL
135AC_CHECK_HEADERS([ \
136 limits.h \
137 stddef.h \
138 sys/time.h \
139])
140
4a97c059
MJ
141
142## ##
143## Programs checks ##
144## ##
145
146AM_PROG_AR
147AC_PROG_AWK
148AC_PROG_MAKE_SET
149
150# Initialize and configure libtool
151LT_INIT
2cbca301 152
4a97c059
MJ
153
154## ##
155## Library checks ##
156## ##
2cbca301
MJ
157
158# Checks for library functions.
159AC_FUNC_MMAP
160AC_FUNC_FORK
161AC_CHECK_FUNCS([ \
4a97c059 162 atexit \
2cbca301
MJ
163 memset \
164 strerror \
165])
166
167# AC_FUNC_MALLOC causes problems when cross-compiling.
168#AC_FUNC_MALLOC
169
9698c399
MD
170# Check dor dlopen() in -ldl or -lc
171AC_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])
183AC_SUBST(DL_LIBS)
2cbca301 184
01bd794d
MJ
185PKG_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
6e284b80
MJ
194
195## ##
196## Optional features selection ##
197## ##
198
367e559c
MD
199# Enabled by default
200AE_FEATURE_DEFAULT_ENABLE
201AE_FEATURE([numa],[disable NUMA support])
202
6e284b80
MJ
203# When given, add -Werror to WARN_CFLAGS and WARN_CXXFLAGS.
204# Disabled by default
205AE_FEATURE_DEFAULT_DISABLE
206AE_FEATURE([Werror], [Treat compiler warnings as errors.])
207
367e559c
MD
208## ##
209## Check for optional features dependencies ##
210## ##
211
212# The numa integration requires libnuma
213AE_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
218libnuma 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
220argument to disable NUMA support.
221 ])
222 ])
223])
224
6e284b80 225
01bd794d
MJ
226## ##
227## Set automake variables for optional feature conditionnals in Makefile.am ##
228## ##
229
71884a4b
MJ
230AM_CONDITIONAL([ENABLE_SHARED], [test "x${enable_shared}" = "xyes"])
231AM_CONDITIONAL([ENABLE_SECCOMP], [test "x${have_seccomp}" = "xyes"])
367e559c 232AM_CONDITIONAL([ENABLE_NUMA], AE_IS_FEATURE_ENABLED([numa]))
01bd794d 233
4a97c059
MJ
234## ##
235## Substitute variables for use in Makefile.am ##
236## ##
237
238# Library versions for libtool
239AC_SUBST([RSEQ_LIBRARY_VERSION], [rseq_lib_version])
2cbca301 240
4a97c059
MJ
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.
244AM_CPPFLAGS="-I\$(top_builddir)/include -I\$(top_srcdir)/include -include config.h"
2cbca301
MJ
245AC_SUBST(AM_CPPFLAGS)
246
6e284b80 247AM_CFLAGS="$WARN_CFLAGS $PTHREAD_CFLAGS"
2cbca301
MJ
248AC_SUBST(AM_CFLAGS)
249
6e284b80 250AM_CXXFLAGS="$WARN_CXXFLAGS $PTHREAD_CFLAGS"
d268885a
MJ
251AC_SUBST(AM_CXXFLAGS)
252
4a97c059
MJ
253
254## ##
255## Output files generated by configure ##
256## ##
257
2cbca301
MJ
258AC_CONFIG_FILES([
259 Makefile
6146efae
MD
260 doc/Makefile
261 doc/man/Makefile
2cbca301
MJ
262 include/Makefile
263 src/Makefile
2cbca301 264 src/librseq.pc
b848736e 265 tests/Makefile
544cdc88 266 tests/utils/Makefile
eb5d1cbe 267 tests/unit/Makefile
2cbca301
MJ
268])
269
270AC_OUTPUT
aa4ed6d6 271
4a97c059 272
aa4ed6d6
MJ
273#
274# Mini-report on what will be built.
275#
276
277PPRINT_INIT
278PPRINT_SET_INDENT(1)
279PPRINT_SET_TS(38)
280
281AS_ECHO
282AS_ECHO("${PPRINT_COLOR_BLDBLU}librseq $PACKAGE_VERSION${PPRINT_COLOR_RST}")
283AS_ECHO
284
285PPRINT_SUBTITLE([Features])
286
287PPRINT_PROP_STRING([Target architecture], $host_cpu)
367e559c
MD
288AE_IS_FEATURE_ENABLED([numa]) && value=1 || value=0
289PPRINT_PROP_BOOL([NUMA], $value)
aa4ed6d6 290
aa4ed6d6
MJ
291report_bindir="`eval eval echo $bindir`"
292report_libdir="`eval eval echo $libdir`"
293
294# Print the bindir and libdir this `make install' will install into.
295AS_ECHO
296PPRINT_SUBTITLE([Install directories])
297PPRINT_PROP_STRING([Binaries], [$report_bindir])
298PPRINT_PROP_STRING([Libraries], [$report_libdir])
This page took 0.0357229999999999 seconds and 4 git commands to generate.