1 dnl SPDX-License-Identifier: MIT
3 dnl SPDX-FileCopyrightText: 2021 EfficiOS, Inc.
5 dnl Process this file with autoconf to produce a configure script.
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)
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)
24 ## Autoconf base setup ##
28 AC_INIT([librseq],[rseq_version],[mathieu dot desnoyers at efficios dot com],[],[https://github.com/compudj/librseq/])
30 AC_CONFIG_HEADERS([include/config.h])
31 AC_CONFIG_AUX_DIR([config])
32 AC_CONFIG_MACRO_DIR([m4])
39 ## Automake base setup ##
42 AM_INIT_AUTOMAKE([1.12 foreign dist-bzip2 no-dist-gzip nostdinc -Wall -Werror])
43 AM_MAINTAINER_MODE([enable])
45 # Enable silent rules by default
46 AM_SILENT_RULES([yes])
50 ## C compiler checks ##
53 # Choose the C compiler
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])
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])])
61 # Enable available system extensions and LFS support
62 AC_USE_SYSTEM_EXTENSIONS
65 # Make sure the C compiler supports __attribute__
67 AS_IF([test "x$ax_cv___attribute__" != "xyes"],
68 [AC_MSG_ERROR([The compiler does not support __attribute__ extensions])])
70 # Make sure we have pthread support
71 AX_PTHREAD([], [AC_MSG_ERROR([Could not configure pthread support])])
73 # Checks for typedefs, structures, and compiler characteristics.
83 # Detect warning flags supported by the C compiler and append them to
85 m4_define([WARN_FLAGS_LIST], [ dnl
88 -Wmissing-prototypes dnl
89 -Wmissing-declarations dnl
90 -Wnull-dereference dnl
93 -Wjump-misses-init dnl
94 -Wsuggest-attribute=format dnl
95 -Wtautological-constant-out-of-range-compare dnl
100 -Wmissing-noreturn dnl
102 -Wduplicated-cond dnl
103 -Wduplicated-branches dnl
105 -Wredundant-decls dnl
108 # Pass -Werror as an extra flag during the test: this is needed to make the
109 # -Wunknown-warning-option diagnostic fatal with clang.
111 AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CFLAGS], [-Werror])
115 AX_APPEND_COMPILE_FLAGS([WARN_FLAGS_LIST], [WARN_CXXFLAGS], [-Werror])
118 AE_IF_FEATURE_ENABLED([Werror], [WARN_CFLAGS="${WARN_CFLAGS} -Werror"])
119 AE_IF_FEATURE_ENABLED([Werror], [WARN_CXXFLAGS="${WARN_CXXFLAGS} -Werror"])
123 ## C++ compiler checks ##
126 # Require a C++11 compiler without GNU extensions (-std=c++11)
127 AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
143 ## Programs checks ##
150 # Initialize and configure libtool
158 # Checks for library functions.
167 # AC_FUNC_MALLOC causes problems when cross-compiling.
170 # Check dor dlopen() in -ldl or -lc
171 AC_CHECK_LIB([dl], [dlopen], [
175 # dlopen not found in libdl, check in libc
176 AC_CHECK_LIB([c], [dlopen], [
180 AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.])
185 PKG_CHECK_MODULES([SECCOMP], [libseccomp],
187 dnl PKG_CHECK_MODULES defines SECCOMP_LIBS
196 ## Optional features selection ##
200 AE_FEATURE_DEFAULT_ENABLE
201 AE_FEATURE([numa],[disable NUMA support])
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.])
209 ## Check for optional features dependencies ##
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.])
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.
227 ## Set automake variables for optional feature conditionnals in Makefile.am ##
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]))
235 ## Substitute variables for use in Makefile.am ##
238 # Library versions for libtool
239 AC_SUBST([RSEQ_LIBRARY_VERSION], [rseq_lib_version])
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)
247 AM_CFLAGS="$WARN_CFLAGS $PTHREAD_CFLAGS"
250 AM_CXXFLAGS="$WARN_CXXFLAGS $PTHREAD_CFLAGS"
251 AC_SUBST(AM_CXXFLAGS)
255 ## Output files generated by configure ##
274 # Mini-report on what will be built.
282 AS_ECHO("${PPRINT_COLOR_BLDBLU}librseq $PACKAGE_VERSION${PPRINT_COLOR_RST}")
285 PPRINT_SUBTITLE([Features])
287 PPRINT_PROP_STRING([Target architecture], $host_cpu)
288 AE_IS_FEATURE_ENABLED([numa]) && value=1 || value=0
289 PPRINT_PROP_BOOL([NUMA], $value)
291 report_bindir="`eval eval echo $bindir`"
292 report_libdir="`eval eval echo $libdir`"
294 # Print the bindir and libdir this `make install' will install into.
296 PPRINT_SUBTITLE([Install directories])
297 PPRINT_PROP_STRING([Binaries], [$report_bindir])
298 PPRINT_PROP_STRING([Libraries], [$report_libdir])