-
Notifications
You must be signed in to change notification settings - Fork 9
/
configure.ac
226 lines (196 loc) · 7.26 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
dnl -*- Autoconf -*-
dnl Process this file with autoconf to produce a configure script.
#
# This file is part of the Off-the-Record Next Generation Messaging
# library (libotr-ng).
#
# Copyright (C) 2016-2019, the libotr-ng contributors.
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 2.1 of the License, or
# (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
#
AC_PREREQ([2.68])
AC_INIT([libotr-ng], [0.0.1], [[email protected]],[],[https://otr.cypherpunks.ca])
AC_CONFIG_SRCDIR([src/otrng.c])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([.])
AM_SILENT_RULES([no])
dnl Debug
AX_CHECK_ENABLE_DEBUG([yes])
dnl Valgrind: make check-valgrind
AX_VALGRIND_DFLT([sgcheck], [off])
AX_VALGRIND_CHECK
AC_USE_SYSTEM_EXTENSIONS
#AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
AM_INIT_AUTOMAKE([-Wall -W -Werror foreign subdir-objects]) # Use this to allow Wextra flag
AM_PROG_AR
LT_INIT
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_PROG_LIBTOOL
AC_PROG_AWK
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
dnl ISO Standard C (currently C99), with fall back to ANSI C89 (ISO C90)
AC_PROG_CC_STDC
dnl Check that our compiler can do const and inline
AC_C_CONST
AC_C_INLINE
AC_CANONICAL_HOST
dnl Checks for libraries.
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.18])
PKG_CHECK_MODULES([LIBGOLDILOCKS], [libgoldilocks >= 0.0.1])
PKG_CHECK_MODULES([LIBSODIUM], [libsodium >= 1.0.0])
AM_PATH_LIBOTR(4.0.0,,AC_MSG_ERROR(libotr 4.x >= 4.0.0 is required.))
AM_PATH_LIBGCRYPT(1:1.6.0,
[AC_DEFINE([HAVE_GCRYPT], [1], [Use GCRYPT])],
AC_MSG_ERROR(libgcrypt 1.6.0 or newer is required.)
)
dnl Checks for header files.
AC_CHECK_HEADERS([stddef.h stdint.h stdlib.h string.h])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_INT64_T
AC_TYPE_SIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
AX_CHECK_COMPILE_FLAG([-std=c99],
[AX_APPEND_FLAG([-std=c99])],
[AC_MSG_NOTICE(No support for -std=c99 flag)]
)
AX_CHECK_COMPILE_FLAG([-pedantic-errors],
[AX_APPEND_FLAG([-pedantic-errors])],
[AC_MSG_NOTICE(No support for -pedantic-errors flag)]
)
AX_CFLAGS_GCC_OPTION([-Wall])
AX_CFLAGS_GCC_OPTION([-Wextra])
AX_CFLAGS_GCC_OPTION([-Werror])
AX_CFLAGS_GCC_OPTION([-Wformat])
AX_CFLAGS_GCC_OPTION([-Wno-format-extra-args])
AX_CFLAGS_GCC_OPTION([-Wfatal-errors])
AX_CFLAGS_GCC_OPTION([-Wbad-function-cast])
AX_CFLAGS_GCC_OPTION([-Wdiv-by-zero])
AX_CFLAGS_GCC_OPTION([-Wfloat-equal])
AX_CFLAGS_GCC_OPTION([-Wnested-externs])
AX_CFLAGS_GCC_OPTION([-Wpointer-arith])
AX_CFLAGS_GCC_OPTION([-Wredundant-decls])
AX_CFLAGS_GCC_OPTION([-Wstrict-prototypes])
AX_CFLAGS_GCC_OPTION([-Wlogical-op])
AX_CFLAGS_GCC_OPTION([-Wbad-cast-qual])
AX_CFLAGS_GCC_OPTION([-Wformat-nonliteral])
AX_CFLAGS_GCC_OPTION([-Wbuiltin-memcpy-chk-size])
AX_CFLAGS_GCC_OPTION([-Wfloat-equal])
AX_CFLAGS_GCC_OPTION([-Wundef])
AX_CFLAGS_GCC_OPTION([-Wshadow])
AX_CFLAGS_GCC_OPTION([-Wpointer-arith])
AX_CFLAGS_GCC_OPTION([-Wcast-align])
AX_CFLAGS_GCC_OPTION([-Wmaybe-uninitialized])
AX_CFLAGS_GCC_OPTION([-Wlogicalop])
AX_CFLAGS_GCC_OPTION([-Wno-type-limits])
AX_CFLAGS_GCC_OPTION([-Wnull-dereference])
AX_CFLAGS_GCC_OPTION([-Wwrite-strings])
AX_CFLAGS_GCC_OPTION([-Wswitch-default])
AX_CFLAGS_GCC_OPTION([-Wswitch-enum])
AX_CFLAGS_GCC_OPTION([-Waddress-of-temporary])
AX_CFLAGS_GCC_OPTION([-Warc])
AX_CFLAGS_GCC_OPTION([-Warraybounds])
AX_CFLAGS_GCC_OPTION([-Wasm])
AX_CFLAGS_GCC_OPTION([-Wgcc-compat])
dnl for undefined behavior
AX_CFLAGS_GCC_OPTION([-fcatch-undefined-behavior])
AX_CFLAGS_GCC_OPTION([-fno-delete-null-pointer-checks])
AX_CFLAGS_GCC_OPTION([-fno-strict-overflow])
AX_CFLAGS_GCC_OPTION([-fno-strict-aliasing])
AX_CFLAGS_GCC_OPTION([-Wno-unknown-pragmas])
AX_CHECK_COMPILE_FLAG([-Wformat-security],
[AX_APPEND_FLAG([-Wformat-security])],
[AC_MSG_NOTICE(No support for -Wformat-security flag - continuing without it)]
)
AX_CHECK_COMPILE_FLAG([-Wstrict-overflow=5],
[AX_APPEND_FLAG([-Wstrict-overflow=5])],
[AC_MSG_NOTICE(No support for -Wstrict-overflow=5 flag - continuing without it)]
)
dnl Code coverage
AX_CODE_COVERAGE
dnl Checks for library functions.
AC_CHECK_FUNCS([memchr memmove memset strstr])
AC_FUNC_MALLOC
AC_FUNC_REALLOC
dnl Switches
AC_ARG_WITH(ctgrind,
[AS_HELP_STRING(--with-ctgrind, Use only if you have ctgrind)],
[AS_IF([test "x$with_ctgrind" = "xyes"], [
AC_CHECK_LIB(ctgrind, ct_poison)
])
])
dnl Enable gprof profiling
AC_ARG_ENABLE([gprof],
[AS_HELP_STRING([--enable-gprof],
[use gprof profiling compiler flags (default is no)])],
[enable_gprof=$enableval],
[enable_gprof=no])
AC_CACHE_SAVE
dnl Enable different -fsanitize options
AC_ARG_WITH([sanitizers],
[AS_HELP_STRING([--with-sanitizers],
[comma separated list of extra sanitizers to build with (default is none enabled)])],
[use_sanitizers=$withval])
if test "x$enable_gprof" = xyes; then
AX_CHECK_COMPILE_FLAG([-pg],[GPROF_CFLAGS="-pg"],
AC_MSG_ERROR(gprof profiling requested but not available))
AX_CHECK_LINK_FLAG([[-pg]],[GPROF_LDFLAGS="$GPROF_LDFLAGS -pg"],
AC_MSG_ERROR(gprof profiling requested but not available), [[$GPROF_LDFLAGS]])
fi
if test x$use_sanitizers != x; then
# First check if the compiler accepts flags. If an incompatible pair like
# -fsanitize=address,thread is used here, this check will fail. This will also
# fail if a bad argument is passed, e.g. -fsanitize=undefined
AX_CHECK_COMPILE_FLAG(
[[-fsanitize=$use_sanitizers]],
[[SANITIZER_CFLAGS=-fsanitize=$use_sanitizers]],
[AC_MSG_ERROR([compiler did not accept requested flags])])
# Some compilers (e.g. GCC) require additional libraries like libasan,
# libtsan, libubsan, etc. Make sure linking still works with the sanitize
# flag.
AX_CHECK_LINK_FLAG(
[[-fsanitize=$use_sanitizers]],
[[SANITIZER_LDFLAGS=-fsanitize=$use_sanitizers]],
[AC_MSG_ERROR([linker did not accept requested flags, you are missing required libraries])])
fi
AC_SUBST(GPROF_CFLAGS)
AC_SUBST(GPROF_LDFLAGS)
AC_SUBST(SANITIZER_CFLAGS)
AC_SUBST(SANITIZER_LDFLAGS)
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile src/Makefile src/include/Makefile src/test/Makefile pkgconfig/Makefile pkgconfig/libotr-ng.pc])
AC_OUTPUT
echo \
"----------------------------------------------------------------------------
Thank you for configuring libotr-ng version ${PACKAGE_VERSION}.
Configuration completed in directory '${prefix}'.
----------------------------------------------------------------------------"
echo
echo "Options used to compile and link:"
echo " sanitizers = $use_sanitizers"
echo " gprof enabled = $enable_gprof"
echo " with ctgrind = $with_ctgrind"
echo " CC = $CC"
echo " CFLAGS = $CFLAGS"
echo " LDFLAGS = $LDFLAGS"
echo