/
configure.ac
327 lines (304 loc) · 11.4 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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
# Process this file with autoconf to produce a configure script.
##
# cdecl -- C gibberish translator
# configure.ac
#
# Copyright (C) 2017-2022 Paul J. Lucas
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
##
AC_INIT([cdecl],[13.0],[https://github.com/paul-j-lucas/cdecl/issues],[],[https://github.com/paul-j-lucas/cdecl])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AM_EXTRA_RECURSIVE_TARGETS([clean-coverage distclean-coverage])
# Testing feature: code coverage (disabled by default)
AC_ARG_ENABLE([coverage],
AS_HELP_STRING([--enable-coverage], [enable code coverage]),
[],
[enable_coverage=no]
)
AS_IF([test "x$enable_coverage" = xyes],
#
# When code coverage is desired, we have to set CFLAGS so it doesn't include
# -O2 (so we can add -O0 later in src/Makefile.am) before AC_PROG_CC is
# called as directed by "Autconf 5.10.3: C Compiler Characteristics":
#
# If output variable CFLAGS was not already set, set it to -g -O2 for the
# GNU C compiler .... If your package does not like this default, then
# it is acceptable to insert the line ': ${CFLAGS=""}' after AC_INIT and
# before AC_PROG_CC to select an empty default instead.
#
# There's still more to do after AC_PROG_CC is called and sets $GCC. This is
# handed below in part 2.
#
[: ${CFLAGS=""}]
)
# Checks for programs.
AC_LANG(C)
AC_PROG_CC
gl_EARLY
AX_PROG_FLEX(
[AC_DEFINE([LEX], [flex], ["flex" found])],
AS_IF([test ! -f "$srcdir/src/lexer.c"],
[AC_MSG_ERROR([required program "flex" not found])])
)
AX_PROG_BISON(
[AC_DEFINE([YACC], [bison], ["bison" found])],
AS_IF([test ! -f "$srcdir/src/parser.c"],
[AC_MSG_ERROR([required program "bison" not found])])
)
AC_PROG_INSTALL
AC_PROG_LN_S
# External dependency: readline (enabled by default)
AC_ARG_WITH([readline],
AS_HELP_STRING([--without-readline], [disable readline]),
[],
[with_readline=yes]
)
AS_IF([test "x$with_readline" != xno],
[
AC_DEFINE([WITH_READLINE], [1],
[Define to 1 if readline support is enabled.])
AS_IF([test "x$withval" != xyes],
[
CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
LDFLAGS="-L${withval}/lib ${LDFLAGS}"
]
)
]
)
# Program feature: Bison debug (disabled by default)
AC_ARG_ENABLE([bison-debug],
AS_HELP_STRING([--enable-bison-debug], [enable Bison debug output]),
[],
[enable_bison_debug=no]
)
AS_IF([test "x$enable_bison_debug" = xyes],
[AC_DEFINE([YYDEBUG], [1],
[Define to 1 if Bison debugging is enabled.])]
)
# Program feature: cdecl-debug (enabled by default)
AC_ARG_ENABLE([cdecl-debug],
AS_HELP_STRING([--disable-cdecl-debug], [disable cdecl debugging]),
[],
[enable_cdecl_debug=yes]
)
AS_IF([test "x$enable_cdecl_debug" = xyes],
[AC_DEFINE([ENABLE_CDECL_DEBUG], [1],
[Define to 1 if cdecl debugging is enabled.])]
)
# Program feature: Flex debug (disabled by default)
AC_ARG_ENABLE([flex-debug],
AS_HELP_STRING([--enable-flex-debug], [enable Flex debug output]),
[],
[enable_flex_debug=no]
)
AS_IF([test "x$enable_flex_debug" = xyes],
[AC_DEFINE([ENABLE_FLEX_DEBUG], [1],
[Define to 1 if Flex debugging is enabled.])]
)
# Program feature: term-size (enabled by default)
AC_ARG_ENABLE([term-size],
AS_HELP_STRING([--disable-term-size], [disable terminal size]),
[],
[enable_term_size=yes]
)
AS_IF([test "x$enable_term_size" = xyes],
[AC_DEFINE([ENABLE_TERM_SIZE], [1],
[Define to 1 if term-size is enabled.])]
)
# Checks for libraries.
# Checks for header files.
AS_IF([test "x$with_readline" != xno],
[
AC_CHECK_HEADERS([readline/readline.h readline/history.h], [],
[AC_MSG_ERROR([readline.h header not found; use --without-readline])]
)
]
)
AS_IF([test "x$enable_term_size" = xyes],
[
AC_CHECK_HEADERS([curses.h ncurses.h], [],
[AC_MSG_ERROR([curses library for term-size not found; use --disable-term-size])]
)
AC_CHECK_HEADERS([term.h], [], [],
[#if defined(HAVE_CURSES_H)
#include <curses.h>
#elif defined(HAVE_NCURSES_H)
#include <ncurses.h>
#endif
])
]
)
AC_HEADER_ASSERT
AC_CHECK_HEADERS([fnmatch.h])
AC_CHECK_HEADERS([getopt.h])
AC_HEADER_STDBOOL
AC_CHECK_HEADERS([pwd.h])
AC_CHECK_HEADERS([sysexits.h])
gl_INIT
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_CHECK_MEMBERS([struct passwd.pw_dir],[],[],[[#include <pwd.h>]])
PJL_COMPILE([__typeof__],[],[__typeof__(1) x __attribute__((unused)) = 1;])
# Checks for library functions.
AC_FUNC_REALLOC
AC_CHECK_FUNCS([geteuid getpwuid fmemopen strsep])
AS_IF([test "x$with_readline" != xno],
[
AC_CHECK_DECLS([rl_completion_matches],[],[],
[#include <stdio.h>
#include <readline/readline.h>
])
AC_CHECK_DECLS([RL_PROMPT_START_IGNORE],[],[],
[#include <stdio.h>
#include <readline/readline.h>
])
AC_CHECK_DECLS([rl_gnu_readline_p],[],[],
[#include <stdio.h>
#include <readline/readline.h>
])
AC_SEARCH_LIBS([readline],[readline], [],
[AC_MSG_ERROR([readline library not found; use --without-readline])]
)
AC_SEARCH_LIBS([add_history],[readline history])
]
)
AS_IF([test "x$enable_term_size" = xyes],
[
AC_SEARCH_LIBS([endwin],[curses ncurses], [],
[AC_MSG_ERROR([curses library for term-size not found; use --disable-term-size])]
)
AC_SEARCH_LIBS([tigetnum],[curses ncurses tinfo], [],
[AC_MSG_ERROR([curses library for term-size not found; use --disable-term-size])]
)
]
)
# Testing feature: Address Sanitizer (ASan)
AC_ARG_ENABLE([asan],
AS_HELP_STRING([--enable-asan],
[enable Address Sanitizer for debugging]),
[],
[enable_asan=no]
)
AS_IF([test "x$enable_asan" = xyes],
[AC_DEFINE([ENABLE_ASAN], [1],
[Define to 1 if Address Sanitizer is enabled.])]
)
# Testing feature: Memory Sanitizer (MSan)
AC_ARG_ENABLE([msan],
AS_HELP_STRING([--enable-msan],
[enable Memory Sanitizer for debugging]),
[],
[enable_msan=no]
)
AS_IF([test "x$enable_msan" = xyes],
[AC_DEFINE([ENABLE_MSAN], [1],
[Define to 1 if Memory Sanitizer is enabled.])]
)
# Testing feature: Undefined Behavior Sanitizer (UBSan)
AC_ARG_ENABLE([ubsan],
AS_HELP_STRING([--enable-ubsan],
[enable Undefined Bahavior Sanitizer for debugging]),
[],
[enable_ubsan=no]
)
AS_IF([test "x$enable_ubsan" = xyes],
[AC_DEFINE([ENABLE_UBSAN], [1],
[Define to 1 if Undefined Bahavior Sanitizer is enabled.])]
)
# Testing feature: code coverage, part 2
AS_IF([test "x$enable_coverage" = xyes],
[
AS_IF([test "x$GCC" != xyes],
[AC_MSG_ERROR([gcc is required for code coverage])])
AC_CHECK_TOOL([GCOV], [gcov], [gcov])
AS_IF([test "x$GCOV" = "x:"],
[AC_MSG_ERROR([required program "gcov" for code coverage not found])])
AC_CHECK_PROG([LCOV], [lcov], [lcov])
AS_IF([test "x$LCOV" = x],
[AC_MSG_ERROR([required program "lcov" for code coverage not found])])
AC_CHECK_PROG([GENHTML], [genhtml], [genhtml])
AS_IF([test "x$GENHTML" = x],
[AC_MSG_ERROR([required program "genhtml" for code coverage not found])])
AC_DEFINE([ENABLE_COVERAGE], [1],
[Define to 1 if code coverage is enabled.])
]
)
# Testing program: expect
AS_IF([test "x$with_readline" != xno],
[
AC_CHECK_PROG([EXPECT], [expect], [expect])
AS_IF([test "x$EXPECT" = x],
[AC_MSG_WARN([optionl program "expect" for testing autocompletion not found])])
]
)
# Makefile conditionals.
AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = xyes])
AM_CONDITIONAL([ENABLE_CDECL_DEBUG], [test "x$enable_cdecl_debug" = xyes])
AM_CONDITIONAL([ENABLE_COVERAGE], [test "x$enable_coverage" = xyes])
AM_CONDITIONAL([ENABLE_BISON_DEBUG], [test "x$enable_bison_debug" = xyes])
AM_CONDITIONAL([ENABLE_FLEX_DEBUG], [test "x$enable_flex_debug" = xyes])
AM_CONDITIONAL([ENABLE_MSAN], [test "x$enable_msan" = xyes])
AM_CONDITIONAL([ENABLE_UBSAN], [test "x$enable_ubsan" = xyes])
AM_CONDITIONAL([WITH_EXPECT], [test "x$EXPECT" != x ])
AM_CONDITIONAL([WITH_READLINE], [test "x$with_readline" != xno ])
# Miscellaneous.
AX_C___ATTRIBUTE__
# Compiler warnings.
AX_CFLAGS_WARN_ALL
AX_CHECK_COMPILE_FLAG([-Wcast-align], [CFLAGS="$CFLAGS -Wcast-align"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wcomma], [CFLAGS="$CFLAGS -Wcomma"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wconditional-type-mismatch], [CFLAGS="$CFLAGS -Wconditional-type-mismatch"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wconditional-uninitialized], [CFLAGS="$CFLAGS -Wconditional-uninitialized"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wconversion], [CFLAGS="$CFLAGS -Wconversion"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wextra], [CFLAGS="$CFLAGS -Wextra"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wfloat-equal], [CFLAGS="$CFLAGS -Wfloat-equal"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wfor-loop-analysis], [CFLAGS="$CFLAGS -Wfor-loop-analysis"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Widiomatic-parentheses], [CFLAGS="$CFLAGS -Widiomatic-parentheses"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough], [CFLAGS="$CFLAGS -Wimplicit-fallthrough"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wlogical-op-parentheses], [CFLAGS="$CFLAGS -Wlogical-op-parentheses"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wnewline-eof], [CFLAGS="$CFLAGS -Wnewline-eof"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wpedantic], [CFLAGS="$CFLAGS -Wpedantic"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wredundant-decls], [CFLAGS="$CFLAGS -Wredundant-decls"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wshadow], [CFLAGS="$CFLAGS -Wshadow"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wshift-sign-overflow], [CFLAGS="$CFLAGS -Wshift-sign-overflow"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wsign-compare], [CFLAGS="$CFLAGS -Wsign-compare"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wsign-conversion], [CFLAGS="$CFLAGS -Wsign-conversion"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wsometimes-uninitialized], [CFLAGS="$CFLAGS -Wsometimes-uninitialized"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wstring-conversion], [CFLAGS="$CFLAGS -Wstring-conversion"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wuninitialized], [CFLAGS="$CFLAGS -Wuninitialized"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wunreachable-code-break], [CFLAGS="$CFLAGS -Wunreachable-code-break"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wunreachable-code], [CFLAGS="$CFLAGS -Wunreachable-code"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wunused], [CFLAGS="$CFLAGS -Wunused"], [], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wwrite-strings], [CFLAGS="$CFLAGS -Wwrite-strings"], [], [-Werror])
# Generate files.
AH_TOP([#ifndef cdecl_config_H
#define cdecl_config_H])
AH_BOTTOM([#endif /* cdecl_config_H */])
AC_CONFIG_HEADERS([src/config.h])
AC_CONFIG_FILES([
Makefile
lib/Makefile
src/Makefile
test/Makefile
man/Makefile
man/man1/Makefile
])
AC_OUTPUT
# vim:set et sw=2 ts=2: