mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-11-21 03:14:19 +08:00
Merge branch 'master' of ssh://repo.or.cz/nasm
This commit is contained in:
commit
913394d52f
19
aclocal.m4
vendored
19
aclocal.m4
vendored
@ -120,3 +120,22 @@ void foo(void)
|
||||
[Define to 1 if your compiler supports __attribute__((error)) on functions])],
|
||||
[AC_MSG_RESULT([no])])
|
||||
])
|
||||
|
||||
dnl --------------------------------------------------------------------------
|
||||
dnl PA_ARG_ENABLED
|
||||
dnl PA_ARG_DISABLED
|
||||
dnl
|
||||
dnl Simpler-to-use versions of AC_ARG_ENABLED, that include the
|
||||
dnl test for $enableval and the AS_HELP_STRING definition
|
||||
dnl --------------------------------------------------------------------------
|
||||
AC_DEFUN(PA_ARG_ENABLED,
|
||||
[AC_ARG_ENABLE([$1],
|
||||
[AS_HELP_STRING([--enable-$1],[$2])], [], [enableval=no])
|
||||
AS_IF([test x"$enableval" != xno], [$3], [$4])
|
||||
])
|
||||
|
||||
AC_DEFUN(PA_ARG_DISABLED,
|
||||
[AC_ARG_ENABLE([$1],
|
||||
[AS_HELP_STRING([--disable-$1],[$2])], [], [enableval=yes])
|
||||
AS_IF([test x"$enableval" = xno], [$3], [$4])
|
||||
])
|
||||
|
@ -113,6 +113,9 @@
|
||||
/* Define to 1 if you have the `_fullpath' function. */
|
||||
#define HAVE__FULLPATH 1
|
||||
|
||||
/* Define to 1 if the system has the type `struct _stati64'. */
|
||||
#define HAVE_STRUCT__STATI64
|
||||
|
||||
/* Define to 1 if you have the `_stati64' function. */
|
||||
#define HAVE__STATI64 1
|
||||
|
||||
|
104
configure.ac
104
configure.ac
@ -9,6 +9,12 @@ AC_PREFIX_PROGRAM(nasm)
|
||||
dnl Save initial CFLAGS, to see if -g -O2 came from configure or not
|
||||
pa_init_cflags="$CFLAGS"
|
||||
|
||||
dnl This prevents us from running Wine and thinking we are not
|
||||
dnl cross-compiling when in fact we are; running Wine here is at
|
||||
dnl the best very slow and doesn't buy us a single thing at all.
|
||||
WINELOADER=/dev/null
|
||||
export WINELOADER
|
||||
|
||||
dnl Checks for programs and enable necessary CC extensions
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
AC_SYS_LARGEFILE
|
||||
@ -18,10 +24,13 @@ AC_PROG_LN_S
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_INSTALL
|
||||
|
||||
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
|
||||
dnl If the user did not specify a CFLAGS default, change default -O2
|
||||
dnl to either -O3 (normal) or -O0 (for debugging)
|
||||
PA_ARG_DISABLED([optimization],
|
||||
[compile without optimization (-O0) to help debugging],
|
||||
[pa_optimize=-O0], [pa_optimize=-O3])
|
||||
AS_IF([test x"$pa_init_cflags" = x],
|
||||
[CFLAGS=`echo "$CFLAGS" | sed -e "s/-O2/$pa_optimize/"`])
|
||||
|
||||
dnl Check for library extension
|
||||
PA_LIBEXT
|
||||
@ -61,12 +70,12 @@ AC_CHECK_PROGS(PS2PDF, ps2pdf, false)
|
||||
AC_CHECK_PROGS(PSTOPDF, pstopdf, false)
|
||||
|
||||
dnl Check for progs needed for manpage generation
|
||||
if test $ASCIIDOC = false; then
|
||||
AC_MSG_WARN([No asciidoc package found])
|
||||
fi
|
||||
if test $XMLTO = false; then
|
||||
AC_MSG_WARN([No xmlto package found])
|
||||
fi
|
||||
AS_IF([test $ASCIIDOC = false],
|
||||
[AC_MSG_WARN([No asciidoc package found])]
|
||||
)
|
||||
AS_IF([test $XMLTO = false],
|
||||
[AC_MSG_WARN([No xmlto package found])]
|
||||
)
|
||||
|
||||
dnl Check for host compiler tools
|
||||
AC_CHECK_TOOL(AR, ar)
|
||||
@ -107,8 +116,6 @@ AC_CHECK_FUNCS([ftruncate _chsize _chsize_s])
|
||||
AC_CHECK_FUNCS([fileno _fileno])
|
||||
|
||||
AC_CHECK_FUNCS(_filelengthi64)
|
||||
AC_CHECK_FUNCS([stat _stati64])
|
||||
AC_CHECK_FUNCS([fstat _fstati64])
|
||||
AC_FUNC_MMAP
|
||||
AC_CHECK_FUNCS(getpagesize)
|
||||
AC_CHECK_FUNCS(sysconf)
|
||||
@ -125,6 +132,12 @@ AC_CHECK_FUNCS([vsnprintf _vsnprintf])
|
||||
AC_CHECK_FUNCS([snprintf _snprintf])
|
||||
AC_CHECK_FUNCS([strlcpy])
|
||||
|
||||
dnl These types are POSIX-specific, and Windows does it differently...
|
||||
AC_CHECK_TYPES([struct _stati64])
|
||||
AC_CHECK_TYPES([struct stat])
|
||||
AC_CHECK_FUNCS([stat _stati64])
|
||||
AC_CHECK_FUNCS([fstat _fstati64])
|
||||
|
||||
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__)
|
||||
@ -157,26 +170,24 @@ PA_FUNC_ATTRIBUTE_ERROR
|
||||
dnl
|
||||
dnl support function sections
|
||||
dnl
|
||||
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])],
|
||||
[])
|
||||
|
||||
PA_ARG_ENABLED([sections],
|
||||
[compile with function/data section support],
|
||||
[PA_ADD_CFLAGS([-ffunction-sections]),
|
||||
PA_ADD_CFLAGS([-fdata-sections])],
|
||||
[])
|
||||
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"
|
||||
], [])
|
||||
PA_ARG_ENABLED([lto],
|
||||
[compile with gcc-style 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_PROGS(CC_AR, [${ccbase}-ar], [$ac_cv_prog_AR])
|
||||
AR="$CC_AR"
|
||||
AC_CHECK_PROGS(CC_RANLIB, [${ccbase}-ranlib], [$ac_cv_prog_RANLIB])
|
||||
RANLIB="$CC_RANLIB"], [])
|
||||
|
||||
dnl If we have gcc, add appropriate code cleanliness options
|
||||
PA_ADD_CFLAGS([-W])
|
||||
@ -191,30 +202,25 @@ PA_ADD_CFLAGS([-Wpedantic-ms-format],[-Wno-pedantic-ms-format])
|
||||
PA_ADD_CFLAGS([-Wc90-c99-compat])
|
||||
PA_ADD_CFLAGS([-Wlong-long],[-Wno-long-long])
|
||||
dnl PA_ADD_CFLAGS([-Wwrite-strings])
|
||||
AC_ARG_ENABLE([werror],
|
||||
[AC_HELP_STRING([--enable-werror],
|
||||
[compile with -Werror to error out on any warning])],
|
||||
[], [enable_werror=no])
|
||||
AS_IF([test x"$enable_werror" != xno],
|
||||
[PA_ADD_CFLAGS([-Werror])],
|
||||
[PA_ADD_CFLAGS([-Werror=implicit])
|
||||
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])
|
||||
PA_ADD_CFLAGS([-Werror=vla])])
|
||||
PA_ARG_ENABLED([werror],
|
||||
[compile with -Werror to error out on any warning],
|
||||
[PA_ADD_CFLAGS([-Werror])],
|
||||
[PA_ADD_CFLAGS([-Werror=implicit])
|
||||
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])
|
||||
PA_ADD_CFLAGS([-Werror=vla])]
|
||||
)
|
||||
|
||||
dnl
|
||||
dnl support ccache
|
||||
dnl
|
||||
AC_ARG_ENABLE([ccache],
|
||||
[AC_HELP_STRING([--enable-ccache], [compile with ccache])],
|
||||
[CC="ccache $CC"],
|
||||
[])
|
||||
PA_ARG_ENABLED([ccache], [compile with ccache], [CC="ccache $CC"], [])
|
||||
|
||||
AC_OUTPUT_COMMANDS([mkdir -p config nasmlib nsis output stdlib x86 asm disasm])
|
||||
AC_OUTPUT(Makefile rdoff/Makefile doc/Makefile)
|
||||
|
@ -186,10 +186,10 @@ bool nasm_file_exists(const char *filename)
|
||||
*/
|
||||
off_t nasm_file_size(FILE *f)
|
||||
{
|
||||
#if defined(HAVE_FILENO) && defined(HAVE__FILELENGTHI64)
|
||||
#ifdef HAVE__FILELENGTHI64
|
||||
return _filelengthi64(fileno(f));
|
||||
#elif defined(nasm_fstat)
|
||||
struct nasm_stat st;
|
||||
nasm_struct_stat st;
|
||||
|
||||
if (nasm_fstat(fileno(f), &st))
|
||||
return (off_t)-1;
|
||||
@ -209,7 +209,7 @@ off_t nasm_file_size(FILE *f)
|
||||
off_t nasm_file_size_by_path(const char *pathname)
|
||||
{
|
||||
#ifdef nasm_stat
|
||||
struct nasm_stat st;
|
||||
nasm_struct_stat st;
|
||||
|
||||
if (nasm_stat(pathname, &st))
|
||||
return (off_t)-1;
|
||||
|
@ -59,11 +59,6 @@
|
||||
# include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_FILENO) && defined(HAVE__FILENO)
|
||||
# define HAVE_FILENO 1
|
||||
# define fileno _fileno
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_ACCESS) && defined(HAVE__ACCESS)
|
||||
# define HAVE_ACCESS 1
|
||||
# define access _access
|
||||
@ -73,31 +68,61 @@
|
||||
#endif
|
||||
|
||||
/* Can we adjust the file size without actually writing all the bytes? */
|
||||
#ifdef HAVE_FILENO /* Useless without fileno() */
|
||||
# ifdef HAVE__CHSIZE_S
|
||||
# define nasm_ftruncate(fd,size) _chsize_s(fd,size)
|
||||
# elif defined(HAVE__CHSIZE)
|
||||
# define nasm_ftruncate(fd,size) _chsize(fd,size)
|
||||
# elif defined(HAVE_FTRUNCATE)
|
||||
# define nasm_ftruncate(fd,size) ftruncate(fd,size)
|
||||
# endif
|
||||
#ifdef HAVE__CHSIZE_S
|
||||
# define nasm_ftruncate(fd,size) _chsize_s(fd,size)
|
||||
#elif defined(HAVE__CHSIZE)
|
||||
# define nasm_ftruncate(fd,size) _chsize(fd,size)
|
||||
#elif defined(HAVE_FTRUNCATE)
|
||||
# define nasm_ftruncate(fd,size) ftruncate(fd,size)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* On Win32, stat has a 32-bit file size but _stati64 has a 64-bit file
|
||||
* size. However, as "stat" is already a macro, don't confuse the situation
|
||||
* further by redefining it, instead we create our own.
|
||||
* On Win32/64, stat has a 32-bit file size but _stati64 has a 64-bit file
|
||||
* size. Things get complicated because some of these may be macros,
|
||||
* which autoconf won't pick up on as the standard autoconf tests do
|
||||
* #undef.
|
||||
*/
|
||||
#ifdef HAVE__STATI64
|
||||
# define nasm_stat _stati64
|
||||
# if defined(HAVE_FILENO) && defined(HAVE__FSTATI64)
|
||||
#ifdef _stati64
|
||||
# define HAVE_STRUCT__STATI64 1
|
||||
# define HAVE__STATI64 1
|
||||
#endif
|
||||
#ifdef _fstati64
|
||||
# define HAVE__FSTATI64 1
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STRUCT__STATI64
|
||||
typedef struct _stati64 nasm_struct_stat;
|
||||
# ifdef HAVE__STATI64
|
||||
# define nasm_stat _stati64
|
||||
# endif
|
||||
# ifdef HAVE__FSTATI64
|
||||
# define nasm_fstat _fstati64
|
||||
# endif
|
||||
#elif defined(HAVE_STAT)
|
||||
# define nasm_stat stat
|
||||
# if defined(HAVE_FILENO) && defined(HAVE_FSTAT)
|
||||
#elif defined(HAVE_STRUCT_STAT)
|
||||
typedef struct stat nasm_struct_stat;
|
||||
# ifdef HAVE_STAT
|
||||
# define nasm_stat stat
|
||||
# endif
|
||||
# ifdef HAVE_FSTAT
|
||||
# define nasm_fstat fstat
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FILENO
|
||||
# ifdef fileno /* autoconf doesn't always pick up macros */
|
||||
# define HAVE_FILENO 1
|
||||
# elif defined(HAVE__FILENO)
|
||||
# define HAVE_FILENO 1
|
||||
# define fileno _fileno
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* These functions are utterly useless without fileno() */
|
||||
#ifndef HAVE_FILENO
|
||||
# undef nasm_fstat
|
||||
# undef nasm_ftruncate
|
||||
# undef HAVE_MMAP
|
||||
# undef HAVE__FILELENGTHI64
|
||||
#endif
|
||||
|
||||
#endif /* NASMLIB_FILE_H */
|
||||
|
Loading…
Reference in New Issue
Block a user