aclocal.m4 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078
  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. # Try to have the compiler default to hiding symbols,
  104. # so that only symbols explicitly exported with
  105. # PCAP_API will be visible outside (shared) libraries.
  106. #
  107. AC_LBL_CHECK_COMPILER_OPT($1, -fvisibility=hidden)
  108. else
  109. $2="$$2 -I/usr/local/include"
  110. LDFLAGS="$LDFLAGS -L/usr/local/lib"
  111. case "$host_os" in
  112. darwin*)
  113. #
  114. # This is assumed either to be GCC or clang, both
  115. # of which use -Werror to force warnings to be errors.
  116. #
  117. ac_lbl_cc_force_warning_errors=-Werror
  118. #
  119. # Try to have the compiler default to hiding symbols,
  120. # so that only symbols explicitly exported with
  121. # PCAP_API will be visible outside (shared) libraries.
  122. #
  123. AC_LBL_CHECK_COMPILER_OPT($1, -fvisibility=hidden)
  124. ;;
  125. hpux*)
  126. #
  127. # HP C, which is what we presume we're using, doesn't
  128. # exit with a non-zero exit status if we hand it an
  129. # invalid -W flag, can't be forced to do so even with
  130. # +We, and doesn't handle GCC-style -W flags, so we
  131. # don't want to try using GCC-style -W flags.
  132. #
  133. ac_lbl_cc_dont_try_gcc_dashW=yes
  134. ;;
  135. irix*)
  136. #
  137. # MIPS C, which is what we presume we're using, doesn't
  138. # necessarily exit with a non-zero exit status if we
  139. # hand it an invalid -W flag, can't be forced to do
  140. # so, and doesn't handle GCC-style -W flags, so we
  141. # don't want to try using GCC-style -W flags.
  142. #
  143. ac_lbl_cc_dont_try_gcc_dashW=yes
  144. #
  145. # It also, apparently, defaults to "char" being
  146. # unsigned, unlike most other C implementations;
  147. # I suppose we could say "signed char" whenever
  148. # we want to guarantee a signed "char", but let's
  149. # just force signed chars.
  150. #
  151. # -xansi is normally the default, but the
  152. # configure script was setting it; perhaps -cckr
  153. # was the default in the Old Days. (Then again,
  154. # that would probably be for backwards compatibility
  155. # in the days when ANSI C was Shiny and New, i.e.
  156. # 1989 and the early '90's, so maybe we can just
  157. # drop support for those compilers.)
  158. #
  159. # -g is equivalent to -g2, which turns off
  160. # optimization; we choose -g3, which generates
  161. # debugging information but doesn't turn off
  162. # optimization (even if the optimization would
  163. # cause inaccuracies in debugging).
  164. #
  165. $1="$$1 -xansi -signed -g3"
  166. ;;
  167. osf*)
  168. #
  169. # Presumed to be DEC OSF/1, Digital UNIX, or
  170. # Tru64 UNIX.
  171. #
  172. # The DEC C compiler, which is what we presume we're
  173. # using, doesn't exit with a non-zero exit status if we
  174. # hand it an invalid -W flag, can't be forced to do
  175. # so, and doesn't handle GCC-style -W flags, so we
  176. # don't want to try using GCC-style -W flags.
  177. #
  178. ac_lbl_cc_dont_try_gcc_dashW=yes
  179. #
  180. # -g is equivalent to -g2, which turns off
  181. # optimization; we choose -g3, which generates
  182. # debugging information but doesn't turn off
  183. # optimization (even if the optimization would
  184. # cause inaccuracies in debugging).
  185. #
  186. $1="$$1 -g3"
  187. ;;
  188. solaris*)
  189. #
  190. # Assumed to be Sun C, which requires -errwarn to force
  191. # warnings to be treated as errors.
  192. #
  193. ac_lbl_cc_force_warning_errors=-errwarn
  194. #
  195. # Try to have the compiler default to hiding symbols,
  196. # so that only symbols explicitly exported with
  197. # PCAP_API will be visible outside (shared) libraries.
  198. #
  199. AC_LBL_CHECK_COMPILER_OPT($1, -xldscope=hidden)
  200. ;;
  201. ultrix*)
  202. AC_MSG_CHECKING(that Ultrix $CC hacks const in prototypes)
  203. AC_CACHE_VAL(ac_cv_lbl_cc_const_proto,
  204. AC_TRY_COMPILE(
  205. [#include <sys/types.h>],
  206. [struct a { int b; };
  207. void c(const struct a *)],
  208. ac_cv_lbl_cc_const_proto=yes,
  209. ac_cv_lbl_cc_const_proto=no))
  210. AC_MSG_RESULT($ac_cv_lbl_cc_const_proto)
  211. if test $ac_cv_lbl_cc_const_proto = no ; then
  212. AC_DEFINE(const,[],
  213. [to handle Ultrix compilers that don't support const in prototypes])
  214. fi
  215. ;;
  216. esac
  217. $1="$$1 -O"
  218. fi
  219. ])
  220. dnl
  221. dnl Check whether, if you pass an unknown warning option to the
  222. dnl compiler, it fails or just prints a warning message and succeeds.
  223. dnl Set ac_lbl_unknown_warning_option_error to the appropriate flag
  224. dnl to force an error if it would otherwise just print a warning message
  225. dnl and succeed.
  226. dnl
  227. AC_DEFUN(AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR,
  228. [
  229. AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option])
  230. save_CFLAGS="$CFLAGS"
  231. CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy"
  232. AC_TRY_COMPILE(
  233. [],
  234. [return 0],
  235. [
  236. AC_MSG_RESULT([no])
  237. #
  238. # We're assuming this is clang, where
  239. # -Werror=unknown-warning-option is the appropriate
  240. # option to force the compiler to fail.
  241. #
  242. ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option"
  243. ],
  244. [
  245. AC_MSG_RESULT([yes])
  246. ])
  247. CFLAGS="$save_CFLAGS"
  248. ])
  249. dnl
  250. dnl Check whether the compiler option specified as the second argument
  251. dnl is supported by the compiler and, if so, add it to the macro
  252. dnl specified as the first argument
  253. dnl
  254. dnl If a third argument is supplied, treat it as C code to be compiled
  255. dnl with the flag in question, and the "treat warnings as errors" flag
  256. dnl set, and don't add the flag to the first argument if the compile
  257. dnl fails; this is for warning options cause problems that can't be
  258. dnl worked around. If a third argument is supplied, a fourth argument
  259. dnl should also be supplied; it's a message desribing what the test
  260. dnl program is checking.
  261. dnl
  262. AC_DEFUN(AC_LBL_CHECK_COMPILER_OPT,
  263. [
  264. AC_MSG_CHECKING([whether the compiler supports the $2 option])
  265. save_CFLAGS="$CFLAGS"
  266. if expr "x$2" : "x-W.*" >/dev/null
  267. then
  268. CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2"
  269. elif expr "x$2" : "x-f.*" >/dev/null
  270. then
  271. CFLAGS="$CFLAGS -Werror $2"
  272. elif expr "x$2" : "x-m.*" >/dev/null
  273. then
  274. CFLAGS="$CFLAGS -Werror $2"
  275. else
  276. CFLAGS="$CFLAGS $2"
  277. fi
  278. AC_TRY_COMPILE(
  279. [],
  280. [return 0],
  281. [
  282. AC_MSG_RESULT([yes])
  283. can_add_to_cflags=yes
  284. #
  285. # The compile supports this; do we have some C code for
  286. # which the warning should *not* appear?
  287. # We test the fourth argument because the third argument
  288. # could contain quotes, breaking the test.
  289. #
  290. if test "x$4" != "x"
  291. then
  292. CFLAGS="$CFLAGS $ac_lbl_cc_force_warning_errors"
  293. AC_MSG_CHECKING(whether $2 $4)
  294. AC_COMPILE_IFELSE(
  295. [AC_LANG_SOURCE($3)],
  296. [
  297. #
  298. # Not a problem.
  299. #
  300. AC_MSG_RESULT(no)
  301. ],
  302. [
  303. #
  304. # A problem.
  305. #
  306. AC_MSG_RESULT(yes)
  307. can_add_to_cflags=no
  308. ])
  309. fi
  310. CFLAGS="$save_CFLAGS"
  311. if test x"$can_add_to_cflags" = "xyes"
  312. then
  313. $1="$$1 $2"
  314. fi
  315. ],
  316. [
  317. AC_MSG_RESULT([no])
  318. CFLAGS="$save_CFLAGS"
  319. ])
  320. ])
  321. dnl
  322. dnl Check whether the compiler supports an option to generate
  323. dnl Makefile-style dependency lines
  324. dnl
  325. dnl GCC uses -M for this. Non-GCC compilers that support this
  326. dnl use a variety of flags, including but not limited to -M.
  327. dnl
  328. dnl We test whether the flag in question is supported, as older
  329. dnl versions of compilers might not support it.
  330. dnl
  331. dnl We don't try all the possible flags, just in case some flag means
  332. dnl "generate dependencies" on one compiler but means something else
  333. dnl on another compiler.
  334. dnl
  335. dnl Most compilers that support this send the output to the standard
  336. dnl output by default. IBM's XLC, however, supports -M but sends
  337. dnl the output to {sourcefile-basename}.u, and AIX has no /dev/stdout
  338. dnl to work around that, so we don't bother with XLC.
  339. dnl
  340. AC_DEFUN(AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT,
  341. [
  342. AC_MSG_CHECKING([whether the compiler supports generating dependencies])
  343. if test "$GCC" = yes ; then
  344. #
  345. # GCC, or a compiler deemed to be GCC by AC_PROG_CC (even
  346. # though it's not); we assume that, in this case, the flag
  347. # would be -M.
  348. #
  349. ac_lbl_dependency_flag="-M"
  350. else
  351. #
  352. # Not GCC or a compiler deemed to be GCC; what platform is
  353. # this? (We're assuming that if the compiler isn't GCC
  354. # it's the compiler from the vendor of the OS; that won't
  355. # necessarily be true for x86 platforms, where it might be
  356. # the Intel C compiler.)
  357. #
  358. case "$host_os" in
  359. irix*|osf*|darwin*)
  360. #
  361. # MIPS C for IRIX, DEC C, and clang all use -M.
  362. #
  363. ac_lbl_dependency_flag="-M"
  364. ;;
  365. solaris*)
  366. #
  367. # Sun C uses -xM.
  368. #
  369. ac_lbl_dependency_flag="-xM"
  370. ;;
  371. hpux*)
  372. #
  373. # HP's older C compilers don't support this.
  374. # HP's newer C compilers support this with
  375. # either +M or +Make; the older compilers
  376. # interpret +M as something completely
  377. # different, so we use +Make so we don't
  378. # think it works with the older compilers.
  379. #
  380. ac_lbl_dependency_flag="+Make"
  381. ;;
  382. *)
  383. #
  384. # Not one of the above; assume no support for
  385. # generating dependencies.
  386. #
  387. ac_lbl_dependency_flag=""
  388. ;;
  389. esac
  390. fi
  391. #
  392. # Is ac_lbl_dependency_flag defined and, if so, does the compiler
  393. # complain about it?
  394. #
  395. # Note: clang doesn't seem to exit with an error status when handed
  396. # an unknown non-warning error, even if you pass it
  397. # -Werror=unknown-warning-option. However, it always supports
  398. # -M, so the fact that this test always succeeds with clang
  399. # isn't an issue.
  400. #
  401. if test ! -z "$ac_lbl_dependency_flag"; then
  402. AC_LANG_CONFTEST(
  403. [AC_LANG_SOURCE([[int main(void) { return 0; }]])])
  404. if AC_RUN_LOG([eval "$CC $ac_lbl_dependency_flag conftest.c >/dev/null 2>&1"]); then
  405. AC_MSG_RESULT([yes, with $ac_lbl_dependency_flag])
  406. DEPENDENCY_CFLAG="$ac_lbl_dependency_flag"
  407. MKDEP='${srcdir}/mkdep'
  408. else
  409. AC_MSG_RESULT([no])
  410. #
  411. # We can't run mkdep, so have "make depend" do
  412. # nothing.
  413. #
  414. MKDEP='${srcdir}/nomkdep'
  415. fi
  416. rm -rf conftest*
  417. else
  418. AC_MSG_RESULT([no])
  419. #
  420. # We can't run mkdep, so have "make depend" do
  421. # nothing.
  422. #
  423. MKDEP='${srcdir}/nomkdep'
  424. fi
  425. AC_SUBST(DEPENDENCY_CFLAG)
  426. AC_SUBST(MKDEP)
  427. ])
  428. dnl
  429. dnl Determine what options are needed to build a shared library
  430. dnl
  431. dnl usage:
  432. dnl
  433. dnl AC_LBL_SHLIBS_INIT
  434. dnl
  435. dnl results:
  436. dnl
  437. dnl V_SHLIB_CCOPT (modified to build position-independent code)
  438. dnl V_SHLIB_CMD
  439. dnl V_SHLIB_OPT
  440. dnl V_SONAME_OPT
  441. dnl V_RPATH_OPT
  442. dnl
  443. AC_DEFUN(AC_LBL_SHLIBS_INIT,
  444. [AC_PREREQ(2.50)
  445. if test "$GCC" = yes ; then
  446. #
  447. # On platforms where we build a shared library:
  448. #
  449. # add options to generate position-independent code,
  450. # if necessary (it's the default in AIX and Darwin/macOS);
  451. #
  452. # define option to set the soname of the shared library,
  453. # if the OS supports that;
  454. #
  455. # add options to specify, at link time, a directory to
  456. # add to the run-time search path, if that's necessary.
  457. #
  458. V_SHLIB_CMD="\$(CC)"
  459. V_SHLIB_OPT="-shared"
  460. case "$host_os" in
  461. aix*)
  462. ;;
  463. freebsd*|netbsd*|openbsd*|dragonfly*|linux*|osf*)
  464. #
  465. # Platforms where the linker is the GNU linker
  466. # or accepts command-line arguments like
  467. # those the GNU linker accepts.
  468. #
  469. # Some instruction sets require -fPIC on some
  470. # operating systems. Check for them. If you
  471. # have a combination that requires it, add it
  472. # here.
  473. #
  474. PIC_OPT=-fpic
  475. case "$host_cpu" in
  476. sparc64*)
  477. case "$host_os" in
  478. freebsd*|openbsd*)
  479. PIC_OPT=-fPIC
  480. ;;
  481. esac
  482. ;;
  483. esac
  484. V_SHLIB_CCOPT="$V_SHLIB_CCOPT $PIC_OPT"
  485. V_SONAME_OPT="-Wl,-soname,"
  486. V_RPATH_OPT="-Wl,-rpath,"
  487. ;;
  488. hpux*)
  489. V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
  490. #
  491. # XXX - this assumes GCC is using the HP linker,
  492. # rather than the GNU linker, and that the "+h"
  493. # option is used on all HP-UX platforms, both .sl
  494. # and .so.
  495. #
  496. V_SONAME_OPT="-Wl,+h,"
  497. #
  498. # By default, directories specifed with -L
  499. # are added to the run-time search path, so
  500. # we don't add them in pcap-config.
  501. #
  502. ;;
  503. solaris*)
  504. V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
  505. #
  506. # XXX - this assumes GCC is using the Sun linker,
  507. # rather than the GNU linker.
  508. #
  509. V_SONAME_OPT="-Wl,-h,"
  510. V_RPATH_OPT="-Wl,-R,"
  511. ;;
  512. esac
  513. else
  514. #
  515. # Set the appropriate compiler flags and, on platforms
  516. # where we build a shared library:
  517. #
  518. # add options to generate position-independent code,
  519. # if necessary (it's the default in Darwin/macOS);
  520. #
  521. # if we generate ".so" shared libraries, define the
  522. # appropriate options for building the shared library;
  523. #
  524. # add options to specify, at link time, a directory to
  525. # add to the run-time search path, if that's necessary.
  526. #
  527. # Note: spaces after V_SONAME_OPT are significant; on
  528. # some platforms the soname is passed with a GCC-like
  529. # "-Wl,-soname,{soname}" option, with the soname part
  530. # of the option, while on other platforms the C compiler
  531. # driver takes it as a regular option with the soname
  532. # following the option. The same applies to V_RPATH_OPT.
  533. #
  534. case "$host_os" in
  535. aix*)
  536. V_SHLIB_CMD="\$(CC)"
  537. V_SHLIB_OPT="-G -bnoentry -bexpall"
  538. ;;
  539. freebsd*|netbsd*|openbsd*|dragonfly*|linux*)
  540. #
  541. # "cc" is GCC.
  542. #
  543. V_SHLIB_CCOPT="$V_SHLIB_CCOPT -fpic"
  544. V_SHLIB_CMD="\$(CC)"
  545. V_SHLIB_OPT="-shared"
  546. V_SONAME_OPT="-Wl,-soname,"
  547. V_RPATH_OPT="-Wl,-rpath,"
  548. ;;
  549. hpux*)
  550. V_SHLIB_CCOPT="$V_SHLIB_CCOPT +z"
  551. V_SHLIB_CMD="\$(LD)"
  552. V_SHLIB_OPT="-b"
  553. V_SONAME_OPT="+h "
  554. #
  555. # By default, directories specifed with -L
  556. # are added to the run-time search path, so
  557. # we don't add them in pcap-config.
  558. #
  559. ;;
  560. osf*)
  561. #
  562. # Presumed to be DEC OSF/1, Digital UNIX, or
  563. # Tru64 UNIX.
  564. #
  565. V_SHLIB_CMD="\$(CC)"
  566. V_SHLIB_OPT="-shared"
  567. V_SONAME_OPT="-soname "
  568. V_RPATH_OPT="-rpath "
  569. ;;
  570. solaris*)
  571. V_SHLIB_CCOPT="$V_SHLIB_CCOPT -Kpic"
  572. V_SHLIB_CMD="\$(CC)"
  573. V_SHLIB_OPT="-G"
  574. V_SONAME_OPT="-h "
  575. V_RPATH_OPT="-R"
  576. ;;
  577. esac
  578. fi
  579. ])
  580. #
  581. # Try compiling a sample of the type of code that appears in
  582. # gencode.c with "inline", "__inline__", and "__inline".
  583. #
  584. # Autoconf's AC_C_INLINE, at least in autoconf 2.13, isn't good enough,
  585. # as it just tests whether a function returning "int" can be inlined;
  586. # at least some versions of HP's C compiler can inline that, but can't
  587. # inline a function that returns a struct pointer.
  588. #
  589. # Make sure we use the V_CCOPT flags, because some of those might
  590. # disable inlining.
  591. #
  592. AC_DEFUN(AC_LBL_C_INLINE,
  593. [AC_MSG_CHECKING(for inline)
  594. save_CFLAGS="$CFLAGS"
  595. CFLAGS="$V_CCOPT"
  596. AC_CACHE_VAL(ac_cv_lbl_inline, [
  597. ac_cv_lbl_inline=""
  598. ac_lbl_cc_inline=no
  599. for ac_lbl_inline in inline __inline__ __inline
  600. do
  601. AC_TRY_COMPILE(
  602. [#define inline $ac_lbl_inline
  603. static inline struct iltest *foo(void);
  604. struct iltest {
  605. int iltest1;
  606. int iltest2;
  607. };
  608. static inline struct iltest *
  609. foo()
  610. {
  611. static struct iltest xxx;
  612. return &xxx;
  613. }],,ac_lbl_cc_inline=yes,)
  614. if test "$ac_lbl_cc_inline" = yes ; then
  615. break;
  616. fi
  617. done
  618. if test "$ac_lbl_cc_inline" = yes ; then
  619. ac_cv_lbl_inline=$ac_lbl_inline
  620. fi])
  621. CFLAGS="$save_CFLAGS"
  622. if test ! -z "$ac_cv_lbl_inline" ; then
  623. AC_MSG_RESULT($ac_cv_lbl_inline)
  624. else
  625. AC_MSG_RESULT(no)
  626. fi
  627. AC_DEFINE_UNQUOTED(inline, $ac_cv_lbl_inline, [Define as token for inline if inlining supported])])
  628. dnl
  629. dnl If using gcc, make sure we have ANSI ioctl definitions
  630. dnl
  631. dnl usage:
  632. dnl
  633. dnl AC_LBL_FIXINCLUDES
  634. dnl
  635. AC_DEFUN(AC_LBL_FIXINCLUDES,
  636. [if test "$GCC" = yes ; then
  637. AC_MSG_CHECKING(for ANSI ioctl definitions)
  638. AC_CACHE_VAL(ac_cv_lbl_gcc_fixincludes,
  639. AC_TRY_COMPILE(
  640. [/*
  641. * This generates a "duplicate case value" when fixincludes
  642. * has not be run.
  643. */
  644. # include <sys/types.h>
  645. # include <sys/time.h>
  646. # include <sys/ioctl.h>
  647. # ifdef HAVE_SYS_IOCCOM_H
  648. # include <sys/ioccom.h>
  649. # endif],
  650. [switch (0) {
  651. case _IO('A', 1):;
  652. case _IO('B', 1):;
  653. }],
  654. ac_cv_lbl_gcc_fixincludes=yes,
  655. ac_cv_lbl_gcc_fixincludes=no))
  656. AC_MSG_RESULT($ac_cv_lbl_gcc_fixincludes)
  657. if test $ac_cv_lbl_gcc_fixincludes = no ; then
  658. # Don't cache failure
  659. unset ac_cv_lbl_gcc_fixincludes
  660. AC_MSG_ERROR(see the INSTALL for more info)
  661. fi
  662. fi])
  663. dnl
  664. dnl Checks to see if union wait is used with WEXITSTATUS()
  665. dnl
  666. dnl usage:
  667. dnl
  668. dnl AC_LBL_UNION_WAIT
  669. dnl
  670. dnl results:
  671. dnl
  672. dnl DECLWAITSTATUS (defined)
  673. dnl
  674. AC_DEFUN(AC_LBL_UNION_WAIT,
  675. [AC_MSG_CHECKING(if union wait is used)
  676. AC_CACHE_VAL(ac_cv_lbl_union_wait,
  677. AC_TRY_COMPILE([
  678. # include <sys/types.h>
  679. # include <sys/wait.h>],
  680. [int status;
  681. u_int i = WEXITSTATUS(status);
  682. u_int j = waitpid(0, &status, 0);],
  683. ac_cv_lbl_union_wait=no,
  684. ac_cv_lbl_union_wait=yes))
  685. AC_MSG_RESULT($ac_cv_lbl_union_wait)
  686. if test $ac_cv_lbl_union_wait = yes ; then
  687. AC_DEFINE(DECLWAITSTATUS,union wait,[type for wait])
  688. else
  689. AC_DEFINE(DECLWAITSTATUS,int,[type for wait])
  690. fi])
  691. dnl
  692. dnl Checks to see if -R is used
  693. dnl
  694. dnl usage:
  695. dnl
  696. dnl AC_LBL_HAVE_RUN_PATH
  697. dnl
  698. dnl results:
  699. dnl
  700. dnl ac_cv_lbl_have_run_path (yes or no)
  701. dnl
  702. AC_DEFUN(AC_LBL_HAVE_RUN_PATH,
  703. [AC_MSG_CHECKING(for ${CC-cc} -R)
  704. AC_CACHE_VAL(ac_cv_lbl_have_run_path,
  705. [echo 'main(){}' > conftest.c
  706. ${CC-cc} -o conftest conftest.c -R/a1/b2/c3 >conftest.out 2>&1
  707. if test ! -s conftest.out ; then
  708. ac_cv_lbl_have_run_path=yes
  709. else
  710. ac_cv_lbl_have_run_path=no
  711. fi
  712. rm -f -r conftest*])
  713. AC_MSG_RESULT($ac_cv_lbl_have_run_path)
  714. ])
  715. dnl
  716. dnl Checks to see if unaligned memory accesses fail
  717. dnl
  718. dnl usage:
  719. dnl
  720. dnl AC_LBL_UNALIGNED_ACCESS
  721. dnl
  722. dnl results:
  723. dnl
  724. dnl LBL_ALIGN (DEFINED)
  725. dnl
  726. AC_DEFUN(AC_LBL_UNALIGNED_ACCESS,
  727. [AC_MSG_CHECKING(if unaligned accesses fail)
  728. AC_CACHE_VAL(ac_cv_lbl_unaligned_fail,
  729. [case "$host_cpu" in
  730. #
  731. # These are CPU types where:
  732. #
  733. # the CPU faults on an unaligned access, but at least some
  734. # OSes that support that CPU catch the fault and simulate
  735. # the unaligned access (e.g., Alpha/{Digital,Tru64} UNIX) -
  736. # the simulation is slow, so we don't want to use it;
  737. #
  738. # the CPU, I infer (from the old
  739. #
  740. # XXX: should also check that they don't do weird things (like on arm)
  741. #
  742. # comment) doesn't fault on unaligned accesses, but doesn't
  743. # do a normal unaligned fetch, either (e.g., presumably, ARM);
  744. #
  745. # for whatever reason, the test program doesn't work
  746. # (this has been claimed to be the case for several of those
  747. # CPUs - I don't know what the problem is; the problem
  748. # was reported as "the test program dumps core" for SuperH,
  749. # but that's what the test program is *supposed* to do -
  750. # it dumps core before it writes anything, so the test
  751. # for an empty output file should find an empty output
  752. # file and conclude that unaligned accesses don't work).
  753. #
  754. # This run-time test won't work if you're cross-compiling, so
  755. # in order to support cross-compiling for a particular CPU,
  756. # we have to wire in the list of CPU types anyway, as far as
  757. # I know, so perhaps we should just have a set of CPUs on
  758. # which we know it doesn't work, a set of CPUs on which we
  759. # know it does work, and have the script just fail on other
  760. # cpu types and update it when such a failure occurs.
  761. #
  762. alpha*|arm*|bfin*|hp*|mips*|sh*|sparc*|ia64|nv1)
  763. ac_cv_lbl_unaligned_fail=yes
  764. ;;
  765. *)
  766. cat >conftest.c <<EOF
  767. # include <sys/types.h>
  768. # include <sys/wait.h>
  769. # include <stdio.h>
  770. unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
  771. main() {
  772. unsigned int i;
  773. pid_t pid;
  774. int status;
  775. /* avoid "core dumped" message */
  776. pid = fork();
  777. if (pid < 0)
  778. exit(2);
  779. if (pid > 0) {
  780. /* parent */
  781. pid = waitpid(pid, &status, 0);
  782. if (pid < 0)
  783. exit(3);
  784. exit(!WIFEXITED(status));
  785. }
  786. /* child */
  787. i = *(unsigned int *)&a[[1]];
  788. printf("%d\n", i);
  789. exit(0);
  790. }
  791. EOF
  792. ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
  793. conftest.c $LIBS >/dev/null 2>&1
  794. if test ! -x conftest ; then
  795. dnl failed to compile for some reason
  796. ac_cv_lbl_unaligned_fail=yes
  797. else
  798. ./conftest >conftest.out
  799. if test ! -s conftest.out ; then
  800. ac_cv_lbl_unaligned_fail=yes
  801. else
  802. ac_cv_lbl_unaligned_fail=no
  803. fi
  804. fi
  805. rm -f -r conftest* core core.conftest
  806. ;;
  807. esac])
  808. AC_MSG_RESULT($ac_cv_lbl_unaligned_fail)
  809. if test $ac_cv_lbl_unaligned_fail = yes ; then
  810. AC_DEFINE(LBL_ALIGN,1,[if unaligned access fails])
  811. fi])
  812. dnl
  813. dnl If the file .devel exists:
  814. dnl Add some warning flags if the compiler supports them
  815. dnl If an os prototype include exists, symlink os-proto.h to it
  816. dnl
  817. dnl usage:
  818. dnl
  819. dnl AC_LBL_DEVEL(copt)
  820. dnl
  821. dnl results:
  822. dnl
  823. dnl $1 (copt appended)
  824. dnl HAVE_OS_PROTO_H (defined)
  825. dnl os-proto.h (symlinked)
  826. dnl
  827. AC_DEFUN(AC_LBL_DEVEL,
  828. [rm -f os-proto.h
  829. if test "${LBL_CFLAGS+set}" = set; then
  830. $1="$$1 ${LBL_CFLAGS}"
  831. fi
  832. if test -f .devel ; then
  833. #
  834. # Skip all the warning option stuff on some compilers.
  835. #
  836. if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then
  837. AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR()
  838. AC_LBL_CHECK_COMPILER_OPT($1, -Wall)
  839. AC_LBL_CHECK_COMPILER_OPT($1, -Wsign-compare)
  840. AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-prototypes)
  841. AC_LBL_CHECK_COMPILER_OPT($1, -Wstrict-prototypes)
  842. AC_LBL_CHECK_COMPILER_OPT($1, -Wshadow)
  843. AC_LBL_CHECK_COMPILER_OPT($1, -Wdeclaration-after-statement)
  844. AC_LBL_CHECK_COMPILER_OPT($1, -Wused-but-marked-unused)
  845. AC_LBL_CHECK_COMPILER_OPT($1, -Wdocumentation)
  846. AC_LBL_CHECK_COMPILER_OPT($1, -Wcomma)
  847. AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-noreturn)
  848. # Warns about safeguards added in case the enums are
  849. # extended
  850. # AC_LBL_CHECK_COMPILER_OPT($1, -Wcovered-switch-default)
  851. AC_LBL_CHECK_COMPILER_OPT($1, -Wmissing-variable-declarations)
  852. AC_LBL_CHECK_COMPILER_OPT($1, -Wunused-parameter)
  853. AC_LBL_CHECK_COMPILER_OPT($1, -Wformat-nonliteral)
  854. #
  855. # This can cause problems with ntohs(), ntohl(),
  856. # htons(), and htonl() on some platforms, such
  857. # as OpenBSD 6.3 with Clang 5.0.1. I guess the
  858. # problem is that the macro that ultimately does
  859. # the byte-swapping involves a conditional
  860. # expression that tests whether the value being
  861. # swapped is a compile-time constant or not,
  862. # using __builtin_constant_p(), and, depending
  863. # on whether it is, does a compile-time swap or
  864. # a run-time swap; perhaps the compiler always
  865. # considers one of the two results of the
  866. # conditional expressin is never evaluated,
  867. # because the conditional check is done at
  868. # compile time, and thus always says "that
  869. # expression is never executed".
  870. #
  871. # (Perhaps there should be a way of flagging
  872. # an expression that you *want* evaluated at
  873. # compile time, so that the compiler 1) warns
  874. # if it *can't* be evaluated at compile time
  875. # and 2) *doesn't* warn that the true or false
  876. # branch will never be reached.)
  877. #
  878. AC_LBL_CHECK_COMPILER_OPT($1, -Wunreachable-code,
  879. [
  880. #include <arpa/inet.h>
  881. unsigned short
  882. testme(unsigned short a)
  883. {
  884. return ntohs(a);
  885. }
  886. ],
  887. [generates warnings from ntohs()])
  888. fi
  889. AC_LBL_CHECK_DEPENDENCY_GENERATION_OPT()
  890. #
  891. # We used to set -n32 for IRIX 6 when not using GCC (presumed
  892. # to mean that we're using MIPS C or MIPSpro C); it specified
  893. # the "new" faster 32-bit ABI, introduced in IRIX 6.2. I'm
  894. # not sure why that would be something to do *only* with a
  895. # .devel file; why should the ABI for which we produce code
  896. # depend on .devel?
  897. #
  898. os=`echo $host_os | sed -e 's/\([[0-9]][[0-9]]*\)[[^0-9]].*$/\1/'`
  899. name="lbl/os-$os.h"
  900. if test -f $name ; then
  901. ln -s $name os-proto.h
  902. AC_DEFINE(HAVE_OS_PROTO_H, 1,
  903. [if there's an os_proto.h for this platform, to use additional prototypes])
  904. else
  905. AC_MSG_WARN(can't find $name)
  906. fi
  907. fi])
  908. dnl
  909. dnl Improved version of AC_CHECK_LIB
  910. dnl
  911. dnl Thanks to John Hawkinson (jhawk@mit.edu)
  912. dnl
  913. dnl usage:
  914. dnl
  915. dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
  916. dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
  917. dnl
  918. dnl results:
  919. dnl
  920. dnl LIBS
  921. dnl
  922. dnl XXX - "AC_LBL_LIBRARY_NET" was redone to use "AC_SEARCH_LIBS"
  923. dnl rather than "AC_LBL_CHECK_LIB", so this isn't used any more.
  924. dnl We keep it around for reference purposes in case it's ever
  925. dnl useful in the future.
  926. dnl
  927. define(AC_LBL_CHECK_LIB,
  928. [AC_MSG_CHECKING([for $2 in -l$1])
  929. dnl Use a cache variable name containing the library, function
  930. dnl name, and extra libraries to link with, because the test really is
  931. dnl for library $1 defining function $2, when linked with potinal
  932. dnl library $5, not just for library $1. Separate tests with the same
  933. dnl $1 and different $2's or $5's may have different results.
  934. ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
  935. AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
  936. [ac_save_LIBS="$LIBS"
  937. LIBS="-l$1 $5 $LIBS"
  938. AC_TRY_LINK(dnl
  939. ifelse([$2], [main], , dnl Avoid conflicting decl of main.
  940. [/* Override any gcc2 internal prototype to avoid an error. */
  941. ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
  942. extern "C"
  943. #endif
  944. ])dnl
  945. [/* We use char because int might match the return type of a gcc2
  946. builtin and then its argument prototype would still apply. */
  947. char $2();
  948. ]),
  949. [$2()],
  950. eval "ac_cv_lbl_lib_$ac_lib_var=yes",
  951. eval "ac_cv_lbl_lib_$ac_lib_var=no")
  952. LIBS="$ac_save_LIBS"
  953. ])dnl
  954. if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
  955. AC_MSG_RESULT(yes)
  956. ifelse([$3], ,
  957. [changequote(, )dnl
  958. ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
  959. -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
  960. changequote([, ])dnl
  961. AC_DEFINE_UNQUOTED($ac_tr_lib)
  962. LIBS="-l$1 $LIBS"
  963. ], [$3])
  964. else
  965. AC_MSG_RESULT(no)
  966. ifelse([$4], , , [$4
  967. ])dnl
  968. fi
  969. ])
  970. dnl
  971. dnl AC_LBL_LIBRARY_NET
  972. dnl
  973. dnl This test is for network applications that need socket functions and
  974. dnl getaddrinfo()/getnameinfo()-ish functions. We now require
  975. dnl getaddrinfo() and getnameinfo(). We also prefer versions of
  976. dnl recvmsg() that conform to the Single UNIX Specification, so that we
  977. dnl can check whether a datagram received with recvmsg() was truncated
  978. dnl when received due to the buffer being too small.
  979. dnl
  980. dnl On most operating systems, they're available in the system library.
  981. dnl
  982. dnl Under Solaris, we need to link with libsocket and libnsl to get
  983. dnl getaddrinfo() and getnameinfo() and, if we have libxnet, we need to
  984. dnl link with libxnet before libsocket to get a version of recvmsg()
  985. dnl that conforms to the Single UNIX Specification.
  986. dnl
  987. dnl We use getaddrinfo() because we want a portable thread-safe way
  988. dnl of getting information for a host name or port; there exist _r
  989. dnl versions of gethostbyname() and getservbyname() on some platforms,
  990. dnl but not on all platforms.
  991. dnl
  992. AC_DEFUN(AC_LBL_LIBRARY_NET, [
  993. #
  994. # Most operating systems have getaddrinfo() in the default searched
  995. # libraries (i.e. libc). Check there first.
  996. #
  997. AC_CHECK_FUNC(getaddrinfo,,
  998. [
  999. #
  1000. # Not found in the standard system libraries.
  1001. # Try libsocket, which requires libnsl.
  1002. #
  1003. AC_CHECK_LIB(socket, getaddrinfo,
  1004. [
  1005. #
  1006. # OK, we found it in libsocket.
  1007. #
  1008. LIBS="-lsocket -lnsl $LIBS"
  1009. ],
  1010. [
  1011. #
  1012. # We didn't find it.
  1013. #
  1014. AC_MSG_ERROR([getaddrinfo is required, but wasn't found])
  1015. ], -lnsl)
  1016. #
  1017. # OK, do we have recvmsg() in libxnet?
  1018. # We also link with libsocket and libnsl.
  1019. #
  1020. AC_CHECK_LIB(xnet, recvmsg,
  1021. [
  1022. #
  1023. # Yes - link with it as well.
  1024. #
  1025. LIBS="-lxnet $LIBS"
  1026. ], , -lsocket -lnsl)
  1027. ])
  1028. # DLPI needs putmsg under HPUX so test for -lstr while we're at it
  1029. AC_SEARCH_LIBS(putmsg, str)
  1030. ])