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