src/oping.c: Implement the "-O" option.
[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.8.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=2
27 LIBOPING_REVISION=11
28 LIBOPING_AGE=2
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
54
55 AC_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'])
59 AC_SUBST([pkgconfigdir])
60
61 # Checks for header files.
62 AC_HEADER_STDC
63 AC_HEADER_TIME
64 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])
65
66 # This sucks, but what can I do..?
67 AC_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 ])
75 AC_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 ])
86 AC_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 ])
100 AC_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 ])
117 AC_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 ])
134 AC_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 ])
151 AC_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.
170 AC_TYPE_SIZE_T
171 AC_TYPE_SSIZE_T
172 AC_TYPE_UID_T
173 AC_TYPE_UINT16_T
174 AC_TYPE_UINT32_T
175 AC_TYPE_UINT8_T
176
177 LIBOPING_PC_LIBS_PRIVATE=''
178
179 socket_needs_socket="no"
180 AC_CHECK_FUNCS(socket, [],
181         AC_CHECK_LIB(socket, socket,
182                 [socket_needs_socket="yes"],
183                 AC_MSG_ERROR(cannot find socket)))
184 if test "x$socket_needs_socket" = "xyes"; then
185         LIBOPING_PC_LIBS_PRIVATE="${LIBOPING_PC_LIBS_PRIVATE} -lsocket"
186 fi
187
188 # Under Solaris, the `xnet' library provides `recvmsg' which complies with the
189 # X/Open CAE Specification.
190 with_libxnet="no"
191 AC_CHECK_LIB(xnet, __xnet_recvmsg, [with_libxnet="yes"],[])
192 if test "x$with_libxnet" = "xyes"
193 then
194         CPPFLAGS="$CPPFLAGS -D_XPG4_2 -D__EXTENSIONS__"
195 fi
196 if test "x$with_libxnet" = "xyes"; then
197         LIBOPING_PC_LIBS_PRIVATE="${LIBOPING_PC_LIBS_PRIVATE} -lxnet"
198 fi
199
200 AC_SUBST(LIBOPING_PC_LIBS_PRIVATE)
201
202 nanosleep_needs_rt="no"
203 AC_CHECK_FUNCS(nanosleep, [],
204         AC_CHECK_LIB(rt, nanosleep,
205                 [nanosleep_needs_rt="yes"],
206                 AC_MSG_ERROR(cannot find nanosleep)))
207 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
208
209 with_ncurses="no"
210 AC_CHECK_HEADERS(ncursesw/ncurses.h ncurses.h, [with_ncurses="yes"], [])
211 if test "x$with_ncurses" = "xyes"
212 then
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)
228 fi
229 AM_CONDITIONAL(BUILD_WITH_LIBNCURSES, test "x$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