configure.in 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. dnl Copyright (c) 1994, 1995, 1996, 1997
  2. dnl The Regents of the University of California. All rights reserved.
  3. dnl
  4. dnl Process this file with autoconf to produce a configure script.
  5. dnl
  6. #
  7. # See
  8. #
  9. # http://ftp.gnu.org/gnu/config/README
  10. #
  11. # for the URLs to use to fetch new versions of config.guess and
  12. # config.sub.
  13. #
  14. AC_PREREQ(2.61)
  15. AC_INIT(tcpdump.c)
  16. AC_CANONICAL_HOST
  17. AC_LBL_C_INIT_BEFORE_CC(V_INCLS)
  18. AC_PROG_CC
  19. AC_LBL_C_INIT(V_CCOPT, V_INCLS)
  20. AC_LBL_C_INLINE
  21. AC_C___ATTRIBUTE__
  22. if test "$ac_cv___attribute__" = "yes"; then
  23. AC_C___ATTRIBUTE___UNUSED
  24. AC_C___ATTRIBUTE___NORETURN_FUNCTION_POINTER
  25. AC_C___ATTRIBUTE___FORMAT
  26. if test "$ac_cv___attribute___format" = "yes"; then
  27. AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER
  28. fi
  29. fi
  30. AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h)
  31. AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
  32. #include <sys/socket.h>
  33. #include <net/if.h>])
  34. if test "$ac_cv_header_net_pfvar_h" = yes; then
  35. AC_CHECK_HEADERS(net/if_pflog.h, , , [#include <sys/types.h>
  36. #include <sys/socket.h>
  37. #include <net/if.h>
  38. #include <net/pfvar.h>])
  39. if test "$ac_cv_header_net_if_pflog_h" = yes; then
  40. LOCALSRC="print-pflog.c $LOCALSRC"
  41. fi
  42. fi
  43. AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
  44. #include <sys/socket.h>])
  45. if test "$ac_cv_header_netinet_if_ether_h" != yes; then
  46. #
  47. # The simple test didn't work.
  48. # Do we need to include <net/if.h> first?
  49. # Unset ac_cv_header_netinet_if_ether_h so we don't
  50. # treat the previous failure as a cached value and
  51. # suppress the next test.
  52. #
  53. AC_MSG_NOTICE([Rechecking with some additional includes])
  54. unset ac_cv_header_netinet_if_ether_h
  55. AC_CHECK_HEADERS(netinet/if_ether.h, , , [#include <sys/types.h>
  56. #include <sys/socket.h>
  57. #include <netinet/in.h>
  58. struct mbuf;
  59. struct rtentry;
  60. #include <net/if.h>])
  61. fi
  62. AC_HEADER_TIME
  63. case "$host_os" in
  64. darwin*)
  65. AC_ARG_ENABLE(universal,
  66. AC_HELP_STRING([--disable-universal],[don't build universal on OS X]))
  67. if test "$enable_universal" != "no"; then
  68. case "$host_os" in
  69. darwin9.*)
  70. #
  71. # Leopard. Build for x86 and 32-bit PowerPC, with
  72. # x86 first. (That's what Apple does.)
  73. #
  74. V_CCOPT="$V_CCOPT -arch i386 -arch ppc"
  75. LDFLAGS="$LDFLAGS -arch i386 -arch ppc"
  76. ;;
  77. darwin10.*)
  78. #
  79. # Snow Leopard. Build for x86-64 and x86, with
  80. # x86-64 first. (That's what Apple does.)
  81. #
  82. V_CCOPT="$V_CCOPT -arch x86_64 -arch i386"
  83. LDFLAGS="$LDFLAGS -arch x86_64 -arch i386"
  84. ;;
  85. esac
  86. fi
  87. ;;
  88. esac
  89. AC_ARG_WITH(smi,
  90. [ --with-smi link with libsmi (allows to load MIBs on the fly to decode SNMP packets. [default=yes]
  91. --without-smi don't link with libsmi],,
  92. with_smi=yes)
  93. if test "x$with_smi" != "xno" ; then
  94. AC_CHECK_HEADER(smi.h,
  95. [
  96. #
  97. # OK, we found smi.h. Do we have libsmi with smiInit?
  98. #
  99. AC_CHECK_LIB(smi, smiInit,
  100. [
  101. #
  102. # OK, we have libsmi with smiInit. Can we use it?
  103. #
  104. AC_MSG_CHECKING([whether to enable libsmi])
  105. savedlibs="$LIBS"
  106. LIBS="-lsmi $LIBS"
  107. AC_TRY_RUN(
  108. [
  109. /* libsmi available check */
  110. #include <smi.h>
  111. main()
  112. {
  113. int current, revision, age, n;
  114. const int required = 2;
  115. if (smiInit(""))
  116. exit(1);
  117. if (strcmp(SMI_LIBRARY_VERSION, smi_library_version))
  118. exit(2);
  119. n = sscanf(smi_library_version, "%d:%d:%d", &current, &revision, &age);
  120. if (n != 3)
  121. exit(3);
  122. if (required < current - age || required > current)
  123. exit(4);
  124. exit(0);
  125. }
  126. ],
  127. [
  128. AC_MSG_RESULT(yes)
  129. AC_DEFINE(USE_LIBSMI, 1,
  130. [Define if you enable support for libsmi])
  131. ],
  132. [
  133. dnl autoconf documentation says that
  134. dnl $? contains the exit value.
  135. dnl reality is that it does not.
  136. dnl We leave this in just in case
  137. dnl autoconf ever comes back to
  138. dnl match the documentation.
  139. case $? in
  140. 1) AC_MSG_RESULT(no - smiInit failed) ;;
  141. 2) AC_MSG_RESULT(no - header/library version mismatch) ;;
  142. 3) AC_MSG_RESULT(no - can't determine library version) ;;
  143. 4) AC_MSG_RESULT(no - too old) ;;
  144. *) AC_MSG_RESULT(no) ;;
  145. esac
  146. LIBS="$savedlibs"
  147. ],
  148. [
  149. AC_MSG_RESULT(not when cross-compiling)
  150. LIBS="$savedlibs"
  151. ]
  152. )
  153. ])
  154. ])
  155. fi
  156. AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
  157. AC_ARG_ENABLE(smb,
  158. [ --enable-smb enable possibly-buggy SMB printer [default=yes]
  159. --disable-smb disable possibly-buggy SMB printer],,
  160. enableval=yes)
  161. case "$enableval" in
  162. yes) AC_MSG_RESULT(yes)
  163. AC_WARN([The SMB printer may have exploitable buffer overflows!!!])
  164. AC_DEFINE(ENABLE_SMB, 1,
  165. [define if you want to build the possibly-buggy SMB printer])
  166. LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
  167. ;;
  168. *) AC_MSG_RESULT(no)
  169. ;;
  170. esac
  171. AC_ARG_WITH(user, [ --with-user=USERNAME drop privileges by default to USERNAME])
  172. AC_MSG_CHECKING([whether to drop root privileges by default])
  173. if test ! -z "$with_user" ; then
  174. AC_DEFINE_UNQUOTED(WITH_USER, "$withval",
  175. [define if should drop privileges by default])
  176. AC_MSG_RESULT(to \"$withval\")
  177. else
  178. AC_MSG_RESULT(no)
  179. fi
  180. AC_ARG_WITH(chroot, [ --with-chroot=DIRECTORY when dropping privileges, chroot to DIRECTORY])
  181. AC_MSG_CHECKING([whether to chroot])
  182. if test ! -z "$with_chroot" && test "$with_chroot" != "no" ; then
  183. AC_DEFINE_UNQUOTED(WITH_CHROOT, "$withval",
  184. [define if should chroot when dropping privileges])
  185. AC_MSG_RESULT(to \"$withval\")
  186. else
  187. AC_MSG_RESULT(no)
  188. fi
  189. AC_ARG_WITH(sandbox-capsicum,
  190. AS_HELP_STRING([--with-sandbox-capsicum],
  191. [use Capsicum security functions @<:@default=yes, if available@:>@]))
  192. #
  193. # Check whether various functions are available. If any are, set
  194. # ac_lbl_capsicum_function_seen to yes; if any are not, set
  195. # ac_lbl_capsicum_function_not_seen to yes.
  196. #
  197. # We don't check cap_rights_init(), as it's a macro, wrapping another
  198. # function, in at least some versions of FreeBSD, and AC_CHECK_FUNCS()
  199. # doesn't handle that.
  200. #
  201. # All of the ones we check for must be available in order to enable
  202. # capsicum sandboxing.
  203. #
  204. # XXX - do we need to check for all of them, or are there some that, if
  205. # present, imply others are present?
  206. #
  207. if test ! -z "$with_sandbox-capsicum" && test "$with_sandbox-capsicum" != "no" ; then
  208. AC_CHECK_FUNCS(cap_enter cap_rights_limit cap_ioctls_limit openat,
  209. ac_lbl_capsicum_function_seen=yes,
  210. ac_lbl_capsicum_function_not_seen=yes)
  211. fi
  212. AC_MSG_CHECKING([whether to sandbox using capsicum])
  213. if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
  214. AC_DEFINE(HAVE_CAPSICUM, 1, [capsicum support available])
  215. AC_MSG_RESULT(yes)
  216. else
  217. AC_MSG_RESULT(no)
  218. fi
  219. #
  220. # We must check this before checking whether to check the OS's IPv6,
  221. # support because, on some platforms (such as SunOS 5.x), the test
  222. # program requires the extra networking libraries.
  223. #
  224. AC_LBL_LIBRARY_NET
  225. #
  226. # Check whether AF_INET6 and struct in6_addr are defined.
  227. # If they aren't both defined, we don't have sufficient OS
  228. # support for IPv6, so we don't look for IPv6 support libraries,
  229. # and we define AF_INET6 and struct in6_addr ourselves.
  230. #
  231. AC_MSG_CHECKING([whether the operating system supports IPv6])
  232. AC_COMPILE_IFELSE(
  233. [
  234. AC_LANG_SOURCE(
  235. [[
  236. /* AF_INET6 available check */
  237. #include <sys/types.h>
  238. #include <sys/socket.h>
  239. #include <netinet/in.h>
  240. #ifdef AF_INET6
  241. void
  242. foo(struct in6_addr *addr)
  243. {
  244. memset(addr, 0, sizeof (struct in6_addr));
  245. }
  246. #else
  247. #error "AF_INET6 not defined"
  248. #endif
  249. ]])
  250. ],
  251. [
  252. AC_MSG_RESULT(yes)
  253. AC_DEFINE(HAVE_OS_IPV6_SUPPORT, 1,
  254. [define if the OS provides AF_INET6 and struct in6_addr])
  255. ipv6=yes
  256. ],
  257. [
  258. AC_MSG_RESULT(no)
  259. ipv6=no
  260. ]
  261. )
  262. ipv6type=unknown
  263. ipv6lib=none
  264. ipv6trylibc=no
  265. if test "$ipv6" = "yes"; then
  266. AC_MSG_CHECKING([ipv6 stack type])
  267. for i in inria kame linux-glibc linux-libinet6 toshiba v6d zeta; do
  268. case $i in
  269. inria)
  270. dnl http://www.kame.net/
  271. AC_EGREP_CPP(yes,
  272. [#include <netinet/in.h>
  273. #ifdef IPV6_INRIA_VERSION
  274. yes
  275. #endif],
  276. [ipv6type=$i])
  277. ;;
  278. kame)
  279. dnl http://www.kame.net/
  280. AC_EGREP_CPP(yes,
  281. [#include <netinet/in.h>
  282. #ifdef __KAME__
  283. yes
  284. #endif],
  285. [ipv6type=$i;
  286. ipv6lib=inet6;
  287. ipv6libdir=/usr/local/v6/lib;
  288. ipv6trylibc=yes])
  289. ;;
  290. linux-glibc)
  291. dnl http://www.v6.linux.or.jp/
  292. AC_EGREP_CPP(yes,
  293. [#include <features.h>
  294. #if defined(__GLIBC__) && __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
  295. yes
  296. #endif],
  297. [ipv6type=$i])
  298. ;;
  299. linux-libinet6)
  300. dnl http://www.v6.linux.or.jp/
  301. dnl
  302. dnl This also matches Solaris 8 and Tru64 UNIX 5.1,
  303. dnl and possibly other versions of those OSes
  304. dnl
  305. if test -d /usr/inet6 -o -f /usr/include/netinet/ip6.h; then
  306. ipv6type=$i
  307. ipv6lib=inet6
  308. ipv6libdir=/usr/inet6/lib
  309. ipv6trylibc=yes;
  310. CFLAGS="-I/usr/inet6/include $CFLAGS"
  311. fi
  312. ;;
  313. toshiba)
  314. AC_EGREP_CPP(yes,
  315. [#include <sys/param.h>
  316. #ifdef _TOSHIBA_INET6
  317. yes
  318. #endif],
  319. [ipv6type=$i;
  320. ipv6lib=inet6;
  321. ipv6libdir=/usr/local/v6/lib])
  322. ;;
  323. v6d)
  324. AC_EGREP_CPP(yes,
  325. [#include </usr/local/v6/include/sys/v6config.h>
  326. #ifdef __V6D__
  327. yes
  328. #endif],
  329. [ipv6type=$i;
  330. ipv6lib=v6;
  331. ipv6libdir=/usr/local/v6/lib;
  332. CFLAGS="-I/usr/local/v6/include $CFLAGS"])
  333. ;;
  334. zeta)
  335. AC_EGREP_CPP(yes,
  336. [#include <sys/param.h>
  337. #ifdef _ZETA_MINAMI_INET6
  338. yes
  339. #endif],
  340. [ipv6type=$i;
  341. ipv6lib=inet6;
  342. ipv6libdir=/usr/local/v6/lib])
  343. ;;
  344. esac
  345. if test "$ipv6type" != "unknown"; then
  346. break
  347. fi
  348. done
  349. AC_MSG_RESULT($ipv6type)
  350. fi
  351. if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
  352. if test -d $ipv6libdir -a -f $ipv6libdir/lib$ipv6lib.a; then
  353. LIBS="-L$ipv6libdir -l$ipv6lib $LIBS"
  354. echo "You have $ipv6lib library, using it"
  355. else
  356. if test "$ipv6trylibc" = "yes"; then
  357. echo "You do not have $ipv6lib library, using libc"
  358. else
  359. echo 'Fatal: no $ipv6lib library found. cannot continue.'
  360. echo "You need to fetch lib$ipv6lib.a from appropriate"
  361. echo 'ipv6 kit and compile beforehand.'
  362. exit 1
  363. fi
  364. fi
  365. fi
  366. AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
  367. [td_cv_decl_netdnet_dnetdb_h_dnet_htoa],
  368. [AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h,
  369. td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes,
  370. td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)])
  371. if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
  372. AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA, 1,
  373. [define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>])
  374. fi
  375. AC_REPLACE_FUNCS(vfprintf strlcat strlcpy strdup strsep getopt_long)
  376. AC_CHECK_FUNCS(fork vfork strftime)
  377. AC_CHECK_FUNCS(setlinebuf alarm)
  378. needsnprintf=no
  379. AC_CHECK_FUNCS(vsnprintf snprintf,,
  380. [needsnprintf=yes])
  381. if test $needsnprintf = yes; then
  382. AC_LIBOBJ(snprintf)
  383. fi
  384. AC_LBL_TYPE_SIGNAL
  385. AC_SEARCH_LIBS(dnet_htoa, dnet,
  386. AC_DEFINE(HAVE_DNET_HTOA, 1, [define if you have the dnet_htoa function]))
  387. AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc
  388. dnl Some platforms may need -lnsl for getrpcbynumber.
  389. AC_SEARCH_LIBS(getrpcbynumber, nsl,
  390. AC_DEFINE(HAVE_GETRPCBYNUMBER, 1, [define if you have getrpcbynumber()]))
  391. AC_LBL_LIBPCAP(V_PCAPDEP, V_INCLS)
  392. #
  393. # Check for these after AC_LBL_LIBPCAP, so we link with the appropriate
  394. # libraries (e.g., "-lsocket -lnsl" on Solaris).
  395. #
  396. # You are in a twisty little maze of UN*Xes, all different.
  397. # Some might not have ether_ntohost().
  398. # Some might have it, but not declare it in any header file.
  399. # Some might have it, but declare it in <netinet/if_ether.h>.
  400. # Some might have it, but declare it in <netinet/ether.h>
  401. # (And some might have it but document it as something declared in
  402. # <netinet/ethernet.h>, although <netinet/if_ether.h> appears to work.)
  403. #
  404. # Before you is a C compiler.
  405. #
  406. AC_CHECK_FUNCS(ether_ntohost, [
  407. AC_CACHE_CHECK(for buggy ether_ntohost, ac_cv_buggy_ether_ntohost, [
  408. AC_TRY_RUN([
  409. #include <netdb.h>
  410. #include <sys/types.h>
  411. #include <sys/param.h>
  412. #include <sys/socket.h>
  413. int
  414. main(int argc, char **argv)
  415. {
  416. u_char ea[6] = { 0xff, 0xff, 0xff, 0xff, 0xff };
  417. char name[MAXHOSTNAMELEN];
  418. ether_ntohost(name, (struct ether_addr *)ea);
  419. exit(0);
  420. }
  421. ], [ac_cv_buggy_ether_ntohost=no],
  422. [ac_cv_buggy_ether_ntohost=yes],
  423. [ac_cv_buggy_ether_ntohost="not while cross-compiling"])])
  424. if test "$ac_cv_buggy_ether_ntohost" = "no"; then
  425. AC_DEFINE(USE_ETHER_NTOHOST, 1,
  426. [define if you have ether_ntohost() and it works])
  427. fi
  428. ])
  429. if test "$ac_cv_func_ether_ntohost" = yes -a \
  430. "$ac_cv_buggy_ether_ntohost" = "no"; then
  431. #
  432. # OK, we have ether_ntohost(). Do we have <netinet/if_ether.h>?
  433. #
  434. if test "$ac_cv_header_netinet_if_ether_h" = yes; then
  435. #
  436. # Yes. Does it declare ether_ntohost()?
  437. #
  438. AC_CHECK_DECL(ether_ntohost,
  439. [
  440. AC_DEFINE(NETINET_IF_ETHER_H_DECLARES_ETHER_NTOHOST,,
  441. [Define to 1 if netinet/if_ether.h declares `ether_ntohost'])
  442. ],,
  443. [
  444. #include <sys/types.h>
  445. #include <sys/socket.h>
  446. #include <netinet/in.h>
  447. #include <arpa/inet.h>
  448. struct mbuf;
  449. struct rtentry;
  450. #include <net/if.h>
  451. #include <netinet/if_ether.h>
  452. ])
  453. fi
  454. #
  455. # Did that succeed?
  456. #
  457. if test "$ac_cv_have_decl_ether_ntohost" != yes; then
  458. #
  459. # No, how about <netinet/ether.h>, as on Linux?
  460. #
  461. AC_CHECK_HEADERS(netinet/ether.h)
  462. if test "$ac_cv_header_netinet_ether_h" = yes; then
  463. #
  464. # We have it - does it declare ether_ntohost()?
  465. # Unset ac_cv_have_decl_ether_ntohost so we don't
  466. # treat the previous failure as a cached value and
  467. # suppress the next test.
  468. #
  469. unset ac_cv_have_decl_ether_ntohost
  470. AC_CHECK_DECL(ether_ntohost,
  471. [
  472. AC_DEFINE(NETINET_ETHER_H_DECLARES_ETHER_NTOHOST,,
  473. [Define to 1 if netinet/ether.h declares `ether_ntohost'])
  474. ],,
  475. [
  476. #include <netinet/ether.h>
  477. ])
  478. fi
  479. fi
  480. #
  481. # Is ether_ntohost() declared?
  482. #
  483. if test "$ac_cv_have_decl_ether_ntohost" != yes; then
  484. #
  485. # No, we'll have to declare it ourselves.
  486. # Do we have "struct ether_addr"?
  487. #
  488. AC_CHECK_TYPES(struct ether_addr,,,
  489. [
  490. #include <sys/types.h>
  491. #include <sys/socket.h>
  492. #include <netinet/in.h>
  493. #include <arpa/inet.h>
  494. struct mbuf;
  495. struct rtentry;
  496. #include <net/if.h>
  497. #include <netinet/if_ether.h>
  498. ])
  499. AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 0,
  500. [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
  501. don't.])
  502. else
  503. AC_DEFINE(HAVE_DECL_ETHER_NTOHOST, 1,
  504. [Define to 1 if you have the declaration of `ether_ntohost', and to 0 if you
  505. don't.])
  506. fi
  507. fi
  508. # libdlpi is needed for Solaris 11 and later.
  509. AC_CHECK_LIB(dlpi, dlpi_walk, LIBS="$LIBS -ldlpi" LDFLAGS="-L/lib $LDFLAGS", ,-L/lib)
  510. dnl
  511. dnl Check for "pcap_list_datalinks()", "pcap_set_datalink()",
  512. dnl and "pcap_datalink_name_to_val()", and use substitute versions
  513. dnl if they're not present.
  514. dnl
  515. AC_CHECK_FUNC(pcap_list_datalinks,
  516. [
  517. AC_DEFINE(HAVE_PCAP_LIST_DATALINKS, 1,
  518. [define if libpcap has pcap_list_datalinks()])
  519. AC_CHECK_FUNCS(pcap_free_datalinks)
  520. ],
  521. [
  522. AC_LIBOBJ(datalinks)
  523. ])
  524. AC_CHECK_FUNCS(pcap_set_datalink)
  525. AC_CHECK_FUNC(pcap_datalink_name_to_val,
  526. [
  527. AC_DEFINE(HAVE_PCAP_DATALINK_NAME_TO_VAL, 1,
  528. [define if libpcap has pcap_datalink_name_to_val()])
  529. AC_CHECK_FUNC(pcap_datalink_val_to_description,
  530. AC_DEFINE(HAVE_PCAP_DATALINK_VAL_TO_DESCRIPTION, 1,
  531. [define if libpcap has pcap_datalink_val_to_description()]),
  532. [
  533. AC_LIBOBJ(dlnames)
  534. ])
  535. ],
  536. [
  537. AC_LIBOBJ(dlnames)
  538. ])
  539. dnl
  540. dnl Check for "pcap_breakloop()"; you can't substitute for it if
  541. dnl it's absent (it has hooks into the live capture routines),
  542. dnl so just define the HAVE_ value if it's there.
  543. dnl
  544. AC_CHECK_FUNCS(pcap_breakloop)
  545. dnl
  546. dnl Check for "pcap_dump_ftell()" and use a substitute version
  547. dnl if it's not present.
  548. dnl
  549. AC_CHECK_FUNC(pcap_dump_ftell,
  550. AC_DEFINE(HAVE_PCAP_DUMP_FTELL, 1,
  551. [define if libpcap has pcap_dump_ftell()]),
  552. [
  553. AC_LIBOBJ(pcap_dump_ftell)
  554. ])
  555. #
  556. # Do we have the new open API? Check for pcap_create, and assume that,
  557. # if we do, we also have pcap_activate() and the other new routines
  558. # introduced in libpcap 1.0.0.
  559. #
  560. AC_CHECK_FUNCS(pcap_create)
  561. if test $ac_cv_func_pcap_create = "yes" ; then
  562. #
  563. # OK, do we have pcap_set_tstamp_type? If so, assume we have
  564. # pcap_list_tstamp_types and pcap_free_tstamp_types as well.
  565. #
  566. AC_CHECK_FUNCS(pcap_set_tstamp_type)
  567. #
  568. # And do we have pcap_set_tstamp_precision? If so, we assume
  569. # we also have pcap_open_offline_with_tstamp_precision.
  570. #
  571. AC_CHECK_FUNCS(pcap_set_tstamp_precision)
  572. fi
  573. #
  574. # Check for a miscellaneous collection of functions which we use
  575. # if we have them.
  576. #
  577. AC_CHECK_FUNCS(pcap_findalldevs pcap_dump_flush pcap_lib_version pcap_setdirection pcap_set_immediate_mode)
  578. if test $ac_cv_func_pcap_findalldevs = "yes" ; then
  579. dnl Check for Mac OS X, which may ship pcap.h from 0.6 but libpcap may
  580. dnl be 0.8; this means that lib has pcap_findalldevs but header doesn't
  581. dnl have pcap_if_t.
  582. savedcppflags="$CPPFLAGS"
  583. CPPFLAGS="$CPPFLAGS $V_INCLS"
  584. AC_CHECK_TYPES(pcap_if_t, , , [#include <pcap.h>])
  585. CPPFLAGS="$savedcppflags"
  586. fi
  587. if test $ac_cv_func_pcap_lib_version = "no" ; then
  588. AC_MSG_CHECKING(whether pcap_version is defined by libpcap)
  589. AC_TRY_LINK([],
  590. [
  591. extern char pcap_version[];
  592. return (int)pcap_version;
  593. ],
  594. ac_lbl_cv_pcap_version_defined=yes,
  595. ac_lbl_cv_pcap_version_defined=no)
  596. if test "$ac_lbl_cv_pcap_version_defined" = yes ; then
  597. AC_MSG_RESULT(yes)
  598. AC_DEFINE(HAVE_PCAP_VERSION, 1, [define if libpcap has pcap_version])
  599. else
  600. AC_MSG_RESULT(no)
  601. fi
  602. fi
  603. #
  604. # Check for special debugging functions
  605. #
  606. AC_CHECK_FUNCS(pcap_set_parser_debug)
  607. if test "$ac_cv_func_pcap_set_parser_debug" = "no" ; then
  608. #
  609. # OK, we don't have pcap_set_parser_debug() to set the libpcap
  610. # filter expression parser debug flag; can we directly set the
  611. # flag?
  612. AC_MSG_CHECKING(whether pcap_debug is defined by libpcap)
  613. AC_TRY_LINK([],
  614. [
  615. extern int pcap_debug;
  616. return pcap_debug;
  617. ],
  618. ac_lbl_cv_pcap_debug_defined=yes,
  619. ac_lbl_cv_pcap_debug_defined=no)
  620. if test "$ac_lbl_cv_pcap_debug_defined" = yes ; then
  621. AC_MSG_RESULT(yes)
  622. AC_DEFINE(HAVE_PCAP_DEBUG, 1, [define if libpcap has pcap_debug])
  623. else
  624. AC_MSG_RESULT(no)
  625. #
  626. # OK, what about "yydebug"?
  627. #
  628. AC_MSG_CHECKING(whether yydebug is defined by libpcap)
  629. AC_TRY_LINK([],
  630. [
  631. extern int yydebug;
  632. return yydebug;
  633. ],
  634. ac_lbl_cv_yydebug_defined=yes,
  635. ac_lbl_cv_yydebug_defined=no)
  636. if test "$ac_lbl_cv_yydebug_defined" = yes ; then
  637. AC_MSG_RESULT(yes)
  638. AC_DEFINE(HAVE_YYDEBUG, 1, [define if libpcap has yydebug])
  639. else
  640. AC_MSG_RESULT(no)
  641. fi
  642. fi
  643. fi
  644. AC_CHECK_FUNCS(pcap_set_optimizer_debug)
  645. AC_REPLACE_FUNCS(bpf_dump) dnl moved to libpcap in 0.6
  646. V_GROUP=0
  647. if test -f /etc/group -a ! -z "`grep '^wheel:' /etc/group`" ; then
  648. V_GROUP=wheel
  649. fi
  650. #
  651. # Assume V7/BSD convention for man pages (file formats in section 5,
  652. # miscellaneous info in section 7).
  653. #
  654. MAN_FILE_FORMATS=5
  655. MAN_MISC_INFO=7
  656. case "$host_os" in
  657. aix*)
  658. dnl Workaround to enable certain features
  659. AC_DEFINE(_SUN,1,[define on AIX to get certain functions])
  660. ;;
  661. hpux*)
  662. #
  663. # Use System V conventions for man pages.
  664. #
  665. MAN_FILE_FORMATS=4
  666. MAN_MISC_INFO=5
  667. ;;
  668. irix*)
  669. V_GROUP=sys
  670. #
  671. # Use System V conventions for man pages.
  672. #
  673. MAN_FILE_FORMATS=4
  674. MAN_MISC_INFO=5
  675. ;;
  676. osf*)
  677. V_GROUP=system
  678. #
  679. # Use System V conventions for man pages.
  680. #
  681. MAN_FILE_FORMATS=4
  682. MAN_MISC_INFO=5
  683. ;;
  684. solaris*)
  685. V_GROUP=sys
  686. #
  687. # Use System V conventions for man pages.
  688. #
  689. MAN_FILE_FORMATS=4
  690. MAN_MISC_INFO=5
  691. ;;
  692. esac
  693. if test -f /dev/bpf0 ; then
  694. V_GROUP=bpf
  695. fi
  696. #
  697. # Make sure we have definitions for all the C99 specified-width types
  698. # (regardless of whether the environment is a C99 environment or not).
  699. #
  700. AC_TYPE_INT8_T
  701. AC_TYPE_INT16_T
  702. AC_TYPE_INT32_T
  703. AC_TYPE_INT64_T
  704. AC_TYPE_UINT8_T
  705. AC_TYPE_UINT16_T
  706. AC_TYPE_UINT32_T
  707. AC_TYPE_UINT64_T
  708. #
  709. # Make sure we have a definition for C99's uintptr_t (regardless of
  710. # whether the environment is a C99 environment or not).
  711. #
  712. AC_TYPE_UINTPTR_T
  713. #
  714. # Define the old BSD specified-width types in terms of the C99 types;
  715. # we may need them with libpcap include files.
  716. #
  717. AC_CHECK_TYPE([u_int8_t], ,
  718. [AC_DEFINE([u_int8_t], [uint8_t],
  719. [Define to `uint8_t' if u_int8_t not defined.])],
  720. [AC_INCLUDES_DEFAULT
  721. #include <sys/types.h>
  722. ])
  723. AC_CHECK_TYPE([u_int16_t], ,
  724. [AC_DEFINE([u_int16_t], [uint16_t],
  725. [Define to `uint16_t' if u_int16_t not defined.])],
  726. [AC_INCLUDES_DEFAULT
  727. #include <sys/types.h>
  728. ])
  729. AC_CHECK_TYPE([u_int32_t], ,
  730. [AC_DEFINE([u_int32_t], [uint32_t],
  731. [Define to `uint32_t' if u_int32_t not defined.])],
  732. [AC_INCLUDES_DEFAULT
  733. #include <sys/types.h>
  734. ])
  735. AC_CHECK_TYPE([u_int64_t], ,
  736. [AC_DEFINE([u_int64_t], [uint64_t],
  737. [Define to `uint64_t' if u_int64_t not defined.])],
  738. [AC_INCLUDES_DEFAULT
  739. #include <sys/types.h>
  740. ])
  741. #
  742. # Check for <inttypes.h>
  743. #
  744. AC_CHECK_HEADERS(inttypes.h,
  745. [
  746. #
  747. # OK, we have inttypes.h, but does it define all the PRI[doxu]64 macros?
  748. # Some systems have an inttypes.h that doesn't define all of them.
  749. #
  750. AC_MSG_CHECKING([[whether inttypes.h defines the PRI[doxu]64 macros]])
  751. AC_COMPILE_IFELSE(
  752. [
  753. AC_LANG_SOURCE(
  754. [[
  755. #include <inttypes.h>
  756. #include <stdio.h>
  757. #include <sys/types.h>
  758. main()
  759. {
  760. printf("%" PRId64 "\n", (uint64_t)1);
  761. printf("%" PRIo64 "\n", (uint64_t)1);
  762. printf("%" PRIx64 "\n", (uint64_t)1);
  763. printf("%" PRIu64 "\n", (uint64_t)1);
  764. }
  765. ]])
  766. ],
  767. [
  768. AC_MSG_RESULT(yes)
  769. ac_lbl_inttypes_h_defines_formats=yes
  770. ],
  771. [
  772. AC_MSG_RESULT(no)
  773. ac_lbl_inttypes_h_defines_formats=no
  774. ])
  775. ],
  776. [
  777. #
  778. # We don't have inttypes.h, so it obviously can't define those
  779. # macros.
  780. #
  781. ac_lbl_inttypes_h_defines_formats=no
  782. ])
  783. if test "$ac_lbl_inttypes_h_defines_formats" = no; then
  784. AC_LBL_CHECK_64BIT_FORMAT(l,
  785. [
  786. AC_LBL_CHECK_64BIT_FORMAT(ll,
  787. [
  788. AC_LBL_CHECK_64BIT_FORMAT(L,
  789. [
  790. AC_LBL_CHECK_64BIT_FORMAT(q,
  791. [
  792. AC_MSG_ERROR([neither %llx nor %Lx nor %qx worked on a 64-bit integer])
  793. ])
  794. ])
  795. ])
  796. ])
  797. fi
  798. #
  799. # Check for some headers introduced in later versions of libpcap
  800. # and used by some printers.
  801. #
  802. # Those headers use the {u_}intN_t types, so we must do this after
  803. # we check for what's needed to get them defined.
  804. #
  805. savedcppflags="$CPPFLAGS"
  806. CPPFLAGS="$CPPFLAGS $V_INCLS"
  807. AC_CHECK_HEADERS(pcap/bluetooth.h,,,[#include "netdissect-stdinc.h"])
  808. AC_CHECK_HEADERS(pcap/nflog.h,,,[#include "netdissect-stdinc.h"])
  809. AC_CHECK_HEADERS(pcap/usb.h,,,[#include "netdissect-stdinc.h"])
  810. CPPFLAGS="$savedcppflags"
  811. AC_PROG_RANLIB
  812. AC_CHECK_TOOL([AR], [ar])
  813. AC_LBL_DEVEL(V_CCOPT)
  814. AC_LBL_SOCKADDR_SA_LEN
  815. AC_LBL_UNALIGNED_ACCESS
  816. # Check for OpenSSL/libressl libcrypto
  817. AC_MSG_CHECKING(whether to use OpenSSL/libressl libcrypto)
  818. # Specify location for both includes and libraries.
  819. want_libcrypto=ifavailable
  820. AC_ARG_WITH(crypto,
  821. AS_HELP_STRING([--with-crypto]@<:@=DIR@:>@,
  822. [use OpenSSL/libressl libcrypto (located in directory DIR, if specified) @<:@default=yes, if available@:>@]),
  823. [
  824. if test $withval = no
  825. then
  826. # User doesn't want to link with libcrypto.
  827. want_libcrypto=no
  828. AC_MSG_RESULT(no)
  829. elif test $withval = yes
  830. then
  831. # User wants to link with libcrypto but hasn't specified
  832. # a directory.
  833. want_libcrypto=yes
  834. AC_MSG_RESULT(yes)
  835. else
  836. # User wants to link with libcrypto and has specified
  837. # a directory, so use the provided value.
  838. want_libcrypto=yes
  839. libcrypto_root=$withval
  840. AC_MSG_RESULT([yes, using the version installed in $withval])
  841. #
  842. # Put the subdirectories of the libcrypto root directory
  843. # at the front of the header and library search path.
  844. #
  845. CFLAGS="-I$withval/include $CFLAGS"
  846. LIBS="-L$withval/lib $LIBS"
  847. fi
  848. ],[
  849. #
  850. # Use libcrypto if it's present, otherwise don't; no directory
  851. # was specified.
  852. #
  853. want_libcrypto=ifavailable
  854. AC_MSG_RESULT([yes, if available])
  855. ])
  856. if test "$want_libcrypto" != "no"; then
  857. #
  858. # Don't check for libcrypto unless we have its headers;
  859. # Apple, bless their pointy little heads, apparently ship
  860. # libcrypto as a library, but not the header files, in
  861. # El Capitan, probably because they don't want you writing
  862. # nasty portable code that could run on other UN*Xes, they
  863. # want you writing code that uses their Shiny New Crypto
  864. # Library and that only runs on OS X.
  865. #
  866. AC_CHECK_HEADER(openssl/crypto.h,
  867. [
  868. AC_CHECK_LIB(crypto, DES_cbc_encrypt)
  869. if test "$ac_cv_lib_crypto_DES_cbc_encrypt" = "yes"; then
  870. AC_CHECK_HEADERS(openssl/evp.h)
  871. #
  872. # OK, then:
  873. #
  874. # 1) do we have EVP_CIPHER_CTX_new?
  875. # If so, we use it to allocate an
  876. # EVP_CIPHER_CTX, as EVP_CIPHER_CTX may be
  877. # opaque; otherwise, we allocate it ourselves.
  878. #
  879. # 2) do we have EVP_CipherInit_ex()?
  880. # If so, we use it, because we need to be
  881. # able to make two "initialize the cipher"
  882. # calls, one with the cipher and key, and
  883. # one with the IV, and, as of OpenSSL 1.1,
  884. # You Can't Do That with EVP_CipherInit(),
  885. # because a call to EVP_CipherInit() will
  886. # unconditionally clear the context, and
  887. # if you don't supply a cipher, it'll
  888. # clear the cipher, rendering the context
  889. # unusable and causing a crash.
  890. #
  891. AC_CHECK_FUNCS(EVP_CIPHER_CTX_new EVP_CipherInit_ex)
  892. fi
  893. ])
  894. fi
  895. # Check for libcap-ng
  896. AC_MSG_CHECKING(whether to use libcap-ng)
  897. # Specify location for both includes and libraries.
  898. want_libcap_ng=ifavailable
  899. AC_ARG_WITH(cap_ng,
  900. AS_HELP_STRING([--with-cap-ng],
  901. [use libcap-ng @<:@default=yes, if available@:>@]),
  902. [
  903. if test $withval = no
  904. then
  905. want_libcap_ng=no
  906. AC_MSG_RESULT(no)
  907. elif test $withval = yes
  908. then
  909. want_libcap_ng=yes
  910. AC_MSG_RESULT(yes)
  911. fi
  912. ],[
  913. #
  914. # Use libcap-ng if it's present, otherwise don't.
  915. #
  916. want_libcap_ng=ifavailable
  917. AC_MSG_RESULT([yes, if available])
  918. ])
  919. if test "$want_libcap_ng" != "no"; then
  920. AC_CHECK_LIB(cap-ng, capng_change_id)
  921. AC_CHECK_HEADERS(cap-ng.h)
  922. fi
  923. dnl
  924. dnl set additional include path if necessary
  925. if test "$missing_includes" = "yes"; then
  926. CPPFLAGS="$CPPFLAGS -I$srcdir/missing"
  927. V_INCLS="$V_INCLS -I$srcdir/missing"
  928. fi
  929. AC_SUBST(V_CCOPT)
  930. AC_SUBST(V_DEFS)
  931. AC_SUBST(V_GROUP)
  932. AC_SUBST(V_INCLS)
  933. AC_SUBST(V_PCAPDEP)
  934. AC_SUBST(LOCALSRC)
  935. AC_SUBST(MAN_FILE_FORMATS)
  936. AC_SUBST(MAN_MISC_INFO)
  937. AC_PROG_INSTALL
  938. AC_CONFIG_HEADER(config.h)
  939. AC_OUTPUT_COMMANDS([if test -f .devel; then
  940. echo timestamp > stamp-h
  941. cat Makefile-devel-adds >> Makefile
  942. make depend
  943. fi])
  944. AC_OUTPUT(Makefile tcpdump.1)
  945. exit 0