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