1 dnl Process this file with autoconf 2.63 or later to produce
2 dnl a configure script.
4 AC_INIT(config/config.h.in)
5 AC_CONFIG_HEADERS(config/config.h)
7 AC_PREFIX_PROGRAM(nasm)
9 dnl Checks for programs.
10 dnl Consider AC_USE_SYSTEM_EXTENSIONS if autoconf 2.61 is OK in the future
11 AC_USE_SYSTEM_EXTENSIONS
19 dnl Check for library extension
22 dnl Checks for typedefs, structures, and compiler characteristics.
27 AC_C_BIGENDIAN(AC_DEFINE(WORDS_BIGENDIAN),AC_DEFINE(WORDS_LITTLEENDIAN),,)
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).])
35 dnl Force gcc and gcc-compatible compilers treat signed integers
37 PA_ADD_CFLAGS([-fwrapv])
39 dnl Some environments abuse __STRICT_ANSI__ to disable some
40 dnl function declarations
41 PA_ADD_CFLAGS([-U__STRICT_ANSI__])
43 dnl Don't put things in common if we can avoid it. We don't want to
44 dnl assume all compilers support common, and this will help find those
45 dnl problems. This also works around an OSX linker problem.
46 PA_ADD_CFLAGS([-fno-common])
48 dnl Look for programs...
49 AC_CHECK_PROGS(NROFF, nroff, false)
50 AC_CHECK_PROGS(ASCIIDOC, asciidoc, false)
51 AC_CHECK_PROGS(XMLTO, xmlto, false)
52 AC_CHECK_PROGS(ACRODIST, acrodist, false)
53 AC_CHECK_PROGS(PS2PDF, ps2pdf, false)
54 AC_CHECK_PROGS(PSTOPDF, pstopdf, false)
56 dnl Check for progs needed for manpage generation
57 if test $ASCIIDOC = false; then
58 AC_MSG_WARN([No asciidoc package found])
60 if test $XMLTO = false; then
61 AC_MSG_WARN([No xmlto package found])
64 dnl Check for host compiler tools
66 AC_CHECK_TOOL(RANLIB, ranlib, :)
67 AC_CHECK_TOOL(STRIP, strip)
69 dnl Checks for header files.
71 AC_CHECK_HEADERS(inttypes.h)
72 AC_CHECK_HEADERS(strings.h)
74 AC_CHECK_HEADERS(stdnoreturn.h)
75 AC_CHECK_HEADERS(io.h)
76 AC_CHECK_HEADERS(fcntl.h)
77 AC_CHECK_HEADERS(unistd.h)
78 AC_CHECK_HEADERS(sys/param.h)
79 AC_CHECK_HEADERS(sys/mman.h)
80 AC_CHECK_HEADERS(sys/stat.h)
81 AC_CHECK_HEADERS(sys/types.h)
83 dnl Checks for library functions.
84 AC_CHECK_FUNCS(strcasecmp stricmp)
85 AC_CHECK_FUNCS(strncasecmp strnicmp)
86 AC_CHECK_FUNCS(strsep)
87 AC_CHECK_FUNCS(strnlen)
89 AC_CHECK_FUNCS(getuid)
90 AC_CHECK_FUNCS(getgid)
92 AC_CHECK_FUNCS(realpath)
93 AC_CHECK_FUNCS(canonicalize_file_name)
94 AC_CHECK_FUNCS(_fullpath)
95 AC_CHECK_FUNCS(pathconf)
98 AC_CHECK_FUNCS([_fseeki64])
99 AC_CHECK_FUNCS([ftruncate _chsize _chsize_s])
100 AC_CHECK_FUNCS([fileno _fileno])
102 AC_CHECK_FUNCS(_filelengthi64)
103 AC_CHECK_FUNCS([stat _stati64])
104 AC_CHECK_FUNCS(fstat)
106 AC_CHECK_FUNCS(getpagesize)
107 AC_CHECK_FUNCS(sysconf)
109 AC_CHECK_FUNCS([access _access faccessat])
111 PA_HAVE_FUNC(__builtin_clz, (0U))
112 PA_HAVE_FUNC(__builtin_clzl, (0UL))
113 PA_HAVE_FUNC(__builtin_clzll, (0ULL))
114 PA_HAVE_FUNC(__builtin_expect, (1,1))
116 dnl Functions for which we have replacements available in lib/
117 AC_CHECK_FUNCS([vsnprintf _vsnprintf])
118 AC_CHECK_FUNCS([snprintf _snprintf])
119 AC_CHECK_FUNCS([strlcpy])
121 dnl Check for functions that might not be declared in the headers for
122 dnl various idiotic reasons (mostly because of library authors
123 dnl abusing the meaning of __STRICT_ANSI__)
124 AC_CHECK_DECLS(strcasecmp)
125 AC_CHECK_DECLS(stricmp)
126 AC_CHECK_DECLS(strncasecmp)
127 AC_CHECK_DECLS(strnicmp)
128 AC_CHECK_DECLS(strsep)
129 AC_CHECK_DECLS(strlcpy)
130 AC_CHECK_DECLS(strnlen)
132 dnl Check for missing types
136 dnl Check for supported gcc attributes; some compilers (e.g. Sun CC)
137 dnl support these, but don't define __GNUC__ as they don't support
138 dnl some other features of gcc.
140 PA_ADD_CFLAGS([-Werror=attributes])
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)
148 PA_FUNC_ATTRIBUTE_ERROR
153 AC_ARG_ENABLE([ccache],
154 [AC_HELP_STRING([--with-ccache], [compile with ccache])],
158 dnl If we have gcc, add appropriate code cleanliness options
160 PA_ADD_CFLAGS([-Wall])
161 PA_ADD_CFLAGS([-pedantic])
162 dnl LLVM doesn't error out on invalid -W options unless this option is
163 dnl specified first. Enable this so this script can actually discover
164 dnl which -W options are possible for this compiler.
165 PA_ADD_CFLAGS([-Werror=unknown-warning-option])
166 dnl Suppress format warning on Windows targets due to their <inttypes.h>
167 PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format])
168 PA_ADD_CFLAGS([-Wc90-c99-compat])
169 PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long])
170 dnl PA_ADD_CFLAGS([-Wwrite-strings])
171 AC_ARG_ENABLE([werror],
172 [AC_HELP_STRING([--enable-werror],
173 [compile with -Werror to error out on any warning])],
174 [], [enable_werror=no])
175 AS_IF([test x"$enable_werror" != xno],
176 [PA_ADD_CFLAGS([-Werror])],
177 [PA_ADD_CFLAGS([-Werror=implicit])
178 PA_ADD_CFLAGS([-Werror=missing-braces])
179 PA_ADD_CFLAGS([-Werror=return-type])
180 PA_ADD_CFLAGS([-Werror=trigraphs])
181 PA_ADD_CFLAGS([-Werror=pointer-arith])
182 PA_ADD_CFLAGS([-Werror=strict-prototypes])
183 PA_ADD_CFLAGS([-Werror=missing-prototypes])
184 PA_ADD_CFLAGS([-Werror=missing-declarations])
185 PA_ADD_CFLAGS([-Werror=comment])
186 PA_ADD_CFLAGS([-Werror=vla])])
188 AC_OUTPUT_COMMANDS([mkdir -p config nasmlib nsis output stdlib x86 asm disasm])
189 AC_OUTPUT(Makefile rdoff/Makefile doc/Makefile)