-
Notifications
You must be signed in to change notification settings - Fork 300
/
configure.ac
353 lines (300 loc) · 10.2 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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
dnl Process this file with autoconf 2.71 or later to produce
dnl a configure script.
AC_PREREQ([2.71])
AC_INIT
AC_CONFIG_SRCDIR([config/config.h.in])
AC_CONFIG_HEADERS([config/config.h])
AC_PREFIX_PROGRAM(nasm)
AC_CONFIG_AUX_DIR(autoconf/helpers)
dnl Mark where in config.h.in macros auto-generated by the configuration
dnl start; this is used to generate config/unconfig.h.
AH_BOTTOM([
/* Begin unconfig.h */])
dnl This prevents us from running Wine and thinking we are not
dnl cross-compiling when in fact we are; running Wine here is at
dnl the best very slow and doesn't buy us a single thing at all.
PA_CROSS_COMPILE
dnl Enable any available C extensions
PA_PROG_CC
AC_USE_SYSTEM_EXTENSIONS
PA_ADD_CPPFLAGS([-std=c17], [], [],
[PA_ADD_CPPFLAGS([-std=c11], [], [],
[PA_ADD_CPPFLAGS([-std=c99])])])
dnl Options for debugging and profiling
PA_OPTION_DEBUG
PA_OPTION_PROFILING
dnl Large files
AC_SYS_LARGEFILE
dnl Abort on panic
PA_ARG_ENABLED([panic-abort],
[call abort() on panic to trap in the debugger],
[AC_DEFINE(ABORT_ON_PANIC)])
AH_TEMPLATE(ABORT_ON_PANIC,
[Define to 1 to call abort() on panics (internal errors), for debugging.])
dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
dnl LLVM doesn't error out on invalid -W options unless this option is
dnl specified first. Enable this so this script can actually discover
dnl which -W options are possible for this compiler.
PA_ADD_CFLAGS([-Werror=unknown-warning-option])
dnl Force gcc and gcc-compatible compilers treat signed integers
dnl as 2's complement
PA_ADD_CFLAGS([-fwrapv])
dnl Force clang to behave in a predictable manner, in order to make bugs
dnl possible to track down. gcc appears to have this behavior by default.
PA_ADD_CFLAGS([-ftrivial-auto-var-init=zero])
dnl Some environments abuse __STRICT_ANSI__ to disable some
dnl function declarations
PA_ADD_CFLAGS([-U__STRICT_ANSI__])
dnl Don't put things in common if we can avoid it. We don't want to
dnl assume all compilers support common, and this will help find those
dnl problems. This also works around an OSX linker problem.
PA_ADD_CFLAGS([-fno-common])
dnl Check for library extension
PA_LIBEXT
dnl Look for programs...
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_PROG_MKDIR_P
AC_CHECK_PROGS([NROFF], nroff, false)
AC_CHECK_PROGS([ASCIIDOC], asciidoc, false)
AC_CHECK_PROGS([XMLTO], xmlto, false)
AC_CHECK_PROGS([XZ], xz, false)
dnl Check for progs needed for manpage generation
MANPAGES=manpages
AS_IF([test x$ASCIIDOC = xfalse],
[AC_MSG_WARN([No asciidoc package found, cannot build man pages])
MANPAGES='']
)
AS_IF([test x"$XMLTO" = xfalse],
[AC_MSG_WARN([No xmlto package found, cannot build man pages])
MANPAGES='']
)
AC_SUBST([MANPAGES])
dnl Don't create .pdf.xz if there is no xz
AS_IF([test x"$XZ" = xfalse],
[],
[XZFILES=xzfiles])
AC_SUBST([XZFILES])
dnl Can't create NSIS package if there is no makensis
dnl ... but it only applies to a Windows target ...
dnl Note: AC_CHECK_TOOLS is supposed to check for the "plain"
dnl version of the program name, but it doesn't seem to.
AC_ARG_WITH([nsis],
[AS_HELP_STRING([[--with-nsis[=makensis]]],
[build an install .exe using NSIS on Windows hosts])],
[], [with_nsis=yes])
AS_IF([test x"$MAKENSIS" = x], [],
[AS_IF([test x"$with_nsis" = xno], []
[with_nsis="$MAKENSIS"])])
MAKENSIS=false
AS_CASE([$host],
[*-win* | *-mingw*],
[AS_IF([test x"$with_nsis" = xno], [],
[NSIS=nsis
AS_IF([test x"$with_nsis" = xyes],
[AC_CHECK_TOOL(MAKENSIS_TOOL, makensis, false)
MAKENSIS="$MAKENSIS_TOOL"
AS_IF([test x"$MAKENSIS" = xfalse],
[AC_CHECK_PROGS(MAKENSIS_PLAIN, makensis, false)
MAKENSIS="$MAKENSIS_PLAIN"])
AS_IF([test x"$MAKENSIS" = xfalse],
[AC_MSG_WARN([no makensis found, cannot build installer])
NSIS=''])],
[MAKENSIS="$with_nsis"])])])
AC_SUBST([MAKENSIS])
AC_SUBST([NSIS])
dnl Check for host compiler tools
AC_CHECK_TOOL(AR, ar)
AC_CHECK_TOOL(RANLIB, ranlib, :)
AC_CHECK_TOOL(STRIP, strip)
dnl
dnl NOTE: the tests for header files and library functions use constructs
dnl that create warnings on modern compilers, due to lack of prototypes,
dnl etc. Therefore, do not add the -Werror options before this.
dnl
dnl Tests which may trigger warnings on some compilers
AC_C_CONST
AC_C_INLINE
AC_C_RESTRICT
dnl Checks for header files.
AC_CHECK_INCLUDES_DEFAULT
dnl Check for variadic macro support
PA_VARIADIC_MACROS
dnl Handle Windows embedded manifests
AS_CASE([$host],
[*-win* | *-mingw*],
[AC_CHECK_TOOL(WINDRES, windres, false)
AS_IF([test x"$WINDRES" != xfalse],
[AC_SUBST(MANIFEST, ['win/manifest.$(O)'])])])
PA_ADD_HEADERS(string.h)
PA_ADD_HEADERS(stdarg.h)
PA_ADD_HEADERS(inttypes.h)
AC_CHECK_HEADERS(strings.h)
AC_HEADER_STDBOOL
AC_CHECK_HEADERS(stdnoreturn.h)
AC_CHECK_HEADERS(io.h)
AC_CHECK_HEADERS(fcntl.h)
AC_CHECK_HEADERS(unistd.h)
AC_CHECK_HEADERS(sys/mman.h)
AC_CHECK_HEADERS(sys/types.h)
AC_CHECK_HEADERS(sys/stat.h)
AC_CHECK_HEADERS(sys/resource.h)
dnl Checks for library functions.
AC_CHECK_FUNCS(strcasecmp stricmp)
AC_CHECK_FUNCS(strncasecmp strnicmp)
AC_CHECK_FUNCS(strsep)
AC_CHECK_FUNCS(strnlen)
AC_CHECK_FUNCS(strrchrnul)
AC_CHECK_FUNCS(iscntrl)
AC_CHECK_FUNCS(isascii)
AC_CHECK_FUNCS(mempcpy)
AC_CHECK_FUNCS(mempset)
AC_CHECK_FUNCS(getuid)
AC_CHECK_FUNCS(getgid)
AC_CHECK_FUNCS(getrlimit)
AC_CHECK_FUNCS(realpath)
AC_CHECK_FUNCS(canonicalize_file_name)
AC_CHECK_FUNCS(_fullpath)
AC_CHECK_FUNCS(pathconf)
AC_FUNC_FSEEKO
AC_CHECK_FUNCS([_fseeki64])
AC_CHECK_FUNCS([ftruncate _chsize _chsize_s])
AC_CHECK_FUNCS([fileno _fileno])
AC_FUNC_MMAP
AC_CHECK_FUNCS(getpagesize)
AC_CHECK_FUNCS(sysconf)
AC_CHECK_FUNCS([access _access faccessat])
PA_HAVE_FUNC(__builtin_expect, (1,1))
dnl ilog2() building blocks
PA_ADD_HEADERS(intrin.h)
PA_HAVE_FUNC(__builtin_clz, (0U))
PA_HAVE_FUNC(__builtin_clzl, (0UL))
PA_HAVE_FUNC(__builtin_clzll, (0ULL))
PA_HAVE_FUNC(_BitScanReverse, (0))
PA_HAVE_FUNC(_BitScanReverse64, (0))
PA_FUNC_SNPRINTF
PA_FUNC_VSNPRINTF
AC_CHECK_FUNCS([strlcpy])
AC_CHECK_FUNCS([strrchrnul])
dnl These types are POSIX-specific, and Windows does it differently...
AC_CHECK_TYPES([struct _stati64])
AC_CHECK_TYPES([struct stat])
AC_CHECK_FUNCS([stat _stati64])
AC_CHECK_FUNCS([fstat _fstati64])
AC_CHECK_FUNCS([S_ISREG])
dnl Check for functions that might not be declared in the headers for
dnl various idiotic reasons (mostly because of library authors
dnl abusing the meaning of __STRICT_ANSI__)
AC_CHECK_DECLS(strcasecmp)
AC_CHECK_DECLS(stricmp)
AC_CHECK_DECLS(strncasecmp)
AC_CHECK_DECLS(strnicmp)
AC_CHECK_DECLS(strsep)
AC_CHECK_DECLS(strlcpy)
AC_CHECK_DECLS(strnlen)
AC_CHECK_DECLS(strrchrnul)
dnl Check for missing types
AC_TYPE_UINTPTR_T
dnl Documentation: should we generate an uncompressed PDF? It is
dnl about twice as big, but it can be externally compressed (e.g. with xz)
dnl and becomes significantly smaller than the original.
PA_ARG_DISABLED([pdf-compression],
[generate an uncompressed documentation PDF],
[PDFOPT='-nocompress'])
AC_SUBST([PDFOPT])
dnl
dnl Look for byte-swapping support...
dnl
PA_ENDIAN
dnl
dnl Some rather useful gcc extensions...
dnl
PA_HAVE_FUNC(__builtin_constant_p, (0))
PA_HAVE_FUNC(__builtin_choose_expr, (0,1,2))
dnl
dnl Check for supported gcc attributes; some compilers (e.g. Sun CC)
dnl support these, but don't define __GNUC__ as they don't support
dnl some other features of gcc.
dnl
PA_COMMON_ATTRIBUTES
dnl
dnl support function sections (if available)
dnl
PA_OPTION_GC
dnl
dnl support LTO
dnl
PA_OPTION_LTO
dnl
dnl support sanitizers (if available)
dnl
PA_OPTION_SANITIZER
dnl
dnl Don't make symbols visible, there is no point and it just
dnl makes the code slower. This mainly affects ELF.
dnl
PA_ADD_CFLAGS([-fvisibility=hidden])
dnl
dnl If we have gcc, add appropriate code cleanliness options. Do this
dnl here at the end, because configure relies on being able to use
dnl some very, very old C constructs.
dnl
PA_ADD_CFLAGS([-Wall])
PA_ARG_DISABLED([pedantic],
[disable some extra paranoid compiler warnings],
[],
[PA_ADD_CFLAGS([-W])
PA_ADD_CFLAGS([-pedantic])
])
dnl Want to turn this on at some point...
dnl PA_ADD_CFLAGS([-Wwrite-strings])
PA_ARG_ENABLED([werror],
[compile with -Werror to error out on any warning],
[PA_ADD_CFLAGS([-Werror])],
[PA_ADD_CFLAGS([-Werror=implicit])
PA_ADD_CFLAGS([-Werror=missing-braces])
PA_ADD_CFLAGS([-Werror=return-type])
PA_ADD_CFLAGS([-Werror=trigraphs])
PA_ADD_CFLAGS([-Werror=pointer-arith])
PA_ADD_CFLAGS([-Werror=comment])
PA_ADD_CFLAGS([-Werror=vla])]
)
dnl These warnings are apparently not included in -Wall -W -pedantic
dnl for some bizarre reason. They are, however, absolutely forbidden
dnl in this code base.
PA_ADD_CFLAGS([-Werror=strict-prototypes])
PA_ADD_CFLAGS([-Werror=missing-prototypes])
PA_ADD_CFLAGS([-Werror=missing-declarations])
dnl Variadic macros are used in this code, but only under explicit guard
PA_ADD_CFLAGS([-Wvariadic-macros],[-Wno-variadic-macros])
dnl Suppress format warning on Windows targets due to their <inttypes.h>
PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format])
PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long])
dnl This is needed because we intentionally expect strncpy() to fill
dnl in a zero-padded (not zero-terminated) buffer in several backends
PA_ADD_CFLAGS([-Wstringop-truncation],[-Wno-stringop-truncation])
dnl This is needed because we assume 2's-completement signed arithmetic;
dnl on compilers with gcc-like command line syntax we pass the -fwrapv
dnl option for exactly that reason.
PA_ADD_CFLAGS([-Wshift-negative-value],[-Wno-shift-negative-value])
dnl Warnings that are probabilistic based on the compiler version, and
dnl only should be used specifically when looking for opportunities to
dnl address or optimize these cases.
PA_ARG_ENABLED([suggestions],
[compile with compiler suggestion warnings enabled],
[PA_ADD_CFLAGS([-Wsuggest-attribute=pure])
PA_ADD_CFLAGS([-Wsuggest-attribute=const])
PA_ADD_CFLAGS([-Wsuggest-attribute=noreturn])
PA_ADD_CFLAGS([-Wsuggest-attribute=format])
PA_ADD_CFLAGS([-Wsuggest-attribute=cold])
PA_ADD_CFLAGS([-Wsuggest-attribute=malloc])])
dnl
dnl Test compiler features. On some compilers, this can be affected
dnl by -Werror options, so run this *after* those options are added.
dnl
PA_CHECK_BAD_STDC_INLINE
PA_C_TYPEOF
AC_CONFIG_FILES([Makefile doc/Makefile])
AC_OUTPUT