Build and run tests as C++ programs
[librseq.git] / configure.ac
CommitLineData
4a97c059
MJ
1dnl SPDX-License-Identifier: MIT
2dnl
3dnl Copyright (C) 2021 EfficiOS, Inc.
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
2cbca301 83
d268885a
MJ
84## ##
85## C++ compiler checks ##
86## ##
87
88# Require a C++11 compiler without GNU extensions (-std=c++11)
89AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
90
91
4a97c059
MJ
92## ##
93## Header checks ##
94## ##
95
96AC_HEADER_STDBOOL
97AC_CHECK_HEADERS([ \
98 limits.h \
99 stddef.h \
100 sys/time.h \
101])
102
103AC_CHECK_HEADER([linux/rseq.h], [],
104 [AC_MSG_ERROR([Cannot find 'linux/rseq.h'.])
105])
106
107
108## ##
109## Programs checks ##
110## ##
111
112AM_PROG_AR
113AC_PROG_AWK
114AC_PROG_MAKE_SET
115
116# Initialize and configure libtool
117LT_INIT
2cbca301 118
4a97c059
MJ
119
120## ##
121## Library checks ##
122## ##
2cbca301
MJ
123
124# Checks for library functions.
125AC_FUNC_MMAP
126AC_FUNC_FORK
127AC_CHECK_FUNCS([ \
4a97c059 128 atexit \
2cbca301
MJ
129 memset \
130 strerror \
131])
132
133# AC_FUNC_MALLOC causes problems when cross-compiling.
134#AC_FUNC_MALLOC
135
9698c399
MD
136# Check dor dlopen() in -ldl or -lc
137AC_CHECK_LIB([dl], [dlopen], [
138 libdl_name=dl
139 DL_LIBS="-ldl"
140], [
141 # dlopen not found in libdl, check in libc
142 AC_CHECK_LIB([c], [dlopen], [
143 libdl_name=c
144 DL_LIBS="-lc"
145 ], [
146 AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.])
147 ])
148])
149AC_SUBST(DL_LIBS)
2cbca301 150
4a97c059
MJ
151## ##
152## Substitute variables for use in Makefile.am ##
153## ##
154
155# Library versions for libtool
156AC_SUBST([RSEQ_LIBRARY_VERSION], [rseq_lib_version])
2cbca301 157
4a97c059
MJ
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.
161AM_CPPFLAGS="-I\$(top_builddir)/include -I\$(top_srcdir)/include -include config.h"
2cbca301
MJ
162AC_SUBST(AM_CPPFLAGS)
163
4a97c059 164AM_CFLAGS="-Wall -Wextra $PTHREAD_CFLAGS"
2cbca301
MJ
165AC_SUBST(AM_CFLAGS)
166
d268885a
MJ
167AM_CXXFLAGS="-Wall -Wextra $PTHREAD_CFLAGS"
168AC_SUBST(AM_CXXFLAGS)
169
4a97c059
MJ
170
171## ##
172## Output files generated by configure ##
173## ##
174
2cbca301
MJ
175AC_CONFIG_FILES([
176 Makefile
6146efae
MD
177 doc/Makefile
178 doc/man/Makefile
2cbca301
MJ
179 include/Makefile
180 src/Makefile
2cbca301 181 src/librseq.pc
b848736e 182 tests/Makefile
544cdc88 183 tests/utils/Makefile
2cbca301
MJ
184])
185
186AC_OUTPUT
aa4ed6d6 187
4a97c059 188
aa4ed6d6
MJ
189#
190# Mini-report on what will be built.
191#
192
193PPRINT_INIT
194PPRINT_SET_INDENT(1)
195PPRINT_SET_TS(38)
196
197AS_ECHO
198AS_ECHO("${PPRINT_COLOR_BLDBLU}librseq $PACKAGE_VERSION${PPRINT_COLOR_RST}")
199AS_ECHO
200
201PPRINT_SUBTITLE([Features])
202
203PPRINT_PROP_STRING([Target architecture], $host_cpu)
204
aa4ed6d6
MJ
205report_bindir="`eval eval echo $bindir`"
206report_libdir="`eval eval echo $libdir`"
207
208# Print the bindir and libdir this `make install' will install into.
209AS_ECHO
210PPRINT_SUBTITLE([Install directories])
211PPRINT_PROP_STRING([Binaries], [$report_bindir])
212PPRINT_PROP_STRING([Libraries], [$report_libdir])
This page took 0.032386 seconds and 4 git commands to generate.