liboping.pc: Let configure create the pkg-config file.
[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.7.0],[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=10
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 AC_ARG_WITH(pkgconfigdir,
52             AC_HELP_STRING([--with-pkgconfigdir], [Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
53             [pkgconfigdir="${withval}"],
54             [pkgconfigdir='${libdir}/pkgconfig'])
55 AC_SUBST([pkgconfigdir])
56
57 # Checks for header files.
58 AC_HEADER_STDC
59 AC_HEADER_TIME
60 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])
61
62 # This sucks, but what can I do..?
63 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
64 [#if HAVE_STDINT_H
65 # include <stdint.h>
66 #endif
67 #if HAVE_SYS_TYPES_H
68 # include <sys/types.h>
69 #endif
70 ])
71 AC_CHECK_HEADERS(netinet/in.h, [], [],
72 [#if HAVE_STDINT_H
73 # include <stdint.h>
74 #endif
75 #if HAVE_SYS_TYPES_H
76 # include <sys/types.h>
77 #endif
78 #if HAVE_NETINET_IN_SYSTM_H
79 # include <netinet/in_systm.h>
80 #endif
81 ])
82 AC_CHECK_HEADERS(netinet/ip.h, [], [],
83 [#if HAVE_STDINT_H
84 # include <stdint.h>
85 #endif
86 #if HAVE_SYS_TYPES_H
87 # include <sys/types.h>
88 #endif
89 #if HAVE_NETINET_IN_SYSTM_H
90 # include <netinet/in_systm.h>
91 #endif
92 #if HAVE_NETINET_IN_H
93 # include <netinet/in.h>
94 #endif
95 ])
96 AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
97 [#if HAVE_STDINT_H
98 # include <stdint.h>
99 #endif
100 #if HAVE_SYS_TYPES_H
101 # include <sys/types.h>
102 #endif
103 #if HAVE_NETINET_IN_SYSTM_H
104 # include <netinet/in_systm.h>
105 #endif
106 #if HAVE_NETINET_IN_H
107 # include <netinet/in.h>
108 #endif
109 #if HAVE_NETINET_IP_H
110 # include <netinet/ip.h>
111 #endif
112 ])
113 AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
114 [#if HAVE_STDINT_H
115 # include <stdint.h>
116 #endif
117 #if HAVE_SYS_TYPES_H
118 # include <sys/types.h>
119 #endif
120 #if HAVE_NETINET_IN_SYSTM_H
121 # include <netinet/in_systm.h>
122 #endif
123 #if HAVE_NETINET_IN_H
124 # include <netinet/in.h>
125 #endif
126 #if HAVE_NETINET_IP_H
127 # include <netinet/ip.h>
128 #endif
129 ])
130 AC_CHECK_HEADERS(netinet/ip6.h, [], [],
131 [#if HAVE_STDINT_H
132 # include <stdint.h>
133 #endif
134 #if HAVE_SYS_TYPES_H
135 # include <sys/types.h>
136 #endif
137 #if HAVE_SYS_TYPES_H
138 # include <sys/types.h>
139 #endif
140 #if HAVE_NETINET_IN_SYSTM_H
141 # include <netinet/in_systm.h>
142 #endif
143 #if HAVE_NETINET_IN_H
144 # include <netinet/in.h>
145 #endif
146 ])
147 AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
148 [#if HAVE_STDINT_H
149 # include <stdint.h>
150 #endif
151 #if HAVE_SYS_TYPES_H
152 # include <sys/types.h>
153 #endif
154 #if HAVE_NETINET_IN_SYSTM_H
155 # include <netinet/in_systm.h>
156 #endif
157 #if HAVE_NETINET_IN_H
158 # include <netinet/in.h>
159 #endif
160 #if HAVE_NETINET_IP6_H
161 # include <netinet/ip6.h>
162 #endif
163 ])
164
165 # Checks for typedefs, structures, and compiler characteristics.
166 AC_TYPE_SIZE_T
167 AC_TYPE_SSIZE_T
168 AC_TYPE_UID_T
169 AC_TYPE_UINT16_T
170 AC_TYPE_UINT32_T
171 AC_TYPE_UINT8_T
172
173 LIBOPING_PC_LIBS_PRIVATE=''
174
175 socket_needs_socket="no"
176 AC_CHECK_FUNCS(socket, [],
177         AC_CHECK_LIB(socket, socket,
178                 [socket_needs_socket="yes"],
179                 AC_MSG_ERROR(cannot find socket)))
180 if test "x$socket_needs_socket" = "xyes"; then
181         LIBOPING_PC_LIBS_PRIVATE="${LIBOPING_PC_LIBS_PRIVATE} -lsocket"
182 fi
183
184 # Under Solaris, the `xnet' library provides `recvmsg' which complies with the
185 # X/Open CAE Specification.
186 with_libxnet="no"
187 AC_CHECK_LIB(xnet, __xnet_recvmsg, [with_libxnet="yes"],[])
188 if test "x$with_libxnet" = "xyes"
189 then
190         CPPFLAGS="$CPPFLAGS -D_XPG4_2 -D__EXTENSIONS__"
191 fi
192 if test "x$with_libxnet" = "xyes"; then
193         LIBOPING_PC_LIBS_PRIVATE="${LIBOPING_PC_LIBS_PRIVATE} -lxnet"
194 fi
195
196 AC_SUBST(LIBOPING_PC_LIBS_PRIVATE)
197
198 nanosleep_needs_rt="no"
199 AC_CHECK_FUNCS(nanosleep, [],
200         AC_CHECK_LIB(rt, nanosleep,
201                 [nanosleep_needs_rt="yes"],
202                 AC_MSG_ERROR(cannot find nanosleep)))
203 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
204
205 with_ncurses="no"
206 AC_CHECK_HEADERS(ncursesw/ncurses.h ncurses.h, [with_ncurses="yes"], [])
207 if test "x$with_ncurses" = "xyes"
208 then
209         have_ncursesw="no"
210         have_ncurses="no"
211         NCURSES_LIB=""
212
213         AC_CHECK_LIB(ncursesw, mvwprintw, [have_ncursesw="yes"], [have_ncursesw="no"])
214         AC_CHECK_LIB(ncurses, mvwprintw, [have_ncurses="yes"], [have_ncurses="no"])
215
216         if test "x$have_ncursesw" = "xyes"; then
217                 NCURSES_LIB="-lncursesw"
218         else if test "x$have_ncurses" = "xyes"; then
219                 NCURSES_LIB="-lncurses"
220         else
221                 with_ncurses="no"
222         fi; fi
223         AC_SUBST(NCURSES_LIB)
224 fi
225 AM_CONDITIONAL(BUILD_WITH_LIBNCURSES, test "x$with_ncurses" = "xyes")
226
227 AC_FUNC_STRERROR_R
228
229 AC_ARG_ENABLE(debug, [AS_HELP_STRING([--enable-debug], [Enable extensive debugging output.])],
230 [
231         if test "x$enable_debug" = "xyes"
232         then
233                 AC_DEFINE(WITH_DEBUG, 1, [Define to 1 if you want to get debugging output.])
234         fi
235 ], [])
236 AM_CONDITIONAL(BUILD_WITH_DEBUG, test "x$enable_debug" = "xyes")
237
238 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
239 [
240         if test "x$withval" != "xno" && test "x$withval" != "xyes"
241         then
242                 PERL_BINDINGS_OPTIONS="$withval"
243                 with_perl_bindings="yes"
244         else
245                 PERL_BINDINGS_OPTIONS=""
246                 with_perl_bindings="$withval"
247         fi
248 ],
249 [
250         PERL_BINDINGS_OPTIONS=""
251         with_perl_bindings="yes"
252 ])
253
254 if test "x$with_perl_bindings" = "xyes"
255 then
256         BINDINGS="perl-bindings"
257 else
258         BINDINGS=""
259 fi
260
261 AC_SUBST(PERL_BINDINGS_OPTIONS)
262
263 AC_SUBST(BINDINGS)
264
265 # Checks for library functions.
266 AC_FUNC_MALLOC
267 AC_FUNC_STRERROR_R
268 AC_CHECK_FUNCS([gettimeofday memset modf select socket sqrt strcasecmp strdup strerror strncasecmp strtoul])
269
270 AC_CONFIG_FILES([Makefile src/Makefile src/liboping.pc src/mans/Makefile bindings/Makefile])
271 AC_OUTPUT