configure: enable extended compiler warnings
[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
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
141AC_CHECK_HEADER([linux/rseq.h], [],
142 [AC_MSG_ERROR([Cannot find 'linux/rseq.h'.])
143])
144
145
146## ##
147## Programs checks ##
148## ##
149
150AM_PROG_AR
151AC_PROG_AWK
152AC_PROG_MAKE_SET
153
154# Initialize and configure libtool
155LT_INIT
2cbca301 156
4a97c059
MJ
157
158## ##
159## Library checks ##
160## ##
2cbca301
MJ
161
162# Checks for library functions.
163AC_FUNC_MMAP
164AC_FUNC_FORK
165AC_CHECK_FUNCS([ \
4a97c059 166 atexit \
2cbca301
MJ
167 memset \
168 strerror \
169])
170
171# AC_FUNC_MALLOC causes problems when cross-compiling.
172#AC_FUNC_MALLOC
173
9698c399
MD
174# Check dor dlopen() in -ldl or -lc
175AC_CHECK_LIB([dl], [dlopen], [
176 libdl_name=dl
177 DL_LIBS="-ldl"
178], [
179 # dlopen not found in libdl, check in libc
180 AC_CHECK_LIB([c], [dlopen], [
181 libdl_name=c
182 DL_LIBS="-lc"
183 ], [
184 AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.])
185 ])
186])
187AC_SUBST(DL_LIBS)
2cbca301 188
6e284b80
MJ
189
190## ##
191## Optional features selection ##
192## ##
193
194# When given, add -Werror to WARN_CFLAGS and WARN_CXXFLAGS.
195# Disabled by default
196AE_FEATURE_DEFAULT_DISABLE
197AE_FEATURE([Werror], [Treat compiler warnings as errors.])
198
199
4a97c059
MJ
200## ##
201## Substitute variables for use in Makefile.am ##
202## ##
203
204# Library versions for libtool
205AC_SUBST([RSEQ_LIBRARY_VERSION], [rseq_lib_version])
2cbca301 206
4a97c059
MJ
207# The order in which the include folders are searched is important.
208# The top_builddir should always be searched first in the event that a build
209# time generated file is included.
210AM_CPPFLAGS="-I\$(top_builddir)/include -I\$(top_srcdir)/include -include config.h"
2cbca301
MJ
211AC_SUBST(AM_CPPFLAGS)
212
6e284b80 213AM_CFLAGS="$WARN_CFLAGS $PTHREAD_CFLAGS"
2cbca301
MJ
214AC_SUBST(AM_CFLAGS)
215
6e284b80 216AM_CXXFLAGS="$WARN_CXXFLAGS $PTHREAD_CFLAGS"
d268885a
MJ
217AC_SUBST(AM_CXXFLAGS)
218
4a97c059
MJ
219
220## ##
221## Output files generated by configure ##
222## ##
223
2cbca301
MJ
224AC_CONFIG_FILES([
225 Makefile
6146efae
MD
226 doc/Makefile
227 doc/man/Makefile
2cbca301
MJ
228 include/Makefile
229 src/Makefile
2cbca301 230 src/librseq.pc
b848736e 231 tests/Makefile
544cdc88 232 tests/utils/Makefile
2cbca301
MJ
233])
234
235AC_OUTPUT
aa4ed6d6 236
4a97c059 237
aa4ed6d6
MJ
238#
239# Mini-report on what will be built.
240#
241
242PPRINT_INIT
243PPRINT_SET_INDENT(1)
244PPRINT_SET_TS(38)
245
246AS_ECHO
247AS_ECHO("${PPRINT_COLOR_BLDBLU}librseq $PACKAGE_VERSION${PPRINT_COLOR_RST}")
248AS_ECHO
249
250PPRINT_SUBTITLE([Features])
251
252PPRINT_PROP_STRING([Target architecture], $host_cpu)
253
aa4ed6d6
MJ
254report_bindir="`eval eval echo $bindir`"
255report_libdir="`eval eval echo $libdir`"
256
257# Print the bindir and libdir this `make install' will install into.
258AS_ECHO
259PPRINT_SUBTITLE([Install directories])
260PPRINT_PROP_STRING([Binaries], [$report_bindir])
261PPRINT_PROP_STRING([Libraries], [$report_libdir])
This page took 0.03341 seconds and 4 git commands to generate.