elf: Align members for file format defs
[nasm.git] / configure.ac
blob29bf0989180f4b8f427d6849431a03446472edb6
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 Checks for programs and enable necessary CC extensions
13 AC_USE_SYSTEM_EXTENSIONS
14 AC_SYS_LARGEFILE
15 AC_PROG_CC
16 AC_PROG_CC_STDC
17 AC_PROG_LN_S
18 AC_PROG_MAKE_SET
19 AC_PROG_INSTALL
21 dnl If the user did not specify a CFLAGS default, change default -O2 to -O3
22 if test x"$pa_init_cflags" = x; then
23    CFLAGS=`echo "$CFLAGS" | sed -e 's/-O2/-O3/'`
26 dnl Check for library extension
27 PA_LIBEXT
29 dnl Checks for typedefs, structures, and compiler characteristics.
30 AC_C_CONST
31 AC_C_INLINE
32 AC_C_RESTRICT
33 AC_TYPE_SIZE_T
34 AC_C_BIGENDIAN(AC_DEFINE(WORDS_BIGENDIAN),AC_DEFINE(WORDS_LITTLEENDIAN),,)
35 AH_TEMPLATE(WORDS_BIGENDIAN,
36 [Define to 1 if your processor stores words with the most significant
37 byte first (like Motorola and SPARC, unlike Intel and VAX).])
38 AH_TEMPLATE(WORDS_LITTLEENDIAN,
39 [Define to 1 if your processor stores words with the least significant
40 byte first (like Intel and VAX, unlike Motorola and SPARC).])
42 dnl Force gcc and gcc-compatible compilers treat signed integers
43 dnl as 2's complement
44 PA_ADD_CFLAGS([-fwrapv])
46 dnl Some environments abuse __STRICT_ANSI__ to disable some
47 dnl function declarations
48 PA_ADD_CFLAGS([-U__STRICT_ANSI__])
50 dnl Don't put things in common if we can avoid it.  We don't want to
51 dnl assume all compilers support common, and this will help find those
52 dnl problems.  This also works around an OSX linker problem.
53 PA_ADD_CFLAGS([-fno-common])
55 dnl Look for programs...
56 AC_CHECK_PROGS(NROFF,    nroff,    false)
57 AC_CHECK_PROGS(ASCIIDOC, asciidoc, false)
58 AC_CHECK_PROGS(XMLTO,    xmlto,    false)
59 AC_CHECK_PROGS(ACRODIST, acrodist, false)
60 AC_CHECK_PROGS(PS2PDF,   ps2pdf,   false)
61 AC_CHECK_PROGS(PSTOPDF,  pstopdf,  false)
63 dnl Check for progs needed for manpage generation
64 if test $ASCIIDOC = false; then
65   AC_MSG_WARN([No asciidoc package found])
67 if test $XMLTO = false; then
68   AC_MSG_WARN([No xmlto package found])
71 dnl Check for host compiler tools
72 AC_CHECK_TOOL(AR, ar)
73 AC_CHECK_TOOL(RANLIB, ranlib, :)
74 AC_CHECK_TOOL(STRIP, strip)
76 dnl Checks for header files.
77 AC_HEADER_STDC
78 AC_CHECK_HEADERS(inttypes.h)
79 AC_CHECK_HEADERS(strings.h)
80 AC_HEADER_STDBOOL
81 AC_CHECK_HEADERS(stdnoreturn.h)
82 AC_CHECK_HEADERS(io.h)
83 AC_CHECK_HEADERS(fcntl.h)
84 AC_CHECK_HEADERS(unistd.h)
85 AC_CHECK_HEADERS(sys/param.h)
86 AC_CHECK_HEADERS(sys/mman.h)
87 AC_CHECK_HEADERS(sys/stat.h)
88 AC_CHECK_HEADERS(sys/types.h)
90 dnl Checks for library functions.
91 AC_CHECK_FUNCS(strcasecmp stricmp)
92 AC_CHECK_FUNCS(strncasecmp strnicmp)
93 AC_CHECK_FUNCS(strsep)
94 AC_CHECK_FUNCS(strnlen)
96 AC_CHECK_FUNCS(getuid)
97 AC_CHECK_FUNCS(getgid)
99 AC_CHECK_FUNCS(realpath)
100 AC_CHECK_FUNCS(canonicalize_file_name)
101 AC_CHECK_FUNCS(_fullpath)
102 AC_CHECK_FUNCS(pathconf)
104 AC_FUNC_FSEEKO
105 AC_CHECK_FUNCS([_fseeki64])
106 AC_CHECK_FUNCS([ftruncate _chsize _chsize_s])
107 AC_CHECK_FUNCS([fileno _fileno])
109 AC_CHECK_FUNCS(_filelengthi64)
110 AC_CHECK_FUNCS([stat _stati64])
111 AC_CHECK_FUNCS(fstat)
112 AC_FUNC_MMAP
113 AC_CHECK_FUNCS(getpagesize)
114 AC_CHECK_FUNCS(sysconf)
116 AC_CHECK_FUNCS([access _access faccessat])
118 PA_HAVE_FUNC(__builtin_clz, (0U))
119 PA_HAVE_FUNC(__builtin_clzl, (0UL))
120 PA_HAVE_FUNC(__builtin_clzll, (0ULL))
121 PA_HAVE_FUNC(__builtin_expect, (1,1))
123 dnl Functions for which we have replacements available in lib/
124 AC_CHECK_FUNCS([vsnprintf _vsnprintf])
125 AC_CHECK_FUNCS([snprintf _snprintf])
126 AC_CHECK_FUNCS([strlcpy])
128 dnl Check for functions that might not be declared in the headers for
129 dnl various idiotic reasons (mostly because of library authors
130 dnl abusing the meaning of __STRICT_ANSI__)
131 AC_CHECK_DECLS(strcasecmp)
132 AC_CHECK_DECLS(stricmp)
133 AC_CHECK_DECLS(strncasecmp)
134 AC_CHECK_DECLS(strnicmp)
135 AC_CHECK_DECLS(strsep)
136 AC_CHECK_DECLS(strlcpy)
137 AC_CHECK_DECLS(strnlen)
139 dnl Check for missing types
140 AC_TYPE_UINTPTR_T
143 dnl Check for supported gcc attributes; some compilers (e.g. Sun CC)
144 dnl support these, but don't define __GNUC__ as they don't support
145 dnl some other features of gcc.
147 PA_ADD_CFLAGS([-Werror=attributes])
148 PA_FUNC_ATTRIBUTE(noreturn)
149 PA_FUNC_ATTRIBUTE(returns_nonnull)
150 PA_FUNC_ATTRIBUTE(malloc)
151 PA_FUNC_ATTRIBUTE(alloc_size, (1))
152 PA_FUNC_ATTRIBUTE(format, [(printf,1,2)], int, [const char *, ...], ["%d",1])
153 PA_FUNC_ATTRIBUTE(const)
154 PA_FUNC_ATTRIBUTE(pure)
155 PA_FUNC_ATTRIBUTE_ERROR
158 dnl support function sections
160 AC_ARG_ENABLE([sections],
161 [AC_HELP_STRING([--enable-sections], [compile with function/data section support])],
162 [PA_ADD_CFLAGS([-ffunction-sections]),
163 PA_ADD_CFLAGS([-fdata-sections])],
167 dnl support LTO
169 AC_ARG_ENABLE([lto],
170 [AC_HELP_STRING([--enable-lto], [compile with gcc link time optimization])],
171 [PA_ADD_CLDFLAGS([-flto])
172 dnl Note: we use _PROG rather than _TOOL since we are prepending the full
173 dnl CC name which ought to already contain the host triplet if needed
174 ccbase=`echo "$CC" | awk '{ print $1; }'`
175 AC_CHECK_PROG(CC_AR, [${ccbase}-ar], [${ccbase}-ar], [$ac_cv_prog_AR])
176 AR="$CC_AR"
177 AC_CHECK_PROG(CC_RANLIB, [${ccbase}-ranlib], [${ccbase}-ranlib], [$ac_cv_prog_RANLIB])
178 RANLIB="$CC_RANLIB"
179 ], [])
181 dnl If we have gcc, add appropriate code cleanliness options
182 PA_ADD_CFLAGS([-W])
183 PA_ADD_CFLAGS([-Wall])
184 PA_ADD_CFLAGS([-pedantic])
185 dnl LLVM doesn't error out on invalid -W options unless this option is
186 dnl specified first.  Enable this so this script can actually discover
187 dnl which -W options are possible for this compiler.
188 PA_ADD_CFLAGS([-Werror=unknown-warning-option])
189 dnl Suppress format warning on Windows targets due to their <inttypes.h>
190 PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format])
191 PA_ADD_CFLAGS([-Wc90-c99-compat])
192 PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long])
193 dnl PA_ADD_CFLAGS([-Wwrite-strings])
194 AC_ARG_ENABLE([werror],
195 [AC_HELP_STRING([--enable-werror],
196 [compile with -Werror to error out on any warning])],
197 [], [enable_werror=no])
198 AS_IF([test x"$enable_werror" != xno],
199 [PA_ADD_CFLAGS([-Werror])],
200 [PA_ADD_CFLAGS([-Werror=implicit])
201 PA_ADD_CFLAGS([-Werror=missing-braces])
202 PA_ADD_CFLAGS([-Werror=return-type])
203 PA_ADD_CFLAGS([-Werror=trigraphs])
204 PA_ADD_CFLAGS([-Werror=pointer-arith])
205 PA_ADD_CFLAGS([-Werror=strict-prototypes])
206 PA_ADD_CFLAGS([-Werror=missing-prototypes])
207 PA_ADD_CFLAGS([-Werror=missing-declarations])
208 PA_ADD_CFLAGS([-Werror=comment])
209 PA_ADD_CFLAGS([-Werror=vla])])
212 dnl support ccache
214 AC_ARG_ENABLE([ccache],
215 [AC_HELP_STRING([--enable-ccache], [compile with ccache])],
216 [CC="ccache $CC"],
219 AC_OUTPUT_COMMANDS([mkdir -p config nasmlib nsis output stdlib x86 asm disasm])
220 AC_OUTPUT(Makefile rdoff/Makefile doc/Makefile)