Commit Graph

170 Commits

Author SHA1 Message Date
Francois-Xavier Le Bail
54974c98c5 autoconf: Add some warning flags for clang 13 or newer
-Wnull-pointer-subtraction
-Wunused-but-set-parameter
-Wunused-but-set-variable
2023-07-28 15:05:18 +02:00
Denis Ovsienko
f2272cbe83 Autoconf: Update a stale comment in aclocal.m4. [skip ci] 2023-03-27 00:48:33 +01:00
Denis Ovsienko
58940573f8 Autoconf: Fix --static-pcap-only test on Solaris 10. [skip appveyor]
On Solaris 10 /usr/bin/grep does not implement the -q flag:

checking for pcap-config... ../libpcap/pcap-config
grep: illegal option -- q
Usage: grep -hblcnsviw pattern file . . .
checking for pcap_loop... yes

Follow recommendation of the "Limitations of Usual Tools" section of GNU
Autoconf manual and use output redirection to fix it:

checking for pcap-config... ../libpcap/pcap-config
checking for pcap_loop... yes
2023-03-26 21:50:22 +01:00
Guy Harris
9c3f8381e1 configure: add -fPIC to CFLAGS, not V_CCOPT, on Haiku.
THat forces *all* uses of the C compiler, whether it's being used in
configure-script tests or used to compile tcpdump, to gave -fPIC, which
is necessary on Haiku in order for linking to work.  Otherwise,
configure script tests that involve linking will fail.
2023-02-13 00:28:09 -08:00
Denis Ovsienko
04c3be6a31 Autoconf: Retire Ultrix-specific workarounds. [skip appveyor]
(same as in tcpslice)

This eliminates one more warning from Autoconf 2.71:

configure.ac:31: warning: The macro `AC_TRY_COMPILE' is obsolete.
2023-02-12 14:42:24 +00:00
Guy Harris
7659491e52 configure: don't use egrep, use $EGREP.
POSIX does not require that a system support egrep; it requires that it
support grep -E.  In AC_LBL_LIBPCAP, use AC_PROG_EGREP to check for a
command that supports egrep-style expressions, and use $EGREP rather
than egrep in subsequent commands.

This squelches warnings on platforms where egrep prints a warning
suggesting that grep -E be used instead.
2023-02-12 02:23:18 -08:00
Guy Harris
64f81903ba configure: fix build with Clang on Haiku. 2023-02-12 00:35:48 -08:00
Denis Ovsienko
80ec01ab2c Autoconf: Refine reporting of os-proto.h. [skip appveyor]
configure: WARNING: can't find lbl/os-darwin22.h
configure: WARNING: can't find lbl/os-freebsd13.h
configure: WARNING: can't find lbl/os-linux-gnu.h
configure: WARNING: can't find lbl/os-netbsd9.h
configure: WARNING: can't find lbl/os-openbsd7.h

It is not clear why the os-proto.h symlink management logic is
conditional on the .devel file, but it is clear that nowadays supported
platforms tend not to need a custom header file.  Thus absence of the
file should not generate a warning, also it would be useful to note its
presence.  With this in mind, convert the warning into a template
message:

(config.guess prints "x86_64-pc-linux-gnu" on a Linux PC.)
checking whether to use an os-proto.h header... no

(config.guess prints "sparc-sun-solaris2.10" on a Solaris 10 host.)
checking whether to use an os-proto.h header... yes, at
  "lbl/os-solaris2.h"
2023-02-11 23:36:14 +00:00
Denis Ovsienko
4729260445 Autoconf: Do not try shlicc2 on BSD/OS. [skip ci]
(same as in tcpslice and libpcap)
2023-02-11 16:53:04 +00:00
Denis Ovsienko
a5fe56ffd0 autoconf: Retire AC_LBL_C_INLINE. [skip appveyor]
In 2002 this macro implemented a workaround for HP C compiler because
the latter did not work with the implementation of AC_C_INLINE in
Autoconf 2.13 (see commit b1263c6).  Since then the required kind of
inline very likely became available in every supported compiler of every
supported OS, but just in case there is still an exception, use
AC_C_INLINE from Autoconf 2.69 (or later) and trust it to work right.
In other words, if the original problem still exists, this will have to
be proven.

This squelches one more warning from Autoconf 2.71:

configure.ac:32: warning: The macro `AC_TRY_COMPILE' is obsolete.
2023-02-08 23:35:39 +00:00
Denis Ovsienko
29d035a0fd autoconf: Lose AC_LBL_CHECK_LIB. [skip ci]
This macro has been unused since commit d57c77a in 2001.
2023-02-08 22:54:23 +00:00
Denis Ovsienko
9fad3e6358 autoconf: Lose AC_LBL_CHECK_64BIT_FORMAT. [skip ci]
This macro has been unused since commit 14c81f0 in 2017.
2023-01-31 16:15:42 +00:00
Denis Ovsienko
43670fb635 Lose LBL_LIBS and various pfopen() entourage.
tcpdump does not call pfopen().
2023-01-24 08:57:11 +00:00
Denis Ovsienko
7cc28450d9 Reduce aclocal.m4 a little bit more. [skip ci]
Remove a copyright boilerplate that stood for IPv6 macros added via
commit c9d84d1 in 1999 and removed via commit 11f73ad in 2015.  Remove
AC_LBL_SSLEAY, which is unused and obsolete.  This change does not
result in any changes in any other files.
2023-01-20 19:35:04 +00:00
Denis Ovsienko
f7f6d6ff5f Remove some unused declarations from aclocal.m4. [skip ci]
AC_LBL_FIXINCLUDES, AC_LBL_UNION_WAIT and AC_LBL_HAVE_RUN_PATH have no
purpose in this source tree.  AC_LBL_SHLIBS_INIT does not exist.  This
change does not introduce meaningful changes in any other files.
2023-01-19 21:26:39 +00:00
Denis Ovsienko
cee234c5e5 Spell INSTALL.md in Autoconf messages. [skip ci] 2023-01-17 22:57:31 +00:00
Jerome Duval
13b7faac2c autoconf: search for gethostbyaddr() in libnetwork
This is needed for building on Haiku.
2023-01-14 13:22:31 -08:00
Guy Harris
b1ccc20ccc configure: check for gethostbyaddr(), not gethostbyname().
We use gethostbyaddr() to translate IP addresses in packets to names; we
don't use gethostbyname() to translate names to IP addresses (libpcap
does the latter when compiling filters, so we leave that up to it, and
nothing's left for us to do).

