]> The Tcpdump Group git mirrors - tcpdump/blob - build.sh
Move capdns from tcpdump.c to addrtoname.c.
[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 # For TESTrun
22 TCPDUMP_BIN="$PREFIX/bin/tcpdump"
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 # tcpdump.c:2290:3: error: implicit declaration of function 'bpf_dump'
35 # [-Werror=implicit-function-declaration]
36 [ "$BUILD_LIBPCAP" = yes ] && TCPDUMP_TAINTED=yes
37 case `cc_id` in
38 clang-*)
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]
45 TCPDUMP_TAINTED=yes
46 ;;
47 esac
48 ;;
49 esac
50 # shellcheck disable=SC2006
51 [ "$TCPDUMP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags`
52
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
60 else
61 run_after_echo ./configure --with-crypto="$CRYPTO" \
62 --enable-smb="$SMB" --prefix="$PREFIX" --disable-local-libpcap
63 fi
64 else
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
74 else
75 run_after_echo cmake -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
76 ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
77 -DCMAKE_INSTALL_PREFIX="$PREFIX" ..
78 fi
79 fi
80 run_after_echo make -s clean
81 if [ "$CMAKE" = no ]; then
82 run_after_echo make -s ${CFLAGS:+CFLAGS="$CFLAGS"}
83 else
84 # The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above.
85 run_after_echo make
86 fi
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.
99 run_after_echo sudo \
100 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
101 "$TCPDUMP_BIN" -J
102 run_after_echo sudo \
103 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
104 "$TCPDUMP_BIN" -L
105 fi
106 if [ "$BUILD_LIBPCAP" = yes ]; then
107 run_after_echo make check
108 fi
109 if [ "$CMAKE" = no ]; then
110 run_after_echo make releasetar
111 fi
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
116 fi
117 handle_matrix_debug
118 if [ "$DELETE_PREFIX" = yes ]; then
119 run_after_echo rm -rf "$PREFIX"
120 fi
121 # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :