]> The Tcpdump Group git mirrors - tcpdump/blob - build.sh
gre: add support for MikroTik Ethernet-over-IP hack.
[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 : "${TCPDUMP_CMAKE_TAINTED:=no}"
14 : "${MAKE_BIN:=make}"
15 # At least one OS (AIX 7) where this software can build does not have at least
16 # one command (mktemp) required for a successful run of "make releasetar".
17 : "${TEST_RELEASETAR:=yes}"
18
19 . ./build_common.sh
20 # Install directory prefix
21 if [ -z "$PREFIX" ]; then
22 PREFIX=`mktempdir tcpdump_build`
23 echo "PREFIX set to '$PREFIX'"
24 fi
25 TCPDUMP_BIN="$PREFIX/bin/tcpdump"
26 # For TESTrun
27 export TCPDUMP_BIN
28
29 print_cc_version
30
31 # The norm is to compile without any warnings, but tcpdump builds on some OSes
32 # are not warning-free for one or another reason. If you manage to fix one of
33 # these cases, please remember to remove respective exemption below to help any
34 # later warnings in the same matrix subset trigger an error.
35
36 case `cc_id`/`os_id` in
37 clang-*/SunOS-5.11)
38 # (Clang 9 on OpenIndiana, Clang 11 on OmniOS)
39 # tcpdump.c:2312:51: warning: this function declaration is not a prototype
40 # [-Wstrict-prototypes]
41 # tcpdump.c:2737:11: warning: this function declaration is not a prototype
42 # [-Wstrict-prototypes]
43 [ "`uname -o`" = illumos ] && TCPDUMP_TAINTED=yes
44 ;;
45 esac
46
47 [ "$TCPDUMP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags`
48
49 # If necessary, set TCPDUMP_CMAKE_TAINTED here to exempt particular cmake from
50 # warnings. Use as specific terms as possible (e.g. some specific version and
51 # some specific OS).
52
53 [ "$TCPDUMP_CMAKE_TAINTED" != yes ] && CMAKE_OPTIONS='-Werror=dev'
54
55 if [ "$CMAKE" = no ]; then
56 if [ "$BUILD_LIBPCAP" = yes ]; then
57 echo "Using PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
58 run_after_echo ./autogen.sh
59 run_after_echo ./configure --with-crypto="$CRYPTO" \
60 --enable-smb="$SMB" --prefix="$PREFIX"
61 LD_LIBRARY_PATH="$PREFIX/lib"
62 export LD_LIBRARY_PATH
63 else
64 run_after_echo ./autogen.sh
65 run_after_echo ./configure --with-crypto="$CRYPTO" \
66 --enable-smb="$SMB" --prefix="$PREFIX" --disable-local-libpcap
67 fi
68 else
69 # See libpcap build.sh for the rationale.
70 run_after_echo rm -rf CMakeFiles/ CMakeCache.txt build/
71 run_after_echo mkdir build
72 run_after_echo cd build
73 if [ "$BUILD_LIBPCAP" = yes ]; then
74 run_after_echo cmake "$CMAKE_OPTIONS" \
75 -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
76 ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
77 -DCMAKE_INSTALL_PREFIX="$PREFIX" -DCMAKE_PREFIX_PATH="$PREFIX" ..
78 LD_LIBRARY_PATH="$PREFIX/lib"
79 export LD_LIBRARY_PATH
80 else
81 run_after_echo cmake "$CMAKE_OPTIONS" \
82 -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
83 ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
84 -DCMAKE_INSTALL_PREFIX="$PREFIX" ..
85 fi
86 fi
87 run_after_echo "$MAKE_BIN" -s clean
88 if [ "$CMAKE" = no ]; then
89 run_after_echo "$MAKE_BIN" -s ${CFLAGS:+CFLAGS="$CFLAGS"}
90 else
91 # The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above.
92 run_after_echo "$MAKE_BIN"
93 fi
94 run_after_echo "$MAKE_BIN" install
95 print_so_deps "$TCPDUMP_BIN"
96 run_after_echo "$TCPDUMP_BIN" -h
97 # The "-D" flag depends on HAVE_PCAP_FINDALLDEVS and it would not be difficult
98 # to run the command below only if the macro is defined. That said, it seems
99 # more useful to run it anyway: every system that currently runs this script
100 # has pcap_findalldevs(), thus if the macro isn't defined, it means something
101 # went wrong in the build process (as was observed with GCC, CMake and the
102 # system libpcap on Solaris 11).
103 run_after_echo "$TCPDUMP_BIN" -D
104 if [ "$CIRRUS_CI" = true ]; then
105 # Likewise for the "-J" flag and HAVE_PCAP_SET_TSTAMP_TYPE.
106 run_after_echo sudo \
107 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
108 "$TCPDUMP_BIN" -J
109 run_after_echo sudo \
110 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
111 "$TCPDUMP_BIN" -L
112 fi
113 if [ "$BUILD_LIBPCAP" = yes ]; then
114 run_after_echo "$MAKE_BIN" check
115 fi
116 if [ "$CMAKE" = no ]; then
117 [ "$TEST_RELEASETAR" = yes ] && run_after_echo "$MAKE_BIN" releasetar
118 fi
119 if [ "$CIRRUS_CI" = true ]; then
120 run_after_echo sudo \
121 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
122 "$TCPDUMP_BIN" -#n -c 10
123 fi
124 handle_matrix_debug
125 if [ "$DELETE_PREFIX" = yes ]; then
126 run_after_echo rm -rf "$PREFIX"
127 fi
128 # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :