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