H. Peter Anvin | cae5d06 | 2017-11-08 10:22:10 -0800 | [diff] [blame] | 1 | dnl Process this file with autoconf 2.69 or later to produce |
H. Peter Anvin | 1170eb6 | 2002-05-19 02:26:38 +0000 | [diff] [blame] | 2 | dnl a configure script. |
H. Peter Anvin | cae5d06 | 2017-11-08 10:22:10 -0800 | [diff] [blame] | 3 | AC_PREREQ(2.69) |
H. Peter Anvin | 97ea4ad | 2019-10-03 21:32:08 -0700 | [diff] [blame^] | 4 | AC_INIT([config/config.h.in]) |
| 5 | AC_CONFIG_HEADERS([config/config.h]) |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 6 | AC_PREFIX_PROGRAM(nasm) |
H. Peter Anvin | 0bddd0f | 2019-02-22 01:13:52 -0800 | [diff] [blame] | 7 | AC_CONFIG_AUX_DIR(autoconf/helpers) |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 8 | |
H. Peter Anvin | 2d89477 | 2017-03-01 12:57:46 -0800 | [diff] [blame] | 9 | dnl Save initial CFLAGS, to see if -g -O2 came from configure or not |
| 10 | pa_init_cflags="$CFLAGS" |
| 11 | |
H. Peter Anvin | 0da1549 | 2017-04-06 15:24:58 -0700 | [diff] [blame] | 12 | dnl This prevents us from running Wine and thinking we are not |
| 13 | dnl cross-compiling when in fact we are; running Wine here is at |
| 14 | dnl the best very slow and doesn't buy us a single thing at all. |
| 15 | WINELOADER=/dev/null |
| 16 | export WINELOADER |
| 17 | |
H. Peter Anvin | 2d89477 | 2017-03-01 12:57:46 -0800 | [diff] [blame] | 18 | dnl Checks for programs and enable necessary CC extensions |
H. Peter Anvin | 2f0f9ea | 2008-06-08 20:53:29 -0700 | [diff] [blame] | 19 | AC_USE_SYSTEM_EXTENSIONS |
H. Peter Anvin | b423c02 | 2016-02-18 11:57:53 -0800 | [diff] [blame] | 20 | AC_SYS_LARGEFILE |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 21 | AC_PROG_CC |
H. Peter Anvin | d338b37 | 2016-02-18 00:54:30 -0800 | [diff] [blame] | 22 | AC_PROG_CC_STDC |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 23 | AC_PROG_LN_S |
| 24 | AC_PROG_MAKE_SET |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 25 | AC_PROG_INSTALL |
| 26 | |
H. Peter Anvin | 48fd154 | 2018-06-14 19:19:09 -0700 | [diff] [blame] | 27 | pa_no_optimize=false |
| 28 | |
| 29 | dnl If the user did not specify a CFLAGS default, change default |
| 30 | dnl to -O0 for debugging |
H. Peter Anvin | 0da1549 | 2017-04-06 15:24:58 -0700 | [diff] [blame] | 31 | PA_ARG_DISABLED([optimization], |
| 32 | [compile without optimization (-O0) to help debugging], |
H. Peter Anvin | 48fd154 | 2018-06-14 19:19:09 -0700 | [diff] [blame] | 33 | [pa_no_optimize=true]) |
H. Peter Anvin | 9b935a0 | 2017-02-28 19:02:51 -0800 | [diff] [blame] | 34 | |
Cyrill Gorcunov | fdbf701 | 2017-07-29 16:05:36 +0300 | [diff] [blame] | 35 | dnl Compile and link with dwarf debug |
| 36 | PA_ARG_ENABLED([gdb], |
| 37 | [disable optimization and compile with extra debug information for GDB debugger], |
H. Peter Anvin | 48fd154 | 2018-06-14 19:19:09 -0700 | [diff] [blame] | 38 | [PA_ADD_CFLAGS([-ggdb3]) |
| 39 | pa_no_optimize=true]) |
H. Peter Anvin | 53259e8 | 2017-10-11 16:47:59 -0700 | [diff] [blame] | 40 | |
H. Peter Anvin | 48fd154 | 2018-06-14 19:19:09 -0700 | [diff] [blame] | 41 | AS_IF([$pa_no_optimize], |
| 42 | [PA_ADD_CFLAGS([-O0]) |
| 43 | PA_ADD_CFLAGS([-fno-omit-frame-pointer])]) |
Cyrill Gorcunov | fdbf701 | 2017-07-29 16:05:36 +0300 | [diff] [blame] | 44 | |
H. Peter Anvin | efee3ea | 2019-02-25 21:00:43 -0800 | [diff] [blame] | 45 | dnl Profiling |
| 46 | PA_ARG_ENABLED([profiling], |
| 47 | [compile with profiling (-pg option)], |
| 48 | [PA_ADD_CFLAGS([-pg])]) |
| 49 | |
H. Peter Anvin | dcbaf67 | 2017-12-20 12:06:54 -0800 | [diff] [blame] | 50 | dnl Abort on panic |
| 51 | PA_ARG_ENABLED([panic-abort], |
| 52 | [call abort() on panic to trap in the debugger], |
| 53 | [AC_DEFINE(ABORT_ON_PANIC)]) |
| 54 | AH_TEMPLATE(ABORT_ON_PANIC, |
| 55 | [Define to 1 to call abort() on panics (internal errors), for debugging.]) |
| 56 | |
H. Peter Anvin | 89c1770 | 2016-03-09 14:11:40 -0800 | [diff] [blame] | 57 | dnl Check for library extension |
| 58 | PA_LIBEXT |
| 59 | |
Cyrill Gorcunov | 7729edf | 2014-12-20 11:35:51 +0300 | [diff] [blame] | 60 | dnl Checks for typedefs, structures, and compiler characteristics. |
| 61 | AC_C_CONST |
H. Peter Anvin | 03f229c | 2015-11-04 11:29:09 -0800 | [diff] [blame] | 62 | AC_C_INLINE |
Cyrill Gorcunov | 7729edf | 2014-12-20 11:35:51 +0300 | [diff] [blame] | 63 | AC_C_RESTRICT |
| 64 | AC_TYPE_SIZE_T |
H. Peter Anvin | ef63588 | 2016-03-01 21:53:09 -0800 | [diff] [blame] | 65 | AC_C_BIGENDIAN(AC_DEFINE(WORDS_BIGENDIAN),AC_DEFINE(WORDS_LITTLEENDIAN),,) |
Cyrill Gorcunov | 7729edf | 2014-12-20 11:35:51 +0300 | [diff] [blame] | 66 | AH_TEMPLATE(WORDS_BIGENDIAN, |
| 67 | [Define to 1 if your processor stores words with the most significant |
| 68 | byte first (like Motorola and SPARC, unlike Intel and VAX).]) |
| 69 | AH_TEMPLATE(WORDS_LITTLEENDIAN, |
| 70 | [Define to 1 if your processor stores words with the least significant |
| 71 | byte first (like Intel and VAX, unlike Motorola and SPARC).]) |
| 72 | |
H. Peter Anvin | b9c1ca7 | 2016-03-01 21:51:40 -0800 | [diff] [blame] | 73 | dnl Force gcc and gcc-compatible compilers treat signed integers |
| 74 | dnl as 2's complement |
H. Peter Anvin | 8d9f591 | 2016-02-27 00:15:13 -0800 | [diff] [blame] | 75 | PA_ADD_CFLAGS([-fwrapv]) |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 76 | |
H. Peter Anvin | 8b19083 | 2016-11-15 14:01:37 -0800 | [diff] [blame] | 77 | dnl Some environments abuse __STRICT_ANSI__ to disable some |
| 78 | dnl function declarations |
| 79 | PA_ADD_CFLAGS([-U__STRICT_ANSI__]) |
| 80 | |
H. Peter Anvin | 43e0262 | 2016-08-02 09:28:22 -0700 | [diff] [blame] | 81 | dnl Don't put things in common if we can avoid it. We don't want to |
| 82 | dnl assume all compilers support common, and this will help find those |
| 83 | dnl problems. This also works around an OSX linker problem. |
| 84 | PA_ADD_CFLAGS([-fno-common]) |
| 85 | |
H. Peter Anvin | eec3b52 | 2008-06-19 11:39:23 -0700 | [diff] [blame] | 86 | dnl Look for programs... |
H. Peter Anvin | a939783 | 2013-05-17 12:02:49 -0700 | [diff] [blame] | 87 | AC_CHECK_PROGS(NROFF, nroff, false) |
H. Peter Anvin | d089c22 | 2013-10-24 13:22:19 +0100 | [diff] [blame] | 88 | AC_CHECK_PROGS(ASCIIDOC, asciidoc, false) |
| 89 | AC_CHECK_PROGS(XMLTO, xmlto, false) |
H. Peter Anvin | 620515a | 2002-04-30 20:57:38 +0000 | [diff] [blame] | 90 | |
H. Peter Anvin | d089c22 | 2013-10-24 13:22:19 +0100 | [diff] [blame] | 91 | dnl Check for progs needed for manpage generation |
H. Peter Anvin | 0da1549 | 2017-04-06 15:24:58 -0700 | [diff] [blame] | 92 | AS_IF([test $ASCIIDOC = false], |
| 93 | [AC_MSG_WARN([No asciidoc package found])] |
| 94 | ) |
| 95 | AS_IF([test $XMLTO = false], |
| 96 | [AC_MSG_WARN([No xmlto package found])] |
| 97 | ) |
H. Peter Anvin | d089c22 | 2013-10-24 13:22:19 +0100 | [diff] [blame] | 98 | |
H. Peter Anvin | cc147f7 | 2016-03-08 02:06:39 -0800 | [diff] [blame] | 99 | dnl Check for host compiler tools |
| 100 | AC_CHECK_TOOL(AR, ar) |
| 101 | AC_CHECK_TOOL(RANLIB, ranlib, :) |
| 102 | AC_CHECK_TOOL(STRIP, strip) |
| 103 | |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 104 | dnl Checks for header files. |
| 105 | AC_HEADER_STDC |
H. Peter Anvin | 3ef4f00 | 2016-03-08 12:14:55 -0800 | [diff] [blame] | 106 | AC_CHECK_HEADERS(inttypes.h) |
H. Peter Anvin | fe50195 | 2007-10-02 21:53:51 -0700 | [diff] [blame] | 107 | AC_CHECK_HEADERS(strings.h) |
H. Peter Anvin | d338b37 | 2016-02-18 00:54:30 -0800 | [diff] [blame] | 108 | AC_HEADER_STDBOOL |
H. Peter Anvin | abd28c9 | 2016-12-20 02:29:58 -0800 | [diff] [blame] | 109 | AC_CHECK_HEADERS(stdnoreturn.h) |
H. Peter Anvin | e65e81b | 2016-02-18 14:24:40 -0800 | [diff] [blame] | 110 | AC_CHECK_HEADERS(io.h) |
H. Peter Anvin | d81a235 | 2016-09-21 14:03:18 -0700 | [diff] [blame] | 111 | AC_CHECK_HEADERS(fcntl.h) |
H. Peter Anvin | 4627e69 | 2016-01-26 12:01:34 -0800 | [diff] [blame] | 112 | AC_CHECK_HEADERS(unistd.h) |
H. Peter Anvin | d81a235 | 2016-09-21 14:03:18 -0700 | [diff] [blame] | 113 | AC_CHECK_HEADERS(sys/mman.h) |
H. Peter Anvin | 4c9132e | 2016-10-19 13:13:38 -0700 | [diff] [blame] | 114 | AC_CHECK_HEADERS(sys/types.h) |
H. Peter Anvin | 675e7b7 | 2017-04-05 21:19:03 -0700 | [diff] [blame] | 115 | AC_CHECK_HEADERS(sys/stat.h) |
H. Peter Anvin | 4627e69 | 2016-01-26 12:01:34 -0800 | [diff] [blame] | 116 | |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 117 | dnl Checks for library functions. |
H. Peter Anvin | fe50195 | 2007-10-02 21:53:51 -0700 | [diff] [blame] | 118 | AC_CHECK_FUNCS(strcasecmp stricmp) |
| 119 | AC_CHECK_FUNCS(strncasecmp strnicmp) |
H. Peter Anvin | 73b22f5 | 2016-02-18 14:40:37 -0800 | [diff] [blame] | 120 | AC_CHECK_FUNCS(strsep) |
H. Peter Anvin | 22538e2 | 2016-05-25 05:42:47 -0700 | [diff] [blame] | 121 | AC_CHECK_FUNCS(strnlen) |
H. Peter Anvin | 81b62b9 | 2017-12-20 13:33:49 -0800 | [diff] [blame] | 122 | AC_CHECK_FUNCS(strrchrnul) |
H. Peter Anvin | 1350620 | 2018-11-28 14:55:58 -0800 | [diff] [blame] | 123 | AC_CHECK_FUNCS(iscntrl) |
| 124 | AC_CHECK_FUNCS(isascii) |
H. Peter Anvin | 06f72bb | 2018-12-26 06:22:47 -0800 | [diff] [blame] | 125 | AC_CHECK_FUNCS(mempcpy) |
H. Peter Anvin | fe50195 | 2007-10-02 21:53:51 -0700 | [diff] [blame] | 126 | |
H. Peter Anvin | 038d861 | 2007-04-12 16:54:50 +0000 | [diff] [blame] | 127 | AC_CHECK_FUNCS(getuid) |
| 128 | AC_CHECK_FUNCS(getgid) |
| 129 | |
H. Peter Anvin | 4627e69 | 2016-01-26 12:01:34 -0800 | [diff] [blame] | 130 | AC_CHECK_FUNCS(realpath) |
| 131 | AC_CHECK_FUNCS(canonicalize_file_name) |
| 132 | AC_CHECK_FUNCS(_fullpath) |
| 133 | AC_CHECK_FUNCS(pathconf) |
| 134 | |
H. Peter Anvin | e65e81b | 2016-02-18 14:24:40 -0800 | [diff] [blame] | 135 | AC_FUNC_FSEEKO |
H. Peter Anvin | ec82d7a | 2016-02-21 21:20:45 -0800 | [diff] [blame] | 136 | AC_CHECK_FUNCS([_fseeki64]) |
H. Peter Anvin | e65e81b | 2016-02-18 14:24:40 -0800 | [diff] [blame] | 137 | AC_CHECK_FUNCS([ftruncate _chsize _chsize_s]) |
H. Peter Anvin | 397c169 | 2016-10-04 17:01:59 -0700 | [diff] [blame] | 138 | AC_CHECK_FUNCS([fileno _fileno]) |
H. Peter Anvin | e65e81b | 2016-02-18 14:24:40 -0800 | [diff] [blame] | 139 | |
H. Peter Anvin | 895a66c | 2017-02-23 20:34:38 -0800 | [diff] [blame] | 140 | AC_FUNC_MMAP |
H. Peter Anvin | d81a235 | 2016-09-21 14:03:18 -0700 | [diff] [blame] | 141 | AC_CHECK_FUNCS(getpagesize) |
| 142 | AC_CHECK_FUNCS(sysconf) |
| 143 | |
H. Peter Anvin | 397c169 | 2016-10-04 17:01:59 -0700 | [diff] [blame] | 144 | AC_CHECK_FUNCS([access _access faccessat]) |
H. Peter Anvin | d81a235 | 2016-09-21 14:03:18 -0700 | [diff] [blame] | 145 | |
H. Peter Anvin | e558dfd | 2017-04-18 16:05:22 -0700 | [diff] [blame] | 146 | PA_HAVE_FUNC(__builtin_expect, (1,1)) |
| 147 | |
| 148 | dnl ilog2() building blocks |
| 149 | PA_ADD_HEADERS(intrin.h) |
H. Peter Anvin | 8d4fb26 | 2016-11-15 14:23:54 -0800 | [diff] [blame] | 150 | PA_HAVE_FUNC(__builtin_clz, (0U)) |
| 151 | PA_HAVE_FUNC(__builtin_clzl, (0UL)) |
| 152 | PA_HAVE_FUNC(__builtin_clzll, (0ULL)) |
H. Peter Anvin | e558dfd | 2017-04-18 16:05:22 -0700 | [diff] [blame] | 153 | PA_HAVE_FUNC(_BitScanReverse, (0)) |
| 154 | PA_HAVE_FUNC(_BitScanReverse64, (0)) |
H. Peter Anvin | d338b37 | 2016-02-18 00:54:30 -0800 | [diff] [blame] | 155 | |
H. Peter Anvin | 81b62b9 | 2017-12-20 13:33:49 -0800 | [diff] [blame] | 156 | dnl Functions for which we have replacements available in stdlib/ |
H. Peter Anvin | cc147f7 | 2016-03-08 02:06:39 -0800 | [diff] [blame] | 157 | AC_CHECK_FUNCS([vsnprintf _vsnprintf]) |
| 158 | AC_CHECK_FUNCS([snprintf _snprintf]) |
| 159 | AC_CHECK_FUNCS([strlcpy]) |
H. Peter Anvin | 81b62b9 | 2017-12-20 13:33:49 -0800 | [diff] [blame] | 160 | AC_CHECK_FUNCS([strrchrnul]) |
H. Peter Anvin | d338b37 | 2016-02-18 00:54:30 -0800 | [diff] [blame] | 161 | |
H. Peter Anvin | 3118429 | 2017-04-06 15:30:56 -0700 | [diff] [blame] | 162 | dnl These types are POSIX-specific, and Windows does it differently... |
| 163 | AC_CHECK_TYPES([struct _stati64]) |
| 164 | AC_CHECK_TYPES([struct stat]) |
| 165 | AC_CHECK_FUNCS([stat _stati64]) |
| 166 | AC_CHECK_FUNCS([fstat _fstati64]) |
H. Peter Anvin (Intel) | 471120f | 2019-05-15 13:07:21 -0700 | [diff] [blame] | 167 | AC_CHECK_FUNCS([S_ISREG]) |
H. Peter Anvin | 3118429 | 2017-04-06 15:30:56 -0700 | [diff] [blame] | 168 | |
H. Peter Anvin | c13d31a | 2007-10-26 18:49:29 -0700 | [diff] [blame] | 169 | dnl Check for functions that might not be declared in the headers for |
| 170 | dnl various idiotic reasons (mostly because of library authors |
| 171 | dnl abusing the meaning of __STRICT_ANSI__) |
| 172 | AC_CHECK_DECLS(strcasecmp) |
| 173 | AC_CHECK_DECLS(stricmp) |
| 174 | AC_CHECK_DECLS(strncasecmp) |
| 175 | AC_CHECK_DECLS(strnicmp) |
| 176 | AC_CHECK_DECLS(strsep) |
H. Peter Anvin | eaa68f1 | 2009-08-10 15:56:52 -0700 | [diff] [blame] | 177 | AC_CHECK_DECLS(strlcpy) |
H. Peter Anvin | 22538e2 | 2016-05-25 05:42:47 -0700 | [diff] [blame] | 178 | AC_CHECK_DECLS(strnlen) |
H. Peter Anvin | 81b62b9 | 2017-12-20 13:33:49 -0800 | [diff] [blame] | 179 | AC_CHECK_DECLS(strrchrnul) |
H. Peter Anvin | c13d31a | 2007-10-26 18:49:29 -0700 | [diff] [blame] | 180 | |
H. Peter Anvin | d81a235 | 2016-09-21 14:03:18 -0700 | [diff] [blame] | 181 | dnl Check for missing types |
| 182 | AC_TYPE_UINTPTR_T |
| 183 | |
H. Peter Anvin | f13effe | 2017-04-10 16:10:28 -0700 | [diff] [blame] | 184 | dnl Documentation: should we generate an uncompressed PDF? It is |
| 185 | dnl about twice as big, but it can be externally compressed (e.g. with xz) |
| 186 | dnl and becomes significantly smaller than the original. |
| 187 | PA_ARG_DISABLED([pdf-compression], |
| 188 | [generate an uncompressed documentation PDF], |
| 189 | [PDFOPT='-nocompress']) |
| 190 | AC_SUBST([PDFOPT]) |
| 191 | |
H. Peter Anvin | 8b19083 | 2016-11-15 14:01:37 -0800 | [diff] [blame] | 192 | dnl |
H. Peter Anvin | 5eb528b | 2017-04-18 15:49:25 -0700 | [diff] [blame] | 193 | dnl Look for byte-swapping support... |
| 194 | dnl |
H. Peter Anvin | e5033df | 2017-11-29 16:04:05 -0800 | [diff] [blame] | 195 | PA_ADD_HEADERS(endian.h sys/endian.h machine/endian.h) |
H. Peter Anvin | 5eb528b | 2017-04-18 15:49:25 -0700 | [diff] [blame] | 196 | PA_HAVE_FUNC(cpu_to_le16, (0)) |
| 197 | PA_HAVE_FUNC(cpu_to_le32, (0)) |
| 198 | PA_HAVE_FUNC(cpu_to_le64, (0)) |
| 199 | PA_HAVE_FUNC(__cpu_to_le16, (0)) |
| 200 | PA_HAVE_FUNC(__cpu_to_le32, (0)) |
| 201 | PA_HAVE_FUNC(__cpu_to_le64, (0)) |
| 202 | PA_HAVE_FUNC(htole16, (0)) |
| 203 | PA_HAVE_FUNC(htole32, (0)) |
| 204 | PA_HAVE_FUNC(htole64, (0)) |
| 205 | PA_HAVE_FUNC(__bswap_16, (0)) |
| 206 | PA_HAVE_FUNC(__bswap_32, (0)) |
| 207 | PA_HAVE_FUNC(__bswap_64, (0)) |
| 208 | PA_HAVE_FUNC(__builtin_bswap16, (0)) |
| 209 | PA_HAVE_FUNC(__builtin_bswap32, (0)) |
| 210 | PA_HAVE_FUNC(__builtin_bswap64, (0)) |
H. Peter Anvin | e558dfd | 2017-04-18 16:05:22 -0700 | [diff] [blame] | 211 | PA_HAVE_FUNC(_byteswap_ushort, (0)) |
| 212 | PA_HAVE_FUNC(_byteswap_ulong, (0)) |
| 213 | PA_HAVE_FUNC(_byteswap_uint64, (0)) |
H. Peter Anvin | 5eb528b | 2017-04-18 15:49:25 -0700 | [diff] [blame] | 214 | |
| 215 | dnl |
H. Peter Anvin (Intel) | b7f24e7 | 2018-12-14 14:21:16 -0800 | [diff] [blame] | 216 | dnl Some rather useful gcc extensions... |
H. Peter Anvin | e5033df | 2017-11-29 16:04:05 -0800 | [diff] [blame] | 217 | dnl |
| 218 | PA_HAVE_FUNC(__builtin_constant_p, (0)) |
H. Peter Anvin (Intel) | b7f24e7 | 2018-12-14 14:21:16 -0800 | [diff] [blame] | 219 | PA_HAVE_FUNC(__builtin_choose_expr, (0,1,2)) |
H. Peter Anvin | e5033df | 2017-11-29 16:04:05 -0800 | [diff] [blame] | 220 | |
| 221 | dnl |
H. Peter Anvin | 8b19083 | 2016-11-15 14:01:37 -0800 | [diff] [blame] | 222 | dnl Check for supported gcc attributes; some compilers (e.g. Sun CC) |
| 223 | dnl support these, but don't define __GNUC__ as they don't support |
| 224 | dnl some other features of gcc. |
| 225 | dnl |
H. Peter Anvin | bc18af1 | 2017-02-23 19:22:27 -0800 | [diff] [blame] | 226 | PA_ADD_CFLAGS([-Werror=attributes]) |
H. Peter Anvin | 8b19083 | 2016-11-15 14:01:37 -0800 | [diff] [blame] | 227 | PA_FUNC_ATTRIBUTE(noreturn) |
H. Peter Anvin (Intel) | 8b6e6bf | 2019-08-16 00:08:27 -0700 | [diff] [blame] | 228 | PA_FUNC_ATTRIBUTE(returns_nonnull,,,,,never_null) |
H. Peter Anvin | 8b19083 | 2016-11-15 14:01:37 -0800 | [diff] [blame] | 229 | PA_FUNC_ATTRIBUTE(malloc) |
H. Peter Anvin (Intel) | 8b6e6bf | 2019-08-16 00:08:27 -0700 | [diff] [blame] | 230 | PA_FUNC_ATTRIBUTE(alloc_size,[1]) |
| 231 | PA_FUNC_ATTRIBUTE(alloc_size,[1,2]) |
| 232 | PA_FUNC_ATTRIBUTE(sentinel,,, [const char *, ...], ["a","b",NULL],end_with_null) |
| 233 | PA_FUNC_ATTRIBUTE(format, [printf,1,2], int, [const char *, ...], ["%d",1]) |
H. Peter Anvin | 8b19083 | 2016-11-15 14:01:37 -0800 | [diff] [blame] | 234 | PA_FUNC_ATTRIBUTE(const) |
| 235 | PA_FUNC_ATTRIBUTE(pure) |
H. Peter Anvin (Intel) | 8b6e6bf | 2019-08-16 00:08:27 -0700 | [diff] [blame] | 236 | PA_FUNC_ATTRIBUTE(cold,,,,,unlikely_func) |
H. Peter Anvin | abd28c9 | 2016-12-20 02:29:58 -0800 | [diff] [blame] | 237 | PA_FUNC_ATTRIBUTE_ERROR |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 238 | |
Cyrill Gorcunov | 325768e | 2010-11-11 11:18:44 +0300 | [diff] [blame] | 239 | dnl |
H. Peter Anvin | 53259e8 | 2017-10-11 16:47:59 -0700 | [diff] [blame] | 240 | dnl support function sections (if available) |
Cyrill Gorcunov | 325768e | 2010-11-11 11:18:44 +0300 | [diff] [blame] | 241 | dnl |
H. Peter Anvin (Intel) | 7dc5b23 | 2018-12-13 22:51:22 -0800 | [diff] [blame] | 242 | PA_ARG_DISABLED([sections], |
Cyrill Gorcunov | 8274623 | 2018-12-23 17:15:41 +0300 | [diff] [blame] | 243 | [do not try to compile with function/data section support], |
H. Peter Anvin (Intel) | 7dc5b23 | 2018-12-13 22:51:22 -0800 | [diff] [blame] | 244 | [], |
H. Peter Anvin | b0121dc | 2018-12-22 18:17:16 -0800 | [diff] [blame] | 245 | [PA_ADD_CFLAGS([-ffunction-sections]) |
| 246 | PA_ADD_CFLAGS([-fdata-sections]) |
| 247 | PA_ADD_LDFLAGS([-Wl,--gc-sections])] |
H. Peter Anvin (Intel) | 7dc5b23 | 2018-12-13 22:51:22 -0800 | [diff] [blame] | 248 | ) |
H. Peter Anvin | 53259e8 | 2017-10-11 16:47:59 -0700 | [diff] [blame] | 249 | |
H. Peter Anvin | 5fe847e | 2017-02-28 18:48:01 -0800 | [diff] [blame] | 250 | dnl |
| 251 | dnl support LTO |
| 252 | dnl |
H. Peter Anvin | 0da1549 | 2017-04-06 15:24:58 -0700 | [diff] [blame] | 253 | PA_ARG_ENABLED([lto], |
| 254 | [compile with gcc-style link time optimization], |
H. Peter Anvin | b0121dc | 2018-12-22 18:17:16 -0800 | [diff] [blame] | 255 | [PA_ADD_CFLAGS([-flto]) |
H. Peter Anvin | 0da1549 | 2017-04-06 15:24:58 -0700 | [diff] [blame] | 256 | dnl Note: we use _PROG rather than _TOOL since we are prepending the full |
| 257 | dnl CC name which ought to already contain the host triplet if needed |
| 258 | ccbase=`echo "$CC" | awk '{ print $1; }'` |
| 259 | AC_CHECK_PROGS(CC_AR, [${ccbase}-ar], [$ac_cv_prog_AR]) |
| 260 | AR="$CC_AR" |
| 261 | AC_CHECK_PROGS(CC_RANLIB, [${ccbase}-ranlib], [$ac_cv_prog_RANLIB]) |
| 262 | RANLIB="$CC_RANLIB"], []) |
H. Peter Anvin | 5fe847e | 2017-02-28 18:48:01 -0800 | [diff] [blame] | 263 | |
H. Peter Anvin | 53259e8 | 2017-10-11 16:47:59 -0700 | [diff] [blame] | 264 | dnl |
| 265 | dnl support sanitizers (if available) |
| 266 | dnl |
| 267 | PA_ARG_ENABLED([sanitizer], |
| 268 | [compile with sanitizers enabled], |
| 269 | [PA_ADD_CFLAGS([-fno-omit-frame-pointer]) |
H. Peter Anvin | b0121dc | 2018-12-22 18:17:16 -0800 | [diff] [blame] | 270 | PA_ADD_CFLAGS([-fsanitize=address]) |
| 271 | PA_ADD_CFLAGS([-fsanitize=undefined])]) |
H. Peter Anvin | 53259e8 | 2017-10-11 16:47:59 -0700 | [diff] [blame] | 272 | |
H. Peter Anvin | 7310d0b | 2018-05-30 11:48:00 -0700 | [diff] [blame] | 273 | dnl |
| 274 | dnl Don't make symbols visible, there is no point and it just |
| 275 | dnl makes the code slower. |
| 276 | dnl |
H. Peter Anvin | b0121dc | 2018-12-22 18:17:16 -0800 | [diff] [blame] | 277 | PA_ADD_CFLAGS([-fvisibility=hidden]) |
H. Peter Anvin | 7310d0b | 2018-05-30 11:48:00 -0700 | [diff] [blame] | 278 | |
H. Peter Anvin | b9c1ca7 | 2016-03-01 21:51:40 -0800 | [diff] [blame] | 279 | dnl If we have gcc, add appropriate code cleanliness options |
H. Peter Anvin | d338b37 | 2016-02-18 00:54:30 -0800 | [diff] [blame] | 280 | PA_ADD_CFLAGS([-Wall]) |
H. Peter Anvin (Intel) | 480d5e2 | 2019-08-16 00:52:26 -0700 | [diff] [blame] | 281 | PA_ARG_DISABLED([pedantic], |
| 282 | [disable some extra paranoid compiler warnings], |
| 283 | [], |
| 284 | [PA_ADD_CFLAGS([-W]) |
| 285 | PA_ADD_CFLAGS([-pedantic]) |
| 286 | PA_ADD_CFLAGS([-Wc90-c99-compat])]) |
H. Peter Anvin | c9fd7b2 | 2016-05-16 21:35:48 -0700 | [diff] [blame] | 287 | dnl LLVM doesn't error out on invalid -W options unless this option is |
| 288 | dnl specified first. Enable this so this script can actually discover |
| 289 | dnl which -W options are possible for this compiler. |
| 290 | PA_ADD_CFLAGS([-Werror=unknown-warning-option]) |
H. Peter Anvin | 25da6ea | 2016-03-01 22:20:10 -0800 | [diff] [blame] | 291 | dnl Suppress format warning on Windows targets due to their <inttypes.h> |
| 292 | PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format]) |
H. Peter Anvin | 25da6ea | 2016-03-01 22:20:10 -0800 | [diff] [blame] | 293 | PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long]) |
H. Peter Anvin | c4e16f7 | 2018-06-02 23:46:21 -0700 | [diff] [blame] | 294 | dnl This is needed because we intentionally expect strncpy() to fill |
| 295 | dnl in a zero-padded (not zero-terminated) buffer in several backends |
| 296 | PA_ADD_CFLAGS([-Wstringop-truncation],[-Wno-stringop-truncation]) |
H. Peter Anvin (Intel) | 64b56ea | 2018-12-12 15:56:28 -0800 | [diff] [blame] | 297 | dnl This is needed because we assume 2's-completement signed arithmetic; |
| 298 | dnl on compilers with gcc-like command line syntax we pass the -fwrapv |
| 299 | dnl option for exactly that reason. |
| 300 | PA_ADD_CFLAGS([-Wshift-negative-value],[-Wno-shift-negative-value]) |
| 301 | |
H. Peter Anvin | cfd56eb | 2016-03-06 21:44:14 -0800 | [diff] [blame] | 302 | dnl PA_ADD_CFLAGS([-Wwrite-strings]) |
H. Peter Anvin | 0da1549 | 2017-04-06 15:24:58 -0700 | [diff] [blame] | 303 | PA_ARG_ENABLED([werror], |
| 304 | [compile with -Werror to error out on any warning], |
| 305 | [PA_ADD_CFLAGS([-Werror])], |
| 306 | [PA_ADD_CFLAGS([-Werror=implicit]) |
| 307 | PA_ADD_CFLAGS([-Werror=missing-braces]) |
| 308 | PA_ADD_CFLAGS([-Werror=return-type]) |
| 309 | PA_ADD_CFLAGS([-Werror=trigraphs]) |
| 310 | PA_ADD_CFLAGS([-Werror=pointer-arith]) |
| 311 | PA_ADD_CFLAGS([-Werror=strict-prototypes]) |
| 312 | PA_ADD_CFLAGS([-Werror=missing-prototypes]) |
| 313 | PA_ADD_CFLAGS([-Werror=missing-declarations]) |
| 314 | PA_ADD_CFLAGS([-Werror=comment]) |
| 315 | PA_ADD_CFLAGS([-Werror=vla])] |
| 316 | ) |
Ozkan Sezer | ec3d426 | 2016-02-12 23:49:49 -0800 | [diff] [blame] | 317 | |
H. Peter Anvin | 0c36965 | 2017-02-28 19:34:36 -0800 | [diff] [blame] | 318 | dnl |
H. Peter Anvin | 99d45c8 | 2018-02-20 12:34:17 -0800 | [diff] [blame] | 319 | dnl On some versions of gcc, -Werror=missing-prototypes causes problems |
| 320 | dnl with C99-style external inlines. Test this *after* adding the -Werror |
| 321 | dnl options. |
| 322 | dnl |
| 323 | PA_CHECK_BAD_STDC_INLINE |
| 324 | |
| 325 | dnl |
H. Peter Anvin | 0c36965 | 2017-02-28 19:34:36 -0800 | [diff] [blame] | 326 | dnl support ccache |
| 327 | dnl |
H. Peter Anvin | 0da1549 | 2017-04-06 15:24:58 -0700 | [diff] [blame] | 328 | PA_ARG_ENABLED([ccache], [compile with ccache], [CC="ccache $CC"], []) |
H. Peter Anvin | 0c36965 | 2017-02-28 19:34:36 -0800 | [diff] [blame] | 329 | |
Ed Beroset | 74fa0a7 | 2017-04-14 17:08:15 -0400 | [diff] [blame] | 330 | AC_OUTPUT_COMMANDS([mkdir -p config nasmlib nsis output stdlib x86 asm disasm rdoff macros common]) |
H. Peter Anvin | 9a714c9 | 2017-04-06 17:24:03 -0700 | [diff] [blame] | 331 | AC_OUTPUT(Makefile doc/Makefile) |