This probably has the same effect as checking for gethostbyname(), but
it makes it a bit clearer why we'd check for it.
2023-01-14 03:22:44 -08:00
Guy Harris
2a6eaf16e1 configure: use pcap-config --static-pcap-only if available.
If we're linking with a libpcap in ../libpcap*, it's static, but we only
need to link with the libraries on wich it immediately depends, we don't
need to link with the libraries on which those libraries depend, etc..

So, if ../libpcap*/pcap-config supports --static-pcap-only, use that.
2022-09-30 16:29:34 -07:00
Francois-Xavier Le Bail
7d2bc7fcb5 Fix some typos
[skip ci]
2022-07-04 14:03:15 +02:00
Denis Ovsienko
af98bb4776 Convert CONTRIBUTING to Markdown. [skip ci] 2022-06-09 10:16:26 +01:00
Guy Harris
c39d40a767 On Solaris, for 64-bit builds, use the 64-bit pcap-config.
There are two versions of pcap-config supplied on Solaris (or, at least,
on 64-bit Solaris) - a version that has the right --libs output to find
the 32-bit libraries and a version that has the right --libs output to
find the 64-bit libraries.

Try to figure out whether we're doing a 32-bit or 64-bit build (based on
the pointer size) and, for 64-bit builds, run the 64-bit version of
pcap-config.
2021-08-08 00:36:42 -07:00
Guy Harris
fc240c64fb configure: special-case macOS /usr/bin/pcap-config as we do in CMake.
macOS's /usr/bin/pcap-config is incorrectly generated - pcap-config
--cflags includes -I/usr/local/include and pcap-config --libs includes
-L/usr/local/lib, even though it's the pcap-config file for the libpcap
that comes with the OS and should omit those.
2021-08-03 12:58:34 -07:00
Guy Harris
a917017bc0 configure: use AC_COMPILE_IFELSE() and AC_LANG_SOURCE() for testing flags.
That lets us completely control the program that's compiled with the
compiler flag we're testing, so we can make it a minimal program that
uses only prototype declarations and that therefore won't generate
warnings with some -W flags, e.g. -Wold-style-definition, and thus won't
falsely report those flags as unsupported.
2021-07-25 03:02:54 -07:00
Guy Harris
95ae3ed835 configure: use ac_c_werror_flag to force unknown compiler flags to fail.
It's not a documented feature, but it's what the documented
AC_LANG_WERROR has used for 13 years, and there's no push/pop mechanism
for AC_LANG_WERROR, so you can't ensure that "fail even on warnings"
will be applied *only* in AC_LBL_CHECK_COMPILER_OPT(), as that's what we
want.  (If we can make sure that *no* compiler tests will produce
warnings, except for the ones we *want* to fail if they produce
warnings, we could just do AC_LANG_WERROR, but that might be tricky to
ensure in the general case.)

