blob: 8dc47322bc1462ced62715a94025a60c90865c27 [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 Anvin (Intel)e2040292020-07-06 11:10:30 -07009dnl Mark where in config.h.in macros auto-generated by the configuration
10dnl start; this is used to generate config/unconfig.h.
11AH_BOTTOM([
12/* Begin unconfig.h */])
13
H. Peter Anvin2d894772017-03-01 12:57:46 -080014dnl Save initial CFLAGS, to see if -g -O2 came from configure or not
15pa_init_cflags="$CFLAGS"
16
H. Peter Anvin0da15492017-04-06 15:24:58 -070017dnl This prevents us from running Wine and thinking we are not
18dnl cross-compiling when in fact we are; running Wine here is at
19dnl the best very slow and doesn't buy us a single thing at all.
20WINELOADER=/dev/null
21export WINELOADER
22
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -070023dnl Get the canonical target system name
24AC_CANONICAL_HOST
25
H. Peter Anvin2d894772017-03-01 12:57:46 -080026dnl Checks for programs and enable necessary CC extensions
H. Peter Anvin2f0f9ea2008-06-08 20:53:29 -070027AC_USE_SYSTEM_EXTENSIONS
H. Peter Anvinb423c022016-02-18 11:57:53 -080028AC_SYS_LARGEFILE
H. Peter Anvin87bc6192002-04-30 20:53:16 +000029AC_PROG_CC
H. Peter Anvind338b372016-02-18 00:54:30 -080030AC_PROG_CC_STDC
H. Peter Anvin48fd1542018-06-14 19:19:09 -070031
32dnl If the user did not specify a CFLAGS default, change default
33dnl to -O0 for debugging
H. Peter Anvin0da15492017-04-06 15:24:58 -070034PA_ARG_DISABLED([optimization],
35 [compile without optimization (-O0) to help debugging],
H. Peter Anvin48fd1542018-06-14 19:19:09 -070036 [pa_no_optimize=true])
H. Peter Anvin9b935a02017-02-28 19:02:51 -080037
H. Peter Anvin (Intel)65ab3ab2020-06-30 10:14:21 -070038dnl 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 Anvin (Intel)0da8a882020-07-06 10:15:11 -070084dnl LLVM doesn't error out on invalid -W options unless this option is
85dnl specified first. Enable this so this script can actually discover
86dnl which -W options are possible for this compiler.
87PA_ADD_CFLAGS([-Werror=unknown-warning-option])
88
H. Peter Anvinb9c1ca72016-03-01 21:51:40 -080089dnl Force gcc and gcc-compatible compilers treat signed integers
90dnl as 2's complement
H. Peter Anvin8d9f5912016-02-27 00:15:13 -080091PA_ADD_CFLAGS([-fwrapv])
H. Peter Anvin87bc6192002-04-30 20:53:16 +000092
H. Peter Anvin (Intel)0da8a882020-07-06 10:15:11 -070093dnl Force clang to behave in a predictable manner, in order to make bugs
94dnl possible to track down. gcc appears to have this behavior by default.
H. Peter Anvin (Intel)0da8a882020-07-06 10:15:11 -070095PA_ADD_CFLAGS([-ftrivial-auto-var-init=zero])
96
H. Peter Anvin8b190832016-11-15 14:01:37 -080097dnl Some environments abuse __STRICT_ANSI__ to disable some
98dnl function declarations
99PA_ADD_CFLAGS([-U__STRICT_ANSI__])
100
H. Peter Anvin43e02622016-08-02 09:28:22 -0700101dnl Don't put things in common if we can avoid it. We don't want to
102dnl assume all compilers support common, and this will help find those
103dnl problems. This also works around an OSX linker problem.
104PA_ADD_CFLAGS([-fno-common])
105
H. Peter Anvin (Intel)30844a42020-07-06 12:39:14 -0700106dnl Other C features
107PA_C_TYPEOF
108
H. Peter Anvineec3b522008-06-19 11:39:23 -0700109dnl Look for programs...
H. Peter Anvina9397832013-05-17 12:02:49 -0700110AC_CHECK_PROGS(NROFF, nroff, false)
H. Peter Anvind089c222013-10-24 13:22:19 +0100111AC_CHECK_PROGS(ASCIIDOC, asciidoc, false)
112AC_CHECK_PROGS(XMLTO, xmlto, false)
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700113AC_CHECK_PROGS(XZ, xz, false)
H. Peter Anvin620515a2002-04-30 20:57:38 +0000114
H. Peter Anvind089c222013-10-24 13:22:19 +0100115dnl Check for progs needed for manpage generation
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700116MANPAGES=manpages
117AS_IF([test x$ASCIIDOC = xfalse],
118 [AC_MSG_WARN([No asciidoc package found, cannot build man pages])
119 MANPAGES='']
H. Peter Anvin0da15492017-04-06 15:24:58 -0700120)
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700121AS_IF([test x"$XMLTO" = xfalse],
122 [AC_MSG_WARN([No xmlto package found, cannot build man pages])
123 MANPAGES='']
H. Peter Anvin0da15492017-04-06 15:24:58 -0700124)
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700125AC_SUBST([MANPAGES])
126
127dnl Don't create .pdf.xz if there is no xz
128AS_IF([test x"$XZ" = xfalse],
129 [],
130 [XZFILES=xzfiles])
131AC_SUBST([XZFILES])
132
133dnl Can't create NSIS package if there is no makensis
134dnl ... but it only applies to a Windows target ...
135dnl Note: AC_CHECK_TOOLS is supposed to check for the "plain"
136dnl version of the program name, but it doesn't seem to.
137AC_ARG_WITH([nsis],
138[AS_HELP_STRING([[--with-nsis[=makensis]]],
139 [build an install .exe using NSIS on Windows hosts])],
140 [], [with_nsis=yes])
141AS_IF([test x"$MAKENSIS" = x], [],
142 [AS_IF([test x"$with_nsis" = xno], []
143 [with_nsis="$MAKENSIS"])])
144
145MAKENSIS=false
146
147AS_CASE([$host],
148 [*-win* | *-mingw*],
149 [AS_IF([test x"$with_nsis" = xno], [],
150 [NSIS=nsis
151 AS_IF([test x"$with_nsis" = xyes],
152 [AC_CHECK_TOOL(MAKENSIS_TOOL, makensis, false)
153 MAKENSIS="$MAKENSIS_TOOL"
154 AS_IF([test x"$MAKENSIS" = xfalse],
155 [AC_CHECK_PROGS(MAKENSIS_PLAIN, makensis, false)
156 MAKENSIS="$MAKENSIS_PLAIN"])
157 AS_IF([test x"$MAKENSIS" = xfalse],
158 [AC_MSG_WARN([no makensis found, cannot build installer])
159 NSIS=''])],
160 [MAKENSIS="$with_nsis"])])])
161AC_SUBST([MAKENSIS])
162AC_SUBST([NSIS])
H. Peter Anvind089c222013-10-24 13:22:19 +0100163
H. Peter Anvincc147f72016-03-08 02:06:39 -0800164dnl Check for host compiler tools
165AC_CHECK_TOOL(AR, ar)
166AC_CHECK_TOOL(RANLIB, ranlib, :)
167AC_CHECK_TOOL(STRIP, strip)
168
H. Peter Anvin87bc6192002-04-30 20:53:16 +0000169dnl Checks for header files.
170AC_HEADER_STDC
H. Peter Anvin3ef4f002016-03-08 12:14:55 -0800171AC_CHECK_HEADERS(inttypes.h)
H. Peter Anvinfe501952007-10-02 21:53:51 -0700172AC_CHECK_HEADERS(strings.h)
H. Peter Anvind338b372016-02-18 00:54:30 -0800173AC_HEADER_STDBOOL
H. Peter Anvinabd28c92016-12-20 02:29:58 -0800174AC_CHECK_HEADERS(stdnoreturn.h)
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800175AC_CHECK_HEADERS(io.h)
H. Peter Anvind81a2352016-09-21 14:03:18 -0700176AC_CHECK_HEADERS(fcntl.h)
H. Peter Anvin4627e692016-01-26 12:01:34 -0800177AC_CHECK_HEADERS(unistd.h)
H. Peter Anvind81a2352016-09-21 14:03:18 -0700178AC_CHECK_HEADERS(sys/mman.h)
H. Peter Anvin4c9132e2016-10-19 13:13:38 -0700179AC_CHECK_HEADERS(sys/types.h)
H. Peter Anvin675e7b72017-04-05 21:19:03 -0700180AC_CHECK_HEADERS(sys/stat.h)
H. Peter Anvin (Intel)5b4de522020-06-01 13:10:46 -0700181AC_CHECK_HEADERS(sys/resource.h)
H. Peter Anvin4627e692016-01-26 12:01:34 -0800182
H. Peter Anvin87bc6192002-04-30 20:53:16 +0000183dnl Checks for library functions.
H. Peter Anvinfe501952007-10-02 21:53:51 -0700184AC_CHECK_FUNCS(strcasecmp stricmp)
185AC_CHECK_FUNCS(strncasecmp strnicmp)
H. Peter Anvin73b22f52016-02-18 14:40:37 -0800186AC_CHECK_FUNCS(strsep)
H. Peter Anvin22538e22016-05-25 05:42:47 -0700187AC_CHECK_FUNCS(strnlen)
H. Peter Anvin81b62b92017-12-20 13:33:49 -0800188AC_CHECK_FUNCS(strrchrnul)
H. Peter Anvin13506202018-11-28 14:55:58 -0800189AC_CHECK_FUNCS(iscntrl)
190AC_CHECK_FUNCS(isascii)
H. Peter Anvin06f72bb2018-12-26 06:22:47 -0800191AC_CHECK_FUNCS(mempcpy)
H. Peter Anvinfe501952007-10-02 21:53:51 -0700192
H. Peter Anvin038d8612007-04-12 16:54:50 +0000193AC_CHECK_FUNCS(getuid)
194AC_CHECK_FUNCS(getgid)
H. Peter Anvin (Intel)5b4de522020-06-01 13:10:46 -0700195AC_CHECK_FUNCS(getrlimit)
H. Peter Anvin038d8612007-04-12 16:54:50 +0000196
H. Peter Anvin4627e692016-01-26 12:01:34 -0800197AC_CHECK_FUNCS(realpath)
198AC_CHECK_FUNCS(canonicalize_file_name)
199AC_CHECK_FUNCS(_fullpath)
200AC_CHECK_FUNCS(pathconf)
201
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800202AC_FUNC_FSEEKO
H. Peter Anvinec82d7a2016-02-21 21:20:45 -0800203AC_CHECK_FUNCS([_fseeki64])
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800204AC_CHECK_FUNCS([ftruncate _chsize _chsize_s])
H. Peter Anvin397c1692016-10-04 17:01:59 -0700205AC_CHECK_FUNCS([fileno _fileno])
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800206
H. Peter Anvin895a66c2017-02-23 20:34:38 -0800207AC_FUNC_MMAP
H. Peter Anvind81a2352016-09-21 14:03:18 -0700208AC_CHECK_FUNCS(getpagesize)
209AC_CHECK_FUNCS(sysconf)
210
H. Peter Anvin397c1692016-10-04 17:01:59 -0700211AC_CHECK_FUNCS([access _access faccessat])
H. Peter Anvind81a2352016-09-21 14:03:18 -0700212
H. Peter Anvine558dfd2017-04-18 16:05:22 -0700213PA_HAVE_FUNC(__builtin_expect, (1,1))
214
215dnl ilog2() building blocks
216PA_ADD_HEADERS(intrin.h)
H. Peter Anvin8d4fb262016-11-15 14:23:54 -0800217PA_HAVE_FUNC(__builtin_clz, (0U))
218PA_HAVE_FUNC(__builtin_clzl, (0UL))
219PA_HAVE_FUNC(__builtin_clzll, (0ULL))
H. Peter Anvine558dfd2017-04-18 16:05:22 -0700220PA_HAVE_FUNC(_BitScanReverse, (0))
221PA_HAVE_FUNC(_BitScanReverse64, (0))
H. Peter Anvind338b372016-02-18 00:54:30 -0800222
H. Peter Anvin81b62b92017-12-20 13:33:49 -0800223dnl Functions for which we have replacements available in stdlib/
H. Peter Anvincc147f72016-03-08 02:06:39 -0800224AC_CHECK_FUNCS([vsnprintf _vsnprintf])
225AC_CHECK_FUNCS([snprintf _snprintf])
226AC_CHECK_FUNCS([strlcpy])
H. Peter Anvin81b62b92017-12-20 13:33:49 -0800227AC_CHECK_FUNCS([strrchrnul])
H. Peter Anvind338b372016-02-18 00:54:30 -0800228
H. Peter Anvin31184292017-04-06 15:30:56 -0700229dnl These types are POSIX-specific, and Windows does it differently...
230AC_CHECK_TYPES([struct _stati64])
231AC_CHECK_TYPES([struct stat])
232AC_CHECK_FUNCS([stat _stati64])
233AC_CHECK_FUNCS([fstat _fstati64])
H. Peter Anvin (Intel)471120f2019-05-15 13:07:21 -0700234AC_CHECK_FUNCS([S_ISREG])
H. Peter Anvin31184292017-04-06 15:30:56 -0700235
H. Peter Anvinc13d31a2007-10-26 18:49:29 -0700236dnl Check for functions that might not be declared in the headers for
237dnl various idiotic reasons (mostly because of library authors
238dnl abusing the meaning of __STRICT_ANSI__)
239AC_CHECK_DECLS(strcasecmp)
240AC_CHECK_DECLS(stricmp)
241AC_CHECK_DECLS(strncasecmp)
242AC_CHECK_DECLS(strnicmp)
243AC_CHECK_DECLS(strsep)
H. Peter Anvineaa68f12009-08-10 15:56:52 -0700244AC_CHECK_DECLS(strlcpy)
H. Peter Anvin22538e22016-05-25 05:42:47 -0700245AC_CHECK_DECLS(strnlen)
H. Peter Anvin81b62b92017-12-20 13:33:49 -0800246AC_CHECK_DECLS(strrchrnul)
H. Peter Anvinc13d31a2007-10-26 18:49:29 -0700247
H. Peter Anvind81a2352016-09-21 14:03:18 -0700248dnl Check for missing types
249AC_TYPE_UINTPTR_T
250
H. Peter Anvinf13effe2017-04-10 16:10:28 -0700251dnl Documentation: should we generate an uncompressed PDF? It is
252dnl about twice as big, but it can be externally compressed (e.g. with xz)
253dnl and becomes significantly smaller than the original.
254PA_ARG_DISABLED([pdf-compression],
255 [generate an uncompressed documentation PDF],
256 [PDFOPT='-nocompress'])
257AC_SUBST([PDFOPT])
258
H. Peter Anvin8b190832016-11-15 14:01:37 -0800259dnl
H. Peter Anvin5eb528b2017-04-18 15:49:25 -0700260dnl Look for byte-swapping support...
261dnl
H. Peter Anvine5033df2017-11-29 16:04:05 -0800262PA_ADD_HEADERS(endian.h sys/endian.h machine/endian.h)
H. Peter Anvin5eb528b2017-04-18 15:49:25 -0700263PA_HAVE_FUNC(cpu_to_le16, (0))
264PA_HAVE_FUNC(cpu_to_le32, (0))
265PA_HAVE_FUNC(cpu_to_le64, (0))
266PA_HAVE_FUNC(__cpu_to_le16, (0))
267PA_HAVE_FUNC(__cpu_to_le32, (0))
268PA_HAVE_FUNC(__cpu_to_le64, (0))
269PA_HAVE_FUNC(htole16, (0))
270PA_HAVE_FUNC(htole32, (0))
271PA_HAVE_FUNC(htole64, (0))
272PA_HAVE_FUNC(__bswap_16, (0))
273PA_HAVE_FUNC(__bswap_32, (0))
274PA_HAVE_FUNC(__bswap_64, (0))
275PA_HAVE_FUNC(__builtin_bswap16, (0))
276PA_HAVE_FUNC(__builtin_bswap32, (0))
277PA_HAVE_FUNC(__builtin_bswap64, (0))
H. Peter Anvine558dfd2017-04-18 16:05:22 -0700278PA_HAVE_FUNC(_byteswap_ushort, (0))
279PA_HAVE_FUNC(_byteswap_ulong, (0))
280PA_HAVE_FUNC(_byteswap_uint64, (0))
H. Peter Anvin5eb528b2017-04-18 15:49:25 -0700281
282dnl
H. Peter Anvin (Intel)b7f24e72018-12-14 14:21:16 -0800283dnl Some rather useful gcc extensions...
H. Peter Anvine5033df2017-11-29 16:04:05 -0800284dnl
285PA_HAVE_FUNC(__builtin_constant_p, (0))
H. Peter Anvin (Intel)b7f24e72018-12-14 14:21:16 -0800286PA_HAVE_FUNC(__builtin_choose_expr, (0,1,2))
H. Peter Anvine5033df2017-11-29 16:04:05 -0800287
288dnl
H. Peter Anvin8b190832016-11-15 14:01:37 -0800289dnl Check for supported gcc attributes; some compilers (e.g. Sun CC)
290dnl support these, but don't define __GNUC__ as they don't support
291dnl some other features of gcc.
292dnl
H. Peter Anvinbc18af12017-02-23 19:22:27 -0800293PA_ADD_CFLAGS([-Werror=attributes])
H. Peter Anvin8b190832016-11-15 14:01:37 -0800294PA_FUNC_ATTRIBUTE(noreturn)
H. Peter Anvin (Intel)8b6e6bf2019-08-16 00:08:27 -0700295PA_FUNC_ATTRIBUTE(returns_nonnull,,,,,never_null)
H. Peter Anvin8b190832016-11-15 14:01:37 -0800296PA_FUNC_ATTRIBUTE(malloc)
H. Peter Anvin (Intel)8b6e6bf2019-08-16 00:08:27 -0700297PA_FUNC_ATTRIBUTE(alloc_size,[1])
298PA_FUNC_ATTRIBUTE(alloc_size,[1,2])
299PA_FUNC_ATTRIBUTE(sentinel,,, [const char *, ...], ["a","b",NULL],end_with_null)
300PA_FUNC_ATTRIBUTE(format, [printf,1,2], int, [const char *, ...], ["%d",1])
H. Peter Anvin8b190832016-11-15 14:01:37 -0800301PA_FUNC_ATTRIBUTE(const)
302PA_FUNC_ATTRIBUTE(pure)
H. Peter Anvin (Intel)8b6e6bf2019-08-16 00:08:27 -0700303PA_FUNC_ATTRIBUTE(cold,,,,,unlikely_func)
H. Peter Anvin (Intel)65ab3ab2020-06-30 10:14:21 -0700304PA_FUNC_ATTRIBUTE(unused)
H. Peter Anvinabd28c92016-12-20 02:29:58 -0800305PA_FUNC_ATTRIBUTE_ERROR
H. Peter Anvin87bc6192002-04-30 20:53:16 +0000306
Cyrill Gorcunov325768e2010-11-11 11:18:44 +0300307dnl
H. Peter Anvin53259e82017-10-11 16:47:59 -0700308dnl support function sections (if available)
Cyrill Gorcunov325768e2010-11-11 11:18:44 +0300309dnl
H. Peter Anvin (Intel)7dc5b232018-12-13 22:51:22 -0800310PA_ARG_DISABLED([sections],
Cyrill Gorcunov82746232018-12-23 17:15:41 +0300311 [do not try to compile with function/data section support],
H. Peter Anvin (Intel)7dc5b232018-12-13 22:51:22 -0800312 [],
H. Peter Anvinb0121dc2018-12-22 18:17:16 -0800313 [PA_ADD_CFLAGS([-ffunction-sections])
314 PA_ADD_CFLAGS([-fdata-sections])
315 PA_ADD_LDFLAGS([-Wl,--gc-sections])]
H. Peter Anvin (Intel)7dc5b232018-12-13 22:51:22 -0800316 )
H. Peter Anvin53259e82017-10-11 16:47:59 -0700317
H. Peter Anvin5fe847e2017-02-28 18:48:01 -0800318dnl
319dnl support LTO
320dnl
H. Peter Anvin0da15492017-04-06 15:24:58 -0700321PA_ARG_ENABLED([lto],
322 [compile with gcc-style link time optimization],
H. Peter Anvinb0121dc2018-12-22 18:17:16 -0800323 [PA_ADD_CFLAGS([-flto])
H. Peter Anvin0da15492017-04-06 15:24:58 -0700324 dnl Note: we use _PROG rather than _TOOL since we are prepending the full
325 dnl CC name which ought to already contain the host triplet if needed
326 ccbase=`echo "$CC" | awk '{ print $1; }'`
327 AC_CHECK_PROGS(CC_AR, [${ccbase}-ar], [$ac_cv_prog_AR])
328 AR="$CC_AR"
329 AC_CHECK_PROGS(CC_RANLIB, [${ccbase}-ranlib], [$ac_cv_prog_RANLIB])
330 RANLIB="$CC_RANLIB"], [])
H. Peter Anvin5fe847e2017-02-28 18:48:01 -0800331
H. Peter Anvin53259e82017-10-11 16:47:59 -0700332dnl
333dnl support sanitizers (if available)
334dnl
335PA_ARG_ENABLED([sanitizer],
336 [compile with sanitizers enabled],
337 [PA_ADD_CFLAGS([-fno-omit-frame-pointer])
H. Peter Anvinb0121dc2018-12-22 18:17:16 -0800338 PA_ADD_CFLAGS([-fsanitize=address])
339 PA_ADD_CFLAGS([-fsanitize=undefined])])
H. Peter Anvin53259e82017-10-11 16:47:59 -0700340
H. Peter Anvin7310d0b2018-05-30 11:48:00 -0700341dnl
342dnl Don't make symbols visible, there is no point and it just
H. Peter Anvin (Intel)65ab3ab2020-06-30 10:14:21 -0700343dnl makes the code slower. This mainly affects ELF.
H. Peter Anvin7310d0b2018-05-30 11:48:00 -0700344dnl
H. Peter Anvinb0121dc2018-12-22 18:17:16 -0800345PA_ADD_CFLAGS([-fvisibility=hidden])
H. Peter Anvin7310d0b2018-05-30 11:48:00 -0700346
H. Peter Anvin (Intel)65ab3ab2020-06-30 10:14:21 -0700347dnl
348dnl If we have gcc, add appropriate code cleanliness options. Do this
349dnl here at the end, because configure relies on being able to use
350dnl some very, very old C constructs.
351dnl
H. Peter Anvind338b372016-02-18 00:54:30 -0800352PA_ADD_CFLAGS([-Wall])
H. Peter Anvin (Intel)480d5e22019-08-16 00:52:26 -0700353PA_ARG_DISABLED([pedantic],
354[disable some extra paranoid compiler warnings],
355[],
356[PA_ADD_CFLAGS([-W])
357 PA_ADD_CFLAGS([-pedantic])
H. Peter Anvin (Intel)65ab3ab2020-06-30 10:14:21 -0700358 PA_ADD_CFLAGS([-Wc90-c99-compat])
359 PA_ADD_CFLAGS([-Wc99-compat])
360 PA_ADD_CFLAGS([-Wc99-extensions])
361])
H. Peter Anvin25da6ea2016-03-01 22:20:10 -0800362dnl Suppress format warning on Windows targets due to their <inttypes.h>
363PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format])
H. Peter Anvin25da6ea2016-03-01 22:20:10 -0800364PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long])
H. Peter Anvinc4e16f72018-06-02 23:46:21 -0700365dnl This is needed because we intentionally expect strncpy() to fill
366dnl in a zero-padded (not zero-terminated) buffer in several backends
367PA_ADD_CFLAGS([-Wstringop-truncation],[-Wno-stringop-truncation])
H. Peter Anvin (Intel)64b56ea2018-12-12 15:56:28 -0800368dnl This is needed because we assume 2's-completement signed arithmetic;
369dnl on compilers with gcc-like command line syntax we pass the -fwrapv
370dnl option for exactly that reason.
371PA_ADD_CFLAGS([-Wshift-negative-value],[-Wno-shift-negative-value])
372
H. Peter Anvin (Intel)65ab3ab2020-06-30 10:14:21 -0700373dnl Want to turn this on at some point...
H. Peter Anvincfd56eb2016-03-06 21:44:14 -0800374dnl PA_ADD_CFLAGS([-Wwrite-strings])
H. Peter Anvin0da15492017-04-06 15:24:58 -0700375PA_ARG_ENABLED([werror],
376 [compile with -Werror to error out on any warning],
377 [PA_ADD_CFLAGS([-Werror])],
378 [PA_ADD_CFLAGS([-Werror=implicit])
379 PA_ADD_CFLAGS([-Werror=missing-braces])
380 PA_ADD_CFLAGS([-Werror=return-type])
381 PA_ADD_CFLAGS([-Werror=trigraphs])
382 PA_ADD_CFLAGS([-Werror=pointer-arith])
383 PA_ADD_CFLAGS([-Werror=strict-prototypes])
384 PA_ADD_CFLAGS([-Werror=missing-prototypes])
385 PA_ADD_CFLAGS([-Werror=missing-declarations])
386 PA_ADD_CFLAGS([-Werror=comment])
387 PA_ADD_CFLAGS([-Werror=vla])]
388)
Ozkan Sezerec3d4262016-02-12 23:49:49 -0800389
H. Peter Anvin0c369652017-02-28 19:34:36 -0800390dnl
H. Peter Anvin99d45c82018-02-20 12:34:17 -0800391dnl On some versions of gcc, -Werror=missing-prototypes causes problems
392dnl with C99-style external inlines. Test this *after* adding the -Werror
393dnl options.
394dnl
395PA_CHECK_BAD_STDC_INLINE
396
397dnl
H. Peter Anvin0c369652017-02-28 19:34:36 -0800398dnl support ccache
399dnl
H. Peter Anvin0da15492017-04-06 15:24:58 -0700400PA_ARG_ENABLED([ccache], [compile with ccache], [CC="ccache $CC"], [])
H. Peter Anvin0c369652017-02-28 19:34:36 -0800401
H. Peter Anvin (Intel)941c75a2020-05-26 14:13:31 -0700402AC_CONFIG_FILES([Makefile doc/Makefile])
403AC_OUTPUT