Annotation of embedaddon/iftop/configure.in, revision 1.1.1.1
1.1 misho 1: dnl
2: dnl configure.in:
3: dnl Autoconf input for iftop.
4: dnl
5: dnl I hate autoconf with a passion. It's an utter pain to write these bloody
6: dnl things and even once you have you find yourself testing for more and more
7: dnl special cases. But that's OK. Paul is going to maintain it :)
8: dnl -- Chris Lightfoot
9: dnl
10: dnl $Id: configure.in,v 1.27 2005/12/25 20:42:45 pdw Exp $
11: dnl
12: dnl To regenerate everything from source, do:
13: dnl autoheader
14: dnl aclocal
15: dnl automake
16: dnl autoconf
17: dnl Now you should have good sources to make into a tarball and distribute.
18: dnl ./configure (perhaps with some arguments)
19: dnl make
20: dnl Tested with Automake 1.4 and autoconf 2.59.
21: dnl
22: dnl Boilerplate configuration
23: dnl
24:
25: AC_INIT(iftop.c)
26:
27: AC_CONFIG_AUX_DIR(config)
28:
29: AC_CANONICAL_SYSTEM
30:
31: AM_CONFIG_HEADER(config.h)
32: AM_INIT_AUTOMAKE(iftop, "0.17")
33:
34: AC_DEFINE_UNQUOTED(IFTOP_VERSION, "$VERSION", [The iftop version number])
35:
36: dnl Make sure we have a C compiler....
37: AC_PROG_CC
38: AC_HEADER_STDC
39:
40: dnl
41: dnl Options to configure.
42: dnl
43:
44: AC_ARG_WITH(resolver,
45: [ --with-resolver=TYPE Technique iftop should use for name resolution.
46: Valid options are:
47: netdb use gethostbyaddr_r in multiple
48: threads.
49: netdb_1thread use gethostbyaddr_r and
50: assume it is not reentrant.
51: ares use the MIT ARES asynchronous
52: resolver library.
53: forking use the REALLY SUCKY forking resolver.
54: guess run experiments to guess a
55: reasonable value. Only works if you
56: aren't cross-compiling. This
57: is the default. guess will
58: either select netdb or netdb_1thread.
59: none don't do name resolution.],
60: [resolver=$withval],
61: [resolver=guess])
62:
63: AC_ARG_WITH(libpcap,
64: [ --with-libpcap=WHERE Where the libpcap packet-capture library is found.
65: The pcap library should be installed in WHERE/lib,
66: and the header file in either WHERE/include or
67: WHERE/include/pcap.
68: [default=look in standard locations]],
69: [libpcap_prefix=$withval],
70: [libpcap_prefix=""])
71:
72: dnl
73: dnl Fairly generic checks.
74: dnl
75:
76: dnl Checks for system headers.
77: AC_CHECK_HEADERS(sys/ioctl.h sys/time.h sys/sockio.h unistd.h)
78:
79: dnl Checks for typedefs, structures, and compiler characteristics.
80: AC_C_CONST
81: AC_TYPE_SIZE_T
82: AC_HEADER_TIME
83:
84: dnl
85: dnl Are we on a system that uses the STREAMS low-level DLPI interface?
86: dnl
87:
88: AC_CHECK_HEADER([sys/dlpi.h],[AC_DEFINE([HAVE_DLPI],1,[Are we running on a STREAMS system with DLPI?])])
89:
90: dnl Checks for library functions.
91: AC_CHECK_FUNCS(regcomp select strdup strerror strspn)
92:
93: AC_SEARCH_LIBS(socket, socket)
94: AC_SEARCH_LIBS(log, m)
95: AC_CHECK_FUNC(gethostbyname, ,
96: [AC_CHECK_LIB(nsl, gethostbyname)] )
97:
98: AC_SEARCH_LIBS(inet_aton, [socket nsl])
99: AC_SEARCH_LIBS(inet_pton, [socket nsl])
100: AC_CHECK_FUNCS(inet_aton inet_pton)
101:
102: dnl
103: dnl Find integers of known physical size. This is a pain in the arse because
104: dnl we can't use AC_CHECK_SIZEOF to find the original variables, since that
105: dnl function doesn't permit us to include a header file. Sigh.
106: dnl
107:
108: for type in u_int8_t u_int16_t u_int32_t ; do
109: AC_MSG_CHECKING([size of $type])
110: AC_RUN_IFELSE([
111: #include <sys/types.h>
112: #include <stdio.h>
113: int main() {
114: $type dummy;
115: FILE *f=fopen("conftestval", "w");
116: if (!f) exit(1);
117: fprintf(f, "%d\n", sizeof($1));
118: exit(0);
119: }
120: ], [
121: x=`cat conftestval`
122: eval "size_$type=$x"
123: AC_MSG_RESULT([$x])
124: ], [
125: eval "size_$type=0"
126: AC_MSG_RESULT([unknown type])
127: ], [
128: eval "size_$type=0"
129: AC_MSG_RESULT([can't determine when cross-compiling])
130: ])
131: done
132:
133: dnl Groan. Have to do things this way so that autoheader can do its thing....
134: AC_DEFINE_UNQUOTED(SIZEOF_U_INT8_T, [$size_u_int8_t], [size of u_int8_t])
135: AC_DEFINE_UNQUOTED(SIZEOF_U_INT16_T, [$size_u_int16_t], [size of u_int16_t])
136: AC_DEFINE_UNQUOTED(SIZEOF_U_INT32_T, [$size_u_int32_t], [size of u_int32_t])
137:
138: dnl If we already have these types, don't piss about any more....
139:
140: if test $size_u_int8_t != 1 || test $size_u_int16_t != 2 || test $size_u_int32_t != 4 ; then
141: dnl XXXif test $size_u_int8_t != 1 -o $size_u_int16_t != 2 -o $size_u_int32_t != 4 ; then
142: do_int_types=1
143: AC_CHECK_HEADERS(
144: stdint.h dnl C99
145: sys/inttypes.h, dnl Solaris
146: [do_int_types=0; break])
147:
148: if test $do_int_types = 1 ; then
149: dnl No C99 int types, so figure them out from basic types.
150: AC_CHECK_SIZEOF(unsigned short int)
151: AC_CHECK_SIZEOF(unsigned int)
152: AC_CHECK_SIZEOF(unsigned long int)
153: else
154: dnl Just use the C99 ones.
155: AC_DEFINE(HAVE_C99_INTS, 1, [C99 fixed-width int types available])
156: fi
157: fi
158:
159: dnl
160: dnl Name resolution.
161: dnl
162: dnl This is complicated because we need some sort of reentrant mechanism for
163: dnl name resolution. Naturally, UNIX vendors have come up with a variety of
164: dnl incompatible schemes for this, many of which don't work at all.
165: dnl
166:
167: dnl First, the default resolver, which uses getnameinfo or gethostbyaddr_r. If
168: dnl not available, we fall back to gethostbyaddr. We could fall back to ARES,
169: dnl but that's probably not available on typical machines.
170:
171: dnl If we've been asked to guess, remember that fact in specified_resolver.
172: dnl From this point on, resolver is our preferred resolver given the
173: dnl experiments we've done so far, or "guess" if we have no idea.
174: specified_resolver=$resolver
175: if test x$specified_resolver = xguess ; then
176: dnl Best possibility is getnameinfo.
177: use_getnameinfo=0
178: AC_SEARCH_LIBS(getnameinfo, [nsl], [use_getnameinfo=1])
179:
180: dnl XXX For the moment, don't use getnameinfo, since it isn't actually
181: dnl thread safe on, e.g., NetBSD.
182: use_getnameinfo=0
183:
184: if test $use_getnameinfo = 1 ; then
185: dnl Done.
186: AC_DEFINE(USE_GETNAMEINFO, 1, [use getnameinfo for name resolution])
187: else
188: dnl Best hope is netdb, which presently means gethostbyaddr_r.
189: resolver=netdb
190: fi
191: fi
192:
193: if test x$resolver = xnetdb ; then
194: dnl Can use gethostbyaddr_r?
195: AC_SEARCH_LIBS(gethostbyaddr_r, [nsl], , [resolver=guess])
196: if test x$resolver = xguess && test x$specified_resolver != xguess ; then
197: dnl They wanted gethostbyaddr_r, but they can't have it, so stop.
198: AC_MSG_ERROR([no library defines gethostbyaddr_r])
199: fi
200: fi
201:
202: dnl We still might do gethostbyaddr_r. Figure out whether we have
203: dnl glibc-style or Solaris-style gethostbyaddr_r (or neither...).
204: dnl Separate determining how to call gethostbyaddr_r from testing
205: dnl whether it works so we can support cross-compilation.
206: if test x$resolver = xnetdb ; then
207: AC_MSG_CHECKING([how to call gethostbyaddr_r])
208: dnl Try 7 arguments returning a struct hostent*.
209: AC_LINK_IFELSE(AC_LANG_SOURCE([`cat config/hostentp_ghba_r.c`]),
210: [AC_MSG_RESULT([7 args])
211: ghba_args=8
212: AC_DEFINE(GETHOSTBYADDR_R_RETURNS_HOSTENT_P, 1,
213: [7-argument gethostbyaddr_r returns struct hostent*])], [
214: dnl Try 8 arguments returning an int.
215: AC_LINK_IFELSE(AC_LANG_SOURCE([`cat config/int_ghba_r.c`]),
216: [AC_MSG_RESULT([8 args, int return])
217: ghba_args=8
218: AC_DEFINE(GETHOSTBYADDR_R_RETURNS_INT, 1,
219: [8-argument gethostbyaddr_r returns int])], [
220: dnl Neither.
221: AC_MSG_RESULT([don't know how])
222: resolver=guess])])
223: if test x$resolver = xguess && test x$specified_resolver != xguess ; then
224: dnl They wanted gethostbyaddr_r, but they can't have it, so stop.
225: AC_MSG_ERROR([gethostbyaddr_r has no known calling convention])
226: fi
227: fi
228:
229: dnl If we still want to do gethostbyaddr_r, and we aren't
230: dnl cross-compiling, test it.
231: if test x$resolver = xnetdb ; then
232: if test x$ghba_args = x8 ; then
233: testfile=int_ghba_r
234: else
235: testfile=hostentp_ghba_r
236: fi
237: AC_MSG_CHECKING(gethostbyaddr_r usability)
238: AC_RUN_IFELSE([`cat config/$testfile.c`],
239: [AC_MSG_RESULT([yes])],
240: [AC_MSG_RESULT([no])
241: resolver=guess],
242: [AC_MSG_RESULT([can't test because we are cross-compiling])])
243: if test x$resolver = xguess ; then
244: if test x$specified_resolver = xguess ; then
245: AC_MSG_RESULT([gethostbyaddr_r doesn't work, so we'll try something else])
246: else
247: dnl They wanted gethostbyaddr_r, but it doesn't work, so stop.
248: AC_MSG_ERROR([gethostbyaddr_r doesn't work])
249: fi
250: fi
251: fi
252:
253: dnl We found a gethostbyaddr_r we know how to use and which seems to
254: dnl work.
255: if test x$resolver = xnetdb ; then
256: AC_DEFINE(USE_GETHOSTBYADDR_R, 1, [use gethostbyaddr_r for name resolution])
257: fi
258:
259: dnl They may have asked for ares.
260: if test x$resolver = xares ; then
261: dnl See if ares is to hand....
262: AC_SEARCH_LIBS(ares_init, [ares], [
263: AC_DEFINE(USE_ARES, 1, [use ARES for name resolution])
264: ], [
265: dnl They asked for ares, but we can't give it to them, so stop.
266: AC_MSG_ERROR([can't find ARES. Re-run configure and ask for a different resolver.])])
267: fi
268:
269: dnl Last thing to try if we haven't decided yet is netdb_1thread.
270: if test x$resolver = xguess ; then
271: resolver=netdb_1thread
272: fi
273:
274: dnl Ugh. Both the single-threaded and the forking resolvers use gethostbyaddr.
275: if test x$resolver = xnetdb_1thread || test x$resolver = xforking ; then
276: AC_SEARCH_LIBS(gethostbyaddr, [nsl], , [
277: AC_MSG_ERROR([gethostbyaddr is not available. You will have to
278: recompile with no name resolution at all.])])
279:
280: if test x$resolver = xnetdb_1thread ; then
281: AC_MSG_WARN([using single-threaded resolver with gethostbyaddr
282: Consider obtaining ARES or a machine with a working gethostbyaddr_r.])
283: AC_DEFINE(USE_GETHOSTBYADDR, 1, [use gethostbyaddr for name resolution])
284: else
285: AC_DEFINE(USE_FORKING_RESOLVER, 1, [use a REALLY SUCKY forking resolver for name resolution])
286: fi
287: fi
288:
289: dnl Otherwise, no resolver at all. Boo hoo.
290:
291: dnl
292: dnl Find libpcap.
293: dnl
294:
295: if test x$libpcap_prefix = x ; then
296: libpcap_prefix="/usr /usr/local /opt /software"
297: fi
298:
299: AC_MSG_CHECKING([where to find pcap.h])
300: foundpcaph=0
301: oldCPPFLAGS=$CPPFLAGS
302: for test_prefix in "" $libpcap_prefix ; do
303: for x in "" /pcap ; do
304: if test x$test_prefix != x ; then
305: CPPFLAGS="$oldCPPFLAGS -I$test_prefix/include$x"
306: fi
307: AC_TRY_CPP([
308: #include <pcap.h>
309: ], [
310: AC_MSG_RESULT([$test_prefix/include$x])
311: foundpcaph=1
312: break
313: ])
314: done
315: if test $foundpcaph = 1 ; then
316: break
317: fi
318: done
319:
320: if test $foundpcaph = 0 ; then
321: AC_MSG_RESULT([no idea])
322: AC_MSG_ERROR([can't find pcap.h
323: You're not going to get very far without libpcap.])
324: else
325: dnl assume that -lpcap is under $test_prefix/lib
326: if test x$test_prefix != x ; then
327: LDFLAGS="$LDFLAGS -L$test_prefix/lib"
328: fi
329: AC_CHECK_LIB(pcap, pcap_open_live, , [
330: AC_MSG_ERROR([can't find libpcap
331: You're not going to get very far without libpcap.])
332: ])
333: fi
334:
335: foundpcap=0
336: AC_CHECK_HEADERS([pcap.h pcap/pcap.h], [
337: foundpcap=1
338: break
339: ])
340:
341: if test $foundpcap = 0 ; then
342: AC_MSG_ERROR([can't find pcap.h
343: You're not going to get very far without libpcap.])
344: fi
345:
346: dnl
347: dnl Curses. Really, we need ncurses or something similarly advanced, since
348: dnl we use the (apparently obscure) mvchgat function. Unfortunately, there's
349: dnl a solid chance that mvchgat is a macro, so we can't just use
350: dnl AC_SEARCH_LIBS....
351: dnl
352:
353: AC_MSG_CHECKING([for a curses library containing mvchgat])
354: oldLIBS=$LIBS
355: for curseslib in curses ncurses ; do
356: LIBS="$oldLIBS -l$curseslib"
357: AC_TRY_LINK([
358: #include <curses.h>
359: ], [
360: mvchgat(0, 0, 1, A_REVERSE, 0, NULL)
361: ], [
362: foundcurseslib=$curseslib
363: break
364: ])
365: done
366:
367: if test x$foundcurseslib = x ; then
368: AC_MSG_RESULT([none found])
369: AC_MSG_ERROR([Curses! Foiled again!
370: (Can't find a curses library supporting mvchgat.)
371: Consider installing ncurses.])
372: else
373: AC_MSG_RESULT([-l$foundcurseslib])
374: fi
375:
376:
377: dnl
378: dnl POSIX threads. Different systems like different combinations of flags,
379: dnl libraries, etc. We use a test program to figure this stuff out.
380: dnl
381:
382: AC_MSG_CHECKING([POSIX threads compilation])
383: thrfail=1
384: oldCFLAGS=$CFLAGS
385: oldLIBS=$LIBS
386: for flag in "" -mt -pthread -thread ; do
387: CFLAGS="$oldCFLAGS $flag"
388: for lib in "" -lpthread "-lpthread -lposix4" ; do
389: LIBS="$oldLIBS $lib"
390: AC_LINK_IFELSE(AC_LANG_SOURCE([`cat config/pthread.c`]), [
391: foundthrlib=$lib
392: foundthrflag=$flag
393: thrfail=0
394: break
395: ])
396: done
397: if test $thrfail = 0 ; then
398: break
399: fi
400: done
401:
402: if test $thrfail = 1 ; then
403: AC_MSG_RESULT([no idea])
404: AC_MSG_ERROR([can't figure out how to compile with POSIX threads
405: If your system actually supports POSIX threads, this means we've messed up.])
406: fi
407:
408: AC_MSG_RESULT([CFLAGS=$foundthrflag and LIBS=$foundthrlib])
409: AC_MSG_CHECKING([POSIX threads usability])
410: AC_RUN_IFELSE([`cat config/pthread.c`],
411: [AC_MSG_RESULT([yes])],
412: [AC_MSG_ERROR(
413: [it fails. We probably guessed the wrong CFLAGS.])],
414: [AC_MSG_RESULT([can't test because we are cross-compiling])])
415:
416: dnl
417: dnl Are we on a system (like Solaris) that requires promiscuous mode in order to
418: dnl see any outgoing packets?
419: dnl
420:
421: AC_MSG_CHECKING([if we need to enable promiscuous mode by default])
422:
423: enable_default_promiscuous="no"
424:
425: case "$host_os" in
426: solaris*) enable_default_promiscuous="yes" ;;
427: esac
428:
429: AC_ARG_ENABLE(default-promiscuous,
430: [ --enable-default-promiscuous If enabled, iftop will operate in promiscuous mode
431: to capture outgoing packets])
432:
433: AC_MSG_RESULT([$enable_default_promiscuous])
434:
435: if test x"$enable_default_promiscuous" = x"yes"; then
436: AC_DEFINE([NEED_PROMISCUOUS_FOR_OUTGOING],1,[Enable default promiscuous mode to capture outgoing packets])
437: fi
438:
439: dnl
440: dnl Wahey! This might even work.
441: dnl
442:
443: AC_SUBST(ac_aux_dir)
444:
445: AC_OUTPUT(Makefile config/Makefile)
446:
447: if echo $VERSION | grep 'pre' ; then
448: AC_MSG_WARN([
449: ******************************************************************************
450:
451: This is a pre-release version. Pre-releases are subject to limited
452: announcements, and therefore limited circulation, as a means of testing
453: the more widely circulated final releases.
454:
455: Please do not be surprised if this release is utterly, utterly broken. If you
456: do find this release to be utterly, utterly broken, do not assume that someone
457: else has spotted it. Instead, please drop a note on the mailing list,
458: or a brief email to me on pdw@ex-parrot.com
459:
460: Thank you for taking the time to be the testing phase of this development
461: process.
462:
463: Paul Warren
464:
465: ******************************************************************************
466: ])
467: fi
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>