]> The Tcpdump Group git mirrors - tcpdump/blob - build.sh
Rename print-rrcp.c to print-realtek.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 : "${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-9.*/SunOS-5.11)
34 # (OpenIndiana)
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 run_after_echo rm -rf build
58 run_after_echo mkdir build
59 run_after_echo cd build
60 if [ "$BUILD_LIBPCAP" = yes ]; then
61 run_after_echo cmake -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
62 ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
63 -DCMAKE_INSTALL_PREFIX="$PREFIX" -DCMAKE_PREFIX_PATH="$PREFIX" ..
64 LD_LIBRARY_PATH="$PREFIX/lib"
65 export LD_LIBRARY_PATH
66 else
67 run_after_echo cmake -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
68 ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
69 -DCMAKE_INSTALL_PREFIX="$PREFIX" ..
70 fi
71 fi
72 run_after_echo "$MAKE_BIN" -s clean
73 if [ "$CMAKE" = no ]; then
74 run_after_echo "$MAKE_BIN" -s ${CFLAGS:+CFLAGS="$CFLAGS"}
75 else
76 # The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above.
77 run_after_echo "$MAKE_BIN"
78 fi
79 run_after_echo "$MAKE_BIN" install
80 print_so_deps "$TCPDUMP_BIN"
81 run_after_echo "$TCPDUMP_BIN" -h
82 # The "-D" flag depends on HAVE_PCAP_FINDALLDEVS and it would not be difficult
83 # to run the command below only if the macro is defined. That said, it seems
84 # more useful to run it anyway: every system that currently runs this script
85 # has pcap_findalldevs(), thus if the macro isn't defined, it means something
86 # went wrong in the build process (as was observed with GCC, CMake and the
87 # system libpcap on Solaris 11).
88 run_after_echo "$TCPDUMP_BIN" -D
89 if [ "$CIRRUS_CI" = true ]; then
90 # Likewise for the "-J" flag and HAVE_PCAP_SET_TSTAMP_TYPE.
91 run_after_echo sudo \
92 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
93 "$TCPDUMP_BIN" -J
94 run_after_echo sudo \
95 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
96 "$TCPDUMP_BIN" -L
97 fi
98 if [ "$BUILD_LIBPCAP" = yes ]; then
99 run_after_echo "$MAKE_BIN" check
100 fi
101 if [ "$CMAKE" = no ]; then
102 run_after_echo "$MAKE_BIN" releasetar
103 fi
104 if [ "$CIRRUS_CI" = true ]; then
105 run_after_echo sudo \
106 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
107 "$TCPDUMP_BIN" -#n -c 10
108 fi
109 handle_matrix_debug
110 if [ "$DELETE_PREFIX" = yes ]; then
111 run_after_echo rm -rf "$PREFIX"
112 fi
113 # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :