Better handling of platforms which hide "extended" functionality
[platform/upstream/nasm.git] / configure.in
1 dnl Process this file with autoconf 2.59 or later to produce
2 dnl a configure script.
3 AC_PREREQ(2.59)
4 AC_INIT(config.h.in)
5 AC_CONFIG_HEADERS(config.h)
6
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
37 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)
44 fi
45 ])
46
47 AC_PREFIX_PROGRAM(nasm)
48
49 dnl Checks for programs.
50 dnl Consider AC_USE_SYSTEM_EXTENSIONS if autoconf 2.61 is OK in the future
51 AC_GNU_SOURCE
52 AC_ISC_POSIX
53 AC_MINIX
54 AC_PROG_CC
55 AC_PROG_LN_S
56 AC_PROG_MAKE_SET
57 if test -f nasm.c; then
58   # we're building in the source dir, so we don't need this check at all
59   ac_cv_prog_make_vpathok=yes
60 else
61   AC_PROG_MAKE_VPATHOK
62 fi
63 AC_PROG_INSTALL
64
65 dnl If we have gcc, add appropriate options
66 PA_ADD_CFLAGS([-W])
67 PA_ADD_CFLAGS([-Wall])
68 PA_ADD_CFLAGS([-std=c99])
69 PA_ADD_CFLAGS([-pedantic])
70
71 dnl Look for "nroff" or "groff"
72 AC_CHECK_PROGS(NROFF, nroff, echo)
73 AC_SUBST(NROFF)
74
75 dnl Checks for header files.
76 AC_HEADER_STDC
77 if test $ac_cv_header_stdc = no; then
78   AC_MSG_ERROR([NASM requires ANSI C header files to compile])
79 fi
80
81 AC_CHECK_HEADERS(limits.h)
82 if test $ac_cv_header_limits_h = no; then
83   AC_MSG_ERROR([NASM requires '<limits.h>' to compile])
84 fi
85
86 dnl Check for <inttypes.h> or add a substitute version
87 AC_CHECK_HEADERS(inttypes.h, , CFLAGS="$CFLAGS -I\$(top_srcdir)/inttypes")
88
89 dnl The standard header for str*casecmp is <strings.h>
90 AC_CHECK_HEADERS(strings.h)
91
92 dnl Look for <stdbool.h>
93 AC_CHECK_HEADERS(stdbool.h)
94
95 dnl Checks for typedefs, structures, and compiler characteristics.
96 AC_C_CONST
97 AC_TYPE_SIZE_T
98
99 dnl Checks for library functions.
100 AC_SUBST(XOBJS)
101
102 AC_CHECK_FUNCS(strcspn, ,
103   AC_MSG_ERROR([NASM requires ANSI C (specifically, "strcspn")]))
104
105 AC_CHECK_FUNCS(strspn, ,
106   AC_MSG_ERROR([NASM requires ANSI C (specifically, "strspn")]))
107
108 missing=true
109 AC_CHECK_FUNCS([vsnprintf _vsnprintf], missing=false)
110 if $missing; then
111    XOBJS="$XOBJS lib/vsnprintf.o"
112 fi
113
114 missing=true
115 AC_CHECK_FUNCS([snprintf _snprintf], missing=false)
116 if $missing; then
117    XOBJS="$XOBJS lib/snprintf.o"
118 fi
119
120 AC_CHECK_FUNCS(strcasecmp stricmp)
121 AC_CHECK_FUNCS(strncasecmp strnicmp)
122 AC_CHECK_FUNCS(strsep)
123
124 AC_CHECK_FUNCS(getuid)
125 AC_CHECK_FUNCS(getgid)
126
127 dnl Check for functions that might not be declared in the headers for
128 dnl various idiotic reasons (mostly because of library authors
129 dnl abusing the meaning of __STRICT_ANSI__)
130 AC_CHECK_DECLS(strcasecmp)
131 AC_CHECK_DECLS(stricmp)
132 AC_CHECK_DECLS(strncasecmp)
133 AC_CHECK_DECLS(strnicmp)
134 AC_CHECK_DECLS(strsep)
135
136 if test $ac_cv_prog_make_vpathok = no; then
137   echo Copying generated srcs into build directory to compensate for VPATH breakage
138   for file in macros.c insnsa.c insnsd.c insnsn.c insnsi.h version.h version.mac; do
139     if test ! -f $file; then cp -p ${srcdir}/${file} .; fi
140   done
141 fi
142
143 AC_OUTPUT_COMMANDS([mkdir -p output])
144 AC_OUTPUT(Makefile rdoff/Makefile doc/Makefile)