1dnl $Id: configure.in,v 1.8.2.1 2006/08/19 22:51:37 marius Exp $
2AC_INIT(include/nylon.h)
3
4AC_CANONICAL_SYSTEM
5
6AM_INIT_AUTOMAKE(nylon, 1.21)
7AM_CONFIG_HEADER(include/config.h)
8
9AC_PROG_MAKE_SET
10
11dnl intitialization
12if test "x$prefix" = "xNONE"; then
13    prefix="/usr/local"
14fi
15
16dnl Checks for programs.
17AC_PROG_CC
18AC_PROG_RANLIB
19AC_PROG_INSTALL
20
21dnl Platform specific stuff
22case "$host" in
23*-*-hpux*)
24	AC_DEFINE(SPT_TYPE,SPT_PSTAT)
25	LIBS="$LIBS -lxnet -lsec"
26	;;
27esac
28
29dnl Checks for standard libraries.  Solaris sucks ...
30AC_CHECK_LIB(socket, socket)
31AC_CHECK_LIB(nsl, gethostbyname)
32AC_CHECK_LIB(resolv, hstrerror)
33
34dnl Checks for header files.
35AC_HEADER_STDC
36AC_HEADER_SYS_WAIT
37
38dnl Check for __progname; from OpenSSHp
39AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
40        AC_TRY_LINK([],
41                [ extern char *__progname; printf("%s", __progname); ],
42                [ ac_cv_libc_defines___progname="yes" ],
43                [ ac_cv_libc_defines___progname="no" ]
44        )
45])
46if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
47        AC_DEFINE(HAVE___PROGNAME)
48fi
49
50AC_CHECK_HEADERS(sys/ioctl.h sys/time.h unistd.h sys/queue.h)
51if test "x$ac_cv_header_sys_queue_h" = "xyes"; then
52  AC_MSG_CHECKING(for TAILQ_FOREACH in sys/queue.h)
53   AC_EGREP_CPP(yes,
54[
55#include <sys/queue.h>
56#ifdef TAILQ_FOREACH
57  yes
58#endif
59],    [AC_MSG_RESULT(yes)
60       AC_DEFINE(HAVE_TAILQFOREACH) ], AC_MSG_RESULT(no)
61	   )
62fi
63
64if test "x$ac_cv_header_sys_queue_h" = "xyes"; then
65   AC_MSG_CHECKING(for LIST_FIRST sys/queue.h)
66   AC_EGREP_CPP(yes,
67[
68#include <sys/queue.h>
69#ifdef LIST_FIRST
70  yes
71#endif
72],    [AC_MSG_RESULT(yes)
73       AC_DEFINE(HAVE_LISTFIRST) ], AC_MSG_RESULT(no)
74	   )
75fi
76
77dnl Checks for typedefs, structures, and compiler characteristics.
78AC_C_CONST
79AC_TYPE_PID_T
80AC_TYPE_SIZE_T
81AC_HEADER_TIME
82AC_CHECK_TYPE(u_int64_t, unsigned long long)
83AC_CHECK_TYPE(u_int32_t, unsigned int)
84AC_CHECK_TYPE(u_int16_t, unsigned short)
85AC_CHECK_TYPE(u_int8_t, unsigned char)
86AC_CHECK_TYPE(in_addr_t, unsigned long)
87AC_CHECK_TYPE(socklen_t, unsigned int)
88
89dnl Checks for library functions.
90AC_PROG_GCC_TRADITIONAL
91AC_TYPE_SIGNAL
92AC_CHECK_FUNCS(socket)
93dnl XXX - this is kind of hacky; we don't incorporate 'err' here since if it
94dnl       is needed, that symbol will already by in libevent.  FIX THIS, though.
95AC_REPLACE_FUNCS(strlcpy strlcat strsep setproctitle daemon)
96
97dnl Checks for libevent
98AC_MSG_CHECKING(for libevent)
99AC_ARG_WITH(libevent,
100[  --with-libevent=DIR     use libevent in DIR],
101[ case "$withval" in
102  yes|no)
103     AC_MSG_RESULT(no)
104     ;;
105  *)
106     AC_MSG_RESULT($withval)
107     if test -f $withval/include/event.h -a -f $withval/lib/libevent.a; then
108        owd=`pwd`
109        if cd $withval; then withval=`pwd`; cd $owd; fi
110        EVENTINC="-I$withval/include"
111        EVENTLIB="-L$withval/lib -levent"
112     elif test -f $withval/event.h -a -f $withval/libevent.a; then
113        owd=`pwd`
114        if cd $withval; then withval=`pwd`; cd $owd; fi
115        EVENTINC="-I$withval"
116        EVENTLIB="-L$withval -levent"
117     else
118        AC_ERROR(event.h or libevent.a not found in $withval)
119     fi
120     ;;
121  esac ],
122[ if test -f ${prefix}/include/event.h -a -f ${prefix}/lib/libevent.a;
123then
124     EVENTINC="-I${prefix}/include"
125     EVENTLIB="-L${prefix}/lib -levent"
126  elif test -f /usr/include/event.h; then
127     EVENTLIB="-levent"
128  else
129     AC_MSG_RESULT(no)
130     AC_ERROR(libevent not found)
131  fi
132  AC_MSG_RESULT(yes) ]
133)
134AC_SUBST(EVENTINC)
135AC_SUBST(EVENTLIB)
136
137if test "x${sysconfdir}" = 'x${prefix}/etc'; then
138    csysconfdir="${prefix}/etc"
139else
140    csysconfdir="${sysconfdir}"
141fi
142
143AC_DEFINE_UNQUOTED(SYSCONFDIR, "${csysconfdir}")
144
145AC_OUTPUT(Makefile src/Makefile man/Makefile include/Makefile)
146