macho: Improve macho_calculate_sizes
[nasm.git] / configure.ac
blob3f148632c390a5d9a9fdfab81972241c7dab27ef
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 dnl Force gcc and gcc-compatible compilers treat signed integers
36 dnl as 2's complement
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
65 AC_CHECK_TOOL(AR, ar)
66 AC_CHECK_TOOL(RANLIB, ranlib, :)
67 AC_CHECK_TOOL(STRIP, strip)
69 dnl Checks for header files.
70 AC_HEADER_STDC
71 AC_CHECK_HEADERS(inttypes.h)
72 AC_CHECK_HEADERS(strings.h)
73 AC_HEADER_STDBOOL
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)
97 AC_FUNC_FSEEKO
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)
105 AC_CHECK_FUNCS(mmap)
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
133 AC_TYPE_UINTPTR_T
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_FUNC_ATTRIBUTE(noreturn)
141 PA_FUNC_ATTRIBUTE(returns_nonnull)
142 PA_FUNC_ATTRIBUTE(malloc)
143 PA_FUNC_ATTRIBUTE(alloc_size, (1))
144 PA_FUNC_ATTRIBUTE(format, [(printf,1,2)], int, [const char *, ...], ["%d",1])
145 PA_FUNC_ATTRIBUTE(const)
146 PA_FUNC_ATTRIBUTE(pure)
147 PA_FUNC_ATTRIBUTE_ERROR
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)