config: add configuration file for unknown compilers
[nasm.git] / configure.ac
blob537efe9c7b36beefb5559fcc2ec2243d4c172f03
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 dnl Check for broken VPATH handling on older NetBSD makes.
8 AC_DEFUN(AC_PROG_MAKE_VPATHOK,
9 [AC_MSG_CHECKING(whether ${MAKE-make} has sane VPATH handling)
10 set dummy ${MAKE-make}; ac_make=`echo "[$]2" | sed 'y%./+-%__p_%'`
11 AC_CACHE_VAL(ac_cv_prog_make_vpathok,
12 [mkdir conftestdir
13 cat > conftestdir/conftestmake <<\EOF
14 VPATH = ..
15 conftestfoo: conftestbar
16         @echo ac_make2temp=ok
17 conftestbar: conftestbaz
18         @echo ac_maketemp=broken
19         @touch conftestbar
20 EOF
21 echo > conftestbaz # these two lines need to be...
22 echo > conftestbar # ... in this order not the other
23 changequote(, )dnl
24 unset ac_maketemp
25 unset ac_make2temp
26 # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
27 eval `cd conftestdir; ${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
28 changequote([, ])dnl
29 if test -n "$ac_maketemp"; then
30   ac_cv_prog_make_vpathok=no
31 else
32   if test -n "$ac_make2temp"; then
33     ac_cv_prog_make_vpathok=yes
34   else
35     ac_cv_prog_make_vpathok=no
36   fi
38 rm -rf conftestdir
39 rm -f conftestbar conftestbaz])dnl
40 if test $ac_cv_prog_make_vpathok = yes; then
41   AC_MSG_RESULT(yes)
42 else
43   AC_MSG_RESULT(no)
47 AC_PREFIX_PROGRAM(nasm)
49 dnl Checks for programs.
50 dnl Consider AC_USE_SYSTEM_EXTENSIONS if autoconf 2.61 is OK in the future
51 AC_USE_SYSTEM_EXTENSIONS
52 AC_SYS_LARGEFILE
53 AC_PROG_CC
54 AC_PROG_CC_STDC
55 AC_PROG_LN_S
56 AC_PROG_MAKE_SET
57 if test -f nasm.c; then
58   # we're building in the source dir, so we don't need this check at all
59   ac_cv_prog_make_vpathok=yes
60 else
61   AC_PROG_MAKE_VPATHOK
63 AC_PROG_INSTALL
65 dnl Check for library extension
66 PA_LIBEXT
68 dnl Checks for typedefs, structures, and compiler characteristics.
69 AC_C_CONST
70 AC_C_INLINE
71 AC_C_RESTRICT
72 AC_TYPE_SIZE_T
73 AC_C_BIGENDIAN(AC_DEFINE(WORDS_BIGENDIAN),AC_DEFINE(WORDS_LITTLEENDIAN),,)
74 AH_TEMPLATE(WORDS_BIGENDIAN,
75 [Define to 1 if your processor stores words with the most significant
76 byte first (like Motorola and SPARC, unlike Intel and VAX).])
77 AH_TEMPLATE(WORDS_LITTLEENDIAN,
78 [Define to 1 if your processor stores words with the least significant
79 byte first (like Intel and VAX, unlike Motorola and SPARC).])
81 dnl Force gcc and gcc-compatible compilers treat signed integers
82 dnl as 2's complement
83 PA_ADD_CFLAGS([-fwrapv])
85 dnl Don't put things in common if we can avoid it.  We don't want to
86 dnl assume all compilers support common, and this will help find those
87 dnl problems.  This also works around an OSX linker problem.
88 PA_ADD_CFLAGS([-fno-common])
90 dnl Look for programs...
91 AC_CHECK_PROGS(NROFF,    nroff,    false)
92 AC_CHECK_PROGS(ASCIIDOC, asciidoc, false)
93 AC_CHECK_PROGS(XMLTO,    xmlto,    false)
94 AC_CHECK_PROGS(ACRODIST, acrodist, false)
95 AC_CHECK_PROGS(PS2PDF,   ps2pdf,   false)
96 AC_CHECK_PROGS(PSTOPDF,  pstopdf,  false)
98 dnl Check for progs needed for manpage generation
99 if test $ASCIIDOC = false; then
100   AC_MSG_WARN([No asciidoc package found])
102 if test $XMLTO = false; then
103   AC_MSG_WARN([No xmlto package found])
106 dnl Check for host compiler tools
107 AC_CHECK_TOOL(AR, ar)
108 AC_CHECK_TOOL(RANLIB, ranlib, :)
109 AC_CHECK_TOOL(STRIP, strip)
111 dnl Checks for header files.
112 AC_HEADER_STDC
113 AC_CHECK_HEADERS(inttypes.h)
114 AC_CHECK_HEADERS(strings.h)
115 AC_HEADER_STDBOOL
116 AC_CHECK_HEADERS(io.h)
117 AC_CHECK_HEADERS(fcntl.h)
118 AC_CHECK_HEADERS(unistd.h)
119 AC_CHECK_HEADERS(sys/param.h)
120 AC_CHECK_HEADERS(sys/mman.h)
121 AC_CHECK_HEADERS(sys/stat.h)
123 dnl Checks for library functions.
124 AC_CHECK_FUNCS(strcasecmp stricmp)
125 AC_CHECK_FUNCS(strncasecmp strnicmp)
126 AC_CHECK_FUNCS(strsep)
127 AC_CHECK_FUNCS(strnlen)
129 AC_CHECK_FUNCS(getuid)
130 AC_CHECK_FUNCS(getgid)
132 AC_CHECK_FUNCS(realpath)
133 AC_CHECK_FUNCS(canonicalize_file_name)
134 AC_CHECK_FUNCS(_fullpath)
135 AC_CHECK_FUNCS(pathconf)
137 AC_FUNC_FSEEKO
138 AC_CHECK_FUNCS([_fseeki64])
139 AC_CHECK_FUNCS([ftruncate _chsize _chsize_s])
140 AC_CHECK_FUNCS([fileno _fileno])
142 AC_CHECK_FUNCS(_filelengthi64)
143 AC_CHECK_FUNCS([stat _stati64])
144 AC_CHECK_FUNCS(fstat)
145 AC_CHECK_FUNCS(mmap)
146 AC_CHECK_FUNCS(getpagesize)
147 AC_CHECK_FUNCS(sysconf)
149 AC_CHECK_FUNCS([access _access faccessat])
151 PA_HAVE_FUNC(__builtin_ctz, (0U))
152 PA_HAVE_FUNC(__builtin_ctzl, (0UL))
153 PA_HAVE_FUNC(__builtin_ctzll, (0ULL))
155 dnl Functions for which we have replacements available in lib/
156 AC_CHECK_FUNCS([vsnprintf _vsnprintf])
157 AC_CHECK_FUNCS([snprintf _snprintf])
158 AC_CHECK_FUNCS([strlcpy])
160 dnl Check for functions that might not be declared in the headers for
161 dnl various idiotic reasons (mostly because of library authors
162 dnl abusing the meaning of __STRICT_ANSI__)
163 AC_CHECK_DECLS(strcasecmp)
164 AC_CHECK_DECLS(stricmp)
165 AC_CHECK_DECLS(strncasecmp)
166 AC_CHECK_DECLS(strnicmp)
167 AC_CHECK_DECLS(strsep)
168 AC_CHECK_DECLS(strlcpy)
169 AC_CHECK_DECLS(strnlen)
171 dnl Check for missing types
172 AC_TYPE_UINTPTR_T
174 if test $ac_cv_prog_make_vpathok = no; then
175   echo Copying generated srcs into build directory to compensate for VPATH breakage
176   for file in macros.c insnsa.c insnsd.c insnsn.c insnsi.h version.h version.mac; do
177     if test ! -f $file; then cp -p ${srcdir}/${file} .; fi
178   done
182 dnl support cchace
184 AC_ARG_ENABLE([ccache],
185 [AC_HELP_STRING([--with-ccache], [compile with ccache])],
186 [CC="ccache $CC"],
189 dnl If we have gcc, add appropriate code cleanliness options
190 PA_ADD_CFLAGS([-W])
191 PA_ADD_CFLAGS([-Wall])
192 PA_ADD_CFLAGS([-std=c99])
193 PA_ADD_CFLAGS([-pedantic])
194 dnl LLVM doesn't error out on invalid -W options unless this option is
195 dnl specified first.  Enable this so this script can actually discover
196 dnl which -W options are possible for this compiler.
197 PA_ADD_CFLAGS([-Werror=unknown-warning-option])
198 dnl Suppress format warning on Windows targets due to their <inttypes.h>
199 PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format])
200 PA_ADD_CFLAGS([-Wc90-c99-compat])
201 PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long])
202 dnl PA_ADD_CFLAGS([-Wwrite-strings])
203 AC_ARG_ENABLE([werror],
204 [AC_HELP_STRING([--enable-werror],
205 [compile with -Werror to error out on any warning])],
206 [], [enable_werror=no])
207 AS_IF([test x"$enable_werror" != xno],
208 [PA_ADD_CFLAGS([-Werror])],
209 [PA_ADD_CFLAGS([-Werror=implicit])
210 PA_ADD_CFLAGS([-Werror=missing-braces])
211 PA_ADD_CFLAGS([-Werror=return-type])
212 PA_ADD_CFLAGS([-Werror=trigraphs])
213 PA_ADD_CFLAGS([-Werror=pointer-arith])
214 PA_ADD_CFLAGS([-Werror=strict-prototypes])
215 PA_ADD_CFLAGS([-Werror=missing-prototypes])
216 PA_ADD_CFLAGS([-Werror=missing-declarations])
217 PA_ADD_CFLAGS([-Werror=comment])
218 PA_ADD_CFLAGS([-Werror=vla])])
220 AC_OUTPUT_COMMANDS([mkdir -p config nasmlib nsis output stdlib x86 asm disasm])
221 AC_OUTPUT(Makefile rdoff/Makefile doc/Makefile)