3 # This script runs one build with setup environment variables: BUILD_LIBPCAP,
4 # REMOTE, CC, CMAKE, CRYPTO and SMB.
6 : "${BUILD_LIBPCAP:=no}"
12 : "${TCPDUMP_TAINTED:=no}"
15 # Install directory prefix
16 if [ -z "$PREFIX" ]; then
17 # shellcheck disable=SC2006
18 PREFIX
=`mktempdir tcpdump_build`
19 echo "PREFIX set to '$PREFIX'"
22 TCPDUMP_BIN
="$PREFIX/bin/tcpdump"
27 # The norm is to compile without any warnings, but tcpdump builds on some OSes
28 # are not warning-free for one or another reason. If you manage to fix one of
29 # these cases, please remember to remove respective exemption below to help any
30 # later warnings in the same matrix subset trigger an error.
31 # shellcheck disable=SC2006
32 case `os_id`/"$CMAKE" in
34 # tcpdump.c:2290:3: error: implicit declaration of function 'bpf_dump'
35 # [-Werror=implicit-function-declaration]
36 [ "$BUILD_LIBPCAP" = yes ] && TCPDUMP_TAINTED
=yes
39 # tcpdump.c:2434:32: error: '_Generic' is a C11 extension
40 # [-Werror,-Wc11-extensions]
41 # tcpdump.c:2439:26: error: '_Generic' is a C11 extension
42 # [-Werror,-Wc11-extensions]
43 # tcpdump.c:2443:9: error: '_Generic' is a C11 extension
44 # [-Werror,-Wc11-extensions]
50 # shellcheck disable=SC2006
51 [ "$TCPDUMP_TAINTED" != yes ] && CFLAGS
=`cc_werr_cflags`
53 if [ "$CMAKE" = no
]; then
54 if [ "$BUILD_LIBPCAP" = yes ]; then
55 echo "Using PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
56 run_after_echo .
/configure
--with-crypto="$CRYPTO" \
57 --enable-smb="$SMB" --prefix="$PREFIX"
58 LD_LIBRARY_PATH
="$PREFIX/lib"
59 export LD_LIBRARY_PATH
61 run_after_echo .
/configure
--with-crypto="$CRYPTO" \
62 --enable-smb="$SMB" --prefix="$PREFIX" --disable-local-libpcap
65 run_after_echo
rm -rf build
66 run_after_echo mkdir build
67 run_after_echo
cd build
68 if [ "$BUILD_LIBPCAP" = yes ]; then
69 run_after_echo cmake
-DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
70 ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
71 -DCMAKE_INSTALL_PREFIX="$PREFIX" -DCMAKE_PREFIX_PATH="$PREFIX" ..
72 LD_LIBRARY_PATH
="$PREFIX/lib"
73 export LD_LIBRARY_PATH
75 run_after_echo cmake
-DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
76 ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
77 -DCMAKE_INSTALL_PREFIX="$PREFIX" ..
80 run_after_echo
make -s clean
81 if [ "$CMAKE" = no
]; then
82 run_after_echo
make -s ${CFLAGS:+CFLAGS="$CFLAGS"}
84 # The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above.
87 run_after_echo
make install
88 print_so_deps
"$TCPDUMP_BIN"
89 run_after_echo
"$TCPDUMP_BIN" -h
90 # The "-D" flag depends on HAVE_PCAP_FINDALLDEVS and it would not be difficult
91 # to run the command below only if the macro is defined. That said, it seems
92 # more useful to run it anyway: every system that currently runs this script
93 # has pcap_findalldevs(), thus if the macro isn't defined, it means something
94 # went wrong in the build process (as was observed with GCC, CMake and the
95 # system libpcap on Solaris 11).
96 run_after_echo
"$TCPDUMP_BIN" -D
97 if [ "$CIRRUS_CI" = true
]; then
98 # Likewise for the "-J" flag and HAVE_PCAP_SET_TSTAMP_TYPE.
100 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
102 run_after_echo sudo \
103 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
106 if [ "$BUILD_LIBPCAP" = yes ]; then
107 run_after_echo
make check
109 if [ "$CMAKE" = no
]; then
110 run_after_echo
make releasetar
112 if [ "$CIRRUS_CI" = true
]; then
113 run_after_echo sudo \
114 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
115 "$TCPDUMP_BIN" -#n -c 10
118 if [ "$DELETE_PREFIX" = yes ]; then
119 run_after_echo
rm -rf "$PREFIX"
121 # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :