1# Process this file with autoconf to produce a configure script.
2
3AC_PREREQ([2.65])
4AC_INIT([liboping],
5	[1.8.0],
6	[liboping@verplant.org],
7	[],
8	[http://noping.cc/])
9AC_CONFIG_SRCDIR([src/liboping.c])
10AC_CONFIG_HEADERS([src/config.h])
11AC_CONFIG_MACRO_DIR([m4])
12AM_INIT_AUTOMAKE([dist-bzip2])
13AC_LANG([C])
14
15AC_PREFIX_DEFAULT("/opt/oping")
16
17# API version
18LIBOPING_MAJOR=`echo $PACKAGE_VERSION | cut -d'.' -f1`
19LIBOPING_MINOR=`echo $PACKAGE_VERSION | cut -d'.' -f2`
20LIBOPING_PATCH=`echo $PACKAGE_VERSION | cut -d'.' -f3`
21AC_SUBST(LIBOPING_MAJOR)
22AC_SUBST(LIBOPING_MINOR)
23AC_SUBST(LIBOPING_PATCH)
24
25# ABI version
26LIBOPING_CURRENT=2
27LIBOPING_REVISION=11
28LIBOPING_AGE=2
29AC_SUBST(LIBOPING_CURRENT)
30AC_SUBST(LIBOPING_REVISION)
31AC_SUBST(LIBOPING_AGE)
32
33#
34# Check for programs/utilities
35#
36AC_PROG_CC
37AC_PROG_CPP
38AC_PROG_INSTALL
39AC_PROG_LN_S
40AC_PROG_MAKE_SET
41AM_CONDITIONAL(COMPILER_IS_GCC, test "x$GCC" = "xyes")
42
43if test "x$PERL" = "x"
44then
45	PERL="perl"
46fi
47AC_ARG_VAR(PERL, [Perl interpreter command])
48
49# configure libtool
50LT_INIT([dlopen])
51
52# pkg-config interface
53PKG_INSTALLDIR
54
55AC_ARG_WITH(pkgconfigdir,
56	    AC_HELP_STRING([--with-pkgconfigdir], [Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
57	    [pkgconfigdir="${withval}"],
58	    [pkgconfigdir='${libdir}/pkgconfig'])
59AC_SUBST([pkgconfigdir])
60
61# Checks for header files.
62AC_HEADER_STDC
63AC_HEADER_TIME
64AC_CHECK_HEADERS([math.h signal.h fcntl.h inttypes.h netdb.h stdint.h stdlib.h string.h sys/socket.h sys/time.h unistd.h locale.h langinfo.h])
65
66# This sucks, but what can I do..?
67AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
68[#if HAVE_STDINT_H
69# include <stdint.h>
70#endif
71#if HAVE_SYS_TYPES_H
72# include <sys/types.h>
73#endif
74])
75AC_CHECK_HEADERS(netinet/in.h, [], [],
76[#if HAVE_STDINT_H
77# include <stdint.h>
78#endif
79#if HAVE_SYS_TYPES_H
80# include <sys/types.h>
81#endif
82#if HAVE_NETINET_IN_SYSTM_H
83# include <netinet/in_systm.h>
84#endif
85])
86AC_CHECK_HEADERS(netinet/ip.h, [], [],
87[#if HAVE_STDINT_H
88# include <stdint.h>
89#endif
90#if HAVE_SYS_TYPES_H
91# include <sys/types.h>
92#endif
93#if HAVE_NETINET_IN_SYSTM_H
94# include <netinet/in_systm.h>
95#endif
96#if HAVE_NETINET_IN_H
97# include <netinet/in.h>
98#endif
99])
100AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
101[#if HAVE_STDINT_H
102# include <stdint.h>
103#endif
104#if HAVE_SYS_TYPES_H
105# include <sys/types.h>
106#endif
107#if HAVE_NETINET_IN_SYSTM_H
108# include <netinet/in_systm.h>
109#endif
110#if HAVE_NETINET_IN_H
111# include <netinet/in.h>
112#endif
113#if HAVE_NETINET_IP_H
114# include <netinet/ip.h>
115#endif
116])
117AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
118[#if HAVE_STDINT_H
119# include <stdint.h>
120#endif
121#if HAVE_SYS_TYPES_H
122# include <sys/types.h>
123#endif
124#if HAVE_NETINET_IN_SYSTM_H
125# include <netinet/in_systm.h>
126#endif
127#if HAVE_NETINET_IN_H
128# include <netinet/in.h>
129#endif
130#if HAVE_NETINET_IP_H
131# include <netinet/ip.h>
132#endif
133])
134AC_CHECK_HEADERS(netinet/ip6.h, [], [],
135[#if HAVE_STDINT_H
136# include <stdint.h>
137#endif
138#if HAVE_SYS_TYPES_H
139# include <sys/types.h>
140#endif
141#if HAVE_SYS_TYPES_H
142# include <sys/types.h>
143#endif
144#if HAVE_NETINET_IN_SYSTM_H
145# include <netinet/in_systm.h>
146#endif
147#if HAVE_NETINET_IN_H
148# include <netinet/in.h>
149#endif
150])
151AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
152[#if HAVE_STDINT_H
153# include <stdint.h>
154#endif
155#if HAVE_SYS_TYPES_H
156# include <sys/types.h>
157#endif
158#if HAVE_NETINET_IN_SYSTM_H
159# include <netinet/in_systm.h>
160#endif
161#if HAVE_NETINET_IN_H
162# include <netinet/in.h>
163#endif
164#if HAVE_NETINET_IP6_H
165# include <netinet/ip6.h>
166#endif
167])
168
169# Checks for typedefs, structures, and compiler characteristics.
170AC_TYPE_SIZE_T
171AC_TYPE_SSIZE_T
172AC_TYPE_UID_T
173AC_TYPE_UINT16_T
174AC_TYPE_UINT32_T
175AC_TYPE_UINT8_T
176
177LIBOPING_PC_LIBS_PRIVATE=''
178
179socket_needs_socket="no"
180AC_CHECK_FUNCS(socket, [],
181	AC_CHECK_LIB(socket, socket,
182		[socket_needs_socket="yes"],
183		AC_MSG_ERROR(cannot find socket)))
184if test "x$socket_needs_socket" = "xyes"; then
185	LIBOPING_PC_LIBS_PRIVATE="${LIBOPING_PC_LIBS_PRIVATE} -lsocket"
186fi
187
188# Under Solaris, the `xnet' library provides `recvmsg' which complies with the
189# X/Open CAE Specification.
190with_libxnet="no"
191AC_CHECK_LIB(xnet, __xnet_recvmsg, [with_libxnet="yes"],[])
192if test "x$with_libxnet" = "xyes"
193then
194	CPPFLAGS="$CPPFLAGS -D_XPG4_2 -D__EXTENSIONS__"
195fi
196if test "x$with_libxnet" = "xyes"; then
197	LIBOPING_PC_LIBS_PRIVATE="${LIBOPING_PC_LIBS_PRIVATE} -lxnet"
198fi
199
200AC_SUBST(LIBOPING_PC_LIBS_PRIVATE)
201
202nanosleep_needs_rt="no"
203AC_CHECK_FUNCS(nanosleep, [],
204	AC_CHECK_LIB(rt, nanosleep,
205		[nanosleep_needs_rt="yes"],
206		AC_MSG_ERROR(cannot find nanosleep)))
207AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
208
209with_ncurses="no"
210AC_CHECK_HEADERS(ncursesw/ncurses.h ncurses.h, [with_ncurses="yes"], [])
211if test "x$with_ncurses" = "xyes"
212then
213	have_ncursesw="no"
214	have_ncurses="no"
215	NCURSES_LIB=""
216
217	AC_CHECK_LIB(ncursesw, mvwprintw, [have_ncursesw="yes"], [have_ncursesw="no"])
218	AC_CHECK_LIB(ncurses, mvwprintw, [have_ncurses="yes"], [have_ncurses="no"])
219
220	if test "x$have_ncursesw" = "xyes"; then
221		NCURSES_LIB="-lncursesw"
222	else if test "x$have_ncurses" = "xyes"; then
223		NCURSES_LIB="-lncurses"
224	else
225		with_ncurses="no"
226	fi; fi
227	AC_SUBST(NCURSES_LIB)
228fi
229AM_CONDITIONAL(BUILD_WITH_LIBNCURSES, test "x$with_ncurses" = "xyes")
230
231AC_FUNC_STRERROR_R
232
233AC_ARG_ENABLE(debug, [AS_HELP_STRING([--enable-debug], [Enable extensive debugging output.])],
234[
235	if test "x$enable_debug" = "xyes"
236	then
237		AC_DEFINE(WITH_DEBUG, 1, [Define to 1 if you want to get debugging output.])
238	fi
239], [])
240AM_CONDITIONAL(BUILD_WITH_DEBUG, test "x$enable_debug" = "xyes")
241
242AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
243[
244	if test "x$withval" != "xno" && test "x$withval" != "xyes"
245	then
246		PERL_BINDINGS_OPTIONS="$withval"
247		with_perl_bindings="yes"
248	else
249		PERL_BINDINGS_OPTIONS=""
250		with_perl_bindings="$withval"
251	fi
252],
253[
254	PERL_BINDINGS_OPTIONS=""
255	with_perl_bindings="yes"
256])
257
258if test "x$with_perl_bindings" = "xyes"
259then
260	BINDINGS="perl-bindings"
261else
262	BINDINGS=""
263fi
264
265AC_SUBST(PERL_BINDINGS_OPTIONS)
266
267AC_SUBST(BINDINGS)
268
269# Checks for library functions.
270AC_FUNC_MALLOC
271AC_FUNC_STRERROR_R
272AC_CHECK_FUNCS([gettimeofday memset modf select socket sqrt strcasecmp strdup strerror strncasecmp strtoul])
273
274AC_CONFIG_FILES([Makefile src/Makefile src/liboping.pc src/mans/Makefile bindings/Makefile])
275AC_OUTPUT
276