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 | 397c169 | 2016-10-04 17:01:59 -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 | |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 7 | AC_PREFIX_PROGRAM(nasm) |
| 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 | 0da1549 | 2017-04-06 15:24:58 -0700 | [diff] [blame] | 27 | dnl If the user did not specify a CFLAGS default, change default -O2 |
| 28 | dnl to either -O3 (normal) or -O0 (for debugging) |
| 29 | PA_ARG_DISABLED([optimization], |
| 30 | [compile without optimization (-O0) to help debugging], |
| 31 | [pa_optimize=-O0], [pa_optimize=-O3]) |
H. Peter Anvin | 9b935a0 | 2017-02-28 19:02:51 -0800 | [diff] [blame] | 32 | |
Cyrill Gorcunov | fdbf701 | 2017-07-29 16:05:36 +0300 | [diff] [blame] | 33 | dnl Compile and link with dwarf debug |
| 34 | PA_ARG_ENABLED([gdb], |
| 35 | [disable optimization and compile with extra debug information for GDB debugger], |
H. Peter Anvin | 53259e8 | 2017-10-11 16:47:59 -0700 | [diff] [blame] | 36 | [pa_optimize='-O0' |
| 37 | PA_ADD_CFLAGS([-ggdb3]) |
| 38 | ]) |
| 39 | |
| 40 | AS_IF([test x"$pa_init_cflags" = x], |
| 41 | [CFLAGS=`echo "$CFLAGS" | sed -e "s/-O2/$pa_optimize/"`]) |
| 42 | |
| 43 | AS_IF([test x"$pa_optimize" = "x-O0"], |
| 44 | [PA_ADD_CFLAGS([-fno-omit-frame-pointer])]) |
Cyrill Gorcunov | fdbf701 | 2017-07-29 16:05:36 +0300 | [diff] [blame] | 45 | |
H. Peter Anvin | dcbaf67 | 2017-12-20 12:06:54 -0800 | [diff] [blame^] | 46 | dnl Abort on panic |
| 47 | PA_ARG_ENABLED([panic-abort], |
| 48 | [call abort() on panic to trap in the debugger], |
| 49 | [AC_DEFINE(ABORT_ON_PANIC)]) |
| 50 | AH_TEMPLATE(ABORT_ON_PANIC, |
| 51 | [Define to 1 to call abort() on panics (internal errors), for debugging.]) |
| 52 | |
H. Peter Anvin | 89c1770 | 2016-03-09 14:11:40 -0800 | [diff] [blame] | 53 | dnl Check for library extension |
| 54 | PA_LIBEXT |
| 55 | |
Cyrill Gorcunov | 7729edf | 2014-12-20 11:35:51 +0300 | [diff] [blame] | 56 | dnl Checks for typedefs, structures, and compiler characteristics. |
| 57 | AC_C_CONST |
H. Peter Anvin | 03f229c | 2015-11-04 11:29:09 -0800 | [diff] [blame] | 58 | AC_C_INLINE |
Cyrill Gorcunov | 7729edf | 2014-12-20 11:35:51 +0300 | [diff] [blame] | 59 | AC_C_RESTRICT |
| 60 | AC_TYPE_SIZE_T |
H. Peter Anvin | ef63588 | 2016-03-01 21:53:09 -0800 | [diff] [blame] | 61 | AC_C_BIGENDIAN(AC_DEFINE(WORDS_BIGENDIAN),AC_DEFINE(WORDS_LITTLEENDIAN),,) |
Cyrill Gorcunov | 7729edf | 2014-12-20 11:35:51 +0300 | [diff] [blame] | 62 | AH_TEMPLATE(WORDS_BIGENDIAN, |
| 63 | [Define to 1 if your processor stores words with the most significant |
| 64 | byte first (like Motorola and SPARC, unlike Intel and VAX).]) |
| 65 | AH_TEMPLATE(WORDS_LITTLEENDIAN, |
| 66 | [Define to 1 if your processor stores words with the least significant |
| 67 | byte first (like Intel and VAX, unlike Motorola and SPARC).]) |
| 68 | |
H. Peter Anvin | b9c1ca7 | 2016-03-01 21:51:40 -0800 | [diff] [blame] | 69 | dnl Force gcc and gcc-compatible compilers treat signed integers |
| 70 | dnl as 2's complement |
H. Peter Anvin | 8d9f591 | 2016-02-27 00:15:13 -0800 | [diff] [blame] | 71 | PA_ADD_CFLAGS([-fwrapv]) |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 72 | |
H. Peter Anvin | 8b19083 | 2016-11-15 14:01:37 -0800 | [diff] [blame] | 73 | dnl Some environments abuse __STRICT_ANSI__ to disable some |
| 74 | dnl function declarations |
| 75 | PA_ADD_CFLAGS([-U__STRICT_ANSI__]) |
| 76 | |
H. Peter Anvin | 43e0262 | 2016-08-02 09:28:22 -0700 | [diff] [blame] | 77 | dnl Don't put things in common if we can avoid it. We don't want to |
| 78 | dnl assume all compilers support common, and this will help find those |
| 79 | dnl problems. This also works around an OSX linker problem. |
| 80 | PA_ADD_CFLAGS([-fno-common]) |
| 81 | |
H. Peter Anvin | eec3b52 | 2008-06-19 11:39:23 -0700 | [diff] [blame] | 82 | dnl Look for programs... |
H. Peter Anvin | a939783 | 2013-05-17 12:02:49 -0700 | [diff] [blame] | 83 | AC_CHECK_PROGS(NROFF, nroff, false) |
H. Peter Anvin | d089c22 | 2013-10-24 13:22:19 +0100 | [diff] [blame] | 84 | AC_CHECK_PROGS(ASCIIDOC, asciidoc, false) |
| 85 | AC_CHECK_PROGS(XMLTO, xmlto, false) |
H. Peter Anvin | 620515a | 2002-04-30 20:57:38 +0000 | [diff] [blame] | 86 | |
H. Peter Anvin | d089c22 | 2013-10-24 13:22:19 +0100 | [diff] [blame] | 87 | dnl Check for progs needed for manpage generation |
H. Peter Anvin | 0da1549 | 2017-04-06 15:24:58 -0700 | [diff] [blame] | 88 | AS_IF([test $ASCIIDOC = false], |
| 89 | [AC_MSG_WARN([No asciidoc package found])] |
| 90 | ) |
| 91 | AS_IF([test $XMLTO = false], |
| 92 | [AC_MSG_WARN([No xmlto package found])] |
| 93 | ) |
H. Peter Anvin | d089c22 | 2013-10-24 13:22:19 +0100 | [diff] [blame] | 94 | |
H. Peter Anvin | cc147f7 | 2016-03-08 02:06:39 -0800 | [diff] [blame] | 95 | dnl Check for host compiler tools |
| 96 | AC_CHECK_TOOL(AR, ar) |
| 97 | AC_CHECK_TOOL(RANLIB, ranlib, :) |
| 98 | AC_CHECK_TOOL(STRIP, strip) |
| 99 | |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 100 | dnl Checks for header files. |
| 101 | AC_HEADER_STDC |
H. Peter Anvin | 3ef4f00 | 2016-03-08 12:14:55 -0800 | [diff] [blame] | 102 | AC_CHECK_HEADERS(inttypes.h) |
H. Peter Anvin | fe50195 | 2007-10-02 21:53:51 -0700 | [diff] [blame] | 103 | AC_CHECK_HEADERS(strings.h) |
H. Peter Anvin | d338b37 | 2016-02-18 00:54:30 -0800 | [diff] [blame] | 104 | AC_HEADER_STDBOOL |
H. Peter Anvin | abd28c9 | 2016-12-20 02:29:58 -0800 | [diff] [blame] | 105 | AC_CHECK_HEADERS(stdnoreturn.h) |
H. Peter Anvin | e65e81b | 2016-02-18 14:24:40 -0800 | [diff] [blame] | 106 | AC_CHECK_HEADERS(io.h) |
H. Peter Anvin | d81a235 | 2016-09-21 14:03:18 -0700 | [diff] [blame] | 107 | AC_CHECK_HEADERS(fcntl.h) |
H. Peter Anvin | 4627e69 | 2016-01-26 12:01:34 -0800 | [diff] [blame] | 108 | AC_CHECK_HEADERS(unistd.h) |
H. Peter Anvin | d81a235 | 2016-09-21 14:03:18 -0700 | [diff] [blame] | 109 | AC_CHECK_HEADERS(sys/mman.h) |
H. Peter Anvin | 4c9132e | 2016-10-19 13:13:38 -0700 | [diff] [blame] | 110 | AC_CHECK_HEADERS(sys/types.h) |
H. Peter Anvin | 675e7b7 | 2017-04-05 21:19:03 -0700 | [diff] [blame] | 111 | AC_CHECK_HEADERS(sys/stat.h) |
H. Peter Anvin | 4627e69 | 2016-01-26 12:01:34 -0800 | [diff] [blame] | 112 | |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 113 | dnl Checks for library functions. |
H. Peter Anvin | fe50195 | 2007-10-02 21:53:51 -0700 | [diff] [blame] | 114 | AC_CHECK_FUNCS(strcasecmp stricmp) |
| 115 | AC_CHECK_FUNCS(strncasecmp strnicmp) |
H. Peter Anvin | 73b22f5 | 2016-02-18 14:40:37 -0800 | [diff] [blame] | 116 | AC_CHECK_FUNCS(strsep) |
H. Peter Anvin | 22538e2 | 2016-05-25 05:42:47 -0700 | [diff] [blame] | 117 | AC_CHECK_FUNCS(strnlen) |
H. Peter Anvin | fe50195 | 2007-10-02 21:53:51 -0700 | [diff] [blame] | 118 | |
H. Peter Anvin | 038d861 | 2007-04-12 16:54:50 +0000 | [diff] [blame] | 119 | AC_CHECK_FUNCS(getuid) |
| 120 | AC_CHECK_FUNCS(getgid) |
| 121 | |
H. Peter Anvin | 4627e69 | 2016-01-26 12:01:34 -0800 | [diff] [blame] | 122 | AC_CHECK_FUNCS(realpath) |
| 123 | AC_CHECK_FUNCS(canonicalize_file_name) |
| 124 | AC_CHECK_FUNCS(_fullpath) |
| 125 | AC_CHECK_FUNCS(pathconf) |
| 126 | |
H. Peter Anvin | e65e81b | 2016-02-18 14:24:40 -0800 | [diff] [blame] | 127 | AC_FUNC_FSEEKO |
H. Peter Anvin | ec82d7a | 2016-02-21 21:20:45 -0800 | [diff] [blame] | 128 | AC_CHECK_FUNCS([_fseeki64]) |
H. Peter Anvin | e65e81b | 2016-02-18 14:24:40 -0800 | [diff] [blame] | 129 | AC_CHECK_FUNCS([ftruncate _chsize _chsize_s]) |
H. Peter Anvin | 397c169 | 2016-10-04 17:01:59 -0700 | [diff] [blame] | 130 | AC_CHECK_FUNCS([fileno _fileno]) |
H. Peter Anvin | e65e81b | 2016-02-18 14:24:40 -0800 | [diff] [blame] | 131 | |
H. Peter Anvin | 397c169 | 2016-10-04 17:01:59 -0700 | [diff] [blame] | 132 | AC_CHECK_FUNCS(_filelengthi64) |
H. Peter Anvin | 895a66c | 2017-02-23 20:34:38 -0800 | [diff] [blame] | 133 | AC_FUNC_MMAP |
H. Peter Anvin | d81a235 | 2016-09-21 14:03:18 -0700 | [diff] [blame] | 134 | AC_CHECK_FUNCS(getpagesize) |
| 135 | AC_CHECK_FUNCS(sysconf) |
| 136 | |
H. Peter Anvin | 397c169 | 2016-10-04 17:01:59 -0700 | [diff] [blame] | 137 | AC_CHECK_FUNCS([access _access faccessat]) |
H. Peter Anvin | d81a235 | 2016-09-21 14:03:18 -0700 | [diff] [blame] | 138 | |
H. Peter Anvin | e558dfd | 2017-04-18 16:05:22 -0700 | [diff] [blame] | 139 | PA_HAVE_FUNC(__builtin_expect, (1,1)) |
| 140 | |
| 141 | dnl ilog2() building blocks |
| 142 | PA_ADD_HEADERS(intrin.h) |
H. Peter Anvin | 8d4fb26 | 2016-11-15 14:23:54 -0800 | [diff] [blame] | 143 | PA_HAVE_FUNC(__builtin_clz, (0U)) |
| 144 | PA_HAVE_FUNC(__builtin_clzl, (0UL)) |
| 145 | PA_HAVE_FUNC(__builtin_clzll, (0ULL)) |
H. Peter Anvin | e558dfd | 2017-04-18 16:05:22 -0700 | [diff] [blame] | 146 | PA_HAVE_FUNC(_BitScanReverse, (0)) |
| 147 | PA_HAVE_FUNC(_BitScanReverse64, (0)) |
H. Peter Anvin | d338b37 | 2016-02-18 00:54:30 -0800 | [diff] [blame] | 148 | |
| 149 | dnl Functions for which we have replacements available in lib/ |
H. Peter Anvin | cc147f7 | 2016-03-08 02:06:39 -0800 | [diff] [blame] | 150 | AC_CHECK_FUNCS([vsnprintf _vsnprintf]) |
| 151 | AC_CHECK_FUNCS([snprintf _snprintf]) |
| 152 | AC_CHECK_FUNCS([strlcpy]) |
H. Peter Anvin | d338b37 | 2016-02-18 00:54:30 -0800 | [diff] [blame] | 153 | |
H. Peter Anvin | 3118429 | 2017-04-06 15:30:56 -0700 | [diff] [blame] | 154 | dnl These types are POSIX-specific, and Windows does it differently... |
| 155 | AC_CHECK_TYPES([struct _stati64]) |
| 156 | AC_CHECK_TYPES([struct stat]) |
| 157 | AC_CHECK_FUNCS([stat _stati64]) |
| 158 | AC_CHECK_FUNCS([fstat _fstati64]) |
| 159 | |
H. Peter Anvin | c13d31a | 2007-10-26 18:49:29 -0700 | [diff] [blame] | 160 | dnl Check for functions that might not be declared in the headers for |
| 161 | dnl various idiotic reasons (mostly because of library authors |
| 162 | dnl abusing the meaning of __STRICT_ANSI__) |
| 163 | AC_CHECK_DECLS(strcasecmp) |
| 164 | AC_CHECK_DECLS(stricmp) |
| 165 | AC_CHECK_DECLS(strncasecmp) |
| 166 | AC_CHECK_DECLS(strnicmp) |
| 167 | AC_CHECK_DECLS(strsep) |
H. Peter Anvin | eaa68f1 | 2009-08-10 15:56:52 -0700 | [diff] [blame] | 168 | AC_CHECK_DECLS(strlcpy) |
H. Peter Anvin | 22538e2 | 2016-05-25 05:42:47 -0700 | [diff] [blame] | 169 | AC_CHECK_DECLS(strnlen) |
H. Peter Anvin | c13d31a | 2007-10-26 18:49:29 -0700 | [diff] [blame] | 170 | |
H. Peter Anvin | d81a235 | 2016-09-21 14:03:18 -0700 | [diff] [blame] | 171 | dnl Check for missing types |
| 172 | AC_TYPE_UINTPTR_T |
| 173 | |
H. Peter Anvin | f13effe | 2017-04-10 16:10:28 -0700 | [diff] [blame] | 174 | dnl Documentation: should we generate an uncompressed PDF? It is |
| 175 | dnl about twice as big, but it can be externally compressed (e.g. with xz) |
| 176 | dnl and becomes significantly smaller than the original. |
| 177 | PA_ARG_DISABLED([pdf-compression], |
| 178 | [generate an uncompressed documentation PDF], |
| 179 | [PDFOPT='-nocompress']) |
| 180 | AC_SUBST([PDFOPT]) |
| 181 | |
H. Peter Anvin | 8b19083 | 2016-11-15 14:01:37 -0800 | [diff] [blame] | 182 | dnl |
H. Peter Anvin | 5eb528b | 2017-04-18 15:49:25 -0700 | [diff] [blame] | 183 | dnl Look for byte-swapping support... |
| 184 | dnl |
H. Peter Anvin | e5033df | 2017-11-29 16:04:05 -0800 | [diff] [blame] | 185 | PA_ADD_HEADERS(endian.h sys/endian.h machine/endian.h) |
H. Peter Anvin | 5eb528b | 2017-04-18 15:49:25 -0700 | [diff] [blame] | 186 | PA_HAVE_FUNC(cpu_to_le16, (0)) |
| 187 | PA_HAVE_FUNC(cpu_to_le32, (0)) |
| 188 | PA_HAVE_FUNC(cpu_to_le64, (0)) |
| 189 | PA_HAVE_FUNC(__cpu_to_le16, (0)) |
| 190 | PA_HAVE_FUNC(__cpu_to_le32, (0)) |
| 191 | PA_HAVE_FUNC(__cpu_to_le64, (0)) |
| 192 | PA_HAVE_FUNC(htole16, (0)) |
| 193 | PA_HAVE_FUNC(htole32, (0)) |
| 194 | PA_HAVE_FUNC(htole64, (0)) |
| 195 | PA_HAVE_FUNC(__bswap_16, (0)) |
| 196 | PA_HAVE_FUNC(__bswap_32, (0)) |
| 197 | PA_HAVE_FUNC(__bswap_64, (0)) |
| 198 | PA_HAVE_FUNC(__builtin_bswap16, (0)) |
| 199 | PA_HAVE_FUNC(__builtin_bswap32, (0)) |
| 200 | PA_HAVE_FUNC(__builtin_bswap64, (0)) |
H. Peter Anvin | e558dfd | 2017-04-18 16:05:22 -0700 | [diff] [blame] | 201 | PA_HAVE_FUNC(_byteswap_ushort, (0)) |
| 202 | PA_HAVE_FUNC(_byteswap_ulong, (0)) |
| 203 | PA_HAVE_FUNC(_byteswap_uint64, (0)) |
H. Peter Anvin | 5eb528b | 2017-04-18 15:49:25 -0700 | [diff] [blame] | 204 | |
| 205 | dnl |
H. Peter Anvin | e5033df | 2017-11-29 16:04:05 -0800 | [diff] [blame] | 206 | dnl Check for __builtin_constant_p() |
| 207 | dnl |
| 208 | PA_HAVE_FUNC(__builtin_constant_p, (0)) |
| 209 | |
| 210 | dnl |
H. Peter Anvin | 8b19083 | 2016-11-15 14:01:37 -0800 | [diff] [blame] | 211 | dnl Check for supported gcc attributes; some compilers (e.g. Sun CC) |
| 212 | dnl support these, but don't define __GNUC__ as they don't support |
| 213 | dnl some other features of gcc. |
| 214 | dnl |
H. Peter Anvin | bc18af1 | 2017-02-23 19:22:27 -0800 | [diff] [blame] | 215 | PA_ADD_CFLAGS([-Werror=attributes]) |
H. Peter Anvin | 8b19083 | 2016-11-15 14:01:37 -0800 | [diff] [blame] | 216 | PA_FUNC_ATTRIBUTE(noreturn) |
| 217 | PA_FUNC_ATTRIBUTE(returns_nonnull) |
| 218 | PA_FUNC_ATTRIBUTE(malloc) |
| 219 | PA_FUNC_ATTRIBUTE(alloc_size, (1)) |
| 220 | PA_FUNC_ATTRIBUTE(format, [(printf,1,2)], int, [const char *, ...], ["%d",1]) |
| 221 | PA_FUNC_ATTRIBUTE(const) |
| 222 | PA_FUNC_ATTRIBUTE(pure) |
H. Peter Anvin | abd28c9 | 2016-12-20 02:29:58 -0800 | [diff] [blame] | 223 | PA_FUNC_ATTRIBUTE_ERROR |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 224 | |
Cyrill Gorcunov | 325768e | 2010-11-11 11:18:44 +0300 | [diff] [blame] | 225 | dnl |
H. Peter Anvin | 53259e8 | 2017-10-11 16:47:59 -0700 | [diff] [blame] | 226 | dnl support function sections (if available) |
Cyrill Gorcunov | 325768e | 2010-11-11 11:18:44 +0300 | [diff] [blame] | 227 | dnl |
H. Peter Anvin | 0da1549 | 2017-04-06 15:24:58 -0700 | [diff] [blame] | 228 | PA_ARG_ENABLED([sections], |
| 229 | [compile with function/data section support], |
H. Peter Anvin | 26fad14 | 2017-04-23 21:42:31 -0700 | [diff] [blame] | 230 | [PA_ADD_CLDFLAGS([-ffunction-sections]) |
| 231 | PA_ADD_CLDFLAGS([-fdata-sections]) |
| 232 | PA_ADD_CLDFLAGS([-Wl,--gc-sections])], |
H. Peter Anvin | 0da1549 | 2017-04-06 15:24:58 -0700 | [diff] [blame] | 233 | []) |
H. Peter Anvin | 53259e8 | 2017-10-11 16:47:59 -0700 | [diff] [blame] | 234 | |
H. Peter Anvin | 5fe847e | 2017-02-28 18:48:01 -0800 | [diff] [blame] | 235 | dnl |
| 236 | dnl support LTO |
| 237 | dnl |
H. Peter Anvin | 0da1549 | 2017-04-06 15:24:58 -0700 | [diff] [blame] | 238 | PA_ARG_ENABLED([lto], |
| 239 | [compile with gcc-style link time optimization], |
| 240 | [PA_ADD_CLDFLAGS([-flto]) |
| 241 | dnl Note: we use _PROG rather than _TOOL since we are prepending the full |
| 242 | dnl CC name which ought to already contain the host triplet if needed |
| 243 | ccbase=`echo "$CC" | awk '{ print $1; }'` |
| 244 | AC_CHECK_PROGS(CC_AR, [${ccbase}-ar], [$ac_cv_prog_AR]) |
| 245 | AR="$CC_AR" |
| 246 | AC_CHECK_PROGS(CC_RANLIB, [${ccbase}-ranlib], [$ac_cv_prog_RANLIB]) |
| 247 | RANLIB="$CC_RANLIB"], []) |
H. Peter Anvin | 5fe847e | 2017-02-28 18:48:01 -0800 | [diff] [blame] | 248 | |
H. Peter Anvin | 53259e8 | 2017-10-11 16:47:59 -0700 | [diff] [blame] | 249 | dnl |
| 250 | dnl support sanitizers (if available) |
| 251 | dnl |
| 252 | PA_ARG_ENABLED([sanitizer], |
| 253 | [compile with sanitizers enabled], |
| 254 | [PA_ADD_CFLAGS([-fno-omit-frame-pointer]) |
| 255 | PA_ADD_CLDFLAGS([-fsanitize=address]) |
| 256 | PA_ADD_CLDFLAGS([-fsanitize=undefined])]) |
| 257 | |
H. Peter Anvin | b9c1ca7 | 2016-03-01 21:51:40 -0800 | [diff] [blame] | 258 | dnl If we have gcc, add appropriate code cleanliness options |
H. Peter Anvin | d338b37 | 2016-02-18 00:54:30 -0800 | [diff] [blame] | 259 | PA_ADD_CFLAGS([-W]) |
| 260 | PA_ADD_CFLAGS([-Wall]) |
Ozkan Sezer | ec3d426 | 2016-02-12 23:49:49 -0800 | [diff] [blame] | 261 | PA_ADD_CFLAGS([-pedantic]) |
H. Peter Anvin | c9fd7b2 | 2016-05-16 21:35:48 -0700 | [diff] [blame] | 262 | dnl LLVM doesn't error out on invalid -W options unless this option is |
| 263 | dnl specified first. Enable this so this script can actually discover |
| 264 | dnl which -W options are possible for this compiler. |
| 265 | PA_ADD_CFLAGS([-Werror=unknown-warning-option]) |
H. Peter Anvin | 25da6ea | 2016-03-01 22:20:10 -0800 | [diff] [blame] | 266 | dnl Suppress format warning on Windows targets due to their <inttypes.h> |
| 267 | PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format]) |
| 268 | PA_ADD_CFLAGS([-Wc90-c99-compat]) |
| 269 | PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long]) |
H. Peter Anvin | cfd56eb | 2016-03-06 21:44:14 -0800 | [diff] [blame] | 270 | dnl PA_ADD_CFLAGS([-Wwrite-strings]) |
H. Peter Anvin | 0da1549 | 2017-04-06 15:24:58 -0700 | [diff] [blame] | 271 | PA_ARG_ENABLED([werror], |
| 272 | [compile with -Werror to error out on any warning], |
| 273 | [PA_ADD_CFLAGS([-Werror])], |
| 274 | [PA_ADD_CFLAGS([-Werror=implicit]) |
| 275 | PA_ADD_CFLAGS([-Werror=missing-braces]) |
| 276 | PA_ADD_CFLAGS([-Werror=return-type]) |
| 277 | PA_ADD_CFLAGS([-Werror=trigraphs]) |
| 278 | PA_ADD_CFLAGS([-Werror=pointer-arith]) |
| 279 | PA_ADD_CFLAGS([-Werror=strict-prototypes]) |
| 280 | PA_ADD_CFLAGS([-Werror=missing-prototypes]) |
| 281 | PA_ADD_CFLAGS([-Werror=missing-declarations]) |
| 282 | PA_ADD_CFLAGS([-Werror=comment]) |
| 283 | PA_ADD_CFLAGS([-Werror=vla])] |
| 284 | ) |
Ozkan Sezer | ec3d426 | 2016-02-12 23:49:49 -0800 | [diff] [blame] | 285 | |
H. Peter Anvin | 0c36965 | 2017-02-28 19:34:36 -0800 | [diff] [blame] | 286 | dnl |
| 287 | dnl support ccache |
| 288 | dnl |
H. Peter Anvin | 0da1549 | 2017-04-06 15:24:58 -0700 | [diff] [blame] | 289 | PA_ARG_ENABLED([ccache], [compile with ccache], [CC="ccache $CC"], []) |
H. Peter Anvin | 0c36965 | 2017-02-28 19:34:36 -0800 | [diff] [blame] | 290 | |
Ed Beroset | 74fa0a7 | 2017-04-14 17:08:15 -0400 | [diff] [blame] | 291 | 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] | 292 | AC_OUTPUT(Makefile doc/Makefile) |