We do this because not all compilers have a command-line flag to force
all warnings, *including* warnings from unknown commad-line flags (I'm
looking at *you* IBM XL C!), so we have to have the test check to make
sure no warnings are produced (which, for AC_TRY_COMPILE(), means
"nothing is written to the standard output").

In addition, AC_TRY_COMPILE() generates a return; don't add one:

If we pass [return 0] to AC_TRY_COMPILE(), the test program it compiles
has two "return 0;" statements in a row, and one of the -W flags we
tests reports a warning for that.

We were testing whether a -W flag is supported by checking the standard
error of the compiler to see if *any* error/warning messages are
generated, and treating the flag as unsupported if any are, that meant
that -Wunreachable-code-return was be treated as unsupported even though
it *is* supported.

This should fix that.  (I'm so glad autoconf makes this all so difficult
to do correctly....)
2021-07-25 02:22:42 -07:00
Francois-Xavier Le Bail
f91ef58f2f autoconf: Find a local libpcap even with rcX directory suffix 2021-06-07 21:01:15 +02:00
Francois-Xavier Le Bail
a4e0f7d9df Remove a trailing tab 2020-08-01 12:04:52 +02:00
Guy Harris
daff285ecf autoconf: replace --with-system-libpcap with --disable-local-libpcap.
--with-system-libpcap didn't work - it didn't prevent searching for a
local libpcap - and had a misleading name.  Replace it with
--disable-local-libpcap.

This should address GitHub issue #823.
2020-07-19 20:12:32 -07:00
Francois-Xavier Le Bail
0181656313 Compile with '-Wmissing-variable-declarations' if it's available
(In devel mode)
2020-05-30 00:05:22 +02:00
Guy Harris
91e2aa9b13 Look for mkdep in the top-level source directory.
Not currently a problem for tcpdump, as we have no subdirectories, but
this will leave us prepared for subdirectories if we ever add any.
2020-03-02 16:15:07 -08:00
Guy Harris
895e3dfd76 Remove the hacks to avoid floating-point issues in the tcpdump checks.
I can't seem to make those issues pop up on my (x86-64) machine, and, if
they do show up on any platforms, the best hack to handle it is probably
to have a special tcpdump flag to force it to do a floating-point
calculation and see what result is generated, and report the result, so
we know what it'll do with the numbers in the test files, and have
tests/TESTrun run tcpdump with that flag.

If those tests *do* fail, we'll know what calculations to do.
2020-02-04 15:47:02 -08:00
Francois-Xavier Le Bail
a602436cc2 Use -Wpointer-sign if it's available 2019-07-13 11:38:48 +02:00
Guy Harris
41df53a5c6 Note that we don't need to worry about pkg-config lacking --exists.
[skip ci]
2019-04-30 00:25:55 -07:00
Guy Harris
45a4d4292c Use pkg-config if we can. Clean up some CMake stuff.
If we have pkg-config, *and* it has .pc files for libpcap, use it to get
the C compiler flags and linker flags for libpcap.

find_library() sets a cache variable; when we're looping over libraries,
trying to find their full paths, we really want the variable to act as a
local variable, as we're looking up different libraries, so unset it
after we're finished processing a particular library.

