nasmlib: we need the exact size for the clz functions
[nasm.git] / configure.ac
blob21624950cf843eaff01d23cc7cc6671397a73562
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 Checks for programs.
10 dnl Consider AC_USE_SYSTEM_EXTENSIONS if autoconf 2.61 is OK in the future
11 AC_USE_SYSTEM_EXTENSIONS
12 AC_SYS_LARGEFILE
13 AC_PROG_CC
14 AC_PROG_CC_STDC
15 AC_PROG_LN_S
16 AC_PROG_MAKE_SET
17 AC_PROG_INSTALL
19 dnl Check for library extension
20 PA_LIBEXT
22 dnl Checks for typedefs, structures, and compiler characteristics.
23 AC_C_CONST
24 AC_C_INLINE
25 AC_C_RESTRICT
26 AC_TYPE_SIZE_T
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 PA_ADD_CFLAGS([-std=c99])
37 dnl Force gcc and gcc-compatible compilers treat signed integers
38 dnl as 2's complement
39 PA_ADD_CFLAGS([-fwrapv])
41 dnl Some environments abuse __STRICT_ANSI__ to disable some
42 dnl function declarations
43 PA_ADD_CFLAGS([-U__STRICT_ANSI__])
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])
50 dnl Look for programs...
51 AC_CHECK_PROGS(NROFF,    nroff,    false)
52 AC_CHECK_PROGS(ASCIIDOC, asciidoc, false)
53 AC_CHECK_PROGS(XMLTO,    xmlto,    false)
54 AC_CHECK_PROGS(ACRODIST, acrodist, false)
55 AC_CHECK_PROGS(PS2PDF,   ps2pdf,   false)
56 AC_CHECK_PROGS(PSTOPDF,  pstopdf,  false)
58 dnl Check for progs needed for manpage generation
59 if test $ASCIIDOC = false; then
60   AC_MSG_WARN([No asciidoc package found])
62 if test $XMLTO = false; then
63   AC_MSG_WARN([No xmlto package found])
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)
71 dnl Checks for header files.
72 AC_HEADER_STDC
73 AC_CHECK_HEADERS(inttypes.h)
74 AC_CHECK_HEADERS(strings.h)
75 AC_HEADER_STDBOOL
76 AC_CHECK_HEADERS(io.h)
77 AC_CHECK_HEADERS(fcntl.h)
78 AC_CHECK_HEADERS(unistd.h)
79 AC_CHECK_HEADERS(sys/param.h)
80 AC_CHECK_HEADERS(sys/mman.h)
81 AC_CHECK_HEADERS(sys/stat.h)
82 AC_CHECK_HEADERS(sys/types.h)
84 dnl Checks for library functions.
85 AC_CHECK_FUNCS(strcasecmp stricmp)
86 AC_CHECK_FUNCS(strncasecmp strnicmp)
87 AC_CHECK_FUNCS(strsep)
88 AC_CHECK_FUNCS(strnlen)
90 AC_CHECK_FUNCS(getuid)
91 AC_CHECK_FUNCS(getgid)
93 AC_CHECK_FUNCS(realpath)
94 AC_CHECK_FUNCS(canonicalize_file_name)
95 AC_CHECK_FUNCS(_fullpath)
96 AC_CHECK_FUNCS(pathconf)
98 AC_FUNC_FSEEKO
99 AC_CHECK_FUNCS([_fseeki64])
100 AC_CHECK_FUNCS([ftruncate _chsize _chsize_s])
101 AC_CHECK_FUNCS([fileno _fileno])
103 AC_CHECK_FUNCS(_filelengthi64)
104 AC_CHECK_FUNCS([stat _stati64])
105 AC_CHECK_FUNCS(fstat)
106 AC_CHECK_FUNCS(mmap)
107 AC_CHECK_FUNCS(getpagesize)
108 AC_CHECK_FUNCS(sysconf)
110 AC_CHECK_FUNCS([access _access faccessat])
112 PA_HAVE_FUNC(__builtin_ctz, (0U))
113 PA_HAVE_FUNC(__builtin_ctzl, (0UL))
114 PA_HAVE_FUNC(__builtin_ctzll, (0ULL))
115 PA_HAVE_FUNC(__builtin_expect, (1,1))
117 dnl Functions for which we have replacements available in lib/
118 AC_CHECK_FUNCS([vsnprintf _vsnprintf])
119 AC_CHECK_FUNCS([snprintf _snprintf])
120 AC_CHECK_FUNCS([strlcpy])
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)
130 AC_CHECK_DECLS(strlcpy)
131 AC_CHECK_DECLS(strnlen)
133 dnl Check for missing types
134 AC_TYPE_UINTPTR_T
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.
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)
150 dnl support cchace
152 AC_ARG_ENABLE([ccache],
153 [AC_HELP_STRING([--with-ccache], [compile with ccache])],
154 [CC="ccache $CC"],
157 dnl If we have gcc, add appropriate code cleanliness options
158 PA_ADD_CFLAGS([-W])
159 PA_ADD_CFLAGS([-Wall])
160 PA_ADD_CFLAGS([-pedantic])
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])
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])
169 dnl PA_ADD_CFLAGS([-Wwrite-strings])
170 AC_ARG_ENABLE([werror],
171 [AC_HELP_STRING([--enable-werror],
172 [compile with -Werror to error out on any warning])],
173 [], [enable_werror=no])
174 AS_IF([test x"$enable_werror" != xno],
175 [PA_ADD_CFLAGS([-Werror])],
176 [PA_ADD_CFLAGS([-Werror=implicit])
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])
185 PA_ADD_CFLAGS([-Werror=vla])])
187 AC_OUTPUT_COMMANDS([mkdir -p config nasmlib nsis output stdlib x86 asm disasm])
188 AC_OUTPUT(Makefile rdoff/Makefile doc/Makefile)