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}"
16 # Install directory prefix
17 if [ -z "$PREFIX" ]; then
18 # shellcheck disable=SC2006
19 PREFIX
=`mktempdir tcpdump_build`
20 echo "PREFIX set to '$PREFIX'"
22 TCPDUMP_BIN
="$PREFIX/bin/tcpdump"
28 # The norm is to compile without any warnings, but tcpdump builds on some OSes
29 # are not warning-free for one or another reason. If you manage to fix one of
30 # these cases, please remember to remove respective exemption below to help any
31 # later warnings in the same matrix subset trigger an error.
33 # shellcheck disable=SC2006
34 case `cc_id`/`os_id` in
37 # tcpdump.c:2312:51: warning: this function declaration is not a prototype
38 # [-Wstrict-prototypes]
39 # tcpdump.c:2737:11: warning: this function declaration is not a prototype
40 # [-Wstrict-prototypes]
41 [ "`uname -o`" = illumos
] && TCPDUMP_TAINTED
=yes
45 # shellcheck disable=SC2006
46 [ "$TCPDUMP_TAINTED" != yes ] && CFLAGS
=`cc_werr_cflags`
48 if [ "$CMAKE" = no
]; then
49 if [ "$BUILD_LIBPCAP" = yes ]; then
50 echo "Using PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
51 run_after_echo .
/configure
--with-crypto="$CRYPTO" \
52 --enable-smb="$SMB" --prefix="$PREFIX"
53 LD_LIBRARY_PATH
="$PREFIX/lib"
54 export LD_LIBRARY_PATH
56 run_after_echo .
/configure
--with-crypto="$CRYPTO" \
57 --enable-smb="$SMB" --prefix="$PREFIX" --disable-local-libpcap
60 run_after_echo
rm -rf build
61 run_after_echo mkdir build
62 run_after_echo
cd build
63 if [ "$BUILD_LIBPCAP" = yes ]; then
64 run_after_echo cmake
-DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
65 ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
66 -DCMAKE_INSTALL_PREFIX="$PREFIX" -DCMAKE_PREFIX_PATH="$PREFIX" ..
67 LD_LIBRARY_PATH
="$PREFIX/lib"
68 export LD_LIBRARY_PATH
70 run_after_echo cmake
-DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
71 ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
72 -DCMAKE_INSTALL_PREFIX="$PREFIX" ..
75 run_after_echo
"$MAKE_BIN" -s clean
76 if [ "$CMAKE" = no
]; then
77 run_after_echo
"$MAKE_BIN" -s ${CFLAGS:+CFLAGS="$CFLAGS"}
79 # The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above.
80 run_after_echo
"$MAKE_BIN"
82 run_after_echo
"$MAKE_BIN" install
83 print_so_deps
"$TCPDUMP_BIN"
84 run_after_echo
"$TCPDUMP_BIN" -h
85 # The "-D" flag depends on HAVE_PCAP_FINDALLDEVS and it would not be difficult
86 # to run the command below only if the macro is defined. That said, it seems
87 # more useful to run it anyway: every system that currently runs this script
88 # has pcap_findalldevs(), thus if the macro isn't defined, it means something
89 # went wrong in the build process (as was observed with GCC, CMake and the
90 # system libpcap on Solaris 11).
91 run_after_echo
"$TCPDUMP_BIN" -D
92 if [ "$CIRRUS_CI" = true
]; then
93 # Likewise for the "-J" flag and HAVE_PCAP_SET_TSTAMP_TYPE.
95 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
98 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
101 if [ "$BUILD_LIBPCAP" = yes ]; then
102 run_after_echo
"$MAKE_BIN" check
104 if [ "$CMAKE" = no
]; then
105 run_after_echo
"$MAKE_BIN" releasetar
107 if [ "$CIRRUS_CI" = true
]; then
108 run_after_echo sudo \
109 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
110 "$TCPDUMP_BIN" -#n -c 10
113 if [ "$DELETE_PREFIX" = yes ]; then
114 run_after_echo
rm -rf "$PREFIX"
116 # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :