]> The Tcpdump Group git mirrors - tcpdump/blob - build.sh
Squelch a warning with Capsicum enabled. [skip appveyor]
[tcpdump] / build.sh
1 #!/bin/sh -e
2
3 # This script runs one build with setup environment variables: BUILD_LIBPCAP,
4 # REMOTE, CC, CMAKE, CRYPTO and SMB.
5
6 : "${BUILD_LIBPCAP:=no}"
7 : "${REMOTE:=no}"
8 : "${CC:=gcc}"
9 : "${CMAKE:=no}"
10 : "${CRYPTO:=no}"
11 : "${SMB:=no}"
12 : "${TCPDUMP_TAINTED:=no}"
13
14 . ./build_common.sh
15 # Install directory prefix
16 if [ -z "$PREFIX" ]; then
17 # shellcheck disable=SC2006
18 PREFIX=`mktempdir tcpdump_build`
19 echo "PREFIX set to '$PREFIX'"
20 fi
21 TCPDUMP_BIN="$PREFIX/bin/tcpdump"
22 # For TESTrun
23 export TCPDUMP_BIN
24
25 print_cc_version
26
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
33 FreeBSD-*/yes)
34 case `cc_id` in
35 clang-*)
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]
42 TCPDUMP_TAINTED=yes
43 ;;
44 esac
45 ;;
46 esac
47 # shellcheck disable=SC2006
48 [ "$TCPDUMP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags`
49
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
57 else
58 run_after_echo ./configure --with-crypto="$CRYPTO" \
59 --enable-smb="$SMB" --prefix="$PREFIX" --disable-local-libpcap
60 fi
61 else
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
71 else
72 run_after_echo cmake -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
73 ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
74 -DCMAKE_INSTALL_PREFIX="$PREFIX" ..
75 fi
76 fi
77 run_after_echo make -s clean
78 if [ "$CMAKE" = no ]; then
79 run_after_echo make -s ${CFLAGS:+CFLAGS="$CFLAGS"}
80 else
81 # The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above.
82 run_after_echo make
83 fi
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.
96 run_after_echo sudo \
97 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
98 "$TCPDUMP_BIN" -J
99 run_after_echo sudo \
100 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
101 "$TCPDUMP_BIN" -L
102 fi
103 if [ "$BUILD_LIBPCAP" = yes ]; then
104 run_after_echo make check
105 fi
106 if [ "$CMAKE" = no ]; then
107 run_after_echo make releasetar
108 fi
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
113 fi
114 handle_matrix_debug
115 if [ "$DELETE_PREFIX" = yes ]; then
116 run_after_echo rm -rf "$PREFIX"
117 fi
118 # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :