]> The Tcpdump Group git mirrors - tcpdump/blob - build.sh
Fix a typo
[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 : "${MAKE_BIN:=make}"
14
15 . ./build_common.sh
16 # Install directory prefix
17 if [ -z "$PREFIX" ]; then
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
32 case `cc_id`/`os_id` in
33 clang-*/SunOS-5.11)
34 # (Clang 9 on OpenIndiana, Clang 11 on OmniOS)
35 # tcpdump.c:2312:51: warning: this function declaration is not a prototype
36 # [-Wstrict-prototypes]
37 # tcpdump.c:2737:11: warning: this function declaration is not a prototype
38 # [-Wstrict-prototypes]
39 [ "`uname -o`" = illumos ] && TCPDUMP_TAINTED=yes
40 ;;
41 esac
42
43 [ "$TCPDUMP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags`
44
45 if [ "$CMAKE" = no ]; then
46 if [ "$BUILD_LIBPCAP" = yes ]; then
47 echo "Using PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
48 run_after_echo ./configure --with-crypto="$CRYPTO" \
49 --enable-smb="$SMB" --prefix="$PREFIX"
50 LD_LIBRARY_PATH="$PREFIX/lib"
51 export LD_LIBRARY_PATH
52 else
53 run_after_echo ./configure --with-crypto="$CRYPTO" \
54 --enable-smb="$SMB" --prefix="$PREFIX" --disable-local-libpcap
55 fi
56 else
57 # See libpcap build.sh for the rationale.
58 run_after_echo rm -rf CMakeFiles/ CMakeCache.txt build/
59 run_after_echo mkdir build
60 run_after_echo cd build
61 if [ "$BUILD_LIBPCAP" = yes ]; then
62 run_after_echo cmake -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
63 ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
64 -DCMAKE_INSTALL_PREFIX="$PREFIX" -DCMAKE_PREFIX_PATH="$PREFIX" ..
65 LD_LIBRARY_PATH="$PREFIX/lib"
66 export LD_LIBRARY_PATH
67 else
68 run_after_echo cmake -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
69 ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
70 -DCMAKE_INSTALL_PREFIX="$PREFIX" ..
71 fi
72 fi
73 run_after_echo "$MAKE_BIN" -s clean
74 if [ "$CMAKE" = no ]; then
75 run_after_echo "$MAKE_BIN" -s ${CFLAGS:+CFLAGS="$CFLAGS"}
76 else
77 # The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above.
78 run_after_echo "$MAKE_BIN"
79 fi
80 run_after_echo "$MAKE_BIN" install
81 print_so_deps "$TCPDUMP_BIN"
82 run_after_echo "$TCPDUMP_BIN" -h
83 # The "-D" flag depends on HAVE_PCAP_FINDALLDEVS and it would not be difficult
84 # to run the command below only if the macro is defined. That said, it seems
85 # more useful to run it anyway: every system that currently runs this script
86 # has pcap_findalldevs(), thus if the macro isn't defined, it means something
87 # went wrong in the build process (as was observed with GCC, CMake and the
88 # system libpcap on Solaris 11).
89 run_after_echo "$TCPDUMP_BIN" -D
90 if [ "$CIRRUS_CI" = true ]; then
91 # Likewise for the "-J" flag and HAVE_PCAP_SET_TSTAMP_TYPE.
92 run_after_echo sudo \
93 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
94 "$TCPDUMP_BIN" -J
95 run_after_echo sudo \
96 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
97 "$TCPDUMP_BIN" -L
98 fi
99 if [ "$BUILD_LIBPCAP" = yes ]; then
100 run_after_echo "$MAKE_BIN" check
101 fi
102 if [ "$CMAKE" = no ]; then
103 run_after_echo "$MAKE_BIN" releasetar
104 fi
105 if [ "$CIRRUS_CI" = true ]; then
106 run_after_echo sudo \
107 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
108 "$TCPDUMP_BIN" -#n -c 10
109 fi
110 handle_matrix_debug
111 if [ "$DELETE_PREFIX" = yes ]; then
112 run_after_echo rm -rf "$PREFIX"
113 fi
114 # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :