]> The Tcpdump Group git mirrors - tcpdump/blob - build.sh
CI: Add warning exemptions for Sun C (suncc-5.14) on Solaris 10
[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 DELETE_PREFIX=yes
25 fi
26 TCPDUMP_BIN="$PREFIX/bin/tcpdump"
27 # For TESTrun
28 export TCPDUMP_BIN
29
30 print_cc_version
31
32 # The norm is to compile without any warnings, but tcpdump builds on some OSes
33 # are not warning-free for one or another reason. If you manage to fix one of
34 # these cases, please remember to remove respective exemption below to help any
35 # later warnings in the same matrix subset trigger an error.
36
37 case `cc_id`/`os_id` in
38 tcc-*/*)
39 # print-802_11.c:3317: warning: assignment discards qualifiers from pointer
40 # target type
41 TCPDUMP_TAINTED=yes
42 ;;
43 suncc-5.14/SunOS-5.10)
44 # "tcpdump.c", line 347: warning: function "exit_tcpdump" marked as not
45 # returning, might return
46 # "netdissect.c", line 317: warning: function "nd_trunc_longjmp" marked as
47 # not returning, might return
48 # "print.c", line 530: warning: function "ndo_error" marked as not
49 # returning, might return
50 TCPDUMP_TAINTED=yes
51 ;;
52 *)
53 ;;
54 esac
55
56 [ "$TCPDUMP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags`
57
58 case `cc_id`/`os_id` in
59 clang-*/SunOS-5.11)
60 # Work around https://www.illumos.org/issues/16369
61 [ "`uname -o`" = illumos ] && grep -Fq OpenIndiana /etc/release && CFLAGS="-Wno-fuse-ld-path${CFLAGS:+ $CFLAGS}"
62 ;;
63 esac
64
65 # If necessary, set TCPDUMP_CMAKE_TAINTED here to exempt particular cmake from
66 # warnings. Use as specific terms as possible (e.g. some specific version and
67 # some specific OS).
68
69 [ "$TCPDUMP_CMAKE_TAINTED" != yes ] && CMAKE_OPTIONS='-Werror=dev'
70
71 if [ "$CMAKE" = no ]; then
72 if [ "$BUILD_LIBPCAP" = yes ]; then
73 echo "Using PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
74 run_after_echo ./autogen.sh
75 run_after_echo ./configure --with-crypto="$CRYPTO" \
76 --enable-smb="$SMB" --prefix="$PREFIX"
77 LD_LIBRARY_PATH="$PREFIX/lib"
78 export LD_LIBRARY_PATH
79 else
80 run_after_echo ./autogen.sh
81 run_after_echo ./configure --with-crypto="$CRYPTO" \
82 --enable-smb="$SMB" --prefix="$PREFIX" --disable-local-libpcap
83 fi
84 else
85 # See libpcap build.sh for the rationale.
86 run_after_echo rm -rf CMakeFiles/ CMakeCache.txt build/
87 run_after_echo mkdir build
88 run_after_echo cd build
89 if [ "$BUILD_LIBPCAP" = yes ]; then
90 run_after_echo cmake ${CMAKE_OPTIONS:+"$CMAKE_OPTIONS"} \
91 -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
92 ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
93 -DCMAKE_INSTALL_PREFIX="$PREFIX" -DCMAKE_PREFIX_PATH="$PREFIX" ..
94 LD_LIBRARY_PATH="$PREFIX/lib"
95 export LD_LIBRARY_PATH
96 else
97 run_after_echo cmake ${CMAKE_OPTIONS:+"$CMAKE_OPTIONS"} \
98 -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
99 ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
100 -DCMAKE_INSTALL_PREFIX="$PREFIX" ..
101 fi
102 fi
103 run_after_echo "$MAKE_BIN" -s clean
104 if [ "$CMAKE" = no ]; then
105 run_after_echo "$MAKE_BIN" -s ${CFLAGS:+CFLAGS="$CFLAGS"}
106 else
107 # The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above.
108 run_after_echo "$MAKE_BIN"
109 fi
110 run_after_echo "$MAKE_BIN" install
111 print_so_deps "$TCPDUMP_BIN"
112 run_after_echo "$TCPDUMP_BIN" -h
113 run_after_echo "$TCPDUMP_BIN" -D
114 if [ "$CIRRUS_CI" = true ]; then
115 # Likewise for the "-J" flag and HAVE_PCAP_SET_TSTAMP_TYPE.
116 run_after_echo sudo \
117 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
118 "$TCPDUMP_BIN" -J
119 run_after_echo sudo \
120 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
121 "$TCPDUMP_BIN" -L
122 fi
123 if [ "$BUILD_LIBPCAP" = yes ]; then
124 run_after_echo "$MAKE_BIN" check
125 fi
126 if [ "$CMAKE" = no ]; then
127 [ "$TEST_RELEASETAR" = yes ] && run_after_echo "$MAKE_BIN" releasetar
128 fi
129 if [ "$CIRRUS_CI" = true ]; then
130 run_after_echo sudo \
131 ${LD_LIBRARY_PATH:+LD_LIBRARY_PATH="$LD_LIBRARY_PATH"} \
132 "$TCPDUMP_BIN" -#n -c 10
133 fi
134 handle_matrix_debug
135 if [ "$DELETE_PREFIX" = yes ]; then
136 run_after_echo rm -rf "$PREFIX"
137 fi
138 # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :