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'"
21 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
36 # tcpdump.c:2434:32: error: '_Generic' is a C11 extension
37 # [-Werror,-Wc11-extensions]
38 # tcpdump.c:2439:26: error: '_Generic' is a C11 extension
39 # [-Werror,-Wc11-extensions]
40 # tcpdump.c:2443:9: error: '_Generic' is a C11 extension
41 # [-Werror,-Wc11-extensions]
47 # shellcheck disable=SC2006
48 [ "$TCPDUMP_TAINTED" != yes ] && CFLAGS
=`cc_werr_cflags`
50 if [ "$CMAKE" = no
]; then
51 if [ "$BUILD_LIBPCAP" = yes ]; then
52 echo "Using PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
53 run_after_echo .
/configure
--with-crypto="$CRYPTO" \
54 --enable-smb="$SMB" --prefix="$PREFIX"
55 LD_LIBRARY_PATH
="$PREFIX/lib"
56 export LD_LIBRARY_PATH
58 run_after_echo .
/configure
--with-crypto="$CRYPTO" \
59 --enable-smb="$SMB" --prefix="$PREFIX" --disable-local-libpcap
62 run_after_echo
rm -rf build
63 run_after_echo mkdir build
64 run_after_echo
cd build
65 if [ "$BUILD_LIBPCAP" = yes ]; then
66 run_after_echo cmake
-DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
67 ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
68 -DCMAKE_INSTALL_PREFIX="$PREFIX" -DCMAKE_PREFIX_PATH="$PREFIX" ..
69 LD_LIBRARY_PATH
="$PREFIX/lib"
70 export LD_LIBRARY_PATH
72 run_after_echo cmake
-DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
73 ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
74 -DCMAKE_INSTALL_PREFIX="$PREFIX" ..
77 run_after_echo
make -s clean
78 if [ "$CMAKE" = no
]; then
79 run_after_echo
make -s ${CFLAGS:+CFLAGS="$CFLAGS"}
81 # The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above.
84 run_after_echo
make install
85 print_so_deps
"$TCPDUMP_BIN"
86 run_after_echo
"$TCPDUMP_BIN" -h
87 # The "-D" flag depends on HAVE_PCAP_FINDALLDEVS and it would not be difficult
88 # to run the command below only if the macro is defined. That said, it seems
89 # more useful to run it anyway: every system that currently runs this script
90 # has pcap_findalldevs(), thus if the macro isn't defined, it means something
91 # went wrong in the build process (as was observed with GCC, CMake and the
92 # system libpcap on Solaris 11).
93 run_after_echo
"$TCPDUMP_BIN" -D
94 if [ "$CIRRUS_CI" = true
]; then
95 # Likewise for the "-J" flag and HAVE_PCAP_SET_TSTAMP_TYPE.
97 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
100 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
103 if [ "$BUILD_LIBPCAP" = yes ]; then
104 run_after_echo
make check
106 if [ "$CMAKE" = no
]; then
107 run_after_echo
make releasetar
109 if [ "$CIRRUS_CI" = true
]; then
110 run_after_echo sudo \
111 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
112 "$TCPDUMP_BIN" -#n -c 10
115 if [ "$DELETE_PREFIX" = yes ]; then
116 run_after_echo
rm -rf "$PREFIX"
118 # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :