Handle separate source and object directories correctly.
[platform/upstream/nasm.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_INIT(nasm.c)
3
4 dnl Check for broken VPATH handling on older NetBSD makes.
5 AC_DEFUN(AC_PROG_MAKE_VPATHOK,
6 [AC_MSG_CHECKING(whether ${MAKE-make} has sane VPATH handling)
7 set dummy ${MAKE-make}; ac_make=`echo "[$]2" | sed 'y%./+-%__p_%'`
8 AC_CACHE_VAL(ac_cv_prog_make_vpathok,
9 [mkdir conftestdir
10 cat > conftestdir/conftestmake <<\EOF
11 VPATH = ..
12 conftestfoo: conftestbar
13         @echo ac_make2temp=ok
14 conftestbar: conftestbaz
15         @echo ac_maketemp=broken
16         @touch conftestbar
17 EOF
18 echo > conftestbaz # these two lines need to be...
19 echo > conftestbar # ... in this order not the other
20 changequote(, )dnl
21 unset ac_maketemp
22 unset ac_make2temp
23 # GNU make sometimes prints "make[1]: Entering...", which would confuse us.
24 eval `cd conftestdir; ${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
25 changequote([, ])dnl
26 if test -n "$ac_maketemp"; then
27   ac_cv_prog_make_vpathok=no
28 else
29   if test -n "$ac_make2temp"; then
30     ac_cv_prog_make_vpathok=yes
31   else
32     ac_cv_prog_make_vpathok=no
33   fi
34 fi
35 rm -rf conftestdir
36 rm -f conftestbar conftestbaz])dnl
37 if test $ac_cv_prog_make_vpathok = yes; then
38   AC_MSG_RESULT(yes)
39 else
40   AC_MSG_RESULT(no)
41 fi
42 ])
43
44 AC_PREFIX_PROGRAM(nasm)
45
46 dnl Checks for programs.
47 AC_PROG_CC
48 AC_PROG_LN_S
49 AC_PROG_MAKE_SET
50 if test -f nasm.c; then
51   # we're building in the source dir, so we don't need this check at all
52   ac_cv_prog_make_vpathok=yes
53 else
54   AC_PROG_MAKE_VPATHOK
55 fi
56 AC_PROG_INSTALL
57
58 if test "$GCC" = "yes"; then
59   GCCFLAGS="-Wall -ansi -pedantic"
60 else
61   GCCFLAGS=
62 fi
63 AC_SUBST(GCCFLAGS)
64
65 dnl Look for "nroff" or "groff"
66 AC_CHECK_PROGS(NROFF, nroff, echo)
67 AC_SUBST(NROFF)
68
69 dnl Checks for header files.
70 AC_HEADER_STDC
71 if test $ac_cv_header_stdc = no; then
72   AC_MSG_ERROR([NASM requires ANSI C header files to compile])
73 fi
74
75 AC_CHECK_HEADERS(limits.h)
76 if test $ac_cv_header_limits_h = no; then
77   AC_MSG_ERROR([NASM requires '<limits.h>' to compile])
78 fi
79
80 dnl Checks for typedefs, structures, and compiler characteristics.
81 AC_C_CONST
82 if test $ac_cv_c_const = no; then
83   AC_MSG_ERROR([NASM requires ANSI C (specifically, working "const")])
84 fi
85
86 AC_TYPE_SIZE_T
87 if test $ac_cv_type_size_t = no; then
88   AC_MSG_ERROR([NASM requires ANSI C (specifically, "size_t")])
89 fi
90
91 dnl Checks for library functions.
92 AC_FUNC_VPRINTF
93 if test $ac_cv_func_vprintf = no; then
94   AC_MSG_ERROR([NASM requires ANSI C (specifically, "vprintf" and friends)])
95 fi
96
97 AC_CHECK_FUNCS(strcspn)
98 if test $ac_cv_func_strcspn = no; then
99   AC_MSG_ERROR([NASM requires ANSI C (specifically, "strcspn")])
100 fi
101
102 AC_CHECK_FUNCS(strspn)
103 if test $ac_cv_func_strspn = no; then
104   AC_MSG_ERROR([NASM requires ANSI C (specifically, "strspn")])
105 fi
106
107 if test $ac_cv_prog_make_vpathok = no; then
108   echo Copying generated srcs into build directory to compensate for VPATH breakage
109   if test ! -f insnsa.c; then cp -p ${srcdir}/insnsa.c .; fi
110   if test ! -f insnsd.c; then cp -p ${srcdir}/insnsd.c .; fi
111   if test ! -f macros.c; then cp -p ${srcdir}/macros.c .; fi
112 fi
113
114 AC_OUTPUT(Makefile rdoff/Makefile doc/Makefile)
115 AC_OUTPUT_COMMANDS([mkdir -p output])