BR 3392437: Fix diagnostic for negative value in TIMES
[nasm.git] / configure.ac
blob37f51afd31f0abfe664fbf7189e720295ef42018
1 dnl Process this file with autoconf 2.63 or later to produce
2 dnl a configure script.
3 AC_PREREQ(2.63)
4 AC_INIT(config/config.h.in)
5 AC_CONFIG_HEADERS(config/config.h)
7 AC_PREFIX_PROGRAM(nasm)
9 dnl Save initial CFLAGS, to see if -g -O2 came from configure or not
10 pa_init_cflags="$CFLAGS"
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
18 dnl Checks for programs and enable necessary CC extensions
19 AC_USE_SYSTEM_EXTENSIONS
20 AC_SYS_LARGEFILE
21 AC_PROG_CC
22 AC_PROG_CC_STDC
23 AC_PROG_LN_S
24 AC_PROG_MAKE_SET
25 AC_PROG_INSTALL
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])
32 AS_IF([test x"$pa_init_cflags" = x],
33       [CFLAGS=`echo "$CFLAGS" | sed -e "s/-O2/$pa_optimize/"`])
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],
38  [CFLAGS=`echo "$CFLAGS" | sed -e "s/\(-O2\|-O3\)/-O0/"`
39    PA_ADD_CLDFLAGS([-ggdb3])])
41 dnl Check for library extension
42 PA_LIBEXT
44 dnl Checks for typedefs, structures, and compiler characteristics.
45 AC_C_CONST
46 AC_C_INLINE
47 AC_C_RESTRICT
48 AC_TYPE_SIZE_T
49 AC_C_BIGENDIAN(AC_DEFINE(WORDS_BIGENDIAN),AC_DEFINE(WORDS_LITTLEENDIAN),,)
50 AH_TEMPLATE(WORDS_BIGENDIAN,
51 [Define to 1 if your processor stores words with the most significant
52 byte first (like Motorola and SPARC, unlike Intel and VAX).])
53 AH_TEMPLATE(WORDS_LITTLEENDIAN,
54 [Define to 1 if your processor stores words with the least significant
55 byte first (like Intel and VAX, unlike Motorola and SPARC).])
57 dnl Force gcc and gcc-compatible compilers treat signed integers
58 dnl as 2's complement
59 PA_ADD_CFLAGS([-fwrapv])
61 dnl Some environments abuse __STRICT_ANSI__ to disable some
62 dnl function declarations
63 PA_ADD_CFLAGS([-U__STRICT_ANSI__])
65 dnl Don't put things in common if we can avoid it.  We don't want to
66 dnl assume all compilers support common, and this will help find those
67 dnl problems.  This also works around an OSX linker problem.
68 PA_ADD_CFLAGS([-fno-common])
70 dnl Look for programs...
71 AC_CHECK_PROGS(NROFF,    nroff,    false)
72 AC_CHECK_PROGS(ASCIIDOC, asciidoc, false)
73 AC_CHECK_PROGS(XMLTO,    xmlto,    false)
75 dnl Check for progs needed for manpage generation
76 AS_IF([test $ASCIIDOC = false],
77   [AC_MSG_WARN([No asciidoc package found])]
79 AS_IF([test $XMLTO = false],
80   [AC_MSG_WARN([No xmlto package found])]
83 dnl Check for host compiler tools
84 AC_CHECK_TOOL(AR, ar)
85 AC_CHECK_TOOL(RANLIB, ranlib, :)
86 AC_CHECK_TOOL(STRIP, strip)
88 dnl Checks for header files.
89 AC_HEADER_STDC
90 AC_CHECK_HEADERS(inttypes.h)
91 AC_CHECK_HEADERS(strings.h)
92 AC_HEADER_STDBOOL
93 AC_CHECK_HEADERS(stdnoreturn.h)
94 AC_CHECK_HEADERS(io.h)
95 AC_CHECK_HEADERS(fcntl.h)
96 AC_CHECK_HEADERS(unistd.h)
97 AC_CHECK_HEADERS(sys/param.h)
98 AC_CHECK_HEADERS(sys/mman.h)
99 AC_CHECK_HEADERS(sys/types.h)
100 AC_CHECK_HEADERS(sys/stat.h)
102 dnl Checks for library functions.
103 AC_CHECK_FUNCS(strcasecmp stricmp)
104 AC_CHECK_FUNCS(strncasecmp strnicmp)
105 AC_CHECK_FUNCS(strsep)
106 AC_CHECK_FUNCS(strnlen)
108 AC_CHECK_FUNCS(getuid)
109 AC_CHECK_FUNCS(getgid)
111 AC_CHECK_FUNCS(realpath)
112 AC_CHECK_FUNCS(canonicalize_file_name)
113 AC_CHECK_FUNCS(_fullpath)
114 AC_CHECK_FUNCS(pathconf)
116 AC_FUNC_FSEEKO
117 AC_CHECK_FUNCS([_fseeki64])
118 AC_CHECK_FUNCS([ftruncate _chsize _chsize_s])
119 AC_CHECK_FUNCS([fileno _fileno])
121 AC_CHECK_FUNCS(_filelengthi64)
122 AC_FUNC_MMAP
123 AC_CHECK_FUNCS(getpagesize)
124 AC_CHECK_FUNCS(sysconf)
126 AC_CHECK_FUNCS([access _access faccessat])
128 PA_HAVE_FUNC(__builtin_clz, (0U))
129 PA_HAVE_FUNC(__builtin_clzl, (0UL))
130 PA_HAVE_FUNC(__builtin_clzll, (0ULL))
131 PA_HAVE_FUNC(__builtin_expect, (1,1))
133 dnl Functions for which we have replacements available in lib/
134 AC_CHECK_FUNCS([vsnprintf _vsnprintf])
135 AC_CHECK_FUNCS([snprintf _snprintf])
136 AC_CHECK_FUNCS([strlcpy])
138 dnl These types are POSIX-specific, and Windows does it differently...
139 AC_CHECK_TYPES([struct _stati64])
140 AC_CHECK_TYPES([struct stat])
141 AC_CHECK_FUNCS([stat _stati64])
142 AC_CHECK_FUNCS([fstat _fstati64])
144 dnl Check for functions that might not be declared in the headers for
145 dnl various idiotic reasons (mostly because of library authors
146 dnl abusing the meaning of __STRICT_ANSI__)
147 AC_CHECK_DECLS(strcasecmp)
148 AC_CHECK_DECLS(stricmp)
149 AC_CHECK_DECLS(strncasecmp)
150 AC_CHECK_DECLS(strnicmp)
151 AC_CHECK_DECLS(strsep)
152 AC_CHECK_DECLS(strlcpy)
153 AC_CHECK_DECLS(strnlen)
155 dnl Check for missing types
156 AC_TYPE_UINTPTR_T
158 dnl Documentation: should we generate an uncompressed PDF?  It is
159 dnl about twice as big, but it can be externally compressed (e.g. with xz)
160 dnl and becomes significantly smaller than the original.
161 PA_ARG_DISABLED([pdf-compression],
162   [generate an uncompressed documentation PDF],
163   [PDFOPT='-nocompress'])
164 AC_SUBST([PDFOPT])
167 dnl Check for supported gcc attributes; some compilers (e.g. Sun CC)
168 dnl support these, but don't define __GNUC__ as they don't support
169 dnl some other features of gcc.
171 PA_ADD_CFLAGS([-Werror=attributes])
172 PA_FUNC_ATTRIBUTE(noreturn)
173 PA_FUNC_ATTRIBUTE(returns_nonnull)
174 PA_FUNC_ATTRIBUTE(malloc)
175 PA_FUNC_ATTRIBUTE(alloc_size, (1))
176 PA_FUNC_ATTRIBUTE(format, [(printf,1,2)], int, [const char *, ...], ["%d",1])
177 PA_FUNC_ATTRIBUTE(const)
178 PA_FUNC_ATTRIBUTE(pure)
179 PA_FUNC_ATTRIBUTE_ERROR
182 dnl support function sections
184 PA_ARG_ENABLED([sections],
185  [compile with function/data section support],
186  [PA_ADD_CLDFLAGS([-ffunction-sections])
187   PA_ADD_CLDFLAGS([-fdata-sections])
188   PA_ADD_CLDFLAGS([-Wl,--gc-sections])],
189  [])
191 dnl support LTO
193 PA_ARG_ENABLED([lto],
194  [compile with gcc-style link time optimization],
195  [PA_ADD_CLDFLAGS([-flto])
196   dnl Note: we use _PROG rather than _TOOL since we are prepending the full
197   dnl CC name which ought to already contain the host triplet if needed
198   ccbase=`echo "$CC" | awk '{ print $1; }'`
199   AC_CHECK_PROGS(CC_AR, [${ccbase}-ar], [$ac_cv_prog_AR])
200   AR="$CC_AR"
201   AC_CHECK_PROGS(CC_RANLIB, [${ccbase}-ranlib], [$ac_cv_prog_RANLIB])
202   RANLIB="$CC_RANLIB"], [])
204 dnl If we have gcc, add appropriate code cleanliness options
205 PA_ADD_CFLAGS([-W])
206 PA_ADD_CFLAGS([-Wall])
207 PA_ADD_CFLAGS([-pedantic])
208 dnl LLVM doesn't error out on invalid -W options unless this option is
209 dnl specified first.  Enable this so this script can actually discover
210 dnl which -W options are possible for this compiler.
211 PA_ADD_CFLAGS([-Werror=unknown-warning-option])
212 dnl Suppress format warning on Windows targets due to their <inttypes.h>
213 PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format])
214 PA_ADD_CFLAGS([-Wc90-c99-compat])
215 PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long])
216 dnl PA_ADD_CFLAGS([-Wwrite-strings])
217 PA_ARG_ENABLED([werror],
218  [compile with -Werror to error out on any warning],
219  [PA_ADD_CFLAGS([-Werror])],
220  [PA_ADD_CFLAGS([-Werror=implicit])
221   PA_ADD_CFLAGS([-Werror=missing-braces])
222   PA_ADD_CFLAGS([-Werror=return-type])
223   PA_ADD_CFLAGS([-Werror=trigraphs])
224   PA_ADD_CFLAGS([-Werror=pointer-arith])
225   PA_ADD_CFLAGS([-Werror=strict-prototypes])
226   PA_ADD_CFLAGS([-Werror=missing-prototypes])
227   PA_ADD_CFLAGS([-Werror=missing-declarations])
228   PA_ADD_CFLAGS([-Werror=comment])
229   PA_ADD_CFLAGS([-Werror=vla])]
233 dnl support ccache
235 PA_ARG_ENABLED([ccache], [compile with ccache], [CC="ccache $CC"], [])
237 AC_OUTPUT_COMMANDS([mkdir -p config nasmlib nsis output stdlib x86 asm disasm rdoff macros common])
238 AC_OUTPUT(Makefile doc/Makefile)