aclocal.m4 40 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361
  1. dnl Copyright (c) 1995, 1996, 1997, 1998
  2. dnl The Regents of the University of California. All rights reserved.
  3. dnl
  4. dnl Redistribution and use in source and binary forms, with or without
  5. dnl modification, are permitted provided that: (1) source code distributions
  6. dnl retain the above copyright notice and this paragraph in its entirety, (2)
  7. dnl distributions including binary code include the above copyright notice and
  8. dnl this paragraph in its entirety in the documentation or other materials
  9. dnl provided with the distribution, and (3) all advertising materials mentioning
  10. dnl features or use of this software display the following acknowledgement:
  11. dnl ``This product includes software developed by the University of California,
  12. dnl Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
  13. dnl the University nor the names of its contributors may be used to endorse
  14. dnl or promote products derived from this software without specific prior
  15. dnl written permission.
  16. dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
  17. dnl WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
  18. dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  19. dnl
  20. dnl LBL autoconf macros
  21. dnl
  22. dnl
  23. dnl Do whatever AC_LBL_C_INIT work is necessary before using AC_PROG_CC.
  24. dnl
  25. dnl It appears that newer versions of autoconf (2.64 and later) will,
  26. dnl if you use AC_TRY_COMPILE in a macro, stick AC_PROG_CC at the
  27. dnl beginning of the macro, even if the macro itself calls AC_PROG_CC.
  28. dnl See the "Prerequisite Macros" and "Expanded Before Required" sections
  29. dnl in the Autoconf documentation.
  30. dnl
  31. dnl This causes a steaming heap of fail in our case, as we were, in
  32. dnl AC_LBL_C_INIT, doing the tests we now do in AC_LBL_C_INIT_BEFORE_CC,
  33. dnl calling AC_PROG_CC, and then doing the tests we now do in
  34. dnl AC_LBL_C_INIT. Now, we run AC_LBL_C_INIT_BEFORE_CC, AC_PROG_CC,
  35. dnl and AC_LBL_C_INIT at the top level.
  36. dnl
  37. AC_DEFUN(AC_LBL_C_INIT_BEFORE_CC,
  38. [
  39. AC_BEFORE([$0], [AC_LBL_C_INIT])
  40. AC_BEFORE([$0], [AC_PROG_CC])
  41. AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
  42. AC_BEFORE([$0], [AC_LBL_DEVEL])
  43. AC_ARG_WITH(gcc, [ --without-gcc don't use gcc])
  44. $1=""
  45. if test "${srcdir}" != "." ; then
  46. $1="-I$srcdir"
  47. fi
  48. if test "${CFLAGS+set}" = set; then
  49. LBL_CFLAGS="$CFLAGS"
  50. fi
  51. if test -z "$CC" ; then
  52. case "$host_os" in
  53. bsdi*)
  54. AC_CHECK_PROG(SHLICC2, shlicc2, yes, no)
  55. if test $SHLICC2 = yes ; then
  56. CC=shlicc2
  57. export CC
  58. fi
  59. ;;
  60. esac
  61. fi
  62. if test -z "$CC" -a "$with_gcc" = no ; then
  63. CC=cc
  64. export CC
  65. fi
  66. ])
  67. dnl
  68. dnl Determine which compiler we're using (cc or gcc)
  69. dnl If using gcc, determine the version number
  70. dnl If using cc:
  71. dnl require that it support ansi prototypes
  72. dnl use -O (AC_PROG_CC will use -g -O2 on gcc, so we don't need to
  73. dnl do that ourselves for gcc)
  74. dnl add -g flags, as appropriate
  75. dnl explicitly specify /usr/local/include
  76. dnl
  77. dnl NOTE WELL: with newer versions of autoconf, "gcc" means any compiler
  78. dnl that defines __GNUC__, which means clang, for example, counts as "gcc".
  79. dnl
  80. dnl usage:
  81. dnl
  82. dnl AC_LBL_C_INIT(copt, incls)
  83. dnl
  84. dnl results:
  85. dnl
  86. dnl $1 (copt set)
  87. dnl $2 (incls set)
  88. dnl CC
  89. dnl LDFLAGS
  90. dnl LBL_CFLAGS
  91. dnl
  92. AC_DEFUN(AC_LBL_C_INIT,
  93. [
  94. AC_BEFORE([$0], [AC_LBL_FIXINCLUDES])
  95. AC_BEFORE([$0], [AC_LBL_DEVEL])
  96. AC_BEFORE([$0], [AC_LBL_SHLIBS_INIT])
  97. if test "$GCC" = yes ; then
  98. #
  99. # -Werror forces warnings to be errors.
  100. #
  101. ac_lbl_cc_force_warning_errors=-Werror
  102. #
  103. # Use -ffloat-store so that, on 32-bit x86, we don't
  104. # do 80-bit arithmetic with the FPU; that way we should
  105. # get the same results for floating-point calculations
  106. # on x86-32 and x86-64.
  107. #
  108. AC_LBL_CHECK_COMPILER_OPT($1, -ffloat-store)
  109. else
  110. $2="$$2 -I/usr/local/include"
  111. LDFLAGS="$LDFLAGS -L/usr/local/lib"
  112. case "$host_os" in
  113. darwin*)
  114. #
  115. # This is assumed either to be GCC or clang, both
  116. # of which use -Werror to force warnings to be errors.
  117. #
  118. ac_lbl_cc_force_warning_errors=-Werror
  119. ;;
  120. hpux*)
  121. #
  122. # HP C, which is what we presume we're using, doesn't
  123. # exit with a non-zero exit status if we hand it an
  124. # invalid -W flag, can't be forced to do so even with
  125. # +We, and doesn't handle GCC-style -W flags, so we
  126. # don't want to try using GCC-style -W flags.
  127. #
  128. ac_lbl_cc_dont_try_gcc_dashW=yes
  129. ;;
  130. irix*)
  131. #
  132. # MIPS C, which is what we presume we're using, doesn't
  133. # necessarily exit with a non-zero exit status if we
  134. # hand it an invalid -W flag, can't be forced to do
  135. # so, and doesn't handle GCC-style -W flags, so we
  136. # don't want to try using GCC-style -W flags.
  137. #
  138. ac_lbl_cc_dont_try_gcc_dashW=yes
  139. #
  140. # It also, apparently, defaults to "char" being
  141. # unsigned, unlike most other C implementations;
  142. # I suppose we could say "signed char" whenever
  143. # we want to guarantee a signed "char", but let's
  144. # just force signed chars.
  145. #
  146. # -xansi is normally the default, but the
  147. # configure script was setting it; perhaps -cckr
  148. # was the default in the Old Days. (Then again,
  149. # that would probably be for backwards compatibility
  150. # in the days when ANSI C was Shiny and New, i.e.
  151. # 1989 and the early '90's, so maybe we can just
  152. # drop support for those compilers.)
  153. #
  154. # -g is equivalent to -g2, which turns off
  155. # optimization; we choose -g3, which generates
  156. # debugging information but doesn't turn off
  157. # optimization (even if the optimization would
  158. # cause inaccuracies in debugging).
  159. #
  160. $1="$$1 -xansi -signed -g3"
  161. ;;
  162. osf*)
  163. #
  164. # Presumed to be DEC OSF/1, Digital UNIX, or
  165. # Tru64 UNIX.
  166. #
  167. # The DEC C compiler, which is what we presume we're
  168. # using, doesn't exit with a non-zero exit status if we
  169. # hand it an invalid -W flag, can't be forced to do
  170. # so, and doesn't handle GCC-style -W flags, so we
  171. # don't want to try using GCC-style -W flags.
  172. #
  173. ac_lbl_cc_dont_try_gcc_dashW=yes
  174. #
  175. # -g is equivalent to -g2, which turns off
  176. # optimization; we choose -g3, which generates
  177. # debugging information but doesn't turn off
  178. # optimization (even if the optimization would
  179. # cause inaccuracies in debugging).
  180. #
  181. $1="$$1 -g3"
  182. ;;
  183. solaris*)
  184. #
  185. # Assumed to be Sun C, which requires -errwarn to force
  186. # warnings to be treated as errors.
  187. #
  188. ac_lbl_cc_force_warning_errors=-errwarn
  189. ;;
  190. ultrix*)
  191. AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
  192. AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
  193. AC_TRY_COMPILE(
  194. [#include <sys/types.h>],
  195. [struct a { int b; };
  196. void c(const struct a *)],
  197. ac_cv_lbl_cc_const_proto=yes,
  198. ac_cv_lbl_cc_const_proto=no))
  199. AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)
  200. if test $ac_cv_lbl_cc_const_proto = no ; then
  201. AC_DEFINE(const,[],
  202. [to handle Ultrix compilers that don't support const in prototypes])
  203. fi
  204. ;;
  205. esac
  206. $1="$$1 -O"
  207. fi
  208. ])
  209. dnl
  210. dnl Check whether, if you pass an unknown warning option to the
  211. dnl compiler, it fails or just prints a warning message and succeeds.
  212. dnl Set ac_lbl_unknown_warning_option_error to the appropriate flag
  213. dnl to force an error if it would otherwise just print a warning message
  214. dnl and succeed.
  215. dnl
  216. AC_DEFUN(AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR,
  217. [
  218. AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option])
  219. save_CFLAGS="$CFLAGS"
  220. CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
  221. AC_TRY_COMPILE(
  222. [],
  223. [return 0],
  224. [
  225. AC_MSG_RESULT([no])
  226. #
  227. # We're assuming this is clang, where
  228. # -Werror=unknown-warning-option is the appropriate
  229. # option to force the compiler to fail.
  230. #
  231. ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option"
  232. ],
  233. [
  234. AC_MSG_RESULT([yes])
  235. ])
  236. CFLAGS="$save_CFLAGS"
  237. ])
  238. dnl
  239. dnl Check whether the compiler option specified as the second argument
  240. dnl is supported by the compiler and, if so, add it to the macro
  241. dnl specified as the first argument
  242. dnl
  243. AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
  244. [
  245. AC_MSG_CHECKING([whether the compiler supports the $2 option])
  246. save_CFLAGS="$CFLAGS"
  247. if expr "x$2" : "x-W.*" >/dev/null
  248. then
  249. CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2"
  250. elif expr "x$2" : "x-f.*" >/dev/null
  251. then
  252. CFLAGS="$CFLAGS -Werror $2"
  253. elif expr "x$2" : "x-m.*" >/dev/null
  254. then
  255. CFLAGS="$CFLAGS -Werror $2"
  256. else
  257. CFLAGS="$CFLAGS $2"
  258. fi
  259. AC_TRY_COMPILE(
  260. [],
  261. [return 0],
  262. [
  263. AC_MSG_RESULT([yes])
  264. CFLAGS="$save_CFLAGS"
  265. $1="$$1 $2"
  266. ],
  267. [
  268. AC_MSG_RESULT([no])
  269. CFLAGS="$save_CFLAGS"
  270. ])
  271. ])
  272. dnl
  273. dnl Check whether the compiler supports an option to generate
  274. dnl Makefile-style dependency lines
  275. dnl
  276. dnl GCC uses -M for this. Non-GCC compilers that support this
  277. dnl use a variety of flags, including but not limited to -M.
  278. dnl
  279. dnl We test whether the flag in question is supported, as older
  280. dnl versions of compilers might not support it.
  281. dnl
  282. dnl We don't try all the possible flags, just in case some flag means
  283. dnl "generate dependencies" on one compiler but means something else
  284. dnl on another compiler.
  285. dnl
  286. dnl Most compilers that support this send the output to the standard
  287. dnl output by default. IBM's XLC, however, supports -M but sends
  288. dnl the output to {sourcefile-basename}.u, and AIX has no /dev/stdout
  289. dnl to work around that, so we don't bother with XLC.
  290. dnl
  291. AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT,
  292. [
  293. AC_MSG_CHECKING([whether the compiler supports generating dependencies])
  294. if test "$GCC" = yes ; then
  295. #
  296. # GCC, or a compiler deemed to be GCC by AC_PROG_CC (even
  297. # though it's not); we assume that, in this case, the flag
  298. # would be -M.
  299. #
  300. ac_lbl_dependency_flag="-M"
  301. else
  302. #
  303. # Not GCC or a compiler deemed to be GCC; what platform is
  304. # this? (We're assuming that if the compiler isn't GCC
  305. # it's the compiler from the vendor of the OS; that won't
  306. # necessarily be true for x86 platforms, where it might be
  307. # the Intel C compiler.)
  308. #
  309. case "$host_os" in
  310. irix*|osf*|darwin*)
  311. #
  312. # MIPS C for IRIX, DEC C, and clang all use -M.
  313. #
  314. ac_lbl_dependency_flag="-M"
  315. ;;
  316. solaris*)
  317. #
  318. # Sun C uses -xM.
  319. #
  320. ac_lbl_dependency_flag="-xM"
  321. ;;
  322. hpux*)
  323. #
  324. # HP's older C compilers don't support this.
  325. # HP's newer C compilers support this with
  326. # either +M or +Make; the older compilers
  327. # interpret +M as something completely
  328. # different, so we use +Make so we don't
  329. # think it works with the older compilers.
  330. #
  331. ac_lbl_dependency_flag="+Make"
  332. ;;
  333. *)
  334. #
  335. # Not one of the above; assume no support for
  336. # generating dependencies.
  337. #
  338. ac_lbl_dependency_flag=""
  339. ;;
  340. esac
  341. fi
  342. #
  343. # Is ac_lbl_dependency_flag defined and, if so, does the compiler
  344. # complain about it?
  345. #
  346. # Note: clang doesn't seem to exit with an error status when handed
  347. # an unknown non-warning error, even if you pass it
  348. # -Werror=unknown-warning-option. However, it always supports
  349. # -M, so the fact that this test always succeeds with clang
  350. # isn't an issue.
  351. #
  352. if test ! -z "$ac_lbl_dependency_flag"; then
  353. AC_LANG_CONFTEST(
  354. [AC_LANG_SOURCE([[int main(void) { return 0; }]])])
  355. echo "$CC" $ac_lbl_dependency_flag conftest.c >&5
  356. if "$CC" $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1; then
  357. AC_MSG_RESULT([yes, with $ac_lbl_dependency_flag])
  358. DEPENDENCY_CFLAG="$ac_lbl_dependency_flag"
  359. MKDEP='${srcdir}/mkdep'
  360. else
  361. AC_MSG_RESULT([no])
  362. #
  363. # We can't run mkdep, so have "make depend" do
  364. # nothing.
  365. #
  366. MKDEP=:
  367. fi
  368. rm -rf conftest*
  369. else
  370. AC_MSG_RESULT([no])
  371. #
  372. # We can't run mkdep, so have "make depend" do
  373. # nothing.
  374. #
  375. MKDEP=:
  376. fi
  377. AC_SUBST(DEPENDENCY_CFLAG)
  378. AC_SUBST(MKDEP)
  379. ])
  380. #
  381. # Try compiling a sample of the type of code that appears in
  382. # gencode.c with "inline", "__inline__", and "__inline".
  383. #
  384. # Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough,
  385. # as it just tests whether a function returning "int" can be inlined;
  386. # at least some versions of HP's C compiler can inline that, but can't
  387. # inline a function that returns a struct pointer.
  388. #
  389. # Make sure we use the V_CCOPT flags, because some of those might
  390. # disable inlining.
  391. #
  392. AC_DEFUN(AC_LBL_C_INLINE,
  393. [AC_MSG_CHECKING(for inline)
  394. save_CFLAGS="$CFLAGS"
  395. CFLAGS="$V_CCOPT"
  396. AC_CACHE_VAL(ac_cv_lbl_inline, [
  397. ac_cv_lbl_inline=""
  398. ac_lbl_cc_inline=no
  399. for ac_lbl_inline in inline __inline__ __inline
  400. do
  401. AC_TRY_COMPILE(
  402. [#define inline $ac_lbl_inline
  403. static inline struct iltest *foo(void);
  404. struct iltest {
  405. int iltest1;
  406. int iltest2;
  407. };
  408. static inline struct iltest *
  409. foo()
  410. {
  411. static struct iltest xxx;
  412. return &xxx;
  413. }],,ac_lbl_cc_inline=yes,)
  414. if test "$ac_lbl_cc_inline" = yes ; then
  415. break;
  416. fi
  417. done
  418. if test "$ac_lbl_cc_inline" = yes ; then
  419. ac_cv_lbl_inline=$ac_lbl_inline
  420. fi])
  421. CFLAGS="$save_CFLAGS"
  422. if test ! -z "$ac_cv_lbl_inline" ; then
  423. AC_MSG_RESULT($ac_cv_lbl_inline)
  424. else
  425. AC_MSG_RESULT(no)
  426. fi
  427. AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])
  428. dnl
  429. dnl Use pfopen.c if available and pfopen() not in standard libraries
  430. dnl Require libpcap
  431. dnl Look for libpcap in ..
  432. dnl Use the installed libpcap if there is no local version
  433. dnl
  434. dnl usage:
  435. dnl
  436. dnl AC_LBL_LIBPCAP(pcapdep, incls)
  437. dnl
  438. dnl results:
  439. dnl
  440. dnl $1 (pcapdep set)
  441. dnl $2 (incls appended)
  442. dnl LIBS
  443. dnl LBL_LIBS
  444. dnl
  445. AC_DEFUN(AC_LBL_LIBPCAP,
  446. [AC_REQUIRE([AC_LBL_LIBRARY_NET])
  447. dnl
  448. dnl save a copy before locating libpcap.a
  449. dnl
  450. LBL_LIBS="$LIBS"
  451. pfopen=/usr/examples/packetfilter/pfopen.c
  452. if test -f $pfopen ; then
  453. AC_CHECK_FUNCS(pfopen)
  454. if test $ac_cv_func_pfopen = "no" ; then
  455. AC_MSG_RESULT(Using $pfopen)
  456. LIBS="$LIBS $pfopen"
  457. fi
  458. fi
  459. libpcap=FAIL
  460. AC_MSG_CHECKING(for local pcap library)
  461. AC_ARG_WITH([system-libpcap],
  462. [AS_HELP_STRING([--with-system-libpcap], [don't use local pcap library])])
  463. if test "x$with_system_libpcap" != xyes ; then
  464. lastdir=FAIL
  465. places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
  466. egrep '/libpcap-[[0-9]]+\.[[0-9]]+(\.[[0-9]]*)?([[ab]][[0-9]]*|-PRE-GIT)?$'`
  467. places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \
  468. egrep '/libpcap-[[0-9]]+\.[[0-9]]+(\.[[0-9]]*)?([[ab]][[0-9]]*|-PRE-GIT)?$'`
  469. for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do
  470. basedir=`echo $dir | sed -e 's/[[ab]][[0-9]]*$//' | \
  471. sed -e 's/-PRE-GIT$//' `
  472. if test $lastdir = $basedir ; then
  473. dnl skip alphas when an actual release is present
  474. continue;
  475. fi
  476. lastdir=$dir
  477. if test -r $dir/libpcap.a ; then
  478. libpcap=$dir/libpcap.a
  479. d=$dir
  480. dnl continue and select the last one that exists
  481. fi
  482. done
  483. fi
  484. if test $libpcap = FAIL ; then
  485. AC_MSG_RESULT(not found)
  486. #
  487. # Look for pcap-config.
  488. #
  489. AC_PATH_TOOL(PCAP_CONFIG, pcap-config)
  490. if test -n "$PCAP_CONFIG" ; then
  491. #
  492. # Found - use it to get the include flags for
  493. # libpcap and the flags to link with libpcap.
  494. #
  495. # Please read section 11.6 "Shell Substitutions"
  496. # in the autoconf manual before doing anything
  497. # to this that involves quoting. Especially note
  498. # the statement "There is just no portable way to use
  499. # double-quoted strings inside double-quoted back-quoted
  500. # expressions (pfew!)."
  501. #
  502. cflags=`"$PCAP_CONFIG" --cflags`
  503. $2="$cflags $$2"
  504. libpcap=`"$PCAP_CONFIG" --libs`
  505. else
  506. #
  507. # Not found; look for pcap.
  508. #
  509. AC_CHECK_LIB(pcap, main, libpcap="-lpcap")
  510. if test $libpcap = FAIL ; then
  511. AC_MSG_ERROR(see the INSTALL doc for more info)
  512. fi
  513. dnl
  514. dnl Some versions of Red Hat Linux put "pcap.h" in
  515. dnl "/usr/include/pcap"; had the LBL folks done so,
  516. dnl that would have been a good idea, but for
  517. dnl the Red Hat folks to do so just breaks source
  518. dnl compatibility with other systems.
  519. dnl
  520. dnl We work around this by assuming that, as we didn't
  521. dnl find a local libpcap, libpcap is in /usr/lib or
  522. dnl /usr/local/lib and that the corresponding header
  523. dnl file is under one of those directories; if we don't
  524. dnl find it in either of those directories, we check to
  525. dnl see if it's in a "pcap" subdirectory of them and,
  526. dnl if so, add that subdirectory to the "-I" list.
  527. dnl
  528. dnl (We now also put pcap.h in /usr/include/pcap, but we
  529. dnl leave behind a /usr/include/pcap.h that includes it,
  530. dnl so you can still just include <pcap.h>.)
  531. dnl
  532. AC_MSG_CHECKING(for extraneous pcap header directories)
  533. if test \( ! -r /usr/local/include/pcap.h \) -a \
  534. \( ! -r /usr/include/pcap.h \); then
  535. if test -r /usr/local/include/pcap/pcap.h; then
  536. d="/usr/local/include/pcap"
  537. elif test -r /usr/include/pcap/pcap.h; then
  538. d="/usr/include/pcap"
  539. fi
  540. fi
  541. if test -z "$d" ; then
  542. AC_MSG_RESULT(not found)
  543. else
  544. $2="-I$d $$2"
  545. AC_MSG_RESULT(found -- -I$d added)
  546. fi
  547. fi
  548. else
  549. $1=$libpcap
  550. places=`ls $srcdir/.. | sed -e 's,/$,,' -e "s,^,$srcdir/../," | \
  551. egrep '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
  552. places2=`ls .. | sed -e 's,/$,,' -e "s,^,../," | \
  553. egrep '/libpcap-[[0-9]]*.[[0-9]]*(.[[0-9]]*)?([[ab]][[0-9]]*)?$'`
  554. pcapH=FAIL
  555. if test -r $d/pcap.h; then
  556. pcapH=$d
  557. else
  558. for dir in $places $srcdir/../libpcap ../libpcap $srcdir/libpcap $places2 ; do
  559. if test -r $dir/pcap.h ; then
  560. pcapH=$dir
  561. fi
  562. done
  563. fi
  564. if test $pcapH = FAIL ; then
  565. AC_MSG_ERROR(cannot find pcap.h: see INSTALL)
  566. fi
  567. $2="-I$pcapH $$2"
  568. AC_MSG_RESULT($libpcap)
  569. AC_PATH_PROG(PCAP_CONFIG, pcap-config,, $d)
  570. if test -n "$PCAP_CONFIG"; then
  571. #
  572. # The libpcap directory has a pcap-config script.
  573. # Use it to get any additioal libraries needed
  574. # to link with the libpcap archive library in
  575. # that directory.
  576. #
  577. # Please read section 11.6 "Shell Substitutions"
  578. # in the autoconf manual before doing anything
  579. # to this that involves quoting. Especially note
  580. # the statement "There is just no portable way to use
  581. # double-quoted strings inside double-quoted back-quoted
  582. # expressions (pfew!)."
  583. #
  584. additional_libs=`"$PCAP_CONFIG" --additional-libs --static`
  585. libpcap="$libpcap $additional_libs"
  586. fi
  587. fi
  588. LIBS="$libpcap $LIBS"
  589. if ! test -n "$PCAP_CONFIG" ; then
  590. #
  591. # We don't have pcap-config; find out any additional link flags
  592. # we need. (If we have pcap-config, we assume it tells us what
  593. # we need.)
  594. #
  595. case "$host_os" in
  596. aix*)
  597. #
  598. # If libpcap is DLPI-based, we have to use /lib/pse.exp if
  599. # present, as we use the STREAMS routines.
  600. #
  601. # (XXX - true only if we're linking with a static libpcap?)
  602. #
  603. pseexe="/lib/pse.exp"
  604. AC_MSG_CHECKING(for $pseexe)
  605. if test -f $pseexe ; then
  606. AC_MSG_RESULT(yes)
  607. LIBS="$LIBS -I:$pseexe"
  608. fi
  609. #
  610. # If libpcap is BPF-based, we need "-lodm" and "-lcfg", as
  611. # we use them to load the BPF module.
  612. #
  613. # (XXX - true only if we're linking with a static libpcap?)
  614. #
  615. LIBS="$LIBS -lodm -lcfg"
  616. ;;
  617. esac
  618. fi
  619. dnl
  620. dnl Check for "pcap_loop()", to make sure we found a working
  621. dnl libpcap and have all the right other libraries with which
  622. dnl to link. (Otherwise, the checks below will fail, not
  623. dnl because the routines are missing from the library, but
  624. dnl because we aren't linking properly with libpcap, and
  625. dnl that will cause confusing errors at build time.)
  626. dnl
  627. AC_CHECK_FUNC(pcap_loop,,
  628. [
  629. AC_MSG_ERROR(
  630. [This is a bug, please follow the guidelines in CONTRIBUTING and include the
  631. config.log file in your report. If you have downloaded libpcap from
  632. tcpdump.org, and built it yourself, please also include the config.log
  633. file from the libpcap source directory, the Makefile from the libpcap
  634. source directory, and the output of the make process for libpcap, as
  635. this could be a problem with the libpcap that was built, and we will
  636. not be able to determine why this is happening, and thus will not be
  637. able to fix it, without that information, as we have not been able to
  638. reproduce this problem ourselves.])
  639. ])
  640. ])
  641. dnl
  642. dnl Define RETSIGTYPE and RETSIGVAL
  643. dnl
  644. dnl usage:
  645. dnl
  646. dnl AC_LBL_TYPE_SIGNAL
  647. dnl
  648. dnl results:
  649. dnl
  650. dnl RETSIGTYPE (defined)
  651. dnl RETSIGVAL (defined)
  652. dnl
  653. AC_DEFUN(AC_LBL_TYPE_SIGNAL,
  654. [AC_BEFORE([$0], [AC_LBL_LIBPCAP])
  655. AC_TYPE_SIGNAL
  656. if test "$ac_cv_type_signal" = void ; then
  657. AC_DEFINE(RETSIGVAL,[],[return value of signal handlers])
  658. else
  659. AC_DEFINE(RETSIGVAL,(0),[return value of signal handlers])
  660. fi
  661. case "$host_os" in
  662. irix*)
  663. AC_DEFINE(_BSD_SIGNALS,1,[get BSD semantics on Irix])
  664. ;;
  665. *)
  666. dnl prefer sigaction() to sigset()
  667. AC_CHECK_FUNCS(sigaction)
  668. if test $ac_cv_func_sigaction = no ; then
  669. AC_CHECK_FUNCS(sigset)
  670. fi
  671. ;;
  672. esac])
  673. dnl
  674. dnl If using gcc, make sure we have ANSI ioctl definitions
  675. dnl
  676. dnl usage:
  677. dnl
  678. dnl AC_LBL_FIXINCLUDES
  679. dnl
  680. AC_DEFUN(AC_LBL_FIXINCLUDES,
  681. [if test "$GCC" = yes ; then
  682. AC_MSG_CHECKING(for ANSI ioctl definitions)
  683. AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes,
  684. AC_TRY_COMPILE(
  685. [/*
  686. * This generates a "duplicate case value" when fixincludes
  687. * has not be run.
  688. */
  689. # include <sys/types.h>
  690. # include <sys/time.h>
  691. # include <sys/ioctl.h>
  692. # ifdef HAVE_SYS_IOCCOM_H
  693. # include <sys/ioccom.h>
  694. # endif],
  695. [switch (0) {
  696. case _IO('A', 1):;
  697. case _IO('B', 1):;
  698. }],
  699. ac_cv_lbl_gcc_fixincludes=yes,
  700. ac_cv_lbl_gcc_fixincludes=no))
  701. AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes)
  702. if test $ac_cv_lbl_gcc_fixincludes = no ; then
  703. # Don't cache failure
  704. unset ac_cv_lbl_gcc_fixincludes
  705. AC_MSG_ERROR(see the INSTALL for more info)
  706. fi
  707. fi])
  708. dnl
  709. dnl Checks to see if union wait is used with WEXITSTATUS()
  710. dnl
  711. dnl usage:
  712. dnl
  713. dnl AC_LBL_UNION_WAIT
  714. dnl
  715. dnl results:
  716. dnl
  717. dnl DECLWAITSTATUS (defined)
  718. dnl
  719. AC_DEFUN(AC_LBL_UNION_WAIT,
  720. [AC_MSG_CHECKING(if union wait is used)
  721. AC_CACHE_VAL(ac_cv_lbl_union_wait,
  722. AC_TRY_COMPILE([
  723. # include <sys/types.h>
  724. # include <sys/wait.h>],
  725. [int status;
  726. u_int i = WEXITSTATUS(status);
  727. u_int j = waitpid(0, &status, 0);],
  728. ac_cv_lbl_union_wait=no,
  729. ac_cv_lbl_union_wait=yes))
  730. AC_MSG_RESULT($ac_cv_lbl_union_wait)
  731. if test $ac_cv_lbl_union_wait = yes ; then
  732. AC_DEFINE(DECLWAITSTATUS,union wait,[type for wait])
  733. else
  734. AC_DEFINE(DECLWAITSTATUS,int,[type for wait])
  735. fi])
  736. dnl
  737. dnl Checks to see if the sockaddr struct has the 4.4 BSD sa_len member
  738. dnl
  739. dnl usage:
  740. dnl
  741. dnl AC_LBL_SOCKADDR_SA_LEN
  742. dnl
  743. dnl results:
  744. dnl
  745. dnl HAVE_SOCKADDR_SA_LEN (defined)
  746. dnl
  747. AC_DEFUN(AC_LBL_SOCKADDR_SA_LEN,
  748. [AC_MSG_CHECKING(if sockaddr struct has the sa_len member)
  749. AC_CACHE_VAL(ac_cv_lbl_sockaddr_has_sa_len,
  750. AC_TRY_COMPILE([
  751. # include <sys/types.h>
  752. # include <sys/socket.h>],
  753. [u_int i = sizeof(((struct sockaddr *)0)->sa_len)],
  754. ac_cv_lbl_sockaddr_has_sa_len=yes,
  755. ac_cv_lbl_sockaddr_has_sa_len=no))
  756. AC_MSG_RESULT($ac_cv_lbl_sockaddr_has_sa_len)
  757. if test $ac_cv_lbl_sockaddr_has_sa_len = yes ; then
  758. AC_DEFINE(HAVE_SOCKADDR_SA_LEN,1,[if struct sockaddr has the sa_len member])
  759. fi])
  760. dnl
  761. dnl Checks to see if -R is used
  762. dnl
  763. dnl usage:
  764. dnl
  765. dnl AC_LBL_HAVE_RUN_PATH
  766. dnl
  767. dnl results:
  768. dnl
  769. dnl ac_cv_lbl_have_run_path (yes or no)
  770. dnl
  771. AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
  772. [AC_MSG_CHECKING(for ${CC-cc} -R)
  773. AC_CACHE_VAL(ac_cv_lbl_have_run_path,
  774. [echo 'main(){}' > conftest.c
  775. ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
  776. if test ! -s conftest.out ; then
  777. ac_cv_lbl_have_run_path=yes
  778. else
  779. ac_cv_lbl_have_run_path=no
  780. fi
  781. rm -f -r conftest*])
  782. AC_MSG_RESULT($ac_cv_lbl_have_run_path)
  783. ])
  784. dnl
  785. dnl Check whether a given format can be used to print 64-bit integers
  786. dnl
  787. AC_DEFUN(AC_LBL_CHECK_64BIT_FORMAT,
  788. [
  789. AC_MSG_CHECKING([whether %$1x can be used to format 64-bit integers])
  790. AC_RUN_IFELSE(
  791. [
  792. AC_LANG_SOURCE(
  793. [[
  794. # ifdef HAVE_INTTYPES_H
  795. #include <inttypes.h>
  796. # endif
  797. #include <stdio.h>
  798. #include <sys/types.h>
  799. main()
  800. {
  801. uint64_t t = 1;
  802. char strbuf[16+1];
  803. sprintf(strbuf, "%016$1x", t << 32);
  804. if (strcmp(strbuf, "0000000100000000") == 0)
  805. exit(0);
  806. else
  807. exit(1);
  808. }
  809. ]])
  810. ],
  811. [
  812. AC_DEFINE(PRId64, "$1d", [define if the platform doesn't define PRId64])
  813. AC_DEFINE(PRIo64, "$1o", [define if the platform doesn't define PRIo64])
  814. AC_DEFINE(PRIx64, "$1x", [define if the platform doesn't define PRIu64])
  815. AC_DEFINE(PRIu64, "$1u", [define if the platform doesn't define PRIx64])
  816. AC_MSG_RESULT(yes)
  817. ],
  818. [
  819. AC_MSG_RESULT(no)
  820. $2
  821. ])
  822. ])
  823. dnl
  824. dnl Checks to see if unaligned memory accesses fail
  825. dnl
  826. dnl usage:
  827. dnl
  828. dnl AC_LBL_UNALIGNED_ACCESS
  829. dnl
  830. dnl results:
  831. dnl
  832. dnl LBL_ALIGN (DEFINED)
  833. dnl
  834. AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
  835. [AC_MSG_CHECKING(if unaligned accesses fail)
  836. AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
  837. [case "$host_cpu" in
  838. #
  839. # These are CPU types where:
  840. #
  841. # the CPU faults on an unaligned access, but at least some
  842. # OSes that support that CPU catch the fault and simulate
  843. # the unaligned access (e.g., Alpha/{Digital,Tru64} UNIX) -
  844. # the simulation is slow, so we don't want to use it;
  845. #
  846. # the CPU, I infer (from the old
  847. #
  848. # XXX: should also check that they don't do weird things (like on arm)
  849. #
  850. # comment) doesn't fault on unaligned accesses, but doesn't
  851. # do a normal unaligned fetch, either (e.g., presumably, ARM);
  852. #
  853. # for whatever reason, the test program doesn't work
  854. # (this has been claimed to be the case for several of those
  855. # CPUs - I don't know what the problem is; the problem
  856. # was reported as "the test program dumps core" for SuperH,
  857. # but that's what the test program is *supposed* to do -
  858. # it dumps core before it writes anything, so the test
  859. # for an empty output file should find an empty output
  860. # file and conclude that unaligned accesses don't work).
  861. #
  862. # This run-time test won't work if you're cross-compiling, so
  863. # in order to support cross-compiling for a particular CPU,
  864. # we have to wire in the list of CPU types anyway, as far as
  865. # I know, so perhaps we should just have a set of CPUs on
  866. # which we know it doesn't work, a set of CPUs on which we
  867. # know it does work, and have the script just fail on other
  868. # cpu types and update it when such a failure occurs.
  869. #
  870. alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1)
  871. ac_cv_lbl_unaligned_fail=yes
  872. ;;
  873. *)
  874. cat >conftest.c <<EOF
  875. # include <sys/types.h>
  876. # include <sys/wait.h>
  877. # include <stdio.h>
  878. unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
  879. main() {
  880. unsigned int i;
  881. pid_t pid;
  882. int status;
  883. /* avoid "core dumped" message */
  884. pid = fork();
  885. if (pid < 0)
  886. exit(2);
  887. if (pid > 0) {
  888. /* parent */
  889. pid = waitpid(pid, &status, 0);
  890. if (pid < 0)
  891. exit(3);
  892. exit(!WIFEXITED(status));
  893. }
  894. /* child */
  895. i = *(unsigned int *)&a[[1]];
  896. printf("%d\n", i);
  897. exit(0);
  898. }
  899. EOF
  900. ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
  901. conftest.c $LIBS >/dev/null 2>&1
  902. if test ! -x conftest ; then
  903. dnl failed to compile for some reason
  904. ac_cv_lbl_unaligned_fail=yes
  905. else
  906. ./conftest >conftest.out
  907. if test ! -s conftest.out ; then
  908. ac_cv_lbl_unaligned_fail=yes
  909. else
  910. ac_cv_lbl_unaligned_fail=no
  911. fi
  912. fi
  913. rm -f -r conftest* core core.conftest
  914. ;;
  915. esac])
  916. AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
  917. if test $ac_cv_lbl_unaligned_fail = yes ; then
  918. AC_DEFINE(LBL_ALIGN,1,[if unaligned access fails])
  919. fi])
  920. dnl
  921. dnl If the file .devel exists:
  922. dnl Add some warning flags if the compiler supports them
  923. dnl If an os prototype include exists, symlink os-proto.h to it
  924. dnl
  925. dnl usage:
  926. dnl
  927. dnl AC_LBL_DEVEL(copt)
  928. dnl
  929. dnl results:
  930. dnl
  931. dnl $1 (copt appended)
  932. dnl HAVE_OS_PROTO_H (defined)
  933. dnl os-proto.h (symlinked)
  934. dnl
  935. AC_DEFUN(AC_LBL_DEVEL,
  936. [rm -f os-proto.h
  937. if test "${LBL_CFLAGS+set}" = set; then
  938. $1="$$1 ${LBL_CFLAGS}"
  939. fi
  940. if test -f .devel ; then
  941. #
  942. # Skip all the warning option stuff on some compilers.
  943. #
  944. if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
  945. AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR()
  946. AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
  947. AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
  948. AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
  949. AC_LBL_CHECK_COMPILER_OPT($1, -Wwrite-strings)
  950. AC_LBL_CHECK_COMPILER_OPT($1, -Wpointer-arith)
  951. AC_LBL_CHECK_COMPILER_OPT($1, -Wcast-qual)
  952. AC_LBL_CHECK_COMPILER_OPT($1, -Wshadow)
  953. AC_LBL_CHECK_COMPILER_OPT($1, -Wdeclaration-after-statement)
  954. AC_LBL_CHECK_COMPILER_OPT($1, -Wpedantic)
  955. AC_LBL_CHECK_COMPILER_OPT($1, -Wold-style-definition)
  956. AC_LBL_CHECK_COMPILER_OPT($1, -Wused-but-marked-unused)
  957. AC_LBL_CHECK_COMPILER_OPT($1, -W)
  958. fi
  959. AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
  960. #
  961. # We used to set -n32 for IRIX 6 when not using GCC (presumed
  962. # to mean that we're using MIPS C or MIPSpro C); it specified
  963. # the "new" faster 32-bit ABI, introduced in IRIX 6.2. I'm
  964. # not sure why that would be something to do *only* with a
  965. # .devel file; why should the ABI for which we produce code
  966. # depend on .devel?
  967. #
  968. os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
  969. name="lbl/os-$os.h"
  970. if test -f $name ; then
  971. ln -s $name os-proto.h
  972. AC_DEFINE(HAVE_OS_PROTO_H, 1,
  973. [if there's an os_proto.h for this platform, to use additional prototypes])
  974. else
  975. AC_MSG_WARN(can't find $name)
  976. fi
  977. fi])
  978. dnl
  979. dnl Improved version of AC_CHECK_LIB
  980. dnl
  981. dnl Thanks to John Hawkinson (jhawk@mit.edu)
  982. dnl
  983. dnl usage:
  984. dnl
  985. dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
  986. dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
  987. dnl
  988. dnl results:
  989. dnl
  990. dnl LIBS
  991. dnl
  992. dnl XXX - "AC_LBL_LIBRARY_NET" was redone to use "AC_SEARCH_LIBS"
  993. dnl rather than "AC_LBL_CHECK_LIB", so this isn't used any more.
  994. dnl We keep it around for reference purposes in case it's ever
  995. dnl useful in the future.
  996. dnl
  997. define(AC_LBL_CHECK_LIB,
  998. [AC_MSG_CHECKING([for $2 in -l$1])
  999. dnl Use a cache variable name containing the library, function
  1000. dnl name, and extra libraries to link with, because the test really is
  1001. dnl for library $1 defining function $2, when linked with potinal
  1002. dnl library $5, not just for library $1. Separate tests with the same
  1003. dnl $1 and different $2's or $5's may have different results.
  1004. ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
  1005. AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
  1006. [ac_save_LIBS="$LIBS"
  1007. LIBS="-l$1 $5 $LIBS"
  1008. AC_TRY_LINK(dnl
  1009. ifelse([$2], [main], , dnl Avoid conflicting decl of main.
  1010. [/* Override any gcc2 internal prototype to avoid an error. */
  1011. ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
  1012. extern "C"
  1013. #endif
  1014. ])dnl
  1015. [/* We use char because int might match the return type of a gcc2
  1016. builtin and then its argument prototype would still apply. */
  1017. char $2();
  1018. ]),
  1019. [$2()],
  1020. eval "ac_cv_lbl_lib_$ac_lib_var=yes",
  1021. eval "ac_cv_lbl_lib_$ac_lib_var=no")
  1022. LIBS="$ac_save_LIBS"
  1023. ])dnl
  1024. if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
  1025. AC_MSG_RESULT(yes)
  1026. ifelse([$3], ,
  1027. [changequote(, )dnl
  1028. ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
  1029. -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
  1030. changequote([, ])dnl
  1031. AC_DEFINE_UNQUOTED($ac_tr_lib)
  1032. LIBS="-l$1 $LIBS"
  1033. ], [$3])
  1034. else
  1035. AC_MSG_RESULT(no)
  1036. ifelse([$4], , , [$4
  1037. ])dnl
  1038. fi
  1039. ])
  1040. dnl
  1041. dnl AC_LBL_LIBRARY_NET
  1042. dnl
  1043. dnl This test is for network applications that need socket() and
  1044. dnl gethostbyname() -ish functions. Under Solaris, those applications
  1045. dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link
  1046. dnl with "-lnsl" but should *not* link with "-lsocket" because
  1047. dnl libsocket.a breaks a number of things (for instance:
  1048. dnl gethostbyname() under IRIX 5.2, and snoop sockets under most
  1049. dnl versions of IRIX).
  1050. dnl
  1051. dnl Unfortunately, many application developers are not aware of this,
  1052. dnl and mistakenly write tests that cause -lsocket to be used under
  1053. dnl IRIX. It is also easy to write tests that cause -lnsl to be used
  1054. dnl under operating systems where neither are necessary (or useful),
  1055. dnl such as SunOS 4.1.4, which uses -lnsl for TLI.
  1056. dnl
  1057. dnl This test exists so that every application developer does not test
  1058. dnl this in a different, and subtly broken fashion.
  1059. dnl It has been argued that this test should be broken up into two
  1060. dnl seperate tests, one for the resolver libraries, and one for the
  1061. dnl libraries necessary for using Sockets API. Unfortunately, the two
  1062. dnl are carefully intertwined and allowing the autoconf user to use
  1063. dnl them independantly potentially results in unfortunate ordering
  1064. dnl dependancies -- as such, such component macros would have to
  1065. dnl carefully use indirection and be aware if the other components were
  1066. dnl executed. Since other autoconf macros do not go to this trouble,
  1067. dnl and almost no applications use sockets without the resolver, this
  1068. dnl complexity has not been implemented.
  1069. dnl
  1070. dnl The check for libresolv is in case you are attempting to link
  1071. dnl statically and happen to have a libresolv.a lying around (and no
  1072. dnl libnsl.a).
  1073. dnl
  1074. AC_DEFUN(AC_LBL_LIBRARY_NET, [
  1075. # Most operating systems have gethostbyname() in the default searched
  1076. # libraries (i.e. libc):
  1077. # Some OSes (eg. Solaris) place it in libnsl
  1078. # Some strange OSes (SINIX) have it in libsocket:
  1079. AC_SEARCH_LIBS(gethostbyname, nsl socket resolv)
  1080. # Unfortunately libsocket sometimes depends on libnsl and
  1081. # AC_SEARCH_LIBS isn't up to the task of handling dependencies like this.
  1082. if test "$ac_cv_search_gethostbyname" = "no"
  1083. then
  1084. AC_CHECK_LIB(socket, gethostbyname,
  1085. LIBS="-lsocket -lnsl $LIBS", , -lnsl)
  1086. fi
  1087. AC_SEARCH_LIBS(socket, socket, ,
  1088. AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl))
  1089. # DLPI needs putmsg under HPUX so test for -lstr while we're at it
  1090. AC_SEARCH_LIBS(putmsg, str)
  1091. ])
  1092. dnl Copyright (c) 1999 WIDE Project. All rights reserved.
  1093. dnl
  1094. dnl Redistribution and use in source and binary forms, with or without
  1095. dnl modification, are permitted provided that the following conditions
  1096. dnl are met:
  1097. dnl 1. Redistributions of source code must retain the above copyright
  1098. dnl notice, this list of conditions and the following disclaimer.
  1099. dnl 2. Redistributions in binary form must reproduce the above copyright
  1100. dnl notice, this list of conditions and the following disclaimer in the
  1101. dnl documentation and/or other materials provided with the distribution.
  1102. dnl 3. Neither the name of the project nor the names of its contributors
  1103. dnl may be used to endorse or promote products derived from this software
  1104. dnl without specific prior written permission.
  1105. dnl
  1106. dnl THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  1107. dnl ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  1108. dnl IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  1109. dnl ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
  1110. dnl FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  1111. dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  1112. dnl OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  1113. dnl HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  1114. dnl LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  1115. dnl OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  1116. dnl SUCH DAMAGE.
  1117. dnl
  1118. dnl Test for __attribute__
  1119. dnl
  1120. AC_DEFUN(AC_C___ATTRIBUTE__, [
  1121. AC_MSG_CHECKING(for __attribute__)
  1122. AC_CACHE_VAL(ac_cv___attribute__, [
  1123. AC_COMPILE_IFELSE([
  1124. AC_LANG_SOURCE([[
  1125. #include <stdlib.h>
  1126. static void foo(void) __attribute__ ((noreturn));
  1127. static void
  1128. foo(void)
  1129. {
  1130. exit(1);
  1131. }
  1132. int
  1133. main(int argc, char **argv)
  1134. {
  1135. foo();
  1136. }
  1137. ]])],
  1138. ac_cv___attribute__=yes,
  1139. ac_cv___attribute__=no)])
  1140. if test "$ac_cv___attribute__" = "yes"; then
  1141. AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
  1142. else
  1143. #
  1144. # We can't use __attribute__, so we can't use __attribute__((unused)),
  1145. # so we define _U_ to an empty string.
  1146. #
  1147. V_DEFS="$V_DEFS -D_U_=\"\""
  1148. fi
  1149. AC_MSG_RESULT($ac_cv___attribute__)
  1150. ])
  1151. dnl
  1152. dnl Test whether __attribute__((unused)) can be used without warnings
  1153. dnl
  1154. AC_DEFUN(AC_C___ATTRIBUTE___UNUSED, [
  1155. AC_MSG_CHECKING([whether __attribute__((unused)) can be used without warnings])
  1156. AC_CACHE_VAL(ac_cv___attribute___unused, [
  1157. save_CFLAGS="$CFLAGS"
  1158. CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
  1159. AC_COMPILE_IFELSE([
  1160. AC_LANG_SOURCE([[
  1161. #include <stdlib.h>
  1162. #include <stdio.h>
  1163. int
  1164. main(int argc __attribute((unused)), char **argv __attribute((unused)))
  1165. {
  1166. printf("Hello, world!\n");
  1167. return 0;
  1168. }
  1169. ]])],
  1170. ac_cv___attribute___unused=yes,
  1171. ac_cv___attribute___unused=no)])
  1172. CFLAGS="$save_CFLAGS"
  1173. if test "$ac_cv___attribute___unused" = "yes"; then
  1174. V_DEFS="$V_DEFS -D_U_=\"__attribute__((unused))\""
  1175. else
  1176. V_DEFS="$V_DEFS -D_U_=\"\""
  1177. fi
  1178. AC_MSG_RESULT($ac_cv___attribute___unused)
  1179. ])
  1180. dnl
  1181. dnl Test whether __attribute__((format)) can be used without warnings
  1182. dnl
  1183. AC_DEFUN(AC_C___ATTRIBUTE___FORMAT, [
  1184. AC_MSG_CHECKING([whether __attribute__((format)) can be used without warnings])
  1185. AC_CACHE_VAL(ac_cv___attribute___format, [
  1186. save_CFLAGS="$CFLAGS"
  1187. CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
  1188. AC_COMPILE_IFELSE([
  1189. AC_LANG_SOURCE([[
  1190. #include <stdlib.h>
  1191. extern int foo(const char *fmt, ...)
  1192. __attribute__ ((format (printf, 1, 2)));
  1193. int
  1194. main(int argc, char **argv)
  1195. {
  1196. foo("%s", "test");
  1197. }
  1198. ]])],
  1199. ac_cv___attribute___format=yes,
  1200. ac_cv___attribute___format=no)])
  1201. CFLAGS="$save_CFLAGS"
  1202. if test "$ac_cv___attribute___format" = "yes"; then
  1203. AC_DEFINE(__ATTRIBUTE___FORMAT_OK, 1,
  1204. [define if your compiler allows __attribute__((format)) without a warning])
  1205. fi
  1206. AC_MSG_RESULT($ac_cv___attribute___format)
  1207. ])
  1208. dnl
  1209. dnl Test whether __attribute__((format)) can be applied to function
  1210. dnl pointers
  1211. dnl
  1212. AC_DEFUN(AC_C___ATTRIBUTE___FORMAT_FUNCTION_POINTER, [
  1213. AC_MSG_CHECKING([whether __attribute__((format)) can be applied to function pointers])
  1214. AC_CACHE_VAL(ac_cv___attribute___format_function_pointer, [
  1215. AC_COMPILE_IFELSE([
  1216. AC_LANG_SOURCE([[
  1217. #include <stdlib.h>
  1218. extern int (*foo)(const char *fmt, ...)
  1219. __attribute__ ((format (printf, 1, 2)));
  1220. int
  1221. main(int argc, char **argv)
  1222. {
  1223. (*foo)("%s", "test");
  1224. }
  1225. ]])],
  1226. ac_cv___attribute___format_function_pointer=yes,
  1227. ac_cv___attribute___format_function_pointer=no)])
  1228. if test "$ac_cv___attribute___format_function_pointer" = "yes"; then
  1229. AC_DEFINE(__ATTRIBUTE___FORMAT_OK_FOR_FUNCTION_POINTERS, 1,
  1230. [define if your compiler allows __attribute__((format)) to be applied to function pointers])
  1231. fi
  1232. AC_MSG_RESULT($ac_cv___attribute___format_function_pointer)
  1233. ])
  1234. AC_DEFUN(AC_C___ATTRIBUTE___NORETURN_FUNCTION_POINTER, [
  1235. AC_MSG_CHECKING([whether __attribute__((noreturn)) can be applied to function pointers without warnings])
  1236. AC_CACHE_VAL(ac_cv___attribute___noreturn_function_pointer, [
  1237. save_CFLAGS="$CFLAGS"
  1238. CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
  1239. AC_COMPILE_IFELSE([
  1240. AC_LANG_SOURCE([[
  1241. #include <stdlib.h>
  1242. extern int (*foo)(int i)
  1243. __attribute__ ((noreturn));
  1244. int
  1245. main(int argc, char **argv)
  1246. {
  1247. (*foo)(1);
  1248. }
  1249. ]])],
  1250. ac_cv___attribute___noreturn_function_pointer=yes,
  1251. ac_cv___attribute___noreturn_function_pointer=no)])
  1252. CFLAGS="$save_CFLAGS"
  1253. if test "$ac_cv___attribute___noreturn_function_pointer" = "yes"; then
  1254. AC_DEFINE(__ATTRIBUTE___NORETURN_OK_FOR_FUNCTION_POINTERS, 1,
  1255. [define if your compiler allows __attribute__((noreturn)) to be applied to function pointers])
  1256. fi
  1257. AC_MSG_RESULT($ac_cv___attribute___noreturn_function_pointer)
  1258. ])
  1259. AC_DEFUN(AC_LBL_SSLEAY,
  1260. [
  1261. #
  1262. # Find the last component of $libdir; it's not necessarily
  1263. # "lib" - it might be "lib64" on, for example, x86-64
  1264. # Linux systems.
  1265. #
  1266. # We assume the directory in which we're looking for
  1267. # libcrypto has a subdirectory with that as its name.
  1268. #
  1269. tmplib=`echo "$libdir" | sed 's,.*/,,'`
  1270. #
  1271. # XXX - is there a better way to check if a given library is
  1272. # in a given directory than checking each of the possible
  1273. # shared library suffixes?
  1274. #
  1275. # Are there any other suffixes we need to look for? Do we
  1276. # have to worry about ".so.{version}"?
  1277. #
  1278. # Or should we just look for "libcrypto.*"?
  1279. #
  1280. if test -d "$1/$tmplib" -a \( -f "$1/$tmplib/libcrypto.a" -o \
  1281. -f "$1/$tmplib/libcrypto.so" -o \
  1282. -f "$1/$tmplib/libcrypto.sl" -o \
  1283. -f "$1/$tmplib/libcrypto.dylib" \); then
  1284. ac_cv_ssleay_path="$1"
  1285. fi
  1286. #
  1287. # Make sure we have the headers as well.
  1288. #
  1289. if test -d "$1/include/openssl" -a -f "$1/include/openssl/des.h"; then
  1290. incdir="-I$1/include"
  1291. fi
  1292. ])