blob: 777b364b7a8d17e7afaea72c35a2298248530e05 [file] [log] [blame]
H. Peter Anvincae5d062017-11-08 10:22:10 -08001dnl Process this file with autoconf 2.69 or later to produce
H. Peter Anvin1170eb62002-05-19 02:26:38 +00002dnl a configure script.
H. Peter Anvincae5d062017-11-08 10:22:10 -08003AC_PREREQ(2.69)
H. Peter Anvin97ea4ad2019-10-03 21:32:08 -07004AC_INIT([config/config.h.in])
5AC_CONFIG_HEADERS([config/config.h])
H. Peter Anvin87bc6192002-04-30 20:53:16 +00006AC_PREFIX_PROGRAM(nasm)
H. Peter Anvin0bddd0f2019-02-22 01:13:52 -08007AC_CONFIG_AUX_DIR(autoconf/helpers)
H. Peter Anvin87bc6192002-04-30 20:53:16 +00008
H. Peter Anvin2d894772017-03-01 12:57:46 -08009dnl Save initial CFLAGS, to see if -g -O2 came from configure or not
10pa_init_cflags="$CFLAGS"
11
H. Peter Anvin0da15492017-04-06 15:24:58 -070012dnl This prevents us from running Wine and thinking we are not
13dnl cross-compiling when in fact we are; running Wine here is at
14dnl the best very slow and doesn't buy us a single thing at all.
15WINELOADER=/dev/null
16export WINELOADER
17
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -070018dnl Get the canonical target system name
19AC_CANONICAL_HOST
20
H. Peter Anvin2d894772017-03-01 12:57:46 -080021dnl Checks for programs and enable necessary CC extensions
H. Peter Anvin2f0f9ea2008-06-08 20:53:29 -070022AC_USE_SYSTEM_EXTENSIONS
H. Peter Anvinb423c022016-02-18 11:57:53 -080023AC_SYS_LARGEFILE
H. Peter Anvin87bc6192002-04-30 20:53:16 +000024AC_PROG_CC
H. Peter Anvind338b372016-02-18 00:54:30 -080025AC_PROG_CC_STDC
H. Peter Anvin87bc6192002-04-30 20:53:16 +000026AC_PROG_LN_S
27AC_PROG_MAKE_SET
H. Peter Anvin87bc6192002-04-30 20:53:16 +000028AC_PROG_INSTALL
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -070029AC_PROG_MKDIR_P
H. Peter Anvin87bc6192002-04-30 20:53:16 +000030
H. Peter Anvin48fd1542018-06-14 19:19:09 -070031pa_no_optimize=false
32
33dnl If the user did not specify a CFLAGS default, change default
34dnl to -O0 for debugging
H. Peter Anvin0da15492017-04-06 15:24:58 -070035PA_ARG_DISABLED([optimization],
36 [compile without optimization (-O0) to help debugging],
H. Peter Anvin48fd1542018-06-14 19:19:09 -070037 [pa_no_optimize=true])
H. Peter Anvin9b935a02017-02-28 19:02:51 -080038
Cyrill Gorcunovfdbf7012017-07-29 16:05:36 +030039dnl Compile and link with dwarf debug
40PA_ARG_ENABLED([gdb],
41 [disable optimization and compile with extra debug information for GDB debugger],
H. Peter Anvin48fd1542018-06-14 19:19:09 -070042 [PA_ADD_CFLAGS([-ggdb3])
43 pa_no_optimize=true])
H. Peter Anvin53259e82017-10-11 16:47:59 -070044
H. Peter Anvin48fd1542018-06-14 19:19:09 -070045AS_IF([$pa_no_optimize],
46 [PA_ADD_CFLAGS([-O0])
47 PA_ADD_CFLAGS([-fno-omit-frame-pointer])])
Cyrill Gorcunovfdbf7012017-07-29 16:05:36 +030048
H. Peter Anvinefee3ea2019-02-25 21:00:43 -080049dnl Profiling
50PA_ARG_ENABLED([profiling],
51 [compile with profiling (-pg option)],
52 [PA_ADD_CFLAGS([-pg])])
53
H. Peter Anvindcbaf672017-12-20 12:06:54 -080054dnl Abort on panic
55PA_ARG_ENABLED([panic-abort],
56 [call abort() on panic to trap in the debugger],
57 [AC_DEFINE(ABORT_ON_PANIC)])
58AH_TEMPLATE(ABORT_ON_PANIC,
59[Define to 1 to call abort() on panics (internal errors), for debugging.])
60
H. Peter Anvin89c17702016-03-09 14:11:40 -080061dnl Check for library extension
62PA_LIBEXT
63
Cyrill Gorcunov7729edf2014-12-20 11:35:51 +030064dnl Checks for typedefs, structures, and compiler characteristics.
65AC_C_CONST
H. Peter Anvin03f229c2015-11-04 11:29:09 -080066AC_C_INLINE
Cyrill Gorcunov7729edf2014-12-20 11:35:51 +030067AC_C_RESTRICT
68AC_TYPE_SIZE_T
H. Peter Anvinef635882016-03-01 21:53:09 -080069AC_C_BIGENDIAN(AC_DEFINE(WORDS_BIGENDIAN),AC_DEFINE(WORDS_LITTLEENDIAN),,)
Cyrill Gorcunov7729edf2014-12-20 11:35:51 +030070AH_TEMPLATE(WORDS_BIGENDIAN,
71[Define to 1 if your processor stores words with the most significant
72byte first (like Motorola and SPARC, unlike Intel and VAX).])
73AH_TEMPLATE(WORDS_LITTLEENDIAN,
74[Define to 1 if your processor stores words with the least significant
75byte first (like Intel and VAX, unlike Motorola and SPARC).])
76
H. Peter Anvinb9c1ca72016-03-01 21:51:40 -080077dnl Force gcc and gcc-compatible compilers treat signed integers
78dnl as 2's complement
H. Peter Anvin8d9f5912016-02-27 00:15:13 -080079PA_ADD_CFLAGS([-fwrapv])
H. Peter Anvin87bc6192002-04-30 20:53:16 +000080
H. Peter Anvin8b190832016-11-15 14:01:37 -080081dnl Some environments abuse __STRICT_ANSI__ to disable some
82dnl function declarations
83PA_ADD_CFLAGS([-U__STRICT_ANSI__])
84
H. Peter Anvin43e02622016-08-02 09:28:22 -070085dnl Don't put things in common if we can avoid it. We don't want to
86dnl assume all compilers support common, and this will help find those
87dnl problems. This also works around an OSX linker problem.
88PA_ADD_CFLAGS([-fno-common])
89
H. Peter Anvineec3b522008-06-19 11:39:23 -070090dnl Look for programs...
H. Peter Anvina9397832013-05-17 12:02:49 -070091AC_CHECK_PROGS(NROFF, nroff, false)
H. Peter Anvind089c222013-10-24 13:22:19 +010092AC_CHECK_PROGS(ASCIIDOC, asciidoc, false)
93AC_CHECK_PROGS(XMLTO, xmlto, false)
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -070094AC_CHECK_PROGS(XZ, xz, false)
H. Peter Anvin620515a2002-04-30 20:57:38 +000095
H. Peter Anvind089c222013-10-24 13:22:19 +010096dnl Check for progs needed for manpage generation
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -070097MANPAGES=manpages
98AS_IF([test x$ASCIIDOC = xfalse],
99 [AC_MSG_WARN([No asciidoc package found, cannot build man pages])
100 MANPAGES='']
H. Peter Anvin0da15492017-04-06 15:24:58 -0700101)
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700102AS_IF([test x"$XMLTO" = xfalse],
103 [AC_MSG_WARN([No xmlto package found, cannot build man pages])
104 MANPAGES='']
H. Peter Anvin0da15492017-04-06 15:24:58 -0700105)
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700106AC_SUBST([MANPAGES])
107
108dnl Don't create .pdf.xz if there is no xz
109AS_IF([test x"$XZ" = xfalse],
110 [],
111 [XZFILES=xzfiles])
112AC_SUBST([XZFILES])
113
114dnl Can't create NSIS package if there is no makensis
115dnl ... but it only applies to a Windows target ...
116dnl Note: AC_CHECK_TOOLS is supposed to check for the "plain"
117dnl version of the program name, but it doesn't seem to.
118AC_ARG_WITH([nsis],
119[AS_HELP_STRING([[--with-nsis[=makensis]]],
120 [build an install .exe using NSIS on Windows hosts])],
121 [], [with_nsis=yes])
122AS_IF([test x"$MAKENSIS" = x], [],
123 [AS_IF([test x"$with_nsis" = xno], []
124 [with_nsis="$MAKENSIS"])])
125
126MAKENSIS=false
127
128AS_CASE([$host],
129 [*-win* | *-mingw*],
130 [AS_IF([test x"$with_nsis" = xno], [],
131 [NSIS=nsis
132 AS_IF([test x"$with_nsis" = xyes],
133 [AC_CHECK_TOOL(MAKENSIS_TOOL, makensis, false)
134 MAKENSIS="$MAKENSIS_TOOL"
135 AS_IF([test x"$MAKENSIS" = xfalse],
136 [AC_CHECK_PROGS(MAKENSIS_PLAIN, makensis, false)
137 MAKENSIS="$MAKENSIS_PLAIN"])
138 AS_IF([test x"$MAKENSIS" = xfalse],
139 [AC_MSG_WARN([no makensis found, cannot build installer])
140 NSIS=''])],
141 [MAKENSIS="$with_nsis"])])])
142AC_SUBST([MAKENSIS])
143AC_SUBST([NSIS])
H. Peter Anvind089c222013-10-24 13:22:19 +0100144
H. Peter Anvincc147f72016-03-08 02:06:39 -0800145dnl Check for host compiler tools
146AC_CHECK_TOOL(AR, ar)
147AC_CHECK_TOOL(RANLIB, ranlib, :)
148AC_CHECK_TOOL(STRIP, strip)
149
H. Peter Anvin87bc6192002-04-30 20:53:16 +0000150dnl Checks for header files.
151AC_HEADER_STDC
H. Peter Anvin3ef4f002016-03-08 12:14:55 -0800152AC_CHECK_HEADERS(inttypes.h)
H. Peter Anvinfe501952007-10-02 21:53:51 -0700153AC_CHECK_HEADERS(strings.h)
H. Peter Anvind338b372016-02-18 00:54:30 -0800154AC_HEADER_STDBOOL
H. Peter Anvinabd28c92016-12-20 02:29:58 -0800155AC_CHECK_HEADERS(stdnoreturn.h)
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800156AC_CHECK_HEADERS(io.h)
H. Peter Anvind81a2352016-09-21 14:03:18 -0700157AC_CHECK_HEADERS(fcntl.h)
H. Peter Anvin4627e692016-01-26 12:01:34 -0800158AC_CHECK_HEADERS(unistd.h)
H. Peter Anvind81a2352016-09-21 14:03:18 -0700159AC_CHECK_HEADERS(sys/mman.h)
H. Peter Anvin4c9132e2016-10-19 13:13:38 -0700160AC_CHECK_HEADERS(sys/types.h)
H. Peter Anvin675e7b72017-04-05 21:19:03 -0700161AC_CHECK_HEADERS(sys/stat.h)
H. Peter Anvin4627e692016-01-26 12:01:34 -0800162
H. Peter Anvin87bc6192002-04-30 20:53:16 +0000163dnl Checks for library functions.
H. Peter Anvinfe501952007-10-02 21:53:51 -0700164AC_CHECK_FUNCS(strcasecmp stricmp)
165AC_CHECK_FUNCS(strncasecmp strnicmp)
H. Peter Anvin73b22f52016-02-18 14:40:37 -0800166AC_CHECK_FUNCS(strsep)
H. Peter Anvin22538e22016-05-25 05:42:47 -0700167AC_CHECK_FUNCS(strnlen)
H. Peter Anvin81b62b92017-12-20 13:33:49 -0800168AC_CHECK_FUNCS(strrchrnul)
H. Peter Anvin13506202018-11-28 14:55:58 -0800169AC_CHECK_FUNCS(iscntrl)
170AC_CHECK_FUNCS(isascii)
H. Peter Anvin06f72bb2018-12-26 06:22:47 -0800171AC_CHECK_FUNCS(mempcpy)
H. Peter Anvinfe501952007-10-02 21:53:51 -0700172
H. Peter Anvin038d8612007-04-12 16:54:50 +0000173AC_CHECK_FUNCS(getuid)
174AC_CHECK_FUNCS(getgid)
175
H. Peter Anvin4627e692016-01-26 12:01:34 -0800176AC_CHECK_FUNCS(realpath)
177AC_CHECK_FUNCS(canonicalize_file_name)
178AC_CHECK_FUNCS(_fullpath)
179AC_CHECK_FUNCS(pathconf)
180
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800181AC_FUNC_FSEEKO
H. Peter Anvinec82d7a2016-02-21 21:20:45 -0800182AC_CHECK_FUNCS([_fseeki64])
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800183AC_CHECK_FUNCS([ftruncate _chsize _chsize_s])
H. Peter Anvin397c1692016-10-04 17:01:59 -0700184AC_CHECK_FUNCS([fileno _fileno])
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800185
H. Peter Anvin895a66c2017-02-23 20:34:38 -0800186AC_FUNC_MMAP
H. Peter Anvind81a2352016-09-21 14:03:18 -0700187AC_CHECK_FUNCS(getpagesize)
188AC_CHECK_FUNCS(sysconf)
189
H. Peter Anvin397c1692016-10-04 17:01:59 -0700190AC_CHECK_FUNCS([access _access faccessat])
H. Peter Anvind81a2352016-09-21 14:03:18 -0700191
H. Peter Anvine558dfd2017-04-18 16:05:22 -0700192PA_HAVE_FUNC(__builtin_expect, (1,1))
193
194dnl ilog2() building blocks
195PA_ADD_HEADERS(intrin.h)
H. Peter Anvin8d4fb262016-11-15 14:23:54 -0800196PA_HAVE_FUNC(__builtin_clz, (0U))
197PA_HAVE_FUNC(__builtin_clzl, (0UL))
198PA_HAVE_FUNC(__builtin_clzll, (0ULL))
H. Peter Anvine558dfd2017-04-18 16:05:22 -0700199PA_HAVE_FUNC(_BitScanReverse, (0))
200PA_HAVE_FUNC(_BitScanReverse64, (0))
H. Peter Anvind338b372016-02-18 00:54:30 -0800201
H. Peter Anvin81b62b92017-12-20 13:33:49 -0800202dnl Functions for which we have replacements available in stdlib/
H. Peter Anvincc147f72016-03-08 02:06:39 -0800203AC_CHECK_FUNCS([vsnprintf _vsnprintf])
204AC_CHECK_FUNCS([snprintf _snprintf])
205AC_CHECK_FUNCS([strlcpy])
H. Peter Anvin81b62b92017-12-20 13:33:49 -0800206AC_CHECK_FUNCS([strrchrnul])
H. Peter Anvind338b372016-02-18 00:54:30 -0800207
H. Peter Anvin31184292017-04-06 15:30:56 -0700208dnl These types are POSIX-specific, and Windows does it differently...
209AC_CHECK_TYPES([struct _stati64])
210AC_CHECK_TYPES([struct stat])
211AC_CHECK_FUNCS([stat _stati64])
212AC_CHECK_FUNCS([fstat _fstati64])
H. Peter Anvin (Intel)471120f2019-05-15 13:07:21 -0700213AC_CHECK_FUNCS([S_ISREG])
H. Peter Anvin31184292017-04-06 15:30:56 -0700214
H. Peter Anvinc13d31a2007-10-26 18:49:29 -0700215dnl Check for functions that might not be declared in the headers for
216dnl various idiotic reasons (mostly because of library authors
217dnl abusing the meaning of __STRICT_ANSI__)
218AC_CHECK_DECLS(strcasecmp)
219AC_CHECK_DECLS(stricmp)
220AC_CHECK_DECLS(strncasecmp)
221AC_CHECK_DECLS(strnicmp)
222AC_CHECK_DECLS(strsep)
H. Peter Anvineaa68f12009-08-10 15:56:52 -0700223AC_CHECK_DECLS(strlcpy)
H. Peter Anvin22538e22016-05-25 05:42:47 -0700224AC_CHECK_DECLS(strnlen)
H. Peter Anvin81b62b92017-12-20 13:33:49 -0800225AC_CHECK_DECLS(strrchrnul)
H. Peter Anvinc13d31a2007-10-26 18:49:29 -0700226
H. Peter Anvind81a2352016-09-21 14:03:18 -0700227dnl Check for missing types
228AC_TYPE_UINTPTR_T
229
H. Peter Anvinf13effe2017-04-10 16:10:28 -0700230dnl Documentation: should we generate an uncompressed PDF? It is
231dnl about twice as big, but it can be externally compressed (e.g. with xz)
232dnl and becomes significantly smaller than the original.
233PA_ARG_DISABLED([pdf-compression],
234 [generate an uncompressed documentation PDF],
235 [PDFOPT='-nocompress'])
236AC_SUBST([PDFOPT])
237
H. Peter Anvin8b190832016-11-15 14:01:37 -0800238dnl
H. Peter Anvin5eb528b2017-04-18 15:49:25 -0700239dnl Look for byte-swapping support...
240dnl
H. Peter Anvine5033df2017-11-29 16:04:05 -0800241PA_ADD_HEADERS(endian.h sys/endian.h machine/endian.h)
H. Peter Anvin5eb528b2017-04-18 15:49:25 -0700242PA_HAVE_FUNC(cpu_to_le16, (0))
243PA_HAVE_FUNC(cpu_to_le32, (0))
244PA_HAVE_FUNC(cpu_to_le64, (0))
245PA_HAVE_FUNC(__cpu_to_le16, (0))
246PA_HAVE_FUNC(__cpu_to_le32, (0))
247PA_HAVE_FUNC(__cpu_to_le64, (0))
248PA_HAVE_FUNC(htole16, (0))
249PA_HAVE_FUNC(htole32, (0))
250PA_HAVE_FUNC(htole64, (0))
251PA_HAVE_FUNC(__bswap_16, (0))
252PA_HAVE_FUNC(__bswap_32, (0))
253PA_HAVE_FUNC(__bswap_64, (0))
254PA_HAVE_FUNC(__builtin_bswap16, (0))
255PA_HAVE_FUNC(__builtin_bswap32, (0))
256PA_HAVE_FUNC(__builtin_bswap64, (0))
H. Peter Anvine558dfd2017-04-18 16:05:22 -0700257PA_HAVE_FUNC(_byteswap_ushort, (0))
258PA_HAVE_FUNC(_byteswap_ulong, (0))
259PA_HAVE_FUNC(_byteswap_uint64, (0))
H. Peter Anvin5eb528b2017-04-18 15:49:25 -0700260
261dnl
H. Peter Anvin (Intel)b7f24e72018-12-14 14:21:16 -0800262dnl Some rather useful gcc extensions...
H. Peter Anvine5033df2017-11-29 16:04:05 -0800263dnl
264PA_HAVE_FUNC(__builtin_constant_p, (0))
H. Peter Anvin (Intel)b7f24e72018-12-14 14:21:16 -0800265PA_HAVE_FUNC(__builtin_choose_expr, (0,1,2))
H. Peter Anvine5033df2017-11-29 16:04:05 -0800266
267dnl
H. Peter Anvin8b190832016-11-15 14:01:37 -0800268dnl Check for supported gcc attributes; some compilers (e.g. Sun CC)
269dnl support these, but don't define __GNUC__ as they don't support
270dnl some other features of gcc.
271dnl
H. Peter Anvinbc18af12017-02-23 19:22:27 -0800272PA_ADD_CFLAGS([-Werror=attributes])
H. Peter Anvin8b190832016-11-15 14:01:37 -0800273PA_FUNC_ATTRIBUTE(noreturn)
H. Peter Anvin (Intel)8b6e6bf2019-08-16 00:08:27 -0700274PA_FUNC_ATTRIBUTE(returns_nonnull,,,,,never_null)
H. Peter Anvin8b190832016-11-15 14:01:37 -0800275PA_FUNC_ATTRIBUTE(malloc)
H. Peter Anvin (Intel)8b6e6bf2019-08-16 00:08:27 -0700276PA_FUNC_ATTRIBUTE(alloc_size,[1])
277PA_FUNC_ATTRIBUTE(alloc_size,[1,2])
278PA_FUNC_ATTRIBUTE(sentinel,,, [const char *, ...], ["a","b",NULL],end_with_null)
279PA_FUNC_ATTRIBUTE(format, [printf,1,2], int, [const char *, ...], ["%d",1])
H. Peter Anvin8b190832016-11-15 14:01:37 -0800280PA_FUNC_ATTRIBUTE(const)
281PA_FUNC_ATTRIBUTE(pure)
H. Peter Anvin (Intel)8b6e6bf2019-08-16 00:08:27 -0700282PA_FUNC_ATTRIBUTE(cold,,,,,unlikely_func)
H. Peter Anvinabd28c92016-12-20 02:29:58 -0800283PA_FUNC_ATTRIBUTE_ERROR
H. Peter Anvin87bc6192002-04-30 20:53:16 +0000284
Cyrill Gorcunov325768e2010-11-11 11:18:44 +0300285dnl
H. Peter Anvin53259e82017-10-11 16:47:59 -0700286dnl support function sections (if available)
Cyrill Gorcunov325768e2010-11-11 11:18:44 +0300287dnl
H. Peter Anvin (Intel)7dc5b232018-12-13 22:51:22 -0800288PA_ARG_DISABLED([sections],
Cyrill Gorcunov82746232018-12-23 17:15:41 +0300289 [do not try to compile with function/data section support],
H. Peter Anvin (Intel)7dc5b232018-12-13 22:51:22 -0800290 [],
H. Peter Anvinb0121dc2018-12-22 18:17:16 -0800291 [PA_ADD_CFLAGS([-ffunction-sections])
292 PA_ADD_CFLAGS([-fdata-sections])
293 PA_ADD_LDFLAGS([-Wl,--gc-sections])]
H. Peter Anvin (Intel)7dc5b232018-12-13 22:51:22 -0800294 )
H. Peter Anvin53259e82017-10-11 16:47:59 -0700295
H. Peter Anvin5fe847e2017-02-28 18:48:01 -0800296dnl
297dnl support LTO
298dnl
H. Peter Anvin0da15492017-04-06 15:24:58 -0700299PA_ARG_ENABLED([lto],
300 [compile with gcc-style link time optimization],
H. Peter Anvinb0121dc2018-12-22 18:17:16 -0800301 [PA_ADD_CFLAGS([-flto])
H. Peter Anvin0da15492017-04-06 15:24:58 -0700302 dnl Note: we use _PROG rather than _TOOL since we are prepending the full
303 dnl CC name which ought to already contain the host triplet if needed
304 ccbase=`echo "$CC" | awk '{ print $1; }'`
305 AC_CHECK_PROGS(CC_AR, [${ccbase}-ar], [$ac_cv_prog_AR])
306 AR="$CC_AR"
307 AC_CHECK_PROGS(CC_RANLIB, [${ccbase}-ranlib], [$ac_cv_prog_RANLIB])
308 RANLIB="$CC_RANLIB"], [])
H. Peter Anvin5fe847e2017-02-28 18:48:01 -0800309
H. Peter Anvin53259e82017-10-11 16:47:59 -0700310dnl
311dnl support sanitizers (if available)
312dnl
313PA_ARG_ENABLED([sanitizer],
314 [compile with sanitizers enabled],
315 [PA_ADD_CFLAGS([-fno-omit-frame-pointer])
H. Peter Anvinb0121dc2018-12-22 18:17:16 -0800316 PA_ADD_CFLAGS([-fsanitize=address])
317 PA_ADD_CFLAGS([-fsanitize=undefined])])
H. Peter Anvin53259e82017-10-11 16:47:59 -0700318
H. Peter Anvin7310d0b2018-05-30 11:48:00 -0700319dnl
320dnl Don't make symbols visible, there is no point and it just
321dnl makes the code slower.
322dnl
H. Peter Anvinb0121dc2018-12-22 18:17:16 -0800323PA_ADD_CFLAGS([-fvisibility=hidden])
H. Peter Anvin7310d0b2018-05-30 11:48:00 -0700324
H. Peter Anvinb9c1ca72016-03-01 21:51:40 -0800325dnl If we have gcc, add appropriate code cleanliness options
H. Peter Anvind338b372016-02-18 00:54:30 -0800326PA_ADD_CFLAGS([-Wall])
H. Peter Anvin (Intel)480d5e22019-08-16 00:52:26 -0700327PA_ARG_DISABLED([pedantic],
328[disable some extra paranoid compiler warnings],
329[],
330[PA_ADD_CFLAGS([-W])
331 PA_ADD_CFLAGS([-pedantic])
332 PA_ADD_CFLAGS([-Wc90-c99-compat])])
H. Peter Anvinc9fd7b22016-05-16 21:35:48 -0700333dnl LLVM doesn't error out on invalid -W options unless this option is
334dnl specified first. Enable this so this script can actually discover
335dnl which -W options are possible for this compiler.
336PA_ADD_CFLAGS([-Werror=unknown-warning-option])
H. Peter Anvin25da6ea2016-03-01 22:20:10 -0800337dnl Suppress format warning on Windows targets due to their <inttypes.h>
338PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format])
H. Peter Anvin25da6ea2016-03-01 22:20:10 -0800339PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long])
H. Peter Anvinc4e16f72018-06-02 23:46:21 -0700340dnl This is needed because we intentionally expect strncpy() to fill
341dnl in a zero-padded (not zero-terminated) buffer in several backends
342PA_ADD_CFLAGS([-Wstringop-truncation],[-Wno-stringop-truncation])
H. Peter Anvin (Intel)64b56ea2018-12-12 15:56:28 -0800343dnl This is needed because we assume 2's-completement signed arithmetic;
344dnl on compilers with gcc-like command line syntax we pass the -fwrapv
345dnl option for exactly that reason.
346PA_ADD_CFLAGS([-Wshift-negative-value],[-Wno-shift-negative-value])
347
H. Peter Anvincfd56eb2016-03-06 21:44:14 -0800348dnl PA_ADD_CFLAGS([-Wwrite-strings])
H. Peter Anvin0da15492017-04-06 15:24:58 -0700349PA_ARG_ENABLED([werror],
350 [compile with -Werror to error out on any warning],
351 [PA_ADD_CFLAGS([-Werror])],
352 [PA_ADD_CFLAGS([-Werror=implicit])
353 PA_ADD_CFLAGS([-Werror=missing-braces])
354 PA_ADD_CFLAGS([-Werror=return-type])
355 PA_ADD_CFLAGS([-Werror=trigraphs])
356 PA_ADD_CFLAGS([-Werror=pointer-arith])
357 PA_ADD_CFLAGS([-Werror=strict-prototypes])
358 PA_ADD_CFLAGS([-Werror=missing-prototypes])
359 PA_ADD_CFLAGS([-Werror=missing-declarations])
360 PA_ADD_CFLAGS([-Werror=comment])
361 PA_ADD_CFLAGS([-Werror=vla])]
362)
Ozkan Sezerec3d4262016-02-12 23:49:49 -0800363
H. Peter Anvin0c369652017-02-28 19:34:36 -0800364dnl
H. Peter Anvin99d45c82018-02-20 12:34:17 -0800365dnl On some versions of gcc, -Werror=missing-prototypes causes problems
366dnl with C99-style external inlines. Test this *after* adding the -Werror
367dnl options.
368dnl
369PA_CHECK_BAD_STDC_INLINE
370
371dnl
H. Peter Anvin0c369652017-02-28 19:34:36 -0800372dnl support ccache
373dnl
H. Peter Anvin0da15492017-04-06 15:24:58 -0700374PA_ARG_ENABLED([ccache], [compile with ccache], [CC="ccache $CC"], [])
H. Peter Anvin0c369652017-02-28 19:34:36 -0800375
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700376AC_CONFIG_FILES([Makefile doc/Makefile])
377AC_OUTPUT