Merge branch 'origin'
[liboping.git] / configure.ac
1 AC_INIT(liboping, 0.3.5)
2 AC_CONFIG_SRCDIR(src/liboping.c)
3 AC_CONFIG_HEADERS(src/config.h)
4 AM_INIT_AUTOMAKE(dist-bzip2)
5 AC_LANG(C)
6
7 AC_PREFIX_DEFAULT("/opt/oping")
8
9 #
10 # Check for programs/utilities
11 #
12 AC_PROG_CC
13 AC_PROG_CPP
14 AC_PROG_INSTALL
15 AC_PROG_LN_S
16 AC_PROG_MAKE_SET
17 AM_CONDITIONAL(COMPILER_IS_GCC, test "x$GCC" = "xyes")
18
19 if test "x$PERL" = "x"
20 then
21         PERL="perl"
22 fi
23 AC_ARG_VAR(PERL, [Perl interpreter command])
24
25 #
26 # configure libtool
27 #
28 AC_LIBTOOL_DLOPEN
29 AC_PROG_LIBTOOL
30 #AC_PROG_RANLIB
31
32 #
33 # Checks for header files.
34 #
35 AC_HEADER_STDC
36 AC_CHECK_HEADERS(unistd.h)
37 AC_CHECK_HEADERS(math.h)
38 AC_CHECK_HEADERS(fcntl.h)
39 AC_CHECK_HEADERS(sys/types.h)
40 AC_CHECK_HEADERS(sys/stat.h)
41 AC_HEADER_TIME
42 AC_CHECK_HEADERS(sys/socket.h)
43 AC_CHECK_HEADERS(netdb.h)
44 AC_CHECK_HEADERS(signal.h)
45
46 # This sucks, but what can I do..?
47 AC_CHECK_HEADERS(netinet/in_systm.h, [], [],
48 [#if HAVE_STDINT_H
49 # include <stdint.h>
50 #endif
51 #if HAVE_SYS_TYPES_H
52 # include <sys/types.h>
53 #endif
54 ])
55 AC_CHECK_HEADERS(netinet/in.h, [], [],
56 [#if HAVE_STDINT_H
57 # include <stdint.h>
58 #endif
59 #if HAVE_SYS_TYPES_H
60 # include <sys/types.h>
61 #endif
62 #if HAVE_NETINET_IN_SYSTM_H
63 # include <netinet/in_systm.h>
64 #endif
65 ])
66 AC_CHECK_HEADERS(netinet/ip.h, [], [],
67 [#if HAVE_STDINT_H
68 # include <stdint.h>
69 #endif
70 #if HAVE_SYS_TYPES_H
71 # include <sys/types.h>
72 #endif
73 #if HAVE_NETINET_IN_SYSTM_H
74 # include <netinet/in_systm.h>
75 #endif
76 #if HAVE_NETINET_IN_H
77 # include <netinet/in.h>
78 #endif
79 ])
80 AC_CHECK_HEADERS(netinet/ip_icmp.h, [], [],
81 [#if HAVE_STDINT_H
82 # include <stdint.h>
83 #endif
84 #if HAVE_SYS_TYPES_H
85 # include <sys/types.h>
86 #endif
87 #if HAVE_NETINET_IN_SYSTM_H
88 # include <netinet/in_systm.h>
89 #endif
90 #if HAVE_NETINET_IN_H
91 # include <netinet/in.h>
92 #endif
93 #if HAVE_NETINET_IP_H
94 # include <netinet/ip.h>
95 #endif
96 ])
97 AC_CHECK_HEADERS(netinet/ip_var.h, [], [],
98 [#if HAVE_STDINT_H
99 # include <stdint.h>
100 #endif
101 #if HAVE_SYS_TYPES_H
102 # include <sys/types.h>
103 #endif
104 #if HAVE_NETINET_IN_SYSTM_H
105 # include <netinet/in_systm.h>
106 #endif
107 #if HAVE_NETINET_IN_H
108 # include <netinet/in.h>
109 #endif
110 #if HAVE_NETINET_IP_H
111 # include <netinet/ip.h>
112 #endif
113 ])
114 AC_CHECK_HEADERS(netinet/ip6.h, [], [],
115 [#if HAVE_STDINT_H
116 # include <stdint.h>
117 #endif
118 #if HAVE_SYS_TYPES_H
119 # include <sys/types.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 ])
131 AC_CHECK_HEADERS(netinet/icmp6.h, [], [],
132 [#if HAVE_STDINT_H
133 # include <stdint.h>
134 #endif
135 #if HAVE_SYS_TYPES_H
136 # include <sys/types.h>
137 #endif
138 #if HAVE_NETINET_IN_SYSTM_H
139 # include <netinet/in_systm.h>
140 #endif
141 #if HAVE_NETINET_IN_H
142 # include <netinet/in.h>
143 #endif
144 #if HAVE_NETINET_IP6_H
145 # include <netinet/ip6.h>
146 #endif
147 ])
148
149 socket_needs_socket="no"
150 AC_CHECK_FUNCS(socket, [],
151         AC_CHECK_LIB(socket, socket,
152                 [socket_needs_socket="yes"],
153                 AC_MSG_ERROR(cannot find socket)))
154 AM_CONDITIONAL(BUILD_WITH_LIBSOCKET, test "x$socket_needs_socket" = "xyes")
155
156 nanosleep_needs_rt="no"
157 AC_CHECK_FUNCS(nanosleep, [],
158         AC_CHECK_LIB(rt, nanosleep,
159                 [nanosleep_needs_rt="yes"],
160                 AC_MSG_ERROR(cannot find nanosleep)))
161 AM_CONDITIONAL(BUILD_WITH_LIBRT, test "x$nanosleep_needs_rt" = "xyes")
162
163 AC_ARG_ENABLE(debug, [AS_HELP_STRING([--enable-debug], [Enable extensive debugging output.])],
164 [
165         if test "x$enable_debug" = "xyes"
166         then
167                 AC_DEFINE(WITH_DEBUG, 1, [Define to 1 if you want to get debugging output.])
168         fi
169 ], [])
170 AM_CONDITIONAL(BUILD_WITH_DEBUG, test "x$enable_debug" = "xyes")
171
172 AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
173 [
174         if test "x$withval" != "xno" && test "x$withval" != "xyes"
175         then
176                 PERL_BINDINGS_OPTIONS="$withval"
177                 with_perl_bindings="yes"
178         else
179                 PERL_BINDINGS_OPTIONS=""
180                 with_perl_bindings="$withval"
181         fi
182 ],
183 [
184         PERL_BINDINGS_OPTIONS=""
185         with_perl_bindings="yes"
186 ])
187
188 if test "x$with_perl_bindings" = "xyes"
189 then
190         BINDINGS="perl-bindings"
191 else
192         BINDINGS=""
193 fi
194
195 AC_SUBST(PERL_BINDINGS_OPTIONS)
196
197 AC_SUBST(BINDINGS)
198
199 AC_OUTPUT(Makefile src/Makefile src/mans/Makefile bindings/Makefile)