When we're searching for static libraries, save the current value of
CMAKE_FIND_LIBRARY_SUFFIXES, set it to ".a", and then restore it when
we're done.  Don't use cmake_push_check_state() for that, as
CMAKE_FIND_LIBRARY_SUFFIXES is *not* one of the variables that it's
guaranteed to save and restore.
2019-04-26 13:15:39 -07:00
Francois-Xavier Le Bail
f34af1aa63 Compile with '-Wsign-compare' in devel mode if supported 2018-10-29 22:28:53 +01:00
Guy Harris
9008c09c88 Don't warn about declarations after statements.
We now allow them, and require a compiler that supports them, so there's
no need to warn about them.
2018-09-15 13:16:02 -07:00
Francois-Xavier Le Bail
46efa1bc47 Fix spaces 2018-09-03 15:18:19 +02:00
Denis Ovsienko
9ea3e1b265 Fix some spelling in comments.
[skip ci]
2018-08-01 14:06:33 +01:00
Francois-Xavier Le Bail
abe1aa5a29 Compile with '-Wunreachable-code-return' in devel mode if supported 2018-07-17 22:22:49 +02:00
Francois-Xavier Le Bail
bcb77e9f99 Sort the tested compiler warning options 2018-07-07 22:01:00 +02:00
Guy Harris
e325894a35 If we have a local libpcap, add it to the dependencies for tcpdump.
We weren't doing so if we found a local pcap-config script.
2018-01-22 21:33:21 -08:00
Guy Harris
08a89b549f Use AC_RUN_LOG when testing the dependency-generating flag. 2018-01-22 20:51:51 -08:00
Guy Harris
45fc519a2a Don't test for __attribute__ in the configure script.
Instead, use compiler test macros to check whether *particular*
attributes are supported, and set various #defines appropriately, in
header files.

Rename the UNALIGNED structure attribute to ND_UNALIGNED, and ask
whether we still need it.
2018-01-21 17:57:20 -08:00
Guy Harris
bfdad0f58f Fix typo, and request additional libraries for *static* linking. 2017-11-30 12:59:54 -08:00
Guy Harris
cfc4c750a2 Fix the handling of libpcap.
We have four possibilities:

  1) local library, with a pcap-config;
  2) local library, without a pcap-config;
  3) installed library, with a pcap-config;
  4) installed library, without a pcap-config.

If we have a local library, i.e. one in ../libpcap{whatever}, we:

    add -I flags to the C compiler flags to point it at whatever
    directories in ../libpcap{whatever};

    add ../libpcap{whatever}/libpcap.a to $LIBS and:

        if it has a pcap-config, we use it, with --additional-libraries,
        to find the additional libraries with which we need to link;

        otherwise, we do the usual OS-dependent hacks to try to figure
        out with what additional flags we need to link;

    and add them to $LIBS after libpcap.a.

If we have an installed library:

    if it has a pcap-config we use it, with --cflags, to find what flags
    to add to the C compiler flags, and use it, with --libs, to see what
    flags to add to $LIBS;

    if it doesn't have a pcap-config, we search for -lpcap and, if that
    succeeds, we assume the headers are under /usr/local/include or
    /usr/include, search for them there, and, if we don't find pcap.h
    there, we look for it in a pcap subdirectory under there, and add
    the appropriate -I flag to the C compiler flags, and then do the
    usual OS-dependent hacks to try to figure out with what additional
    flags we need to link.

While we're at it, we do the libdlpi check only on Solaris, as part of
"the usual OS-dependent hacks".
2017-11-29 18:18:18 -08:00
Guy Harris
55e0de4ea1 Clean up indentation. 2017-11-13 18:55:32 -08:00
Ali Abdulkadir
27da449d5b Some tweaks for AC_LBL_LIBPCAP 2017-11-14 03:57:28 +03:00
Guy Harris
2b9bfa05b6 Check for unaligned memory access support at compile time.
Don't test at configure time; that doesn't work when cross-compiling and
may be a pain to do with CMake.
2017-10-16 01:39:10 -07:00
Guy Harris
fdd0467bcd On UN*X, always use sigaction(), and always have signal handlers return void.
Some time between the mid 1980's and 1990 called; they want their
old-fashioned UNIX signal handling back.  ANSI C has had signal handlers
returning void sincer, well, 1989, and POSIX has had sigaction() since
close to forever.  No need to worry about really old UN*Xes here.

On Windows, it's also void (as per ANSI C); use signal().
2017-10-15 22:36:07 -07:00
Guy Harris
88d1467627 Get rid of an unnecessary test.
We don't care whether struct sockaddr has an sa_len field or not.
2017-10-15 22:16:01 -07:00