Whitespace changes
[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.9.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 AC_SEARCH_LIBS([nanosleep],[rt],[],
203                 [AC_MSG_ERROR([cannot find nanosleep])])
204 AC_SEARCH_LIBS([clock_gettime],[rt],[],
205                 [AC_MSG_ERROR([cannot find clock_gettime])])
206
207 with_ncurses="no"
208 AC_CHECK_HEADERS(ncursesw/ncurses.h ncurses.h, [with_ncurses="yes"], [])
209 if test "x$with_ncurses" = "xyes"
210 then
211         have_ncursesw="no"
212         have_ncurses="no"
213         NCURSES_LIB=""
214
215         AC_CHECK_LIB(ncursesw, mvwprintw, [have_ncursesw="yes"], [have_ncursesw="no"])
216         AC_CHECK_LIB(ncurses, mvwprintw, [have_ncurses="yes"], [have_ncurses="no"])
217
218         if test "x$have_ncursesw" = "xyes"; then
219                 NCURSES_LIB="-lncursesw"
220         else if test "x$have_ncurses" = "xyes"; then
221                 NCURSES_LIB="-lncurses"
222         else
223                 with_ncurses="no"
224         fi; fi
225         AC_SUBST(NCURSES_LIB)
226 fi
227 AM_CONDITIONAL(BUILD_WITH_LIBNCURSES, test "x$with_ncurses" = "xyes")
228
229 AC_FUNC_STRERROR_R
230
231 AC_ARG_ENABLE(debug, [AS_HELP_STRING([--enable-debug], [Enable extensive debugging output.])],
232 [
233         if test "x$enable_debug" = "xyes"
234         then
235                 AC_DEFINE(WITH_DEBUG, 1, [Define to 1 if you want to get debugging output.])
236         fi
237 ], [])
238 AM_CONDITIONAL(BUILD_WITH_DEBUG, test "x$enable_debug" = "xyes")
239
240 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
241 [
242         if test "x$withval" != "xno" && test "x$withval" != "xyes"
243         then
244                 PERL_BINDINGS_OPTIONS="$withval"
245                 with_perl_bindings="yes"
246         else
247                 PERL_BINDINGS_OPTIONS=""
248                 with_perl_bindings="$withval"
249         fi
250 ],
251 [
252         PERL_BINDINGS_OPTIONS=""
253         with_perl_bindings="yes"
254 ])
255
256 if test "x$with_perl_bindings" = "xyes"
257 then
258         BINDINGS="perl-bindings"
259 else
260         BINDINGS=""
261 fi
262
263 AC_SUBST(PERL_BINDINGS_OPTIONS)
264
265 AC_SUBST(BINDINGS)
266
267 # Checks for library functions.
268 AC_FUNC_MALLOC
269 AC_FUNC_STRERROR_R
270 AC_CHECK_FUNCS([gettimeofday memset modf select socket sqrt strcasecmp strdup strerror strncasecmp strtoul])
271
272 AC_CONFIG_FILES([Makefile src/Makefile src/liboping.pc src/mans/Makefile bindings/Makefile])
273 AC_OUTPUT