blob: e13eeffc3c50e39d444a4dd0df319175f8d14b80 [file] [log] [blame]
H. Peter Anvind338b372016-02-18 00:54:30 -08001dnl Process this file with autoconf 2.63 or later to produce
H. Peter Anvin1170eb62002-05-19 02:26:38 +00002dnl a configure script.
H. Peter Anvind338b372016-02-18 00:54:30 -08003AC_PREREQ(2.63)
H. Peter Anvineea6b7a2003-09-08 20:02:10 +00004AC_INIT(config.h.in)
H. Peter Anvin2ef2f062003-09-01 04:19:37 +00005AC_CONFIG_HEADERS(config.h)
H. Peter Anvin87bc6192002-04-30 20:53:16 +00006
7dnl Check for broken VPATH handling on older NetBSD makes.
8AC_DEFUN(AC_PROG_MAKE_VPATHOK,
9[AC_MSG_CHECKING(whether ${MAKE-make} has sane VPATH handling)
10set dummy ${MAKE-make}; ac_make=`echo "[$]2" | sed 'y%./+-%__p_%'`
11AC_CACHE_VAL(ac_cv_prog_make_vpathok,
12[mkdir conftestdir
13cat > conftestdir/conftestmake <<\EOF
14VPATH = ..
15conftestfoo: conftestbar
16 @echo ac_make2temp=ok
17conftestbar: conftestbaz
18 @echo ac_maketemp=broken
19 @touch conftestbar
20EOF
21echo > conftestbaz # these two lines need to be...
22echo > conftestbar # ... in this order not the other
23changequote(, )dnl
24unset ac_maketemp
25unset ac_make2temp
26# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
27eval `cd conftestdir; ${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
28changequote([, ])dnl
29if test -n "$ac_maketemp"; then
30 ac_cv_prog_make_vpathok=no
31else
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
37fi
38rm -rf conftestdir
39rm -f conftestbar conftestbaz])dnl
40if test $ac_cv_prog_make_vpathok = yes; then
41 AC_MSG_RESULT(yes)
42else
43 AC_MSG_RESULT(no)
44fi
45])
46
47AC_PREFIX_PROGRAM(nasm)
48
49dnl Checks for programs.
H. Peter Anvin70a5d142007-10-13 23:12:46 -070050dnl Consider AC_USE_SYSTEM_EXTENSIONS if autoconf 2.61 is OK in the future
H. Peter Anvin2f0f9ea2008-06-08 20:53:29 -070051AC_USE_SYSTEM_EXTENSIONS
H. Peter Anvinb423c022016-02-18 11:57:53 -080052AC_SYS_LARGEFILE
H. Peter Anvin87bc6192002-04-30 20:53:16 +000053AC_PROG_CC
H. Peter Anvind338b372016-02-18 00:54:30 -080054AC_PROG_CC_STDC
H. Peter Anvin87bc6192002-04-30 20:53:16 +000055AC_PROG_LN_S
56AC_PROG_MAKE_SET
57if 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
60else
61 AC_PROG_MAKE_VPATHOK
62fi
63AC_PROG_INSTALL
64
Cyrill Gorcunov7729edf2014-12-20 11:35:51 +030065dnl Checks for typedefs, structures, and compiler characteristics.
66AC_C_CONST
H. Peter Anvin03f229c2015-11-04 11:29:09 -080067AC_C_INLINE
Cyrill Gorcunov7729edf2014-12-20 11:35:51 +030068AC_C_RESTRICT
69AC_TYPE_SIZE_T
Cyrill Gorcunov7729edf2014-12-20 11:35:51 +030070AC_C_BIGENDIAN(AC_DEFINE(WORDS_BIGENDIAN),AC_DEFINE(WORDS_LITTLEENDIAN))
71AH_TEMPLATE(WORDS_BIGENDIAN,
72[Define to 1 if your processor stores words with the most significant
73byte first (like Motorola and SPARC, unlike Intel and VAX).])
74AH_TEMPLATE(WORDS_LITTLEENDIAN,
75[Define to 1 if your processor stores words with the least significant
76byte first (like Intel and VAX, unlike Motorola and SPARC).])
77
H. Peter Anvinb9c1ca72016-03-01 21:51:40 -080078dnl Force gcc and gcc-compatible compilers treat signed integers
79dnl as 2's complement
H. Peter Anvin8d9f5912016-02-27 00:15:13 -080080PA_ADD_CFLAGS([-fwrapv])
H. Peter Anvin87bc6192002-04-30 20:53:16 +000081
H. Peter Anvineec3b522008-06-19 11:39:23 -070082dnl Look for programs...
H. Peter Anvina9397832013-05-17 12:02:49 -070083AC_CHECK_PROGS(NROFF, nroff, false)
H. Peter Anvind089c222013-10-24 13:22:19 +010084AC_CHECK_PROGS(ASCIIDOC, asciidoc, false)
85AC_CHECK_PROGS(XMLTO, xmlto, false)
H. Peter Anvineec3b522008-06-19 11:39:23 -070086AC_CHECK_PROGS(ACRODIST, acrodist, false)
87AC_CHECK_PROGS(PS2PDF, ps2pdf, false)
88AC_CHECK_PROGS(PSTOPDF, pstopdf, false)
H. Peter Anvin620515a2002-04-30 20:57:38 +000089
H. Peter Anvind089c222013-10-24 13:22:19 +010090dnl Check for progs needed for manpage generation
91if test $ASCIIDOC = false; then
92 AC_MSG_WARN([No acsciidoc package found])
93fi
94if test $XMLTO = false; then
95 AC_MSG_WARN([No xmlto package found])
96fi
97
H. Peter Anvin87bc6192002-04-30 20:53:16 +000098dnl Checks for header files.
99AC_HEADER_STDC
100if test $ac_cv_header_stdc = no; then
101 AC_MSG_ERROR([NASM requires ANSI C header files to compile])
102fi
103
104AC_CHECK_HEADERS(limits.h)
105if test $ac_cv_header_limits_h = no; then
106 AC_MSG_ERROR([NASM requires '<limits.h>' to compile])
107fi
108
H. Peter Anvin52daec52007-06-21 19:00:12 +0000109dnl Check for <inttypes.h> or add a substitute version
110AC_CHECK_HEADERS(inttypes.h, , CFLAGS="$CFLAGS -I\$(top_srcdir)/inttypes")
111
H. Peter Anvinfe501952007-10-02 21:53:51 -0700112dnl The standard header for str*casecmp is <strings.h>
113AC_CHECK_HEADERS(strings.h)
114
H. Peter Anvin6867acc2007-10-10 14:58:45 -0700115dnl Look for <stdbool.h>
H. Peter Anvind338b372016-02-18 00:54:30 -0800116AC_HEADER_STDBOOL
H. Peter Anvin6867acc2007-10-10 14:58:45 -0700117
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800118dnl Look for <io.h>
119AC_CHECK_HEADERS(io.h)
120
H. Peter Anvin4627e692016-01-26 12:01:34 -0800121dnl Look for <unistd.h>
122AC_CHECK_HEADERS(unistd.h)
123
124dnl Look for <sys/param.h>
125AC_CHECK_HEADERS(sys/param.h)
126
H. Peter Anvin87bc6192002-04-30 20:53:16 +0000127dnl Checks for library functions.
H. Peter Anvinb8af9aa2007-09-17 13:53:14 -0700128AC_CHECK_FUNCS(strcspn, ,
129 AC_MSG_ERROR([NASM requires ANSI C (specifically, "strcspn")]))
H. Peter Anvin87bc6192002-04-30 20:53:16 +0000130
H. Peter Anvinb8af9aa2007-09-17 13:53:14 -0700131AC_CHECK_FUNCS(strspn, ,
132 AC_MSG_ERROR([NASM requires ANSI C (specifically, "strspn")]))
H. Peter Anvin87bc6192002-04-30 20:53:16 +0000133
H. Peter Anvinfe501952007-10-02 21:53:51 -0700134AC_CHECK_FUNCS(strcasecmp stricmp)
135AC_CHECK_FUNCS(strncasecmp strnicmp)
H. Peter Anvin73b22f52016-02-18 14:40:37 -0800136AC_CHECK_FUNCS(strsep)
H. Peter Anvinfe501952007-10-02 21:53:51 -0700137
H. Peter Anvin038d8612007-04-12 16:54:50 +0000138AC_CHECK_FUNCS(getuid)
139AC_CHECK_FUNCS(getgid)
140
H. Peter Anvin4627e692016-01-26 12:01:34 -0800141AC_CHECK_FUNCS(realpath)
142AC_CHECK_FUNCS(canonicalize_file_name)
143AC_CHECK_FUNCS(_fullpath)
144AC_CHECK_FUNCS(pathconf)
145
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800146AC_FUNC_FSEEKO
H. Peter Anvinec82d7a2016-02-21 21:20:45 -0800147AC_CHECK_FUNCS([_fseeki64])
H. Peter Anvine65e81b2016-02-18 14:24:40 -0800148AC_CHECK_FUNCS([ftruncate _chsize _chsize_s])
149AC_CHECK_FUNCS([fileno])
150
H. Peter Anvind338b372016-02-18 00:54:30 -0800151PA_HAVE_FUNC(__builtin_ctz, (0U))
152PA_HAVE_FUNC(__builtin_ctzl, (0UL))
153PA_HAVE_FUNC(__builtin_ctzll, (0ULL))
154
155dnl Functions for which we have replacements available in lib/
156AC_CONFIG_LIBOBJ_DIR([lib])
157AC_SUBST([LIBOBJDIR], [lib/])
158PA_REPLACE_FUNC([vsnprintf _vsnprintf])
159PA_REPLACE_FUNC([snprintf _snprintf])
160PA_REPLACE_FUNC([strlcpy])
H. Peter Anvind338b372016-02-18 00:54:30 -0800161
H. Peter Anvinc13d31a2007-10-26 18:49:29 -0700162dnl Check for functions that might not be declared in the headers for
163dnl various idiotic reasons (mostly because of library authors
164dnl abusing the meaning of __STRICT_ANSI__)
165AC_CHECK_DECLS(strcasecmp)
166AC_CHECK_DECLS(stricmp)
167AC_CHECK_DECLS(strncasecmp)
168AC_CHECK_DECLS(strnicmp)
169AC_CHECK_DECLS(strsep)
H. Peter Anvineaa68f12009-08-10 15:56:52 -0700170AC_CHECK_DECLS(strlcpy)
H. Peter Anvinc13d31a2007-10-26 18:49:29 -0700171
H. Peter Anvin87bc6192002-04-30 20:53:16 +0000172if test $ac_cv_prog_make_vpathok = no; then
173 echo Copying generated srcs into build directory to compensate for VPATH breakage
H. Peter Anvin1170eb62002-05-19 02:26:38 +0000174 for file in macros.c insnsa.c insnsd.c insnsn.c insnsi.h version.h version.mac; do
175 if test ! -f $file; then cp -p ${srcdir}/${file} .; fi
176 done
H. Peter Anvin87bc6192002-04-30 20:53:16 +0000177fi
178
Cyrill Gorcunov325768e2010-11-11 11:18:44 +0300179dnl
180dnl support cchace
181dnl
H. Peter Anvin44a609b2016-02-18 12:09:31 -0800182AC_ARG_ENABLE([ccache],
183[AC_HELP_STRING([--with-ccache], [compile with ccache])],
184[CC="ccache $CC"],
185[])
Cyrill Gorcunov325768e2010-11-11 11:18:44 +0300186
H. Peter Anvinb9c1ca72016-03-01 21:51:40 -0800187dnl If we have gcc, add appropriate code cleanliness options
H. Peter Anvind338b372016-02-18 00:54:30 -0800188PA_ADD_CFLAGS([-W])
189PA_ADD_CFLAGS([-Wall])
H. Peter Anvinb9c1ca72016-03-01 21:51:40 -0800190PA_ADD_CFLAGS([-std=c99])
Ozkan Sezerec3d4262016-02-12 23:49:49 -0800191PA_ADD_CFLAGS([-pedantic])
H. Peter Anvin44a609b2016-02-18 12:09:31 -0800192AC_ARG_ENABLE([werror],
193[AC_HELP_STRING([--enable-werror],
194[compile with -Werror to error out on any warning])],
195[PA_ADD_CFLAGS([-Werror])],
196[PA_ADD_CFLAGS([-Werror=implicit])
Ozkan Sezerec3d4262016-02-12 23:49:49 -0800197PA_ADD_CFLAGS([-Werror=missing-braces])
198PA_ADD_CFLAGS([-Werror=return-type])
199PA_ADD_CFLAGS([-Werror=trigraphs])
200PA_ADD_CFLAGS([-Werror=pointer-arith])
201PA_ADD_CFLAGS([-Werror=strict-prototypes])
202PA_ADD_CFLAGS([-Werror=missing-prototypes])
203PA_ADD_CFLAGS([-Werror=missing-declarations])
204PA_ADD_CFLAGS([-Werror=comment])
H. Peter Anvin44a609b2016-02-18 12:09:31 -0800205PA_ADD_CFLAGS([-Werror=vla])])
Ozkan Sezerec3d4262016-02-12 23:49:49 -0800206
H. Peter Anvin4b563af2002-05-04 00:15:02 +0000207AC_OUTPUT_COMMANDS([mkdir -p output])
H. Peter Anvin0fcdade2002-05-19 01:57:54 +0000208AC_OUTPUT(Makefile rdoff/Makefile doc/Makefile)