NASM: relicense under the 2-clause BSD license
[platform/upstream/nasm.git] / configure.in
index b5fb0e1..b47675b 100644 (file)
@@ -1,5 +1,8 @@
-dnl Process this file with autoconf to produce a configure script.
-AC_INIT(nasm.c)
+dnl Process this file with autoconf 2.61 or later to produce
+dnl a configure script.
+AC_PREREQ(2.61)
+AC_INIT(config.h.in)
+AC_CONFIG_HEADERS(config.h)
 
 dnl Check for broken VPATH handling on older NetBSD makes.
 AC_DEFUN(AC_PROG_MAKE_VPATHOK,
@@ -44,6 +47,8 @@ fi
 AC_PREFIX_PROGRAM(nasm)
 
 dnl Checks for programs.
+dnl Consider AC_USE_SYSTEM_EXTENSIONS if autoconf 2.61 is OK in the future
+AC_USE_SYSTEM_EXTENSIONS
 AC_PROG_CC
 AC_PROG_LN_S
 AC_PROG_MAKE_SET
@@ -55,12 +60,17 @@ else
 fi
 AC_PROG_INSTALL
 
-if test "$GCC" = "yes"; then
-  GCCFLAGS="-Wall -ansi -pedantic"
-else
-  GCCFLAGS=
-fi
-AC_SUBST(GCCFLAGS)
+dnl If we have gcc, add appropriate options
+PA_ADD_CFLAGS([-W])
+PA_ADD_CFLAGS([-Wall])
+PA_ADD_CFLAGS([-std=c99])
+PA_ADD_CFLAGS([-pedantic])
+
+dnl Look for programs...
+AC_CHECK_PROGS(NROFF,    nroff,    echo)
+AC_CHECK_PROGS(ACRODIST, acrodist, false)
+AC_CHECK_PROGS(PS2PDF,   ps2pdf,   false)
+AC_CHECK_PROGS(PSTOPDF,  pstopdf,  false)
 
 dnl Checks for header files.
 AC_HEADER_STDC
@@ -73,38 +83,72 @@ if test $ac_cv_header_limits_h = no; then
   AC_MSG_ERROR([NASM requires '<limits.h>' to compile])
 fi
 
+dnl Check for <inttypes.h> or add a substitute version
+AC_CHECK_HEADERS(inttypes.h, , CFLAGS="$CFLAGS -I\$(top_srcdir)/inttypes")
+
+dnl The standard header for str*casecmp is <strings.h>
+AC_CHECK_HEADERS(strings.h)
+
+dnl Look for <stdbool.h>
+AC_CHECK_HEADERS(stdbool.h)
+
 dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
-if test $ac_cv_c_const = no; then
-  AC_MSG_ERROR([NASM requires ANSI C (specifically, working "const")])
-fi
-
+AC_C_INLINE
+AC_C_RESTRICT
 AC_TYPE_SIZE_T
-if test $ac_cv_type_size_t = no; then
-  AC_MSG_ERROR([NASM requires ANSI C (specifically, "size_t")])
-fi
+PA_WORKING_BOOL
+AC_C_BIGENDIAN(AC_DEFINE(WORDS_BIGENDIAN),AC_DEFINE(WORDS_LITTLEENDIAN))
+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).])
 
 dnl Checks for library functions.
-AC_FUNC_VPRINTF
-if test $ac_cv_func_vprintf = no; then
-  AC_MSG_ERROR([NASM requires ANSI C (specifically, "vprintf" and friends)])
-fi
+AC_SUBST(XOBJS)
+
+AC_CHECK_FUNCS(strcspn, ,
+  AC_MSG_ERROR([NASM requires ANSI C (specifically, "strcspn")]))
+
+AC_CHECK_FUNCS(strspn, ,
+  AC_MSG_ERROR([NASM requires ANSI C (specifically, "strspn")]))
 
-AC_CHECK_FUNCS(strcspn)
-if test $ac_cv_func_strcspn = no; then
-  AC_MSG_ERROR([NASM requires ANSI C (specifically, "strcspn")])
+missing=true
+AC_CHECK_FUNCS([vsnprintf _vsnprintf], missing=false)
+if $missing; then
+   XOBJS="$XOBJS lib/vsnprintf.o"
 fi
 
-AC_CHECK_FUNCS(strspn)
-if test $ac_cv_func_strspn = no; then
-  AC_MSG_ERROR([NASM requires ANSI C (specifically, "strspn")])
+missing=true
+AC_CHECK_FUNCS([snprintf _snprintf], missing=false)
+if $missing; then
+   XOBJS="$XOBJS lib/snprintf.o"
 fi
 
+AC_CHECK_FUNCS(strcasecmp stricmp)
+AC_CHECK_FUNCS(strncasecmp strnicmp)
+AC_CHECK_FUNCS(strsep)
+
+AC_CHECK_FUNCS(getuid)
+AC_CHECK_FUNCS(getgid)
+
+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)
+
 if test $ac_cv_prog_make_vpathok = no; then
   echo Copying generated srcs into build directory to compensate for VPATH breakage
-  if test ! -f insnsa.c; then cp -p ${srcdir}/insnsa.c .; fi
-  if test ! -f insnsd.c; then cp -p ${srcdir}/insnsd.c .; fi
-  if test ! -f macros.c; then cp -p ${srcdir}/macros.c .; fi
+  for file in macros.c insnsa.c insnsd.c insnsn.c insnsi.h version.h version.mac; do
+    if test ! -f $file; then cp -p ${srcdir}/${file} .; fi
+  done
 fi
 
-AC_OUTPUT(Makefile rdoff/Makefile)
+AC_OUTPUT_COMMANDS([mkdir -p output])
+AC_OUTPUT(Makefile rdoff/Makefile doc/Makefile)