Cleaner way to handle MSVC's _snprintf() underscore damage
[nasm.git] / configure.in
bloba52b620bd6edcd0f1f09f5f95d4f28ab29b4fb31
1 dnl Process this file with autoconf 2.53 or later to produce
2 dnl a configure script.
3 AC_PREREQ(2.53)
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 AC_PROG_CC
51 AC_PROG_LN_S
52 AC_PROG_MAKE_SET
53 if test -f nasm.c; then
54   # we're building in the source dir, so we don't need this check at all
55   ac_cv_prog_make_vpathok=yes
56 else
57   AC_PROG_MAKE_VPATHOK
59 AC_PROG_INSTALL
61 dnl If we have gcc, add appropriate options
62 PA_ADD_CFLAGS([-W])
63 PA_ADD_CFLAGS([-Wall])
64 PA_ADD_CFLAGS([-std=c99])
65 PA_ADD_CFLAGS([-pedantic])
67 dnl Look for "nroff" or "groff"
68 AC_CHECK_PROGS(NROFF, nroff, echo)
69 AC_SUBST(NROFF)
71 dnl Checks for header files.
72 AC_HEADER_STDC
73 if test $ac_cv_header_stdc = no; then
74   AC_MSG_ERROR([NASM requires ANSI C header files to compile])
77 AC_CHECK_HEADERS(limits.h)
78 if test $ac_cv_header_limits_h = no; then
79   AC_MSG_ERROR([NASM requires '<limits.h>' to compile])
82 dnl Check for <inttypes.h> or add a substitute version
83 AC_CHECK_HEADERS(inttypes.h, , CFLAGS="$CFLAGS -I\$(top_srcdir)/inttypes")
85 dnl Checks for typedefs, structures, and compiler characteristics.
86 AC_C_CONST
87 AC_TYPE_SIZE_T
89 dnl Checks for library functions.
91 AC_CHECK_FUNCS(strcspn, ,
92   AC_MSG_ERROR([NASM requires ANSI C (specifically, "strcspn")]))
94 AC_CHECK_FUNCS(strspn, ,
95   AC_MSG_ERROR([NASM requires ANSI C (specifically, "strspn")]))
97 missing=true
98 AC_CHECK_FUNCS([snprintf _snprintf], missing=false)
99 if $missing; then
100   AC_MSG_ERROR([NASM requires ISO C99 (specifically, "snprintf")])
103 missing=true
104 AC_CHECK_FUNCS([vsnprintf _vsnprintf], missing=false)
105 if $missing; then
106   AC_MSG_ERROR([NASM requires ISO C99 (specifically, "vsnprintf")])
109 AC_CHECK_FUNCS(getuid)
110 AC_CHECK_FUNCS(getgid)
112 if test $ac_cv_prog_make_vpathok = no; then
113   echo Copying generated srcs into build directory to compensate for VPATH breakage
114   for file in macros.c insnsa.c insnsd.c insnsn.c insnsi.h version.h version.mac; do
115     if test ! -f $file; then cp -p ${srcdir}/${file} .; fi
116   done
119 AC_OUTPUT_COMMANDS([mkdir -p output])
120 AC_OUTPUT(Makefile rdoff/Makefile doc/Makefile)