Windows portability fixes
[nasm.git] / configure.in
blob38306c2defdf1e6e907e85edbe7859c81f8b66e8
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.h.in)
5 AC_CONFIG_HEADERS(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 Checks for typedefs, structures, and compiler characteristics.
66 AC_C_CONST
67 AC_C_INLINE
68 AC_C_RESTRICT
69 AC_TYPE_SIZE_T
70 AC_C_BIGENDIAN(AC_DEFINE(WORDS_BIGENDIAN),AC_DEFINE(WORDS_LITTLEENDIAN))
71 AH_TEMPLATE(WORDS_BIGENDIAN,
72 [Define to 1 if your processor stores words with the most significant
73 byte first (like Motorola and SPARC, unlike Intel and VAX).])
74 AH_TEMPLATE(WORDS_LITTLEENDIAN,
75 [Define to 1 if your processor stores words with the least significant
76 byte first (like Intel and VAX, unlike Motorola and SPARC).])
78 dnl Look for programs...
79 AC_CHECK_PROGS(NROFF,    nroff,    false)
80 AC_CHECK_PROGS(ASCIIDOC, asciidoc, false)
81 AC_CHECK_PROGS(XMLTO,    xmlto,    false)
82 AC_CHECK_PROGS(ACRODIST, acrodist, false)
83 AC_CHECK_PROGS(PS2PDF,   ps2pdf,   false)
84 AC_CHECK_PROGS(PSTOPDF,  pstopdf,  false)
86 dnl Check for progs needed for manpage generation
87 if test $ASCIIDOC = false; then
88   AC_MSG_WARN([No acsciidoc package found])
90 if test $XMLTO = false; then
91   AC_MSG_WARN([No xmlto package found])
94 dnl Checks for header files.
95 AC_HEADER_STDC
96 if test $ac_cv_header_stdc = no; then
97   AC_MSG_ERROR([NASM requires ANSI C header files to compile])
100 AC_CHECK_HEADERS(limits.h)
101 if test $ac_cv_header_limits_h = no; then
102   AC_MSG_ERROR([NASM requires '<limits.h>' to compile])
105 dnl Check for <inttypes.h> or add a substitute version
106 AC_CHECK_HEADERS(inttypes.h, , CFLAGS="$CFLAGS -I\$(top_srcdir)/inttypes")
108 dnl The standard header for str*casecmp is <strings.h>
109 AC_CHECK_HEADERS(strings.h)
111 dnl Look for <stdbool.h>
112 AC_HEADER_STDBOOL
114 dnl Look for <io.h>
115 AC_CHECK_HEADERS(io.h)
117 dnl Look for <unistd.h>
118 AC_CHECK_HEADERS(unistd.h)
120 dnl Look for <sys/param.h>
121 AC_CHECK_HEADERS(sys/param.h)
123 dnl Checks for library functions.
124 AC_CHECK_FUNCS(strcspn, ,
125   AC_MSG_ERROR([NASM requires ANSI C (specifically, "strcspn")]))
127 AC_CHECK_FUNCS(strspn, ,
128   AC_MSG_ERROR([NASM requires ANSI C (specifically, "strspn")]))
130 AC_CHECK_FUNCS(strcasecmp stricmp)
131 AC_CHECK_FUNCS(strncasecmp strnicmp)
132 AC_CHECK_FUNCS(strsep)
134 AC_CHECK_FUNCS(getuid)
135 AC_CHECK_FUNCS(getgid)
137 AC_CHECK_FUNCS(realpath)
138 AC_CHECK_FUNCS(canonicalize_file_name)
139 AC_CHECK_FUNCS(_fullpath)
140 AC_CHECK_FUNCS(pathconf)
142 AC_TYPE_OFF_T
143 AC_FUNC_FSEEKO
144 AC_CHECK_FUNCS([ftruncate _chsize _chsize_s])
145 AC_CHECK_FUNCS([fileno])
147 PA_HAVE_FUNC(__builtin_ctz, (0U))
148 PA_HAVE_FUNC(__builtin_ctzl, (0UL))
149 PA_HAVE_FUNC(__builtin_ctzll, (0ULL))
151 dnl Functions for which we have replacements available in lib/
152 AC_CONFIG_LIBOBJ_DIR([lib])
153 AC_SUBST([LIBOBJDIR], [lib/])
154 PA_REPLACE_FUNC([vsnprintf _vsnprintf])
155 PA_REPLACE_FUNC([snprintf _snprintf])
156 PA_REPLACE_FUNC([strlcpy])
158 dnl Check for functions that might not be declared in the headers for
159 dnl various idiotic reasons (mostly because of library authors
160 dnl abusing the meaning of __STRICT_ANSI__)
161 AC_CHECK_DECLS(strcasecmp)
162 AC_CHECK_DECLS(stricmp)
163 AC_CHECK_DECLS(strncasecmp)
164 AC_CHECK_DECLS(strnicmp)
165 AC_CHECK_DECLS(strsep)
166 AC_CHECK_DECLS(strlcpy)
168 if test $ac_cv_prog_make_vpathok = no; then
169   echo Copying generated srcs into build directory to compensate for VPATH breakage
170   for file in macros.c insnsa.c insnsd.c insnsn.c insnsi.h version.h version.mac; do
171     if test ! -f $file; then cp -p ${srcdir}/${file} .; fi
172   done
176 dnl support cchace
178 AC_ARG_ENABLE([ccache],
179 [AC_HELP_STRING([--with-ccache], [compile with ccache])],
180 [CC="ccache $CC"],
183 dnl If we have gcc, add appropriate options
184 PA_ADD_CFLAGS([-W])
185 PA_ADD_CFLAGS([-Wall])
186 PA_ADD_CFLAGS([-pedantic])
187 AC_ARG_ENABLE([werror],
188 [AC_HELP_STRING([--enable-werror],
189 [compile with -Werror to error out on any warning])],
190 [PA_ADD_CFLAGS([-Werror])],
191 [PA_ADD_CFLAGS([-Werror=implicit])
192 PA_ADD_CFLAGS([-Werror=missing-braces])
193 PA_ADD_CFLAGS([-Werror=return-type])
194 PA_ADD_CFLAGS([-Werror=trigraphs])
195 PA_ADD_CFLAGS([-Werror=pointer-arith])
196 PA_ADD_CFLAGS([-Werror=strict-prototypes])
197 PA_ADD_CFLAGS([-Werror=missing-prototypes])
198 PA_ADD_CFLAGS([-Werror=missing-declarations])
199 PA_ADD_CFLAGS([-Werror=comment])
200 PA_ADD_CFLAGS([-Werror=vla])])
202 AC_OUTPUT_COMMANDS([mkdir -p output])
203 AC_OUTPUT(Makefile rdoff/Makefile doc/Makefile)