1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(enigma.h)
3
4dnl Check for broken VPATH handling on older NetBSD makes.
5AC_DEFUN(AC_PROG_MAKE_VPATHOK,
6[AC_MSG_CHECKING(whether ${MAKE-make} has sane VPATH handling)
7set dummy ${MAKE-make}; ac_make=`echo "[$]2" | sed 'y%./+-%__p_%'`
8AC_CACHE_VAL(ac_cv_prog_make_vpathok,
9[mkdir conftestdir
10cat > conftestdir/conftestmake <<\EOF
11VPATH = ..
12conftestfoo: conftestbar
13	@echo ac_make2temp=ok
14conftestbar: conftestbaz
15	@echo ac_maketemp=broken
16	@touch conftestbar
17EOF
18echo > conftestbaz # these two lines need to be...
19echo > conftestbar # ... in this order not the other
20changequote(, )dnl
21unset ac_maketemp
22unset ac_make2temp
23# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
24eval `cd conftestdir; ${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
25changequote([, ])dnl
26if test -n "$ac_maketemp"; then
27  ac_cv_prog_make_vpathok=no
28else
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
34fi
35rm -rf conftestdir
36rm -f conftestbar conftestbaz])dnl
37if test $ac_cv_prog_make_vpathok = yes; then
38  AC_MSG_RESULT(yes)
39else
40  AC_MSG_RESULT(no)
41fi
42])
43
44AC_PREFIX_PROGRAM(enigma)
45
46dnl Checks for programs.
47AC_PROG_CC
48AC_PROG_LN_S
49AC_PROG_MAKE_SET
50if test -f enigma.h; 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
53else
54  AC_PROG_MAKE_VPATHOK
55fi
56AC_PROG_INSTALL
57
58if test "$GCC" = "yes"; then
59  GCCFLAGS="-Wall -W"
60else
61  GCCFLAGS=
62fi
63AC_SUBST(GCCFLAGS)
64
65dnl Look for "nroff" or "groff"
66AC_CHECK_PROGS(NROFF, nroff, echo)
67AC_SUBST(NROFF)
68
69dnl Checks for header files.
70AC_HEADER_STDC
71if test $ac_cv_header_stdc = no; then
72  AC_MSG_ERROR([Enigma requires ANSI C header files to compile])
73fi
74
75AC_TYPE_SIZE_T
76if test $ac_cv_type_size_t = no; then
77  AC_MSG_ERROR([Enigma requires ANSI C (specifically, "size_t")])
78fi
79
80AC_CHECK_FUNCS(strcspn)
81if test $ac_cv_func_strcspn = no; then
82  AC_MSG_ERROR([Enigma requires ANSI C (specifically, "strcspn")])
83fi
84
85AC_CHECK_FUNCS(strspn)
86if test $ac_cv_func_strspn = no; then
87  AC_MSG_ERROR([Enigma requires ANSI C (specifically, "strspn")])
88fi
89
90dnl Checks for Curses library.
91curslib=ncurses
92AC_CHECK_LIB(ncurses,initscr)
93AC_CHECK_HEADER(ncurses.h)
94if test $ac_cv_lib_ncurses_initscr = no || test $ac_cv_header_ncurses_h = no; then
95  curslib=curses
96  AC_CHECK_LIB(curses,initscr)
97  AC_CHECK_HEADER(curses.h)
98  if test $ac_cv_lib_curses_initscr = no || test $ac_cv_header_curses_h = no; then
99    AC_MSG_ERROR([Enigma requires libcurses and curses.h])
100  fi
101fi
102
103dnl Checks for attr_t in curses header.
104AC_MSG_CHECKING(for attr_t in ${curslib}.h)
105AC_TRY_COMPILE(#include <${curslib}.h>
106,attr_t i;
107,cursattr=" -DHAS_ATTR_T"
108AC_MSG_RESULT(yes),
109AC_MSG_RESULT(no))
110CURSES="-DCURSES_HDR=\"<${curslib}.h>\"$cursattr"
111
112AC_SUBST(CURSES)
113
114AC_OUTPUT(Makefile)
115