1 dnl SPDX-License-Identifier: MIT
3 dnl Copyright (C) 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.
85 ## C++ compiler checks ##
88 # Require a C++11 compiler without GNU extensions (-std=c++11)
89 AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
103 AC_CHECK_HEADER([linux/rseq.h], [],
104 [AC_MSG_ERROR([Cannot find 'linux/rseq.h'.])
109 ## Programs checks ##
116 # Initialize and configure libtool
124 # Checks for library functions.
133 # AC_FUNC_MALLOC causes problems when cross-compiling.
136 # Check dor dlopen() in -ldl or -lc
137 AC_CHECK_LIB([dl], [dlopen], [
141 # dlopen not found in libdl, check in libc
142 AC_CHECK_LIB([c], [dlopen], [
146 AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.])
152 ## Substitute variables for use in Makefile.am ##
155 # Library versions for libtool
156 AC_SUBST([RSEQ_LIBRARY_VERSION], [rseq_lib_version])
158 # The order in which the include folders are searched is important.
159 # The top_builddir should always be searched first in the event that a build
160 # time generated file is included.
161 AM_CPPFLAGS="-I\$(top_builddir)/include -I\$(top_srcdir)/include -include config.h"
162 AC_SUBST(AM_CPPFLAGS)
164 AM_CFLAGS="-Wall -Wextra $PTHREAD_CFLAGS"
167 AM_CXXFLAGS="-Wall -Wextra $PTHREAD_CFLAGS"
168 AC_SUBST(AM_CXXFLAGS)
172 ## Output files generated by configure ##
190 # Mini-report on what will be built.
198 AS_ECHO("${PPRINT_COLOR_BLDBLU}librseq $PACKAGE_VERSION${PPRINT_COLOR_RST}")
201 PPRINT_SUBTITLE([Features])
203 PPRINT_PROP_STRING([Target architecture], $host_cpu)
205 report_bindir="`eval eval echo $bindir`"
206 report_libdir="`eval eval echo $libdir`"
208 # Print the bindir and libdir this `make install' will install into.
210 PPRINT_SUBTITLE([Install directories])
211 PPRINT_PROP_STRING([Binaries], [$report_bindir])
212 PPRINT_PROP_STRING([Libraries], [$report_libdir])