blob: d9d4583734c46da2e806d77d6e3fdcb57c0f66f5 [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 Anvin48fd1542018-06-14 19:19:09 -070026
27dnl If the user did not specify a CFLAGS default, change default
28dnl to -O0 for debugging
H. Peter Anvin0da15492017-04-06 15:24:58 -070029PA_ARG_DISABLED([optimization],
30 [compile without optimization (-O0) to help debugging],
H. Peter Anvin48fd1542018-06-14 19:19:09 -070031 [pa_no_optimize=true])
H. Peter Anvin9b935a02017-02-28 19:02:51 -080032
H. Peter Anvin (Intel)65ab3ab2020-06-30 10:14:21 -070033dnl LLVM doesn't error out on invalid -W options unless this option is
34dnl specified first. Enable this so this script can actually discover
35dnl which -W options are possible for this compiler.
36PA_ADD_CFLAGS([-Werror=unknown-warning-option])
37
38dnl Other programs
39AC_PROG_LN_S
40AC_PROG_MAKE_SET
41AC_PROG_INSTALL
42AC_PROG_MKDIR_P
43
44pa_no_optimize=false
45
Cyrill Gorcunovfdbf7012017-07-29 16:05:36 +030046dnl Compile and link with dwarf debug
47PA_ARG_ENABLED([gdb],
48 [disable optimization and compile with extra debug information for GDB debugger],
H. Peter Anvin48fd1542018-06-14 19:19:09 -070049 [PA_ADD_CFLAGS([-ggdb3])
50 pa_no_optimize=true])
H. Peter Anvin53259e82017-10-11 16:47:59 -070051
H. Peter Anvin48fd1542018-06-14 19:19:09 -070052AS_IF([$pa_no_optimize],
53 [PA_ADD_CFLAGS([-O0])
54 PA_ADD_CFLAGS([-fno-omit-frame-pointer])])
Cyrill Gorcunovfdbf7012017-07-29 16:05:36 +030055
H. Peter Anvinefee3ea2019-02-25 21:00:43 -080056dnl Profiling
57PA_ARG_ENABLED([profiling],
58 [compile with profiling (-pg option)],
59 [PA_ADD_CFLAGS([-pg])])
60
H. Peter Anvindcbaf672017-12-20 12:06:54 -080061dnl Abort on panic
62PA_ARG_ENABLED([panic-abort],
63 [call abort() on panic to trap in the debugger],
64 [AC_DEFINE(ABORT_ON_PANIC)])
65AH_TEMPLATE(ABORT_ON_PANIC,
66[Define to 1 to call abort() on panics (internal errors), for debugging.])
67
H. Peter Anvin89c17702016-03-09 14:11:40 -080068dnl Check for library extension
69PA_LIBEXT
70
Cyrill Gorcunov7729edf2014-12-20 11:35:51 +030071dnl Checks for typedefs, structures, and compiler characteristics.
72AC_C_CONST
H. Peter Anvin03f229c2015-11-04 11:29:09 -080073AC_C_INLINE
Cyrill Gorcunov7729edf2014-12-20 11:35:51 +030074AC_C_RESTRICT
75AC_TYPE_SIZE_T
H. Peter Anvinef635882016-03-01 21:53:09 -080076AC_C_BIGENDIAN(AC_DEFINE(WORDS_BIGENDIAN),AC_DEFINE(WORDS_LITTLEENDIAN),,)
Cyrill Gorcunov7729edf2014-12-20 11:35:51 +030077AH_TEMPLATE(WORDS_BIGENDIAN,
78[Define to 1 if your processor stores words with the most significant
79byte first (like Motorola and SPARC, unlike Intel and VAX).])
80AH_TEMPLATE(WORDS_LITTLEENDIAN,
81[Define to 1 if your processor stores words with the least significant
82byte first (like Intel and VAX, unlike Motorola and SPARC).])
83
H. Peter Anvinb9c1ca72016-03-01 21:51:40 -080084dnl Force gcc and gcc-compatible compilers treat signed integers
85dnl as 2's complement
H. Peter Anvin8d9f5912016-02-27 00:15:13 -080086PA_ADD_CFLAGS([-fwrapv])
H. Peter Anvin87bc6192002-04-30 20:53:16 +000087
H. Peter Anvin8b190832016-11-15 14:01:37 -080088dnl Some environments abuse __STRICT_ANSI__ to disable some
89dnl function declarations
90PA_ADD_CFLAGS([-U__STRICT_ANSI__])
91
H. Peter Anvin43e02622016-08-02 09:28:22 -070092dnl Don't put things in common if we can avoid it. We don't want to
93dnl assume all compilers support common, and this will help find those
94dnl problems. This also works around an OSX linker problem.
95PA_ADD_CFLAGS([-fno-common])
96
H. Peter Anvineec3b522008-06-19 11:39:23 -070097dnl Look for programs...
H. Peter Anvina9397832013-05-17 12:02:49 -070098AC_CHECK_PROGS(NROFF, nroff, false)
H. Peter Anvind089c222013-10-24 13:22:19 +010099AC_CHECK_PROGS(ASCIIDOC, asciidoc, false)
100AC_CHECK_PROGS(XMLTO, xmlto, false)
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700101AC_CHECK_PROGS(XZ, xz, false)
H. Peter Anvin620515a2002-04-30 20:57:38 +0000102
H. Peter Anvind089c222013-10-24 13:22:19 +0100103dnl Check for progs needed for manpage generation
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700104MANPAGES=manpages
105AS_IF([test x$ASCIIDOC = xfalse],
106 [AC_MSG_WARN([No asciidoc package found, cannot build man pages])
107 MANPAGES='']
H. Peter Anvin0da15492017-04-06 15:24:58 -0700108)
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700109AS_IF([test x"$XMLTO" = xfalse],
110 [AC_MSG_WARN([No xmlto package found, cannot build man pages])
111 MANPAGES='']
H. Peter Anvin0da15492017-04-06 15:24:58 -0700112)
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700113AC_SUBST([MANPAGES])
114
115dnl Don't create .pdf.xz if there is no xz
116AS_IF([test x"$XZ" = xfalse],
117 [],
118 [XZFILES=xzfiles])
119AC_SUBST([XZFILES])
120
121dnl Can't create NSIS package if there is no makensis
122dnl ... but it only applies to a Windows target ...
123dnl Note: AC_CHECK_TOOLS is supposed to check for the "plain"
124dnl version of the program name, but it doesn't seem to.
125AC_ARG_WITH([nsis],
126[AS_HELP_STRING([[--with-nsis[=makensis]]],
127 [build an install .exe using NSIS on Windows hosts])],
128 [], [with_nsis=yes])
129AS_IF([test x"$MAKENSIS" = x], [],
130 [AS_IF([test x"$with_nsis" = xno], []
131 [with_nsis="$MAKENSIS"])])
132
133MAKENSIS=false
134
135AS_CASE([$host],
136 [*-win* | *-mingw*],
137 [AS_IF([test x"$with_nsis" = xno], [],
138 [NSIS=nsis
139 AS_IF([test x"$with_nsis" = xyes],
140 [AC_CHECK_TOOL(MAKENSIS_TOOL, makensis, false)
141 MAKENSIS="$MAKENSIS_TOOL"
142 AS_IF([test x"$MAKENSIS" = xfalse],
143 [AC_CHECK_PROGS(MAKENSIS_PLAIN, makensis, false)
144 MAKENSIS="$MAKENSIS_PLAIN"])
145 AS_IF([test x"$MAKENSIS" = xfalse],
146 [AC_MSG_WARN([no makensis found, cannot build installer])
147 NSIS=''])],
148 [MAKENSIS="$with_nsis"])])])
149AC_SUBST([MAKENSIS])
150AC_SUBST([NSIS])
H. Peter Anvind089c222013-10-24 13:22:19 +0100151
H. Peter Anvincc147f72016-03-08 02:06:39 -0800152dnl Check for host compiler tools
153AC_CHECK_TOOL(AR, ar)
154AC_CHECK_TOOL(RANLIB, ranlib, :)
155AC_CHECK_TOOL(STRIP, strip)
156
H. Peter Anvin87bc6192002-04-30 20:53:16 +0000157dnl Checks for header files.
158AC_HEADER_STDC
H. Peter Anvin3ef4f002016-03-08 12:14:55 -0800159AC_CHECK_HEADERS(inttypes.h)
H. Peter Anvinfe501952007-10-02 21:53:51 -0700160AC_CHECK_HEADERS(strings.h)
H. Peter Anvind338b372016-02-18 00:54:30 -0800161AC_HEADER_STDBOOL
H. Peter Anvinabd28c92016-12-20 02:29:58 -0800162AC_CHECK_HEADERS(stdnoreturn.h)
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800163AC_CHECK_HEADERS(io.h)
H. Peter Anvind81a2352016-09-21 14:03:18 -0700164AC_CHECK_HEADERS(fcntl.h)
H. Peter Anvin4627e692016-01-26 12:01:34 -0800165AC_CHECK_HEADERS(unistd.h)
H. Peter Anvind81a2352016-09-21 14:03:18 -0700166AC_CHECK_HEADERS(sys/mman.h)
H. Peter Anvin4c9132e2016-10-19 13:13:38 -0700167AC_CHECK_HEADERS(sys/types.h)
H. Peter Anvin675e7b72017-04-05 21:19:03 -0700168AC_CHECK_HEADERS(sys/stat.h)
H. Peter Anvin (Intel)5b4de522020-06-01 13:10:46 -0700169AC_CHECK_HEADERS(sys/resource.h)
H. Peter Anvin4627e692016-01-26 12:01:34 -0800170
H. Peter Anvin87bc6192002-04-30 20:53:16 +0000171dnl Checks for library functions.
H. Peter Anvinfe501952007-10-02 21:53:51 -0700172AC_CHECK_FUNCS(strcasecmp stricmp)
173AC_CHECK_FUNCS(strncasecmp strnicmp)
H. Peter Anvin73b22f52016-02-18 14:40:37 -0800174AC_CHECK_FUNCS(strsep)
H. Peter Anvin22538e22016-05-25 05:42:47 -0700175AC_CHECK_FUNCS(strnlen)
H. Peter Anvin81b62b92017-12-20 13:33:49 -0800176AC_CHECK_FUNCS(strrchrnul)
H. Peter Anvin13506202018-11-28 14:55:58 -0800177AC_CHECK_FUNCS(iscntrl)
178AC_CHECK_FUNCS(isascii)
H. Peter Anvin06f72bb2018-12-26 06:22:47 -0800179AC_CHECK_FUNCS(mempcpy)
H. Peter Anvinfe501952007-10-02 21:53:51 -0700180
H. Peter Anvin038d8612007-04-12 16:54:50 +0000181AC_CHECK_FUNCS(getuid)
182AC_CHECK_FUNCS(getgid)
H. Peter Anvin (Intel)5b4de522020-06-01 13:10:46 -0700183AC_CHECK_FUNCS(getrlimit)
H. Peter Anvin038d8612007-04-12 16:54:50 +0000184
H. Peter Anvin4627e692016-01-26 12:01:34 -0800185AC_CHECK_FUNCS(realpath)
186AC_CHECK_FUNCS(canonicalize_file_name)
187AC_CHECK_FUNCS(_fullpath)
188AC_CHECK_FUNCS(pathconf)
189
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800190AC_FUNC_FSEEKO
H. Peter Anvinec82d7a2016-02-21 21:20:45 -0800191AC_CHECK_FUNCS([_fseeki64])
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800192AC_CHECK_FUNCS([ftruncate _chsize _chsize_s])
H. Peter Anvin397c1692016-10-04 17:01:59 -0700193AC_CHECK_FUNCS([fileno _fileno])
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800194
H. Peter Anvin895a66c2017-02-23 20:34:38 -0800195AC_FUNC_MMAP
H. Peter Anvind81a2352016-09-21 14:03:18 -0700196AC_CHECK_FUNCS(getpagesize)
197AC_CHECK_FUNCS(sysconf)
198
H. Peter Anvin397c1692016-10-04 17:01:59 -0700199AC_CHECK_FUNCS([access _access faccessat])
H. Peter Anvind81a2352016-09-21 14:03:18 -0700200
H. Peter Anvine558dfd2017-04-18 16:05:22 -0700201PA_HAVE_FUNC(__builtin_expect, (1,1))
202
203dnl ilog2() building blocks
204PA_ADD_HEADERS(intrin.h)
H. Peter Anvin8d4fb262016-11-15 14:23:54 -0800205PA_HAVE_FUNC(__builtin_clz, (0U))
206PA_HAVE_FUNC(__builtin_clzl, (0UL))
207PA_HAVE_FUNC(__builtin_clzll, (0ULL))
H. Peter Anvine558dfd2017-04-18 16:05:22 -0700208PA_HAVE_FUNC(_BitScanReverse, (0))
209PA_HAVE_FUNC(_BitScanReverse64, (0))
H. Peter Anvind338b372016-02-18 00:54:30 -0800210
H. Peter Anvin81b62b92017-12-20 13:33:49 -0800211dnl Functions for which we have replacements available in stdlib/
H. Peter Anvincc147f72016-03-08 02:06:39 -0800212AC_CHECK_FUNCS([vsnprintf _vsnprintf])
213AC_CHECK_FUNCS([snprintf _snprintf])
214AC_CHECK_FUNCS([strlcpy])
H. Peter Anvin81b62b92017-12-20 13:33:49 -0800215AC_CHECK_FUNCS([strrchrnul])
H. Peter Anvind338b372016-02-18 00:54:30 -0800216
H. Peter Anvin31184292017-04-06 15:30:56 -0700217dnl These types are POSIX-specific, and Windows does it differently...
218AC_CHECK_TYPES([struct _stati64])
219AC_CHECK_TYPES([struct stat])
220AC_CHECK_FUNCS([stat _stati64])
221AC_CHECK_FUNCS([fstat _fstati64])
H. Peter Anvin (Intel)471120f2019-05-15 13:07:21 -0700222AC_CHECK_FUNCS([S_ISREG])
H. Peter Anvin31184292017-04-06 15:30:56 -0700223
H. Peter Anvinc13d31a2007-10-26 18:49:29 -0700224dnl Check for functions that might not be declared in the headers for
225dnl various idiotic reasons (mostly because of library authors
226dnl abusing the meaning of __STRICT_ANSI__)
227AC_CHECK_DECLS(strcasecmp)
228AC_CHECK_DECLS(stricmp)
229AC_CHECK_DECLS(strncasecmp)
230AC_CHECK_DECLS(strnicmp)
231AC_CHECK_DECLS(strsep)
H. Peter Anvineaa68f12009-08-10 15:56:52 -0700232AC_CHECK_DECLS(strlcpy)
H. Peter Anvin22538e22016-05-25 05:42:47 -0700233AC_CHECK_DECLS(strnlen)
H. Peter Anvin81b62b92017-12-20 13:33:49 -0800234AC_CHECK_DECLS(strrchrnul)
H. Peter Anvinc13d31a2007-10-26 18:49:29 -0700235
H. Peter Anvind81a2352016-09-21 14:03:18 -0700236dnl Check for missing types
237AC_TYPE_UINTPTR_T
238
H. Peter Anvinf13effe2017-04-10 16:10:28 -0700239dnl Documentation: should we generate an uncompressed PDF? It is
240dnl about twice as big, but it can be externally compressed (e.g. with xz)
241dnl and becomes significantly smaller than the original.
242PA_ARG_DISABLED([pdf-compression],
243 [generate an uncompressed documentation PDF],
244 [PDFOPT='-nocompress'])
245AC_SUBST([PDFOPT])
246
H. Peter Anvin8b190832016-11-15 14:01:37 -0800247dnl
H. Peter Anvin5eb528b2017-04-18 15:49:25 -0700248dnl Look for byte-swapping support...
249dnl
H. Peter Anvine5033df2017-11-29 16:04:05 -0800250PA_ADD_HEADERS(endian.h sys/endian.h machine/endian.h)
H. Peter Anvin5eb528b2017-04-18 15:49:25 -0700251PA_HAVE_FUNC(cpu_to_le16, (0))
252PA_HAVE_FUNC(cpu_to_le32, (0))
253PA_HAVE_FUNC(cpu_to_le64, (0))
254PA_HAVE_FUNC(__cpu_to_le16, (0))
255PA_HAVE_FUNC(__cpu_to_le32, (0))
256PA_HAVE_FUNC(__cpu_to_le64, (0))
257PA_HAVE_FUNC(htole16, (0))
258PA_HAVE_FUNC(htole32, (0))
259PA_HAVE_FUNC(htole64, (0))
260PA_HAVE_FUNC(__bswap_16, (0))
261PA_HAVE_FUNC(__bswap_32, (0))
262PA_HAVE_FUNC(__bswap_64, (0))
263PA_HAVE_FUNC(__builtin_bswap16, (0))
264PA_HAVE_FUNC(__builtin_bswap32, (0))
265PA_HAVE_FUNC(__builtin_bswap64, (0))
H. Peter Anvine558dfd2017-04-18 16:05:22 -0700266PA_HAVE_FUNC(_byteswap_ushort, (0))
267PA_HAVE_FUNC(_byteswap_ulong, (0))
268PA_HAVE_FUNC(_byteswap_uint64, (0))
H. Peter Anvin5eb528b2017-04-18 15:49:25 -0700269
270dnl
H. Peter Anvin (Intel)b7f24e72018-12-14 14:21:16 -0800271dnl Some rather useful gcc extensions...
H. Peter Anvine5033df2017-11-29 16:04:05 -0800272dnl
273PA_HAVE_FUNC(__builtin_constant_p, (0))
H. Peter Anvin (Intel)b7f24e72018-12-14 14:21:16 -0800274PA_HAVE_FUNC(__builtin_choose_expr, (0,1,2))
H. Peter Anvine5033df2017-11-29 16:04:05 -0800275
276dnl
H. Peter Anvin8b190832016-11-15 14:01:37 -0800277dnl Check for supported gcc attributes; some compilers (e.g. Sun CC)
278dnl support these, but don't define __GNUC__ as they don't support
279dnl some other features of gcc.
280dnl
H. Peter Anvinbc18af12017-02-23 19:22:27 -0800281PA_ADD_CFLAGS([-Werror=attributes])
H. Peter Anvin8b190832016-11-15 14:01:37 -0800282PA_FUNC_ATTRIBUTE(noreturn)
H. Peter Anvin (Intel)8b6e6bf2019-08-16 00:08:27 -0700283PA_FUNC_ATTRIBUTE(returns_nonnull,,,,,never_null)
H. Peter Anvin8b190832016-11-15 14:01:37 -0800284PA_FUNC_ATTRIBUTE(malloc)
H. Peter Anvin (Intel)8b6e6bf2019-08-16 00:08:27 -0700285PA_FUNC_ATTRIBUTE(alloc_size,[1])
286PA_FUNC_ATTRIBUTE(alloc_size,[1,2])
287PA_FUNC_ATTRIBUTE(sentinel,,, [const char *, ...], ["a","b",NULL],end_with_null)
288PA_FUNC_ATTRIBUTE(format, [printf,1,2], int, [const char *, ...], ["%d",1])
H. Peter Anvin8b190832016-11-15 14:01:37 -0800289PA_FUNC_ATTRIBUTE(const)
290PA_FUNC_ATTRIBUTE(pure)
H. Peter Anvin (Intel)8b6e6bf2019-08-16 00:08:27 -0700291PA_FUNC_ATTRIBUTE(cold,,,,,unlikely_func)
H. Peter Anvin (Intel)65ab3ab2020-06-30 10:14:21 -0700292PA_FUNC_ATTRIBUTE(unused)
H. Peter Anvinabd28c92016-12-20 02:29:58 -0800293PA_FUNC_ATTRIBUTE_ERROR
H. Peter Anvin87bc6192002-04-30 20:53:16 +0000294
Cyrill Gorcunov325768e2010-11-11 11:18:44 +0300295dnl
H. Peter Anvin53259e82017-10-11 16:47:59 -0700296dnl support function sections (if available)
Cyrill Gorcunov325768e2010-11-11 11:18:44 +0300297dnl
H. Peter Anvin (Intel)7dc5b232018-12-13 22:51:22 -0800298PA_ARG_DISABLED([sections],
Cyrill Gorcunov82746232018-12-23 17:15:41 +0300299 [do not try to compile with function/data section support],
H. Peter Anvin (Intel)7dc5b232018-12-13 22:51:22 -0800300 [],
H. Peter Anvinb0121dc2018-12-22 18:17:16 -0800301 [PA_ADD_CFLAGS([-ffunction-sections])
302 PA_ADD_CFLAGS([-fdata-sections])
303 PA_ADD_LDFLAGS([-Wl,--gc-sections])]
H. Peter Anvin (Intel)7dc5b232018-12-13 22:51:22 -0800304 )
H. Peter Anvin53259e82017-10-11 16:47:59 -0700305
H. Peter Anvin5fe847e2017-02-28 18:48:01 -0800306dnl
307dnl support LTO
308dnl
H. Peter Anvin0da15492017-04-06 15:24:58 -0700309PA_ARG_ENABLED([lto],
310 [compile with gcc-style link time optimization],
H. Peter Anvinb0121dc2018-12-22 18:17:16 -0800311 [PA_ADD_CFLAGS([-flto])
H. Peter Anvin0da15492017-04-06 15:24:58 -0700312 dnl Note: we use _PROG rather than _TOOL since we are prepending the full
313 dnl CC name which ought to already contain the host triplet if needed
314 ccbase=`echo "$CC" | awk '{ print $1; }'`
315 AC_CHECK_PROGS(CC_AR, [${ccbase}-ar], [$ac_cv_prog_AR])
316 AR="$CC_AR"
317 AC_CHECK_PROGS(CC_RANLIB, [${ccbase}-ranlib], [$ac_cv_prog_RANLIB])
318 RANLIB="$CC_RANLIB"], [])
H. Peter Anvin5fe847e2017-02-28 18:48:01 -0800319
H. Peter Anvin53259e82017-10-11 16:47:59 -0700320dnl
321dnl support sanitizers (if available)
322dnl
323PA_ARG_ENABLED([sanitizer],
324 [compile with sanitizers enabled],
325 [PA_ADD_CFLAGS([-fno-omit-frame-pointer])
H. Peter Anvinb0121dc2018-12-22 18:17:16 -0800326 PA_ADD_CFLAGS([-fsanitize=address])
327 PA_ADD_CFLAGS([-fsanitize=undefined])])
H. Peter Anvin53259e82017-10-11 16:47:59 -0700328
H. Peter Anvin7310d0b2018-05-30 11:48:00 -0700329dnl
330dnl Don't make symbols visible, there is no point and it just
H. Peter Anvin (Intel)65ab3ab2020-06-30 10:14:21 -0700331dnl makes the code slower. This mainly affects ELF.
H. Peter Anvin7310d0b2018-05-30 11:48:00 -0700332dnl
H. Peter Anvinb0121dc2018-12-22 18:17:16 -0800333PA_ADD_CFLAGS([-fvisibility=hidden])
H. Peter Anvin7310d0b2018-05-30 11:48:00 -0700334
H. Peter Anvin (Intel)65ab3ab2020-06-30 10:14:21 -0700335dnl
336dnl If we have gcc, add appropriate code cleanliness options. Do this
337dnl here at the end, because configure relies on being able to use
338dnl some very, very old C constructs.
339dnl
H. Peter Anvind338b372016-02-18 00:54:30 -0800340PA_ADD_CFLAGS([-Wall])
H. Peter Anvin (Intel)480d5e22019-08-16 00:52:26 -0700341PA_ARG_DISABLED([pedantic],
342[disable some extra paranoid compiler warnings],
343[],
344[PA_ADD_CFLAGS([-W])
345 PA_ADD_CFLAGS([-pedantic])
H. Peter Anvin (Intel)65ab3ab2020-06-30 10:14:21 -0700346 PA_ADD_CFLAGS([-Wc90-c99-compat])
347 PA_ADD_CFLAGS([-Wc99-compat])
348 PA_ADD_CFLAGS([-Wc99-extensions])
349])
H. Peter Anvin25da6ea2016-03-01 22:20:10 -0800350dnl Suppress format warning on Windows targets due to their <inttypes.h>
351PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format])
H. Peter Anvin25da6ea2016-03-01 22:20:10 -0800352PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long])
H. Peter Anvinc4e16f72018-06-02 23:46:21 -0700353dnl This is needed because we intentionally expect strncpy() to fill
354dnl in a zero-padded (not zero-terminated) buffer in several backends
355PA_ADD_CFLAGS([-Wstringop-truncation],[-Wno-stringop-truncation])
H. Peter Anvin (Intel)64b56ea2018-12-12 15:56:28 -0800356dnl This is needed because we assume 2's-completement signed arithmetic;
357dnl on compilers with gcc-like command line syntax we pass the -fwrapv
358dnl option for exactly that reason.
359PA_ADD_CFLAGS([-Wshift-negative-value],[-Wno-shift-negative-value])
360
H. Peter Anvin (Intel)65ab3ab2020-06-30 10:14:21 -0700361dnl Want to turn this on at some point...
H. Peter Anvincfd56eb2016-03-06 21:44:14 -0800362dnl PA_ADD_CFLAGS([-Wwrite-strings])
H. Peter Anvin0da15492017-04-06 15:24:58 -0700363PA_ARG_ENABLED([werror],
364 [compile with -Werror to error out on any warning],
365 [PA_ADD_CFLAGS([-Werror])],
366 [PA_ADD_CFLAGS([-Werror=implicit])
367 PA_ADD_CFLAGS([-Werror=missing-braces])
368 PA_ADD_CFLAGS([-Werror=return-type])
369 PA_ADD_CFLAGS([-Werror=trigraphs])
370 PA_ADD_CFLAGS([-Werror=pointer-arith])
371 PA_ADD_CFLAGS([-Werror=strict-prototypes])
372 PA_ADD_CFLAGS([-Werror=missing-prototypes])
373 PA_ADD_CFLAGS([-Werror=missing-declarations])
374 PA_ADD_CFLAGS([-Werror=comment])
375 PA_ADD_CFLAGS([-Werror=vla])]
376)
Ozkan Sezerec3d4262016-02-12 23:49:49 -0800377
H. Peter Anvin0c369652017-02-28 19:34:36 -0800378dnl
H. Peter Anvin99d45c82018-02-20 12:34:17 -0800379dnl On some versions of gcc, -Werror=missing-prototypes causes problems
380dnl with C99-style external inlines. Test this *after* adding the -Werror
381dnl options.
382dnl
383PA_CHECK_BAD_STDC_INLINE
384
385dnl
H. Peter Anvin0c369652017-02-28 19:34:36 -0800386dnl support ccache
387dnl
H. Peter Anvin0da15492017-04-06 15:24:58 -0700388PA_ARG_ENABLED([ccache], [compile with ccache], [CC="ccache $CC"], [])
H. Peter Anvin0c369652017-02-28 19:34:36 -0800389
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700390AC_CONFIG_FILES([Makefile doc/Makefile])
391AC_OUTPUT