]> The Tcpdump Group git mirrors - tcpdump/blob - build_matrix.sh
Revert "Clean a bunch of fuzzed files not to fuzz the container."
[tcpdump] / build_matrix.sh
1 #!/bin/sh -e
2
3 # This script executes the matrix loops, exclude tests and cleaning.
4 # It calls the build.sh script which runs one build with setup environment
5 # variables: BUILD_LIBPCAP, REMOTE, CC, CMAKE, CRYPTO and SMB.
6 # The matrix can be configured with environment variables
7 # MATRIX_BUILD_LIBPCAP, MATRIX_REMOTE, MATRIX_CC, MATRIX_CMAKE, MATRIX_CRYPTO
8 # and MATRIX_SMB.
9
10 : "${MATRIX_BUILD_LIBPCAP:=no yes}"
11 : "${MATRIX_REMOTE:=no}"
12 : "${MATRIX_CC:=gcc clang}"
13 : "${MATRIX_CMAKE:=no yes}"
14 : "${MATRIX_CRYPTO:=no yes}"
15 : "${MATRIX_SMB:=no yes}"
16 # Set this variable to "yes" before calling this script to disregard all
17 # warnings in a particular environment (CI or a local working copy). Set it
18 # to "yes" in this script or in build.sh when a matrix subset is known to be
19 # not warning-free because of the OS, the compiler or whatever other factor
20 # that the scripts can detect both in and out of CI.
21 : "${TCPDUMP_TAINTED:=no}"
22 # Some OSes have native make without parallel jobs support and sometimes have
23 # GNU Make available as "gmake".
24 : "${MAKE_BIN:=make}"
25
26 . ./build_common.sh
27 print_sysinfo
28 # Install directory prefix
29 if [ -z "$PREFIX" ]; then
30 PREFIX=`mktempdir tcpdump_build_matrix`
31 echo "PREFIX set to '$PREFIX'"
32 export PREFIX
33 fi
34 COUNT=0
35 export TCPDUMP_TAINTED
36 export MAKE_BIN
37
38 build_tcpdump() {
39 for CMAKE in $MATRIX_CMAKE; do
40 export CMAKE
41 for CRYPTO in $MATRIX_CRYPTO; do
42 export CRYPTO
43 for SMB in $MATRIX_SMB; do
44 export SMB
45 COUNT=`increment $COUNT`
46 echo_magenta "===== SETUP $COUNT: BUILD_LIBPCAP=$BUILD_LIBPCAP REMOTE=${REMOTE:-?} CC=$CC CMAKE=$CMAKE CRYPTO=$CRYPTO SMB=$SMB =====" >&2
47 # Run one build with setup environment variables:
48 # BUILD_LIBPCAP, REMOTE, CC, CMAKE, CRYPTO and SMB
49 run_after_echo ./build.sh
50 echo 'Cleaning...'
51 if [ "$CMAKE" = yes ]; then
52 run_after_echo rm -rf build
53 else
54 run_after_echo "$MAKE_BIN" distclean
55 fi
56 run_after_echo rm -rf "$PREFIX"/bin/tcpdump*
57 run_after_echo git status -suall
58 # Cancel changes in configure
59 run_after_echo git checkout configure
60 done
61 done
62 done
63 }
64
65 touch .devel configure
66 for CC in $MATRIX_CC; do
67 export CC
68 discard_cc_cache
69 if gcc_is_clang_in_disguise; then
70 echo '(skipped)'
71 continue
72 fi
73 for BUILD_LIBPCAP in $MATRIX_BUILD_LIBPCAP; do
74 export BUILD_LIBPCAP
75 if [ "$BUILD_LIBPCAP" = yes ]; then
76 for REMOTE in $MATRIX_REMOTE; do
77 export REMOTE
78 # Build libpcap with Autoconf.
79 echo_magenta "Build libpcap (CMAKE=no REMOTE=$REMOTE)" >&2
80 (cd ../libpcap && CMAKE=no ./build.sh)
81 # Set PKG_CONFIG_PATH for configure when building libpcap
82 if [ "$CMAKE" != no ]; then
83 PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig"
84 export PKG_CONFIG_PATH
85 fi
86 build_tcpdump
87 done
88 else
89 echo_magenta 'Use system libpcap' >&2
90 purge_directory "$PREFIX"
91 if [ -d ../libpcap ]; then
92 (cd ../libpcap; "$MAKE_BIN" distclean || echo '(Ignoring the make error.)')
93 fi
94 build_tcpdump
95 fi
96 done
97 done
98
99 run_after_echo rm -rf "$PREFIX"
100 echo_magenta "Tested setup count: $COUNT" >&2
101 # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :