1AC_INIT([eif], [1.3.4], [marcolz@stack.nl])
2AC_CONFIG_SRCDIR([src/eif.c])
3AM_INIT_AUTOMAKE
4AC_CONFIG_HEADERS(config.h)
5
6dnl Checks for programs.
7
8dnl Why doesn't configure do this by itself ? It might be necessary for
9dnl header checks...
10
11if test x$includedir != x
12then
13	CPPFLAGS="${CPPFLAGS} -I${includedir}"
14fi
15
16if test x$oldincludedir != x
17then
18	CPPFLAGS="${CPPFLAGS} -I${oldincludedir}"
19fi
20
21CPPFLAGS="${CPPFLAGS} -I/usr/local/include -I/usr/pkg/include"
22LDFLAGS="${LDFLAGS} -L/usr/local/lib -L/usr/pkg/lib"
23
24if test x$libdir != x
25then
26	LDFLAGS="${LDFLAGS} -L${libdir}"
27fi
28
29if test x$GCC != x
30then
31	CFLAGS="${CFLAGS} -Wall -W -Wshadow -Wbad-function-cast -Wcast-qual -Wwrite-strings"
32fi
33
34
35AC_PROG_CC
36AC_PROG_LN_S
37AC_PROG_GCC_TRADITIONAL
38AC_PROG_RANLIB
39
40dnl Checks for libraries.
41
42AC_CHECK_LIB(bsd, bsd_ioctl)
43AC_CHECK_LIB(curses, tgetent)
44
45dnl AC_CHECK_LIB(dl, main)
46
47AC_CHECK_LIB(readline, rl_unbind_key, ,AC_MSG_ERROR([You really need this one !.]))
48
49AC_CHECK_LIB(termcap, main)
50
51dnl Checks for header files.
52AC_HEADER_DIRENT
53AC_HEADER_STDC
54AC_CHECK_HEADERS(fcntl.h malloc.h stdlib.h string.h strings.h sys/file.h sys/ioctl.h sys/select.h sys/time.h termcap.h termio.h unistd.h readline/tilde.h)
55AC_CHECK_HEADERS(readline/readline.h, , AC_MSG_ERROR([You really need this one !.]))
56
57dnl Checks for typedefs, structures, and compiler characteristics.
58AC_C_CONST
59AC_HEADER_TIME
60
61dnl Checks for library functions.
62AC_FUNC_ALLOCA
63AC_TYPE_SIGNAL
64AC_FUNC_VPRINTF
65AC_CHECK_FUNCS(getaddrinfo getnameinfo getwd select setenv socket strdup unsetenv)
66
67AC_DEFUN([EIF_FD_SET_NEEDS_STRUCT],[
68	AC_CACHE_CHECK([whether fd_set needs 'struct'], [ac_cv_fd_set_needs_struct],
69		[
70		AC_TRY_COMPILE([
71			#ifdef	HAVE_SYS_SELECT_H
72			#include	<sys/select.h>
73			#endif
74			#ifdef	HAVE_SYS_TIME_H
75			#include	<sys/time.h>
76			#endif
77			#include	<sys/types.h>
78		],[
79			fd_set		a;
80		],[ac_cv_fd_set_needs_struct=no],AC_TRY_COMPILE([
81			#ifdef	HAVE_SYS_SELECT_H
82			#include	<sys/select.h>
83			#endif
84			#ifdef	HAVE_SYS_TIME_H
85			#include	<sys/time.h>
86			#endif
87			#include	<sys/types.h>
88		],[
89			struct fd_set	a;
90		],[ac_cv_fd_set_needs_struct=yes],
91		[ac_cv_fd_set_needs_struct=no]))
92	])
93	if test "$ac_cv_fd_set_needs_struct" = "yes"; then
94		AC_DEFINE(FD_SET_NEEDS_STRUCT, [struct])
95	else
96		AC_DEFINE(FD_SET_NEEDS_STRUCT,[])
97	fi
98])
99
100AC_DEFUN([EIF_READLINE_HANDLES_CONST],[
101	SAVE_CFLAGS="${SAVE_CFLAGS}"
102	CFLAGS="${CFLAGS} -Werror"
103	AC_CACHE_CHECK([whether readline handles 'const char *'], [ac_cv_readline_uses_const],
104		[
105		AC_TRY_COMPILE([
106			#include	<readline/history.h>
107		],[
108			write_history("/dev/tty");
109		],[ac_cv_readline_uses_const=yes],
110		[ac_cv_readline_uses_const=no])
111	])
112	CFLAGS="${SAVE_CFLAGS}"
113	if test "$ac_cv_readline_uses_const" = "yes"; then
114		AC_DEFINE(READLINE_HANDLES_CONST, 1)
115	fi
116])
117
118AC_DEFUN([EIF_READLINE_UNBIND_KEY],[
119	SAVE_CFLAGS="${SAVE_CFLAGS}"
120	CFLAGS="${CFLAGS} -Wimplicit-function-declaration -Werror"
121	AC_CACHE_CHECK([whether readline.h prototypes 'rl_unbind_key'], ac_cv_readline_unbind_key,
122		[
123		AC_TRY_COMPILE([
124			#include	<stdio.h>
125			#include	<readline/readline.h>
126		],[
127			rl_unbind_key(1);
128		],[ac_cv_readline_unbind_key=yes],
129		[ac_cv_readline_unbind_key=no])
130	])
131	CFLAGS="${SAVE_CFLAGS}"
132	if test "$ac_cv_readline_unbind_key" = "yes"; then
133		AC_DEFINE(READLINE_UNBIND_KEY, 1)
134	fi
135])
136
137dnl old acconfig.h
138AH_TOP([#ifndef EIF_CONFIG_H
139#define EIF_CONFIG_H
140])
141
142AH_TEMPLATE([FD_SET_NEEDS_STRUCT], [Some systems need 'struct fd_set', others just 'fd_set'])
143
144AH_TEMPLATE([EIF_READLINE_HANDLES_CONST], [Readline is old code and does not always handle 'const char *'])
145
146AH_TEMPLATE([EIF_READLINE_UNBIND_KEY], [OpenBSD uses a stripped version of readline's headerfiles])
147
148AH_BOTTOM([#ifdef  HAVE_GETADDRINFO
149#ifdef  HAVE_GETNAMEINFO
150#define USE_IPv6
151#endif  /* HAVE_GETNAMEINFO */
152#endif  /* HAVE_GETADDRINFO */
153
154#ifndef HAVE_READLINE_TILDE_H
155#ifdef  READLINE_HANDLES_CONST
156extern char *tilde_expand(const char *);
157#else   /* READLINE_HANDLES_CONST */
158extern char *tilde_expand(char *);
159#endif  /* READLINE_HANDLES_CONST */
160#endif  /* HAVE_READLINE_TILDE_H */
161
162#ifndef READLINE_UNBIND_KEY
163int     rl_unbind_key(int key);
164#endif  /* READLINE_UNBIND_KEY */
165#endif  /* EIF_CONFIG_H */
166])
167
168dnl Local additions from aclocal.m4
169EIF_FD_SET_NEEDS_STRUCT
170EIF_READLINE_HANDLES_CONST
171EIF_READLINE_UNBIND_KEY
172
173AC_SUBST(AM_CFLAGS)
174
175AC_CONFIG_FILES([ \
176	Makefile \
177	src/Makefile \
178	src/connect/Makefile \
179	contrib/Makefile \
180	doc/Makefile \
181	])
182AC_OUTPUT
183