blob: 1e69c4d1a5f73ee52ca7805498ffba2f34164c1e [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 Other programs
34AC_PROG_LN_S
35AC_PROG_MAKE_SET
36AC_PROG_INSTALL
37AC_PROG_MKDIR_P
38
39pa_no_optimize=false
40
Cyrill Gorcunovfdbf7012017-07-29 16:05:36 +030041dnl Compile and link with dwarf debug
42PA_ARG_ENABLED([gdb],
43 [disable optimization and compile with extra debug information for GDB debugger],
H. Peter Anvin48fd1542018-06-14 19:19:09 -070044 [PA_ADD_CFLAGS([-ggdb3])
45 pa_no_optimize=true])
H. Peter Anvin53259e82017-10-11 16:47:59 -070046
H. Peter Anvin48fd1542018-06-14 19:19:09 -070047AS_IF([$pa_no_optimize],
48 [PA_ADD_CFLAGS([-O0])
49 PA_ADD_CFLAGS([-fno-omit-frame-pointer])])
Cyrill Gorcunovfdbf7012017-07-29 16:05:36 +030050
H. Peter Anvinefee3ea2019-02-25 21:00:43 -080051dnl Profiling
52PA_ARG_ENABLED([profiling],
53 [compile with profiling (-pg option)],
54 [PA_ADD_CFLAGS([-pg])])
55
H. Peter Anvindcbaf672017-12-20 12:06:54 -080056dnl Abort on panic
57PA_ARG_ENABLED([panic-abort],
58 [call abort() on panic to trap in the debugger],
59 [AC_DEFINE(ABORT_ON_PANIC)])
60AH_TEMPLATE(ABORT_ON_PANIC,
61[Define to 1 to call abort() on panics (internal errors), for debugging.])
62
H. Peter Anvin89c17702016-03-09 14:11:40 -080063dnl Check for library extension
64PA_LIBEXT
65
Cyrill Gorcunov7729edf2014-12-20 11:35:51 +030066dnl Checks for typedefs, structures, and compiler characteristics.
67AC_C_CONST
H. Peter Anvin03f229c2015-11-04 11:29:09 -080068AC_C_INLINE
Cyrill Gorcunov7729edf2014-12-20 11:35:51 +030069AC_C_RESTRICT
70AC_TYPE_SIZE_T
H. Peter Anvinef635882016-03-01 21:53:09 -080071AC_C_BIGENDIAN(AC_DEFINE(WORDS_BIGENDIAN),AC_DEFINE(WORDS_LITTLEENDIAN),,)
Cyrill Gorcunov7729edf2014-12-20 11:35:51 +030072AH_TEMPLATE(WORDS_BIGENDIAN,
73[Define to 1 if your processor stores words with the most significant
74byte first (like Motorola and SPARC, unlike Intel and VAX).])
75AH_TEMPLATE(WORDS_LITTLEENDIAN,
76[Define to 1 if your processor stores words with the least significant
77byte first (like Intel and VAX, unlike Motorola and SPARC).])
78
H. Peter Anvin (Intel)0da8a882020-07-06 10:15:11 -070079dnl LLVM doesn't error out on invalid -W options unless this option is
80dnl specified first. Enable this so this script can actually discover
81dnl which -W options are possible for this compiler.
82PA_ADD_CFLAGS([-Werror=unknown-warning-option])
83
84dnl Without this option, clang sometimes fail to link if LDFLAGS is
85dnl a superset of CFLAGS, which is the normal thing...
86PA_ADD_CFLAGS([-Wno-unused-command-line-argument])
87
H. Peter Anvinb9c1ca72016-03-01 21:51:40 -080088dnl Force gcc and gcc-compatible compilers treat signed integers
89dnl as 2's complement
H. Peter Anvin8d9f5912016-02-27 00:15:13 -080090PA_ADD_CFLAGS([-fwrapv])
H. Peter Anvin87bc6192002-04-30 20:53:16 +000091
H. Peter Anvin (Intel)0da8a882020-07-06 10:15:11 -070092dnl Force clang to behave in a predictable manner, in order to make bugs
93dnl possible to track down. gcc appears to have this behavior by default.
94dnl Needing the -enable-... option is kind of a bizarre thing.
95PA_ADD_CFLAGS([-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang])
96PA_ADD_CFLAGS([-ftrivial-auto-var-init=zero])
97
H. Peter Anvin8b190832016-11-15 14:01:37 -080098dnl Some environments abuse __STRICT_ANSI__ to disable some
99dnl function declarations
100PA_ADD_CFLAGS([-U__STRICT_ANSI__])
101
H. Peter Anvin43e02622016-08-02 09:28:22 -0700102dnl Don't put things in common if we can avoid it. We don't want to
103dnl assume all compilers support common, and this will help find those
104dnl problems. This also works around an OSX linker problem.
105PA_ADD_CFLAGS([-fno-common])
106
H. Peter Anvineec3b522008-06-19 11:39:23 -0700107dnl Look for programs...
H. Peter Anvina9397832013-05-17 12:02:49 -0700108AC_CHECK_PROGS(NROFF, nroff, false)
H. Peter Anvind089c222013-10-24 13:22:19 +0100109AC_CHECK_PROGS(ASCIIDOC, asciidoc, false)
110AC_CHECK_PROGS(XMLTO, xmlto, false)
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700111AC_CHECK_PROGS(XZ, xz, false)
H. Peter Anvin620515a2002-04-30 20:57:38 +0000112
H. Peter Anvind089c222013-10-24 13:22:19 +0100113dnl Check for progs needed for manpage generation
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700114MANPAGES=manpages
115AS_IF([test x$ASCIIDOC = xfalse],
116 [AC_MSG_WARN([No asciidoc package found, cannot build man pages])
117 MANPAGES='']
H. Peter Anvin0da15492017-04-06 15:24:58 -0700118)
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700119AS_IF([test x"$XMLTO" = xfalse],
120 [AC_MSG_WARN([No xmlto package found, cannot build man pages])
121 MANPAGES='']
H. Peter Anvin0da15492017-04-06 15:24:58 -0700122)
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700123AC_SUBST([MANPAGES])
124
125dnl Don't create .pdf.xz if there is no xz
126AS_IF([test x"$XZ" = xfalse],
127 [],
128 [XZFILES=xzfiles])
129AC_SUBST([XZFILES])
130
131dnl Can't create NSIS package if there is no makensis
132dnl ... but it only applies to a Windows target ...
133dnl Note: AC_CHECK_TOOLS is supposed to check for the "plain"
134dnl version of the program name, but it doesn't seem to.
135AC_ARG_WITH([nsis],
136[AS_HELP_STRING([[--with-nsis[=makensis]]],
137 [build an install .exe using NSIS on Windows hosts])],
138 [], [with_nsis=yes])
139AS_IF([test x"$MAKENSIS" = x], [],
140 [AS_IF([test x"$with_nsis" = xno], []
141 [with_nsis="$MAKENSIS"])])
142
143MAKENSIS=false
144
145AS_CASE([$host],
146 [*-win* | *-mingw*],
147 [AS_IF([test x"$with_nsis" = xno], [],
148 [NSIS=nsis
149 AS_IF([test x"$with_nsis" = xyes],
150 [AC_CHECK_TOOL(MAKENSIS_TOOL, makensis, false)
151 MAKENSIS="$MAKENSIS_TOOL"
152 AS_IF([test x"$MAKENSIS" = xfalse],
153 [AC_CHECK_PROGS(MAKENSIS_PLAIN, makensis, false)
154 MAKENSIS="$MAKENSIS_PLAIN"])
155 AS_IF([test x"$MAKENSIS" = xfalse],
156 [AC_MSG_WARN([no makensis found, cannot build installer])
157 NSIS=''])],
158 [MAKENSIS="$with_nsis"])])])
159AC_SUBST([MAKENSIS])
160AC_SUBST([NSIS])
H. Peter Anvind089c222013-10-24 13:22:19 +0100161
H. Peter Anvincc147f72016-03-08 02:06:39 -0800162dnl Check for host compiler tools
163AC_CHECK_TOOL(AR, ar)
164AC_CHECK_TOOL(RANLIB, ranlib, :)
165AC_CHECK_TOOL(STRIP, strip)
166
H. Peter Anvin87bc6192002-04-30 20:53:16 +0000167dnl Checks for header files.
168AC_HEADER_STDC
H. Peter Anvin3ef4f002016-03-08 12:14:55 -0800169AC_CHECK_HEADERS(inttypes.h)
H. Peter Anvinfe501952007-10-02 21:53:51 -0700170AC_CHECK_HEADERS(strings.h)
H. Peter Anvind338b372016-02-18 00:54:30 -0800171AC_HEADER_STDBOOL
H. Peter Anvinabd28c92016-12-20 02:29:58 -0800172AC_CHECK_HEADERS(stdnoreturn.h)
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800173AC_CHECK_HEADERS(io.h)
H. Peter Anvind81a2352016-09-21 14:03:18 -0700174AC_CHECK_HEADERS(fcntl.h)
H. Peter Anvin4627e692016-01-26 12:01:34 -0800175AC_CHECK_HEADERS(unistd.h)
H. Peter Anvind81a2352016-09-21 14:03:18 -0700176AC_CHECK_HEADERS(sys/mman.h)
H. Peter Anvin4c9132e2016-10-19 13:13:38 -0700177AC_CHECK_HEADERS(sys/types.h)
H. Peter Anvin675e7b72017-04-05 21:19:03 -0700178AC_CHECK_HEADERS(sys/stat.h)
H. Peter Anvin (Intel)5b4de522020-06-01 13:10:46 -0700179AC_CHECK_HEADERS(sys/resource.h)
H. Peter Anvin4627e692016-01-26 12:01:34 -0800180
H. Peter Anvin87bc6192002-04-30 20:53:16 +0000181dnl Checks for library functions.
H. Peter Anvinfe501952007-10-02 21:53:51 -0700182AC_CHECK_FUNCS(strcasecmp stricmp)
183AC_CHECK_FUNCS(strncasecmp strnicmp)
H. Peter Anvin73b22f52016-02-18 14:40:37 -0800184AC_CHECK_FUNCS(strsep)
H. Peter Anvin22538e22016-05-25 05:42:47 -0700185AC_CHECK_FUNCS(strnlen)
H. Peter Anvin81b62b92017-12-20 13:33:49 -0800186AC_CHECK_FUNCS(strrchrnul)
H. Peter Anvin13506202018-11-28 14:55:58 -0800187AC_CHECK_FUNCS(iscntrl)
188AC_CHECK_FUNCS(isascii)
H. Peter Anvin06f72bb2018-12-26 06:22:47 -0800189AC_CHECK_FUNCS(mempcpy)
H. Peter Anvinfe501952007-10-02 21:53:51 -0700190
H. Peter Anvin038d8612007-04-12 16:54:50 +0000191AC_CHECK_FUNCS(getuid)
192AC_CHECK_FUNCS(getgid)
H. Peter Anvin (Intel)5b4de522020-06-01 13:10:46 -0700193AC_CHECK_FUNCS(getrlimit)
H. Peter Anvin038d8612007-04-12 16:54:50 +0000194
H. Peter Anvin4627e692016-01-26 12:01:34 -0800195AC_CHECK_FUNCS(realpath)
196AC_CHECK_FUNCS(canonicalize_file_name)
197AC_CHECK_FUNCS(_fullpath)
198AC_CHECK_FUNCS(pathconf)
199
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800200AC_FUNC_FSEEKO
H. Peter Anvinec82d7a2016-02-21 21:20:45 -0800201AC_CHECK_FUNCS([_fseeki64])
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800202AC_CHECK_FUNCS([ftruncate _chsize _chsize_s])
H. Peter Anvin397c1692016-10-04 17:01:59 -0700203AC_CHECK_FUNCS([fileno _fileno])
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800204
H. Peter Anvin895a66c2017-02-23 20:34:38 -0800205AC_FUNC_MMAP
H. Peter Anvind81a2352016-09-21 14:03:18 -0700206AC_CHECK_FUNCS(getpagesize)
207AC_CHECK_FUNCS(sysconf)
208
H. Peter Anvin397c1692016-10-04 17:01:59 -0700209AC_CHECK_FUNCS([access _access faccessat])
H. Peter Anvind81a2352016-09-21 14:03:18 -0700210
H. Peter Anvine558dfd2017-04-18 16:05:22 -0700211PA_HAVE_FUNC(__builtin_expect, (1,1))
212
213dnl ilog2() building blocks
214PA_ADD_HEADERS(intrin.h)
H. Peter Anvin8d4fb262016-11-15 14:23:54 -0800215PA_HAVE_FUNC(__builtin_clz, (0U))
216PA_HAVE_FUNC(__builtin_clzl, (0UL))
217PA_HAVE_FUNC(__builtin_clzll, (0ULL))
H. Peter Anvine558dfd2017-04-18 16:05:22 -0700218PA_HAVE_FUNC(_BitScanReverse, (0))
219PA_HAVE_FUNC(_BitScanReverse64, (0))
H. Peter Anvind338b372016-02-18 00:54:30 -0800220
H. Peter Anvin81b62b92017-12-20 13:33:49 -0800221dnl Functions for which we have replacements available in stdlib/
H. Peter Anvincc147f72016-03-08 02:06:39 -0800222AC_CHECK_FUNCS([vsnprintf _vsnprintf])
223AC_CHECK_FUNCS([snprintf _snprintf])
224AC_CHECK_FUNCS([strlcpy])
H. Peter Anvin81b62b92017-12-20 13:33:49 -0800225AC_CHECK_FUNCS([strrchrnul])
H. Peter Anvind338b372016-02-18 00:54:30 -0800226
H. Peter Anvin31184292017-04-06 15:30:56 -0700227dnl These types are POSIX-specific, and Windows does it differently...
228AC_CHECK_TYPES([struct _stati64])
229AC_CHECK_TYPES([struct stat])
230AC_CHECK_FUNCS([stat _stati64])
231AC_CHECK_FUNCS([fstat _fstati64])
H. Peter Anvin (Intel)471120f2019-05-15 13:07:21 -0700232AC_CHECK_FUNCS([S_ISREG])
H. Peter Anvin31184292017-04-06 15:30:56 -0700233
H. Peter Anvinc13d31a2007-10-26 18:49:29 -0700234dnl Check for functions that might not be declared in the headers for
235dnl various idiotic reasons (mostly because of library authors
236dnl abusing the meaning of __STRICT_ANSI__)
237AC_CHECK_DECLS(strcasecmp)
238AC_CHECK_DECLS(stricmp)
239AC_CHECK_DECLS(strncasecmp)
240AC_CHECK_DECLS(strnicmp)
241AC_CHECK_DECLS(strsep)
H. Peter Anvineaa68f12009-08-10 15:56:52 -0700242AC_CHECK_DECLS(strlcpy)
H. Peter Anvin22538e22016-05-25 05:42:47 -0700243AC_CHECK_DECLS(strnlen)
H. Peter Anvin81b62b92017-12-20 13:33:49 -0800244AC_CHECK_DECLS(strrchrnul)
H. Peter Anvinc13d31a2007-10-26 18:49:29 -0700245
H. Peter Anvind81a2352016-09-21 14:03:18 -0700246dnl Check for missing types
247AC_TYPE_UINTPTR_T
248
H. Peter Anvinf13effe2017-04-10 16:10:28 -0700249dnl Documentation: should we generate an uncompressed PDF? It is
250dnl about twice as big, but it can be externally compressed (e.g. with xz)
251dnl and becomes significantly smaller than the original.
252PA_ARG_DISABLED([pdf-compression],
253 [generate an uncompressed documentation PDF],
254 [PDFOPT='-nocompress'])
255AC_SUBST([PDFOPT])
256
H. Peter Anvin8b190832016-11-15 14:01:37 -0800257dnl
H. Peter Anvin5eb528b2017-04-18 15:49:25 -0700258dnl Look for byte-swapping support...
259dnl
H. Peter Anvine5033df2017-11-29 16:04:05 -0800260PA_ADD_HEADERS(endian.h sys/endian.h machine/endian.h)
H. Peter Anvin5eb528b2017-04-18 15:49:25 -0700261PA_HAVE_FUNC(cpu_to_le16, (0))
262PA_HAVE_FUNC(cpu_to_le32, (0))
263PA_HAVE_FUNC(cpu_to_le64, (0))
264PA_HAVE_FUNC(__cpu_to_le16, (0))
265PA_HAVE_FUNC(__cpu_to_le32, (0))
266PA_HAVE_FUNC(__cpu_to_le64, (0))
267PA_HAVE_FUNC(htole16, (0))
268PA_HAVE_FUNC(htole32, (0))
269PA_HAVE_FUNC(htole64, (0))
270PA_HAVE_FUNC(__bswap_16, (0))
271PA_HAVE_FUNC(__bswap_32, (0))
272PA_HAVE_FUNC(__bswap_64, (0))
273PA_HAVE_FUNC(__builtin_bswap16, (0))
274PA_HAVE_FUNC(__builtin_bswap32, (0))
275PA_HAVE_FUNC(__builtin_bswap64, (0))
H. Peter Anvine558dfd2017-04-18 16:05:22 -0700276PA_HAVE_FUNC(_byteswap_ushort, (0))
277PA_HAVE_FUNC(_byteswap_ulong, (0))
278PA_HAVE_FUNC(_byteswap_uint64, (0))
H. Peter Anvin5eb528b2017-04-18 15:49:25 -0700279
280dnl
H. Peter Anvin (Intel)b7f24e72018-12-14 14:21:16 -0800281dnl Some rather useful gcc extensions...
H. Peter Anvine5033df2017-11-29 16:04:05 -0800282dnl
283PA_HAVE_FUNC(__builtin_constant_p, (0))
H. Peter Anvin (Intel)b7f24e72018-12-14 14:21:16 -0800284PA_HAVE_FUNC(__builtin_choose_expr, (0,1,2))
H. Peter Anvine5033df2017-11-29 16:04:05 -0800285
286dnl
H. Peter Anvin8b190832016-11-15 14:01:37 -0800287dnl Check for supported gcc attributes; some compilers (e.g. Sun CC)
288dnl support these, but don't define __GNUC__ as they don't support
289dnl some other features of gcc.
290dnl
H. Peter Anvinbc18af12017-02-23 19:22:27 -0800291PA_ADD_CFLAGS([-Werror=attributes])
H. Peter Anvin8b190832016-11-15 14:01:37 -0800292PA_FUNC_ATTRIBUTE(noreturn)
H. Peter Anvin (Intel)8b6e6bf2019-08-16 00:08:27 -0700293PA_FUNC_ATTRIBUTE(returns_nonnull,,,,,never_null)
H. Peter Anvin8b190832016-11-15 14:01:37 -0800294PA_FUNC_ATTRIBUTE(malloc)
H. Peter Anvin (Intel)8b6e6bf2019-08-16 00:08:27 -0700295PA_FUNC_ATTRIBUTE(alloc_size,[1])
296PA_FUNC_ATTRIBUTE(alloc_size,[1,2])
297PA_FUNC_ATTRIBUTE(sentinel,,, [const char *, ...], ["a","b",NULL],end_with_null)
298PA_FUNC_ATTRIBUTE(format, [printf,1,2], int, [const char *, ...], ["%d",1])
H. Peter Anvin8b190832016-11-15 14:01:37 -0800299PA_FUNC_ATTRIBUTE(const)
300PA_FUNC_ATTRIBUTE(pure)
H. Peter Anvin (Intel)8b6e6bf2019-08-16 00:08:27 -0700301PA_FUNC_ATTRIBUTE(cold,,,,,unlikely_func)
H. Peter Anvin (Intel)65ab3ab2020-06-30 10:14:21 -0700302PA_FUNC_ATTRIBUTE(unused)
H. Peter Anvinabd28c92016-12-20 02:29:58 -0800303PA_FUNC_ATTRIBUTE_ERROR
H. Peter Anvin87bc6192002-04-30 20:53:16 +0000304
Cyrill Gorcunov325768e2010-11-11 11:18:44 +0300305dnl
H. Peter Anvin53259e82017-10-11 16:47:59 -0700306dnl support function sections (if available)
Cyrill Gorcunov325768e2010-11-11 11:18:44 +0300307dnl
H. Peter Anvin (Intel)7dc5b232018-12-13 22:51:22 -0800308PA_ARG_DISABLED([sections],
Cyrill Gorcunov82746232018-12-23 17:15:41 +0300309 [do not try to compile with function/data section support],
H. Peter Anvin (Intel)7dc5b232018-12-13 22:51:22 -0800310 [],
H. Peter Anvinb0121dc2018-12-22 18:17:16 -0800311 [PA_ADD_CFLAGS([-ffunction-sections])
312 PA_ADD_CFLAGS([-fdata-sections])
313 PA_ADD_LDFLAGS([-Wl,--gc-sections])]
H. Peter Anvin (Intel)7dc5b232018-12-13 22:51:22 -0800314 )
H. Peter Anvin53259e82017-10-11 16:47:59 -0700315
H. Peter Anvin5fe847e2017-02-28 18:48:01 -0800316dnl
317dnl support LTO
318dnl
H. Peter Anvin0da15492017-04-06 15:24:58 -0700319PA_ARG_ENABLED([lto],
320 [compile with gcc-style link time optimization],
H. Peter Anvinb0121dc2018-12-22 18:17:16 -0800321 [PA_ADD_CFLAGS([-flto])
H. Peter Anvin0da15492017-04-06 15:24:58 -0700322 dnl Note: we use _PROG rather than _TOOL since we are prepending the full
323 dnl CC name which ought to already contain the host triplet if needed
324 ccbase=`echo "$CC" | awk '{ print $1; }'`
325 AC_CHECK_PROGS(CC_AR, [${ccbase}-ar], [$ac_cv_prog_AR])
326 AR="$CC_AR"
327 AC_CHECK_PROGS(CC_RANLIB, [${ccbase}-ranlib], [$ac_cv_prog_RANLIB])
328 RANLIB="$CC_RANLIB"], [])
H. Peter Anvin5fe847e2017-02-28 18:48:01 -0800329
H. Peter Anvin53259e82017-10-11 16:47:59 -0700330dnl
331dnl support sanitizers (if available)
332dnl
333PA_ARG_ENABLED([sanitizer],
334 [compile with sanitizers enabled],
335 [PA_ADD_CFLAGS([-fno-omit-frame-pointer])
H. Peter Anvinb0121dc2018-12-22 18:17:16 -0800336 PA_ADD_CFLAGS([-fsanitize=address])
337 PA_ADD_CFLAGS([-fsanitize=undefined])])
H. Peter Anvin53259e82017-10-11 16:47:59 -0700338
H. Peter Anvin7310d0b2018-05-30 11:48:00 -0700339dnl
340dnl Don't make symbols visible, there is no point and it just
H. Peter Anvin (Intel)65ab3ab2020-06-30 10:14:21 -0700341dnl makes the code slower. This mainly affects ELF.
H. Peter Anvin7310d0b2018-05-30 11:48:00 -0700342dnl
H. Peter Anvinb0121dc2018-12-22 18:17:16 -0800343PA_ADD_CFLAGS([-fvisibility=hidden])
H. Peter Anvin7310d0b2018-05-30 11:48:00 -0700344
H. Peter Anvin (Intel)65ab3ab2020-06-30 10:14:21 -0700345dnl
346dnl If we have gcc, add appropriate code cleanliness options. Do this
347dnl here at the end, because configure relies on being able to use
348dnl some very, very old C constructs.
349dnl
H. Peter Anvind338b372016-02-18 00:54:30 -0800350PA_ADD_CFLAGS([-Wall])
H. Peter Anvin (Intel)480d5e22019-08-16 00:52:26 -0700351PA_ARG_DISABLED([pedantic],
352[disable some extra paranoid compiler warnings],
353[],
354[PA_ADD_CFLAGS([-W])
355 PA_ADD_CFLAGS([-pedantic])
H. Peter Anvin (Intel)65ab3ab2020-06-30 10:14:21 -0700356 PA_ADD_CFLAGS([-Wc90-c99-compat])
357 PA_ADD_CFLAGS([-Wc99-compat])
358 PA_ADD_CFLAGS([-Wc99-extensions])
359])
H. Peter Anvin25da6ea2016-03-01 22:20:10 -0800360dnl Suppress format warning on Windows targets due to their <inttypes.h>
361PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format])
H. Peter Anvin25da6ea2016-03-01 22:20:10 -0800362PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long])
H. Peter Anvinc4e16f72018-06-02 23:46:21 -0700363dnl This is needed because we intentionally expect strncpy() to fill
364dnl in a zero-padded (not zero-terminated) buffer in several backends
365PA_ADD_CFLAGS([-Wstringop-truncation],[-Wno-stringop-truncation])
H. Peter Anvin (Intel)64b56ea2018-12-12 15:56:28 -0800366dnl This is needed because we assume 2's-completement signed arithmetic;
367dnl on compilers with gcc-like command line syntax we pass the -fwrapv
368dnl option for exactly that reason.
369PA_ADD_CFLAGS([-Wshift-negative-value],[-Wno-shift-negative-value])
370
H. Peter Anvin (Intel)65ab3ab2020-06-30 10:14:21 -0700371dnl Want to turn this on at some point...
H. Peter Anvincfd56eb2016-03-06 21:44:14 -0800372dnl PA_ADD_CFLAGS([-Wwrite-strings])
H. Peter Anvin0da15492017-04-06 15:24:58 -0700373PA_ARG_ENABLED([werror],
374 [compile with -Werror to error out on any warning],
375 [PA_ADD_CFLAGS([-Werror])],
376 [PA_ADD_CFLAGS([-Werror=implicit])
377 PA_ADD_CFLAGS([-Werror=missing-braces])
378 PA_ADD_CFLAGS([-Werror=return-type])
379 PA_ADD_CFLAGS([-Werror=trigraphs])
380 PA_ADD_CFLAGS([-Werror=pointer-arith])
381 PA_ADD_CFLAGS([-Werror=strict-prototypes])
382 PA_ADD_CFLAGS([-Werror=missing-prototypes])
383 PA_ADD_CFLAGS([-Werror=missing-declarations])
384 PA_ADD_CFLAGS([-Werror=comment])
385 PA_ADD_CFLAGS([-Werror=vla])]
386)
Ozkan Sezerec3d4262016-02-12 23:49:49 -0800387
H. Peter Anvin0c369652017-02-28 19:34:36 -0800388dnl
H. Peter Anvin99d45c82018-02-20 12:34:17 -0800389dnl On some versions of gcc, -Werror=missing-prototypes causes problems
390dnl with C99-style external inlines. Test this *after* adding the -Werror
391dnl options.
392dnl
393PA_CHECK_BAD_STDC_INLINE
394
395dnl
H. Peter Anvin0c369652017-02-28 19:34:36 -0800396dnl support ccache
397dnl
H. Peter Anvin0da15492017-04-06 15:24:58 -0700398PA_ARG_ENABLED([ccache], [compile with ccache], [CC="ccache $CC"], [])
H. Peter Anvin0c369652017-02-28 19:34:36 -0800399
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700400AC_CONFIG_FILES([Makefile doc/Makefile])
401AC_OUTPUT