outmacho: Fix relative relocations for 32-bit Mach-O (fix typo)
[nasm.git] / configure.in
blob61a9f7b04fe864726d9cb76c24bfd9e632a0a1ad
1 dnl Process this file with autoconf 2.61 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_LN_S
55 AC_PROG_MAKE_SET
56 if test -f nasm.c; then
57   # we're building in the source dir, so we don't need this check at all
58   ac_cv_prog_make_vpathok=yes
59 else
60   AC_PROG_MAKE_VPATHOK
62 AC_PROG_INSTALL
64 dnl Checks for typedefs, structures, and compiler characteristics.
65 AC_C_CONST
66 AC_C_INLINE
67 AC_C_RESTRICT
68 AC_TYPE_SIZE_T
69 PA_WORKING_BOOL
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 If we have gcc, add appropriate options
79 PA_ADD_CFLAGS([-W])
80 PA_ADD_CFLAGS([-Wall])
81 PA_ADD_CFLAGS([-std=c99])
82 PA_ADD_CFLAGS([-fwrapv])
84 dnl Look for programs...
85 AC_CHECK_PROGS(NROFF,    nroff,    false)
86 AC_CHECK_PROGS(ASCIIDOC, asciidoc, false)
87 AC_CHECK_PROGS(XMLTO,    xmlto,    false)
88 AC_CHECK_PROGS(ACRODIST, acrodist, false)
89 AC_CHECK_PROGS(PS2PDF,   ps2pdf,   false)
90 AC_CHECK_PROGS(PSTOPDF,  pstopdf,  false)
92 dnl Check for progs needed for manpage generation
93 if test $ASCIIDOC = false; then
94   AC_MSG_WARN([No acsciidoc package found])
96 if test $XMLTO = false; then
97   AC_MSG_WARN([No xmlto package found])
100 dnl Checks for header files.
101 AC_HEADER_STDC
102 if test $ac_cv_header_stdc = no; then
103   AC_MSG_ERROR([NASM requires ANSI C header files to compile])
106 AC_CHECK_HEADERS(limits.h)
107 if test $ac_cv_header_limits_h = no; then
108   AC_MSG_ERROR([NASM requires '<limits.h>' to compile])
111 dnl Check for <inttypes.h> or add a substitute version
112 AC_CHECK_HEADERS(inttypes.h, , CFLAGS="$CFLAGS -I\$(top_srcdir)/inttypes")
114 dnl The standard header for str*casecmp is <strings.h>
115 AC_CHECK_HEADERS(strings.h)
117 dnl Look for <stdbool.h>
118 AC_CHECK_HEADERS(stdbool.h)
120 dnl Look for <unistd.h>
121 AC_CHECK_HEADERS(unistd.h)
123 dnl Look for <sys/param.h>
124 AC_CHECK_HEADERS(sys/param.h)
126 dnl Checks for library functions.
127 AC_SUBST(XOBJS)
129 AC_CHECK_FUNCS(strcspn, ,
130   AC_MSG_ERROR([NASM requires ANSI C (specifically, "strcspn")]))
132 AC_CHECK_FUNCS(strspn, ,
133   AC_MSG_ERROR([NASM requires ANSI C (specifically, "strspn")]))
135 missing=true
136 AC_CHECK_FUNCS([vsnprintf _vsnprintf], missing=false)
137 if $missing; then
138    XOBJS="$XOBJS lib/vsnprintf.o"
141 missing=true
142 AC_CHECK_FUNCS([snprintf _snprintf], missing=false)
143 if $missing; then
144    XOBJS="$XOBJS lib/snprintf.o"
147 AC_CHECK_FUNCS(strcasecmp stricmp)
148 AC_CHECK_FUNCS(strncasecmp strnicmp)
149 AC_CHECK_FUNCS(strsep)
150 AC_CHECK_FUNCS(strlcpy)
152 AC_CHECK_FUNCS(getuid)
153 AC_CHECK_FUNCS(getgid)
155 AC_CHECK_FUNCS(realpath)
156 AC_CHECK_FUNCS(canonicalize_file_name)
157 AC_CHECK_FUNCS(_fullpath)
158 AC_CHECK_FUNCS(pathconf)
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)
170 if test $ac_cv_prog_make_vpathok = no; then
171   echo Copying generated srcs into build directory to compensate for VPATH breakage
172   for file in macros.c insnsa.c insnsd.c insnsn.c insnsi.h version.h version.mac; do
173     if test ! -f $file; then cp -p ${srcdir}/${file} .; fi
174   done
178 dnl support cchace
180 AC_ARG_ENABLE([ccache],
181 [AC_HELP_STRING([--with-ccache], [compile with ccache])],
182 [CC="ccache $CC"],
185 PA_ADD_CFLAGS([-pedantic])
186 dnl LLVM doesn't error out on invalid -W options unless this option is
187 dnl specified first.  Enable this so this script can actually discover
188 dnl which -W options are possible for this compiler.
189 PA_ADD_CFLAGS([-Werror=unknown-warning-option])
190 dnl Suppress format warning on Windows targets due to their <inttypes.h>
191 PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format])
192 PA_ADD_CFLAGS([-Wc90-c99-compat])
193 PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long])
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])])
211 AC_OUTPUT_COMMANDS([mkdir -p lib nsis output])
212 AC_OUTPUT(Makefile rdoff/Makefile doc/Makefile)