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