1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ(2.59)
5AC_INIT(libspf2, 1.2.10, libspf2@anarres.org)
6AC_CONFIG_AUX_DIR(config)
7AM_INIT_AUTOMAKE(libspf2, $PACKAGE_VERSION)
8AC_CONFIG_SRCDIR([src/libspf2/spf_server.c])
9AM_CONFIG_HEADER(config.h)
10
11dnl AC_USE_SYSTEM_EXTENSIONS
12
13# remember the version info for later
14
15KV_MAJOR=`echo $PACKAGE_VERSION | sed 's/^\([[0-9]]*\)\.[[0-9]]*\.[[0-9]]*/\1/'`
16KV_MINOR=`echo $PACKAGE_VERSION | sed 's/^[[0-9]]*\.\([[0-9]]*\)\.[[0-9]]*/\1/'`
17KV_PATCH=`echo $PACKAGE_VERSION | sed 's/^[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)/\1/'`
18AC_SUBST([KV_MAJOR])
19AC_SUBST([KV_MINOR])
20AC_SUBST([KV_PATCH])
21
22cat >src/include/spf_lib_version.h <<_EOF_VERSION
23/**
24 * @file
25 * @brief Autogenerated configuration information - do not edit.
26 */
27#ifndef INC_SPF_VERSION
28#define INC_SPF_VERSION
29
30#define SPF_LIB_VERSION_MAJOR	$KV_MAJOR
31#define SPF_LIB_VERSION_MINOR	$KV_MINOR
32#define SPF_LIB_VERSION_PATCH	$KV_PATCH
33
34#endif
35_EOF_VERSION
36
37AX_WITH_PERL
38PERL_SUBDIRS=""
39AC_SUBST([PERL_SUBDIRS])
40AC_ARG_ENABLE(perl,
41	AC_HELP_STRING([--enable-perl],
42		[build the Perl/XS interface to libspf2]),
43[
44	PERL_SUBDIRS="perl"
45	AC_CONFIG_COMMANDS([perl/Makefile], [
46		# XXX This needs to use $PERL, somehow.
47		( cd perl && perl Makefile.PL )
48	])
49])
50
51
52# Checks for programs.
53AC_PROG_CC
54if test "X$ac_cv_prog_gcc" = "Xyes"; then
55        gcc_ver=`gcc -v 2>&1 | grep version | sed 's/.*gcc version \([[0-9]][[0-9]]*\)\..*/\1/'`
56#        echo "GCC version: $gcc_ver"
57        if test "X$gcc_ver" = "X3"; then
58        	CFLAGS="$CFLAGS -W -Wall -Wmissing-prototypes -Wwrite-strings"
59#        	CFLAGS="$CFLAGS -std=c89 -D_BSD_SOURCE -W -Wall -Wmissing-prototypes -Wwrite-strings"
60#        	CFLAGS="$CFLAGS -std=c99 -W -Wall -Wmissing-prototypes -Wwrite-strings"
61#        	CFLAGS="$CFLAGS -std=gnu99 -W -Wall -Wmissing-prototypes -Wwrite-strings"
62        else
63        	CFLAGS="$CFLAGS -Wall"
64        fi
65fi
66AC_PROG_CPP
67AC_SUBST([SUBDIRS])
68AC_PROG_MAKE_SET
69AC_SUBST([LIBPROGS])
70AC_PROG_LIBTOOL
71AC_PROG_INSTALL
72AC_PROG_LN_S
73dnl This is obsolete
74dnl AC_PROG_RANLIB
75
76# Check if the linker accepts --rpath (for Darwin)
77AC_MSG_CHECKING([if ld accepts --rpath])
78SAVEDLDFLAGS=$LDFLAGS
79LDFLAGS=$LDFLAGS" -Wl,--rpath=/"
80AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
81    [rpath="--rpath="; ldrpath=yes], [rpath="-L"; ldrpath=no])
82LDFLAGS=$SAVEDLDFLAGS
83AC_MSG_RESULT([$ldrpath])
84
85# Checks for header files.
86AC_HEADER_STDC
87AC_HEADER_SYS_WAIT
88AC_HEADER_TIME
89AC_CHECK_SIZEOF([int])
90AC_CHECK_HEADERS([limits.h sys/param.h syslog.h sys/time.h errno.h sys/types.h])
91AC_CHECK_HEADERS([fcntl.h malloc.h nmemory.h stddef.h inttypes.h stdlib.h string.h strings.h unistd.h stdarg.h])
92AC_CHECK_HEADERS([pthread.h pwd.h grp.h libintl.h getopt.h])
93AC_CHECK_HEADERS([netdb.h netinet/in.h sys/socket.h arpa/inet.h arpa/nameser.h])
94AC_CHECK_HEADERS([resolv.h], [], [], [[
95	#if HAVE_SYS_TYPES_H
96	#  include <sys/types.h>
97	#endif
98	#ifdef HAVE_SYS_SOCKET_H
99	#  include <sys/socket.h> /* DNS HEADER struct */
100	#endif
101	#ifdef HAVE_NETINET_IN_H
102	#  include <netinet/in.h>   /* inet_ functions / structs */
103	#endif
104	#ifdef HAVE_ARPA_NAMESER_H
105	#  include <arpa/nameser.h> /* DNS HEADER struct */
106	#endif
107	]])
108dnl XXX This is no longer true.
109AC_CHECK_HEADER(pthread.h, , [
110	echo "pthread.h is required to build this program."
111	exit 1;
112])
113
114dnl Moved to after header checks by Shevek
115AC_ARG_WITH(bind,
116        [  --with-bind=DIR  Find BIND resolver in DIR],
117        [AC_CHECK_FILE([$withval/include/bind/resolv.h],
118                [CFLAGS="$CFLAGS -I$withval/include/bind"],
119                [CFLAGS="$CFLAGS -I$withval/include"])
120         LDFLAGS="$LDFLAGS -L$withval/lib -Wl,$rpath$withval/lib"
121         AC_CHECK_LIB([bind], [res_query], [LIBS="$LIBS -lbind"],
122                [AC_CHECK_LIB([resolv],
123                        [res_query],
124                        [LIBS="$LIBS -lresolv"],
125                        [echo "cannot find resolver library"; exit 1;])
126                ])
127        ],
128		[dnl Have to include resolv.h as res_query is sometimes defined as a macro
129				AC_MSG_CHECKING([for res_query in -lresolv (with resolv.h if present)])
130				saved_libs="$LIBS"
131				LIBS="-lresolv $LIBS"
132				AC_TRY_LINK([
133						#ifdef HAVE_RESOLV_H
134						#include <resolv.h>
135						#endif],
136						[res_query(0,0,0,0,0)],
137						[AC_MSG_RESULT(yes)
138								have_res_query=yes],
139						[AC_MSG_RESULT(no)
140								LIBS="$saved_libs"])
141        ])
142
143
144
145dnl [AC_CHECK_LIB(resolv, res_query)])
146
147# Checks for libraries.
148AC_CHECK_LIB(nsl, inet_pton)
149AC_CHECK_LIB(socket, socket)
150AC_CHECK_LIB(intl, gettext)
151AC_CHECK_LIB(pthread, pthread_create)
152
153
154# Checks for typedefs, structures, and compiler characteristics.
155AC_C_CONST
156AC_C_INLINE
157AC_TYPE_PID_T
158AC_TYPE_UID_T
159AC_TYPE_SIZE_T
160AC_C_VOLATILE
161AC_C_BIGENDIAN
162AC_C_INLINE
163AC_C_CHAR_UNSIGNED
164AC_CHECK_TYPES([u_char, u_int8_t, u_int16_t, u_int32_t, uint8_t, uint16_t, uint32_t])
165AC_CHECK_TYPES([ns_type], [], [], [[
166	#ifdef HAVE_SYS_TYPES_H
167	# include <sys/types.h>
168	#endif
169	#ifdef HAVE_SYS_SOCKET_H
170	# include <sys/socket.h>		/* inet_ functions / structs */
171	#endif
172	#ifdef HAVE_NETINET_IN_H
173	# include <netinet/in.h>		/* inet_ functions / structs */
174	#endif
175	#ifdef HAVE_ARPA_NAMESER_H
176	# include <arpa/nameser.h> /* DNS HEADER struct */
177	#endif
178	]])
179AC_CHECK_TYPES([struct in6_addr], [], [], [[
180	#ifdef HAVE_NETINET_IN_H
181	# include <netinet/in.h>   /* inet_ functions / structs */
182	#endif
183	]])
184
185# Checks for library functions.
186AC_FUNC_FORK
187AC_FUNC_MALLOC
188AC_FUNC_MEMCMP
189AC_FUNC_REALLOC
190AC_FUNC_SETPGRP
191AC_FUNC_SELECT_ARGTYPES
192AC_TYPE_SIGNAL
193
194
195# It is not clear if BIND8 and/or BIND9 require the use of the
196# res_ninit() and res_nquery() functions when threading, but it is
197# safest to use them.
198
199# Nowadays, I think libspf2 requires this function to be available.
200AC_CHECK_DECLS([res_ninit], [], [], [[
201	#ifdef HAVE_SYS_TYPES_H
202	# include <sys/types.h>
203	#endif
204	#ifdef HAVE_SYS_SOCKET_H
205	# include <sys/socket.h>		/* inet_ functions / structs */
206	#endif
207	#ifdef HAVE_NETINET_IN_H
208	# include <netinet/in.h>		/* inet_ functions / structs */
209	#endif
210	#ifdef HAVE_ARPA_NAMESER_H
211	#  include <arpa/nameser.h> /* DNS HEADER struct */
212	#endif
213	#ifdef HAVE_RESOLV_H
214	# include <resolv.h>
215	#endif
216	]])
217AC_CHECK_DECLS([res_ndestroy], [], [], [[
218	#ifdef HAVE_SYS_TYPES_H
219	# include <sys/types.h>
220	#endif
221	#ifdef HAVE_SYS_SOCKET_H
222	# include <sys/socket.h>		/* inet_ functions / structs */
223	#endif
224	#ifdef HAVE_NETINET_IN_H
225	# include <netinet/in.h>		/* inet_ functions / structs */
226	#endif
227	#ifdef HAVE_ARPA_NAMESER_H
228	#  include <arpa/nameser.h> /* DNS HEADER struct */
229	#endif
230	#ifdef HAVE_RESOLV_H
231	# include <resolv.h>
232	#endif
233	]])
234
235AC_CHECK_DECLS([ns_t_spf], [], [], [[
236	#ifdef HAVE_SYS_TYPES_H
237	# include <sys/types.h>
238	#endif
239	#ifdef HAVE_SYS_SOCKET_H
240	# include <sys/socket.h>		/* inet_ functions / structs */
241	#endif
242	#ifdef HAVE_NETINET_IN_H
243	# include <netinet/in.h>		/* inet_ functions / structs */
244	#endif
245	#ifdef HAVE_ARPA_NAMESER_H
246	#  include <arpa/nameser.h> /* DNS HEADER struct */
247	#endif
248	#ifdef HAVE_RESOLV_H
249	# include <resolv.h>
250	#endif
251	]])
252
253AC_CHECK_DECLS([ns_t_invalid], [], [], [[
254	#ifdef HAVE_SYS_TYPES_H
255	# include <sys/types.h>
256	#endif
257	#ifdef HAVE_SYS_SOCKET_H
258	# include <sys/socket.h>		/* inet_ functions / structs */
259	#endif
260	#ifdef HAVE_NETINET_IN_H
261	# include <netinet/in.h>		/* inet_ functions / structs */
262	#endif
263	#ifdef HAVE_ARPA_NAMESER_H
264	#  include <arpa/nameser.h> /* DNS HEADER struct */
265	#endif
266	#ifdef HAVE_RESOLV_H
267	# include <resolv.h>
268	#endif
269	]])
270
271AC_CHECK_FUNCS([ftruncate gethostname memmove memset socket])
272AC_CHECK_FUNCS([strchr strcspn strdup strerror])
273AC_CHECK_FUNCS([strcasecmp strncasecmp strspn strtoul])
274AC_CHECK_FUNCS([gethostbyname inet_ntoa select strrchr strstr strtol])
275
276AC_REPLACE_FUNCS([getopt_long_only strncasecmp])
277AC_REPLACE_FUNCS([__ns_initparse __ns_name_uncompress __ns_msg_getflag])
278dnl Magnus Holmgren says this avoids linking a private function
279AC_LIBOBJ([__ns_get16])
280
281AC_CONFIG_FILES([Makefile
282                 Doxyfile
283                 src/Makefile
284                 src/include/Makefile
285                 src/libreplace/Makefile
286                 src/libspf2/Makefile
287                 src/spfquery/Makefile
288                 src/spftest/Makefile
289                 src/spfd/Makefile
290                 src/spf_example/Makefile])
291AC_OUTPUT
292