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