H. Peter Anvin | d338b37 | 2016-02-18 00:54:30 -0800 | [diff] [blame] | 1 | dnl Process this file with autoconf 2.63 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 | d338b37 | 2016-02-18 00:54:30 -0800 | [diff] [blame] | 3 | AC_PREREQ(2.63) |
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 | |
| 9 | dnl Checks for programs. |
H. Peter Anvin | 70a5d14 | 2007-10-13 23:12:46 -0700 | [diff] [blame] | 10 | dnl Consider AC_USE_SYSTEM_EXTENSIONS if autoconf 2.61 is OK in the future |
H. Peter Anvin | 2f0f9ea | 2008-06-08 20:53:29 -0700 | [diff] [blame] | 11 | AC_USE_SYSTEM_EXTENSIONS |
H. Peter Anvin | b423c02 | 2016-02-18 11:57:53 -0800 | [diff] [blame] | 12 | AC_SYS_LARGEFILE |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 13 | AC_PROG_CC |
H. Peter Anvin | d338b37 | 2016-02-18 00:54:30 -0800 | [diff] [blame] | 14 | AC_PROG_CC_STDC |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 15 | AC_PROG_LN_S |
| 16 | AC_PROG_MAKE_SET |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 17 | AC_PROG_INSTALL |
| 18 | |
H. Peter Anvin | 89c1770 | 2016-03-09 14:11:40 -0800 | [diff] [blame] | 19 | dnl Check for library extension |
| 20 | PA_LIBEXT |
| 21 | |
Cyrill Gorcunov | 7729edf | 2014-12-20 11:35:51 +0300 | [diff] [blame] | 22 | dnl Checks for typedefs, structures, and compiler characteristics. |
| 23 | AC_C_CONST |
H. Peter Anvin | 03f229c | 2015-11-04 11:29:09 -0800 | [diff] [blame] | 24 | AC_C_INLINE |
Cyrill Gorcunov | 7729edf | 2014-12-20 11:35:51 +0300 | [diff] [blame] | 25 | AC_C_RESTRICT |
| 26 | AC_TYPE_SIZE_T |
H. Peter Anvin | ef63588 | 2016-03-01 21:53:09 -0800 | [diff] [blame] | 27 | AC_C_BIGENDIAN(AC_DEFINE(WORDS_BIGENDIAN),AC_DEFINE(WORDS_LITTLEENDIAN),,) |
Cyrill Gorcunov | 7729edf | 2014-12-20 11:35:51 +0300 | [diff] [blame] | 28 | AH_TEMPLATE(WORDS_BIGENDIAN, |
| 29 | [Define to 1 if your processor stores words with the most significant |
| 30 | byte first (like Motorola and SPARC, unlike Intel and VAX).]) |
| 31 | AH_TEMPLATE(WORDS_LITTLEENDIAN, |
| 32 | [Define to 1 if your processor stores words with the least significant |
| 33 | byte first (like Intel and VAX, unlike Motorola and SPARC).]) |
| 34 | |
H. Peter Anvin | 8b19083 | 2016-11-15 14:01:37 -0800 | [diff] [blame] | 35 | PA_ADD_CFLAGS([-std=c99]) |
| 36 | |
H. Peter Anvin | b9c1ca7 | 2016-03-01 21:51:40 -0800 | [diff] [blame] | 37 | dnl Force gcc and gcc-compatible compilers treat signed integers |
| 38 | dnl as 2's complement |
H. Peter Anvin | 8d9f591 | 2016-02-27 00:15:13 -0800 | [diff] [blame] | 39 | PA_ADD_CFLAGS([-fwrapv]) |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 40 | |
H. Peter Anvin | 8b19083 | 2016-11-15 14:01:37 -0800 | [diff] [blame] | 41 | dnl Some environments abuse __STRICT_ANSI__ to disable some |
| 42 | dnl function declarations |
| 43 | PA_ADD_CFLAGS([-U__STRICT_ANSI__]) |
| 44 | |
H. Peter Anvin | 43e0262 | 2016-08-02 09:28:22 -0700 | [diff] [blame] | 45 | dnl Don't put things in common if we can avoid it. We don't want to |
| 46 | dnl assume all compilers support common, and this will help find those |
| 47 | dnl problems. This also works around an OSX linker problem. |
| 48 | PA_ADD_CFLAGS([-fno-common]) |
| 49 | |
H. Peter Anvin | eec3b52 | 2008-06-19 11:39:23 -0700 | [diff] [blame] | 50 | dnl Look for programs... |
H. Peter Anvin | a939783 | 2013-05-17 12:02:49 -0700 | [diff] [blame] | 51 | AC_CHECK_PROGS(NROFF, nroff, false) |
H. Peter Anvin | d089c22 | 2013-10-24 13:22:19 +0100 | [diff] [blame] | 52 | AC_CHECK_PROGS(ASCIIDOC, asciidoc, false) |
| 53 | AC_CHECK_PROGS(XMLTO, xmlto, false) |
H. Peter Anvin | eec3b52 | 2008-06-19 11:39:23 -0700 | [diff] [blame] | 54 | AC_CHECK_PROGS(ACRODIST, acrodist, false) |
| 55 | AC_CHECK_PROGS(PS2PDF, ps2pdf, false) |
| 56 | AC_CHECK_PROGS(PSTOPDF, pstopdf, false) |
H. Peter Anvin | 620515a | 2002-04-30 20:57:38 +0000 | [diff] [blame] | 57 | |
H. Peter Anvin | d089c22 | 2013-10-24 13:22:19 +0100 | [diff] [blame] | 58 | dnl Check for progs needed for manpage generation |
| 59 | if test $ASCIIDOC = false; then |
H. Peter Anvin | cc147f7 | 2016-03-08 02:06:39 -0800 | [diff] [blame] | 60 | AC_MSG_WARN([No asciidoc package found]) |
H. Peter Anvin | d089c22 | 2013-10-24 13:22:19 +0100 | [diff] [blame] | 61 | fi |
| 62 | if test $XMLTO = false; then |
| 63 | AC_MSG_WARN([No xmlto package found]) |
| 64 | fi |
| 65 | |
H. Peter Anvin | cc147f7 | 2016-03-08 02:06:39 -0800 | [diff] [blame] | 66 | dnl Check for host compiler tools |
| 67 | AC_CHECK_TOOL(AR, ar) |
| 68 | AC_CHECK_TOOL(RANLIB, ranlib, :) |
| 69 | AC_CHECK_TOOL(STRIP, strip) |
| 70 | |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 71 | dnl Checks for header files. |
| 72 | AC_HEADER_STDC |
H. Peter Anvin | 3ef4f00 | 2016-03-08 12:14:55 -0800 | [diff] [blame] | 73 | AC_CHECK_HEADERS(inttypes.h) |
H. Peter Anvin | fe50195 | 2007-10-02 21:53:51 -0700 | [diff] [blame] | 74 | AC_CHECK_HEADERS(strings.h) |
H. Peter Anvin | d338b37 | 2016-02-18 00:54:30 -0800 | [diff] [blame] | 75 | AC_HEADER_STDBOOL |
H. Peter Anvin | e65e81b | 2016-02-18 14:24:40 -0800 | [diff] [blame] | 76 | AC_CHECK_HEADERS(io.h) |
H. Peter Anvin | d81a235 | 2016-09-21 14:03:18 -0700 | [diff] [blame] | 77 | AC_CHECK_HEADERS(fcntl.h) |
H. Peter Anvin | 4627e69 | 2016-01-26 12:01:34 -0800 | [diff] [blame] | 78 | AC_CHECK_HEADERS(unistd.h) |
H. Peter Anvin | 4627e69 | 2016-01-26 12:01:34 -0800 | [diff] [blame] | 79 | AC_CHECK_HEADERS(sys/param.h) |
H. Peter Anvin | d81a235 | 2016-09-21 14:03:18 -0700 | [diff] [blame] | 80 | AC_CHECK_HEADERS(sys/mman.h) |
| 81 | AC_CHECK_HEADERS(sys/stat.h) |
H. Peter Anvin | 4c9132e | 2016-10-19 13:13:38 -0700 | [diff] [blame] | 82 | AC_CHECK_HEADERS(sys/types.h) |
H. Peter Anvin | 4627e69 | 2016-01-26 12:01:34 -0800 | [diff] [blame] | 83 | |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 84 | dnl Checks for library functions. |
H. Peter Anvin | fe50195 | 2007-10-02 21:53:51 -0700 | [diff] [blame] | 85 | AC_CHECK_FUNCS(strcasecmp stricmp) |
| 86 | AC_CHECK_FUNCS(strncasecmp strnicmp) |
H. Peter Anvin | 73b22f5 | 2016-02-18 14:40:37 -0800 | [diff] [blame] | 87 | AC_CHECK_FUNCS(strsep) |
H. Peter Anvin | 22538e2 | 2016-05-25 05:42:47 -0700 | [diff] [blame] | 88 | AC_CHECK_FUNCS(strnlen) |
H. Peter Anvin | fe50195 | 2007-10-02 21:53:51 -0700 | [diff] [blame] | 89 | |
H. Peter Anvin | 038d861 | 2007-04-12 16:54:50 +0000 | [diff] [blame] | 90 | AC_CHECK_FUNCS(getuid) |
| 91 | AC_CHECK_FUNCS(getgid) |
| 92 | |
H. Peter Anvin | 4627e69 | 2016-01-26 12:01:34 -0800 | [diff] [blame] | 93 | AC_CHECK_FUNCS(realpath) |
| 94 | AC_CHECK_FUNCS(canonicalize_file_name) |
| 95 | AC_CHECK_FUNCS(_fullpath) |
| 96 | AC_CHECK_FUNCS(pathconf) |
| 97 | |
H. Peter Anvin | e65e81b | 2016-02-18 14:24:40 -0800 | [diff] [blame] | 98 | AC_FUNC_FSEEKO |
H. Peter Anvin | ec82d7a | 2016-02-21 21:20:45 -0800 | [diff] [blame] | 99 | AC_CHECK_FUNCS([_fseeki64]) |
H. Peter Anvin | e65e81b | 2016-02-18 14:24:40 -0800 | [diff] [blame] | 100 | AC_CHECK_FUNCS([ftruncate _chsize _chsize_s]) |
H. Peter Anvin | 397c169 | 2016-10-04 17:01:59 -0700 | [diff] [blame] | 101 | AC_CHECK_FUNCS([fileno _fileno]) |
H. Peter Anvin | e65e81b | 2016-02-18 14:24:40 -0800 | [diff] [blame] | 102 | |
H. Peter Anvin | 397c169 | 2016-10-04 17:01:59 -0700 | [diff] [blame] | 103 | AC_CHECK_FUNCS(_filelengthi64) |
| 104 | AC_CHECK_FUNCS([stat _stati64]) |
H. Peter Anvin | d81a235 | 2016-09-21 14:03:18 -0700 | [diff] [blame] | 105 | AC_CHECK_FUNCS(fstat) |
| 106 | AC_CHECK_FUNCS(mmap) |
| 107 | AC_CHECK_FUNCS(getpagesize) |
| 108 | AC_CHECK_FUNCS(sysconf) |
| 109 | |
H. Peter Anvin | 397c169 | 2016-10-04 17:01:59 -0700 | [diff] [blame] | 110 | AC_CHECK_FUNCS([access _access faccessat]) |
H. Peter Anvin | d81a235 | 2016-09-21 14:03:18 -0700 | [diff] [blame] | 111 | |
H. Peter Anvin | 8d4fb26 | 2016-11-15 14:23:54 -0800 | [diff] [blame^] | 112 | PA_HAVE_FUNC(__builtin_clz, (0U)) |
| 113 | PA_HAVE_FUNC(__builtin_clzl, (0UL)) |
| 114 | PA_HAVE_FUNC(__builtin_clzll, (0ULL)) |
H. Peter Anvin | 8b19083 | 2016-11-15 14:01:37 -0800 | [diff] [blame] | 115 | PA_HAVE_FUNC(__builtin_expect, (1,1)) |
H. Peter Anvin | d338b37 | 2016-02-18 00:54:30 -0800 | [diff] [blame] | 116 | |
| 117 | dnl Functions for which we have replacements available in lib/ |
H. Peter Anvin | cc147f7 | 2016-03-08 02:06:39 -0800 | [diff] [blame] | 118 | AC_CHECK_FUNCS([vsnprintf _vsnprintf]) |
| 119 | AC_CHECK_FUNCS([snprintf _snprintf]) |
| 120 | AC_CHECK_FUNCS([strlcpy]) |
H. Peter Anvin | d338b37 | 2016-02-18 00:54:30 -0800 | [diff] [blame] | 121 | |
H. Peter Anvin | c13d31a | 2007-10-26 18:49:29 -0700 | [diff] [blame] | 122 | dnl Check for functions that might not be declared in the headers for |
| 123 | dnl various idiotic reasons (mostly because of library authors |
| 124 | dnl abusing the meaning of __STRICT_ANSI__) |
| 125 | AC_CHECK_DECLS(strcasecmp) |
| 126 | AC_CHECK_DECLS(stricmp) |
| 127 | AC_CHECK_DECLS(strncasecmp) |
| 128 | AC_CHECK_DECLS(strnicmp) |
| 129 | AC_CHECK_DECLS(strsep) |
H. Peter Anvin | eaa68f1 | 2009-08-10 15:56:52 -0700 | [diff] [blame] | 130 | AC_CHECK_DECLS(strlcpy) |
H. Peter Anvin | 22538e2 | 2016-05-25 05:42:47 -0700 | [diff] [blame] | 131 | AC_CHECK_DECLS(strnlen) |
H. Peter Anvin | c13d31a | 2007-10-26 18:49:29 -0700 | [diff] [blame] | 132 | |
H. Peter Anvin | d81a235 | 2016-09-21 14:03:18 -0700 | [diff] [blame] | 133 | dnl Check for missing types |
| 134 | AC_TYPE_UINTPTR_T |
| 135 | |
H. Peter Anvin | 8b19083 | 2016-11-15 14:01:37 -0800 | [diff] [blame] | 136 | dnl |
| 137 | dnl Check for supported gcc attributes; some compilers (e.g. Sun CC) |
| 138 | dnl support these, but don't define __GNUC__ as they don't support |
| 139 | dnl some other features of gcc. |
| 140 | dnl |
| 141 | PA_FUNC_ATTRIBUTE(noreturn) |
| 142 | PA_FUNC_ATTRIBUTE(returns_nonnull) |
| 143 | PA_FUNC_ATTRIBUTE(malloc) |
| 144 | PA_FUNC_ATTRIBUTE(alloc_size, (1)) |
| 145 | PA_FUNC_ATTRIBUTE(format, [(printf,1,2)], int, [const char *, ...], ["%d",1]) |
| 146 | PA_FUNC_ATTRIBUTE(const) |
| 147 | PA_FUNC_ATTRIBUTE(pure) |
H. Peter Anvin | 87bc619 | 2002-04-30 20:53:16 +0000 | [diff] [blame] | 148 | |
Cyrill Gorcunov | 325768e | 2010-11-11 11:18:44 +0300 | [diff] [blame] | 149 | dnl |
| 150 | dnl support cchace |
| 151 | dnl |
H. Peter Anvin | 44a609b | 2016-02-18 12:09:31 -0800 | [diff] [blame] | 152 | AC_ARG_ENABLE([ccache], |
| 153 | [AC_HELP_STRING([--with-ccache], [compile with ccache])], |
| 154 | [CC="ccache $CC"], |
| 155 | []) |
Cyrill Gorcunov | 325768e | 2010-11-11 11:18:44 +0300 | [diff] [blame] | 156 | |
H. Peter Anvin | b9c1ca7 | 2016-03-01 21:51:40 -0800 | [diff] [blame] | 157 | dnl If we have gcc, add appropriate code cleanliness options |
H. Peter Anvin | d338b37 | 2016-02-18 00:54:30 -0800 | [diff] [blame] | 158 | PA_ADD_CFLAGS([-W]) |
| 159 | PA_ADD_CFLAGS([-Wall]) |
Ozkan Sezer | ec3d426 | 2016-02-12 23:49:49 -0800 | [diff] [blame] | 160 | PA_ADD_CFLAGS([-pedantic]) |
H. Peter Anvin | c9fd7b2 | 2016-05-16 21:35:48 -0700 | [diff] [blame] | 161 | dnl LLVM doesn't error out on invalid -W options unless this option is |
| 162 | dnl specified first. Enable this so this script can actually discover |
| 163 | dnl which -W options are possible for this compiler. |
| 164 | PA_ADD_CFLAGS([-Werror=unknown-warning-option]) |
H. Peter Anvin | 25da6ea | 2016-03-01 22:20:10 -0800 | [diff] [blame] | 165 | dnl Suppress format warning on Windows targets due to their <inttypes.h> |
| 166 | PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format]) |
| 167 | PA_ADD_CFLAGS([-Wc90-c99-compat]) |
| 168 | PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long]) |
H. Peter Anvin | cfd56eb | 2016-03-06 21:44:14 -0800 | [diff] [blame] | 169 | dnl PA_ADD_CFLAGS([-Wwrite-strings]) |
H. Peter Anvin | 44a609b | 2016-02-18 12:09:31 -0800 | [diff] [blame] | 170 | AC_ARG_ENABLE([werror], |
| 171 | [AC_HELP_STRING([--enable-werror], |
| 172 | [compile with -Werror to error out on any warning])], |
H. Peter Anvin | fdf0d07 | 2016-03-03 12:39:02 -0800 | [diff] [blame] | 173 | [], [enable_werror=no]) |
| 174 | AS_IF([test x"$enable_werror" != xno], |
H. Peter Anvin | 44a609b | 2016-02-18 12:09:31 -0800 | [diff] [blame] | 175 | [PA_ADD_CFLAGS([-Werror])], |
| 176 | [PA_ADD_CFLAGS([-Werror=implicit]) |
Ozkan Sezer | ec3d426 | 2016-02-12 23:49:49 -0800 | [diff] [blame] | 177 | PA_ADD_CFLAGS([-Werror=missing-braces]) |
| 178 | PA_ADD_CFLAGS([-Werror=return-type]) |
| 179 | PA_ADD_CFLAGS([-Werror=trigraphs]) |
| 180 | PA_ADD_CFLAGS([-Werror=pointer-arith]) |
| 181 | PA_ADD_CFLAGS([-Werror=strict-prototypes]) |
| 182 | PA_ADD_CFLAGS([-Werror=missing-prototypes]) |
| 183 | PA_ADD_CFLAGS([-Werror=missing-declarations]) |
| 184 | PA_ADD_CFLAGS([-Werror=comment]) |
H. Peter Anvin | 44a609b | 2016-02-18 12:09:31 -0800 | [diff] [blame] | 185 | PA_ADD_CFLAGS([-Werror=vla])]) |
Ozkan Sezer | ec3d426 | 2016-02-12 23:49:49 -0800 | [diff] [blame] | 186 | |
H. Peter Anvin | 397c169 | 2016-10-04 17:01:59 -0700 | [diff] [blame] | 187 | AC_OUTPUT_COMMANDS([mkdir -p config nasmlib nsis output stdlib x86 asm disasm]) |
H. Peter Anvin | 0fcdade | 2002-05-19 01:57:54 +0000 | [diff] [blame] | 188 | AC_OUTPUT(Makefile rdoff/Makefile doc/Makefile) |