2016-02-18 16:54:30 +08:00
|
|
|
dnl Process this file with autoconf 2.63 or later to produce
|
2002-05-19 10:26:38 +08:00
|
|
|
dnl a configure script.
|
2016-02-18 16:54:30 +08:00
|
|
|
AC_PREREQ(2.63)
|
2016-10-05 08:01:59 +08:00
|
|
|
AC_INIT(config/config.h.in)
|
|
|
|
AC_CONFIG_HEADERS(config/config.h)
|
2002-05-01 04:53:16 +08:00
|
|
|
|
|
|
|
AC_PREFIX_PROGRAM(nasm)
|
|
|
|
|
2017-03-02 04:57:46 +08:00
|
|
|
dnl Save initial CFLAGS, to see if -g -O2 came from configure or not
|
|
|
|
pa_init_cflags="$CFLAGS"
|
|
|
|
|
|
|
|
dnl Checks for programs and enable necessary CC extensions
|
2008-06-09 11:53:29 +08:00
|
|
|
AC_USE_SYSTEM_EXTENSIONS
|
2016-02-19 03:57:53 +08:00
|
|
|
AC_SYS_LARGEFILE
|
2002-05-01 04:53:16 +08:00
|
|
|
AC_PROG_CC
|
2016-02-18 16:54:30 +08:00
|
|
|
AC_PROG_CC_STDC
|
2002-05-01 04:53:16 +08:00
|
|
|
AC_PROG_LN_S
|
|
|
|
AC_PROG_MAKE_SET
|
|
|
|
AC_PROG_INSTALL
|
|
|
|
|
2017-03-02 04:57:46 +08:00
|
|
|
dnl If the user did not specify a CFLAGS default, change default -O2 to -O3
|
|
|
|
if test x"$pa_init_cflags" = x; then
|
|
|
|
CFLAGS=`echo "$CFLAGS" | sed -e 's/-O2/-O3/'`
|
|
|
|
fi
|
2017-03-01 11:02:51 +08:00
|
|
|
|
2016-03-10 06:11:40 +08:00
|
|
|
dnl Check for library extension
|
|
|
|
PA_LIBEXT
|
|
|
|
|
2014-12-20 16:35:51 +08:00
|
|
|
dnl Checks for typedefs, structures, and compiler characteristics.
|
|
|
|
AC_C_CONST
|
2015-11-05 03:29:09 +08:00
|
|
|
AC_C_INLINE
|
2014-12-20 16:35:51 +08:00
|
|
|
AC_C_RESTRICT
|
|
|
|
AC_TYPE_SIZE_T
|
2016-03-02 13:53:09 +08:00
|
|
|
AC_C_BIGENDIAN(AC_DEFINE(WORDS_BIGENDIAN),AC_DEFINE(WORDS_LITTLEENDIAN),,)
|
2014-12-20 16:35:51 +08:00
|
|
|
AH_TEMPLATE(WORDS_BIGENDIAN,
|
|
|
|
[Define to 1 if your processor stores words with the most significant
|
|
|
|
byte first (like Motorola and SPARC, unlike Intel and VAX).])
|
|
|
|
AH_TEMPLATE(WORDS_LITTLEENDIAN,
|
|
|
|
[Define to 1 if your processor stores words with the least significant
|
|
|
|
byte first (like Intel and VAX, unlike Motorola and SPARC).])
|
|
|
|
|
2016-03-02 13:51:40 +08:00
|
|
|
dnl Force gcc and gcc-compatible compilers treat signed integers
|
|
|
|
dnl as 2's complement
|
2016-02-27 16:15:13 +08:00
|
|
|
PA_ADD_CFLAGS([-fwrapv])
|
2002-05-01 04:53:16 +08:00
|
|
|
|
2016-11-16 06:01:37 +08:00
|
|
|
dnl Some environments abuse __STRICT_ANSI__ to disable some
|
|
|
|
dnl function declarations
|
|
|
|
PA_ADD_CFLAGS([-U__STRICT_ANSI__])
|
|
|
|
|
2016-08-03 00:28:22 +08:00
|
|
|
dnl Don't put things in common if we can avoid it. We don't want to
|
|
|
|
dnl assume all compilers support common, and this will help find those
|
|
|
|
dnl problems. This also works around an OSX linker problem.
|
|
|
|
PA_ADD_CFLAGS([-fno-common])
|
|
|
|
|
2008-06-20 02:39:23 +08:00
|
|
|
dnl Look for programs...
|
2013-05-18 03:02:49 +08:00
|
|
|
AC_CHECK_PROGS(NROFF, nroff, false)
|
2013-10-24 20:22:19 +08:00
|
|
|
AC_CHECK_PROGS(ASCIIDOC, asciidoc, false)
|
|
|
|
AC_CHECK_PROGS(XMLTO, xmlto, false)
|
2008-06-20 02:39:23 +08:00
|
|
|
AC_CHECK_PROGS(ACRODIST, acrodist, false)
|
|
|
|
AC_CHECK_PROGS(PS2PDF, ps2pdf, false)
|
|
|
|
AC_CHECK_PROGS(PSTOPDF, pstopdf, false)
|
2002-05-01 04:57:38 +08:00
|
|
|
|
2013-10-24 20:22:19 +08:00
|
|
|
dnl Check for progs needed for manpage generation
|
|
|
|
if test $ASCIIDOC = false; then
|
2016-03-08 18:06:39 +08:00
|
|
|
AC_MSG_WARN([No asciidoc package found])
|
2013-10-24 20:22:19 +08:00
|
|
|
fi
|
|
|
|
if test $XMLTO = false; then
|
|
|
|
AC_MSG_WARN([No xmlto package found])
|
|
|
|
fi
|
|
|
|
|
2016-03-08 18:06:39 +08:00
|
|
|
dnl Check for host compiler tools
|
|
|
|
AC_CHECK_TOOL(AR, ar)
|
|
|
|
AC_CHECK_TOOL(RANLIB, ranlib, :)
|
|
|
|
AC_CHECK_TOOL(STRIP, strip)
|
|
|
|
|
2002-05-01 04:53:16 +08:00
|
|
|
dnl Checks for header files.
|
|
|
|
AC_HEADER_STDC
|
2016-03-09 04:14:55 +08:00
|
|
|
AC_CHECK_HEADERS(inttypes.h)
|
2007-10-03 12:53:51 +08:00
|
|
|
AC_CHECK_HEADERS(strings.h)
|
2016-02-18 16:54:30 +08:00
|
|
|
AC_HEADER_STDBOOL
|
2016-12-20 18:29:58 +08:00
|
|
|
AC_CHECK_HEADERS(stdnoreturn.h)
|
2016-02-19 06:24:40 +08:00
|
|
|
AC_CHECK_HEADERS(io.h)
|
2016-09-22 05:03:18 +08:00
|
|
|
AC_CHECK_HEADERS(fcntl.h)
|
2016-01-27 04:01:34 +08:00
|
|
|
AC_CHECK_HEADERS(unistd.h)
|
|
|
|
AC_CHECK_HEADERS(sys/param.h)
|
2016-09-22 05:03:18 +08:00
|
|
|
AC_CHECK_HEADERS(sys/mman.h)
|
|
|
|
AC_CHECK_HEADERS(sys/stat.h)
|
2016-10-20 04:13:38 +08:00
|
|
|
AC_CHECK_HEADERS(sys/types.h)
|
2016-01-27 04:01:34 +08:00
|
|
|
|
2002-05-01 04:53:16 +08:00
|
|
|
dnl Checks for library functions.
|
2007-10-03 12:53:51 +08:00
|
|
|
AC_CHECK_FUNCS(strcasecmp stricmp)
|
|
|
|
AC_CHECK_FUNCS(strncasecmp strnicmp)
|
2016-02-19 06:40:37 +08:00
|
|
|
AC_CHECK_FUNCS(strsep)
|
2016-05-25 20:42:47 +08:00
|
|
|
AC_CHECK_FUNCS(strnlen)
|
2007-10-03 12:53:51 +08:00
|
|
|
|
2007-04-13 00:54:50 +08:00
|
|
|
AC_CHECK_FUNCS(getuid)
|
|
|
|
AC_CHECK_FUNCS(getgid)
|
|
|
|
|
2016-01-27 04:01:34 +08:00
|
|
|
AC_CHECK_FUNCS(realpath)
|
|
|
|
AC_CHECK_FUNCS(canonicalize_file_name)
|
|
|
|
AC_CHECK_FUNCS(_fullpath)
|
|
|
|
AC_CHECK_FUNCS(pathconf)
|
|
|
|
|
2016-02-19 06:24:40 +08:00
|
|
|
AC_FUNC_FSEEKO
|
2016-02-22 13:20:45 +08:00
|
|
|
AC_CHECK_FUNCS([_fseeki64])
|
2016-02-19 06:24:40 +08:00
|
|
|
AC_CHECK_FUNCS([ftruncate _chsize _chsize_s])
|
2016-10-05 08:01:59 +08:00
|
|
|
AC_CHECK_FUNCS([fileno _fileno])
|
2016-02-19 06:24:40 +08:00
|
|
|
|
2016-10-05 08:01:59 +08:00
|
|
|
AC_CHECK_FUNCS(_filelengthi64)
|
|
|
|
AC_CHECK_FUNCS([stat _stati64])
|
2016-09-22 05:03:18 +08:00
|
|
|
AC_CHECK_FUNCS(fstat)
|
2017-02-24 12:34:38 +08:00
|
|
|
AC_FUNC_MMAP
|
2016-09-22 05:03:18 +08:00
|
|
|
AC_CHECK_FUNCS(getpagesize)
|
|
|
|
AC_CHECK_FUNCS(sysconf)
|
|
|
|
|
2016-10-05 08:01:59 +08:00
|
|
|
AC_CHECK_FUNCS([access _access faccessat])
|
2016-09-22 05:03:18 +08:00
|
|
|
|
2016-11-16 06:23:54 +08:00
|
|
|
PA_HAVE_FUNC(__builtin_clz, (0U))
|
|
|
|
PA_HAVE_FUNC(__builtin_clzl, (0UL))
|
|
|
|
PA_HAVE_FUNC(__builtin_clzll, (0ULL))
|
2016-11-16 06:01:37 +08:00
|
|
|
PA_HAVE_FUNC(__builtin_expect, (1,1))
|
2016-02-18 16:54:30 +08:00
|
|
|
|
|
|
|
dnl Functions for which we have replacements available in lib/
|
2016-03-08 18:06:39 +08:00
|
|
|
AC_CHECK_FUNCS([vsnprintf _vsnprintf])
|
|
|
|
AC_CHECK_FUNCS([snprintf _snprintf])
|
|
|
|
AC_CHECK_FUNCS([strlcpy])
|
2016-02-18 16:54:30 +08:00
|
|
|
|
2007-10-27 09:49:29 +08:00
|
|
|
dnl Check for functions that might not be declared in the headers for
|
|
|
|
dnl various idiotic reasons (mostly because of library authors
|
|
|
|
dnl abusing the meaning of __STRICT_ANSI__)
|
|
|
|
AC_CHECK_DECLS(strcasecmp)
|
|
|
|
AC_CHECK_DECLS(stricmp)
|
|
|
|
AC_CHECK_DECLS(strncasecmp)
|
|
|
|
AC_CHECK_DECLS(strnicmp)
|
|
|
|
AC_CHECK_DECLS(strsep)
|
2009-08-11 06:56:52 +08:00
|
|
|
AC_CHECK_DECLS(strlcpy)
|
2016-05-25 20:42:47 +08:00
|
|
|
AC_CHECK_DECLS(strnlen)
|
2007-10-27 09:49:29 +08:00
|
|
|
|
2016-09-22 05:03:18 +08:00
|
|
|
dnl Check for missing types
|
|
|
|
AC_TYPE_UINTPTR_T
|
|
|
|
|
2016-11-16 06:01:37 +08:00
|
|
|
dnl
|
|
|
|
dnl Check for supported gcc attributes; some compilers (e.g. Sun CC)
|
|
|
|
dnl support these, but don't define __GNUC__ as they don't support
|
|
|
|
dnl some other features of gcc.
|
|
|
|
dnl
|
2017-02-24 11:22:27 +08:00
|
|
|
PA_ADD_CFLAGS([-Werror=attributes])
|
2016-11-16 06:01:37 +08:00
|
|
|
PA_FUNC_ATTRIBUTE(noreturn)
|
|
|
|
PA_FUNC_ATTRIBUTE(returns_nonnull)
|
|
|
|
PA_FUNC_ATTRIBUTE(malloc)
|
|
|
|
PA_FUNC_ATTRIBUTE(alloc_size, (1))
|
|
|
|
PA_FUNC_ATTRIBUTE(format, [(printf,1,2)], int, [const char *, ...], ["%d",1])
|
|
|
|
PA_FUNC_ATTRIBUTE(const)
|
|
|
|
PA_FUNC_ATTRIBUTE(pure)
|
2016-12-20 18:29:58 +08:00
|
|
|
PA_FUNC_ATTRIBUTE_ERROR
|
2002-05-01 04:53:16 +08:00
|
|
|
|
2010-11-11 16:18:44 +08:00
|
|
|
dnl
|
2017-03-01 11:34:36 +08:00
|
|
|
dnl support function sections
|
2010-11-11 16:18:44 +08:00
|
|
|
dnl
|
2017-03-01 11:34:36 +08:00
|
|
|
AC_ARG_ENABLE([sections],
|
|
|
|
[AC_HELP_STRING([--enable-sections], [compile with function/data section support])],
|
|
|
|
[PA_ADD_CFLAGS([-ffunction-sections]),
|
|
|
|
PA_ADD_CFLAGS([-fdata-sections])],
|
2016-02-19 04:09:31 +08:00
|
|
|
[])
|
2010-11-11 16:18:44 +08:00
|
|
|
|
2017-03-01 10:48:01 +08:00
|
|
|
dnl
|
|
|
|
dnl support LTO
|
|
|
|
dnl
|
|
|
|
AC_ARG_ENABLE([lto],
|
|
|
|
[AC_HELP_STRING([--enable-lto], [compile with gcc link time optimization])],
|
|
|
|
[PA_ADD_CLDFLAGS([-flto])
|
|
|
|
dnl Note: we use _PROG rather than _TOOL since we are prepending the full
|
|
|
|
dnl CC name which ought to already contain the host triplet if needed
|
|
|
|
ccbase=`echo "$CC" | awk '{ print $1; }'`
|
|
|
|
AC_CHECK_PROG(CC_AR, [${ccbase}-ar], [${ccbase}-ar], [$ac_cv_prog_AR])
|
|
|
|
AR="$CC_AR"
|
|
|
|
AC_CHECK_PROG(CC_RANLIB, [${ccbase}-ranlib], [${ccbase}-ranlib], [$ac_cv_prog_RANLIB])
|
|
|
|
RANLIB="$CC_RANLIB"
|
|
|
|
], [])
|
|
|
|
|
2016-03-02 13:51:40 +08:00
|
|
|
dnl If we have gcc, add appropriate code cleanliness options
|
2016-02-18 16:54:30 +08:00
|
|
|
PA_ADD_CFLAGS([-W])
|
|
|
|
PA_ADD_CFLAGS([-Wall])
|
2016-02-13 15:49:49 +08:00
|
|
|
PA_ADD_CFLAGS([-pedantic])
|
2016-05-17 12:35:48 +08:00
|
|
|
dnl LLVM doesn't error out on invalid -W options unless this option is
|
|
|
|
dnl specified first. Enable this so this script can actually discover
|
|
|
|
dnl which -W options are possible for this compiler.
|
|
|
|
PA_ADD_CFLAGS([-Werror=unknown-warning-option])
|
2016-03-02 14:20:10 +08:00
|
|
|
dnl Suppress format warning on Windows targets due to their <inttypes.h>
|
|
|
|
PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format])
|
|
|
|
PA_ADD_CFLAGS([-Wc90-c99-compat])
|
|
|
|
PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long])
|
2016-03-07 13:44:14 +08:00
|
|
|
dnl PA_ADD_CFLAGS([-Wwrite-strings])
|
2016-02-19 04:09:31 +08:00
|
|
|
AC_ARG_ENABLE([werror],
|
|
|
|
[AC_HELP_STRING([--enable-werror],
|
|
|
|
[compile with -Werror to error out on any warning])],
|
2016-03-04 04:39:02 +08:00
|
|
|
[], [enable_werror=no])
|
|
|
|
AS_IF([test x"$enable_werror" != xno],
|
2016-02-19 04:09:31 +08:00
|
|
|
[PA_ADD_CFLAGS([-Werror])],
|
|
|
|
[PA_ADD_CFLAGS([-Werror=implicit])
|
2016-02-13 15:49:49 +08:00
|
|
|
PA_ADD_CFLAGS([-Werror=missing-braces])
|
|
|
|
PA_ADD_CFLAGS([-Werror=return-type])
|
|
|
|
PA_ADD_CFLAGS([-Werror=trigraphs])
|
|
|
|
PA_ADD_CFLAGS([-Werror=pointer-arith])
|
|
|
|
PA_ADD_CFLAGS([-Werror=strict-prototypes])
|
|
|
|
PA_ADD_CFLAGS([-Werror=missing-prototypes])
|
|
|
|
PA_ADD_CFLAGS([-Werror=missing-declarations])
|
|
|
|
PA_ADD_CFLAGS([-Werror=comment])
|
2016-02-19 04:09:31 +08:00
|
|
|
PA_ADD_CFLAGS([-Werror=vla])])
|
2016-02-13 15:49:49 +08:00
|
|
|
|
2017-03-01 11:34:36 +08:00
|
|
|
dnl
|
|
|
|
dnl support ccache
|
|
|
|
dnl
|
|
|
|
AC_ARG_ENABLE([ccache],
|
|
|
|
[AC_HELP_STRING([--enable-ccache], [compile with ccache])],
|
|
|
|
[CC="ccache $CC"],
|
|
|
|
[])
|
|
|
|
|
2016-10-05 08:01:59 +08:00
|
|
|
AC_OUTPUT_COMMANDS([mkdir -p config nasmlib nsis output stdlib x86 asm disasm])
|
2002-05-19 09:57:54 +08:00
|
|
|
AC_OUTPUT(Makefile rdoff/Makefile doc/Makefile)
|