]> The Tcpdump Group git mirrors - tcpdump/blob - build_matrix.sh
CI: Port recent improvements from tcpslice. [skip appveyor]
[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
23 . ./build_common.sh
24 print_sysinfo
25 # Install directory prefix
26 if [ -z "$PREFIX" ]; then
27 # shellcheck disable=SC2006
28 PREFIX=`mktempdir tcpdump_build_matrix`
29 echo "PREFIX set to '$PREFIX'"
30 export PREFIX
31 fi
32 COUNT=0
33 export TCPDUMP_TAINTED
34
35 build_tcpdump() {
36 for CMAKE in $MATRIX_CMAKE; do
37 export CMAKE
38 for CRYPTO in $MATRIX_CRYPTO; do
39 export CRYPTO
40 for SMB in $MATRIX_SMB; do
41 export SMB
42 # shellcheck disable=SC2006
43 COUNT=`increment $COUNT`
44 echo_magenta "===== SETUP $COUNT: BUILD_LIBPCAP=$BUILD_LIBPCAP REMOTE=${REMOTE:-?} CC=$CC CMAKE=$CMAKE CRYPTO=$CRYPTO SMB=$SMB =====" >&2
45 # Run one build with setup environment variables:
46 # BUILD_LIBPCAP, REMOTE, CC, CMAKE, CRYPTO and SMB
47 run_after_echo ./build.sh
48 echo 'Cleaning...'
49 if [ "$CMAKE" = yes ]; then
50 run_after_echo rm -rf build
51 else
52 run_after_echo make distclean
53 fi
54 run_after_echo rm -rf "$PREFIX"/bin/tcpdump*
55 run_after_echo git status -suall
56 # Cancel changes in configure
57 run_after_echo git checkout configure
58 done
59 done
60 done
61 }
62
63 touch .devel configure
64 for CC in $MATRIX_CC; do
65 export CC
66 discard_cc_cache
67 if gcc_is_clang_in_disguise; then
68 echo '(skipped)'
69 continue
70 fi
71 for BUILD_LIBPCAP in $MATRIX_BUILD_LIBPCAP; do
72 export BUILD_LIBPCAP
73 if [ "$BUILD_LIBPCAP" = yes ]; then
74 for REMOTE in $MATRIX_REMOTE; do
75 export REMOTE
76 # Build libpcap with Autoconf.
77 echo_magenta "Build libpcap (CMAKE=no REMOTE=$REMOTE)" >&2
78 (cd ../libpcap && CMAKE=no ./build.sh)
79 # Set PKG_CONFIG_PATH for configure when building libpcap
80 if [ "$CMAKE" != no ]; then
81 PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig"
82 export PKG_CONFIG_PATH
83 fi
84 build_tcpdump
85 done
86 else
87 echo_magenta 'Use system libpcap' >&2
88 purge_directory "$PREFIX"
89 (cd ../libpcap; make distclean || echo '(Ignoring the make error.)')
90 build_tcpdump
91 fi
92 done
93 done
94
95 run_after_echo rm -rf "$PREFIX"
96 echo_magenta "Tested setup count: $COUNT" >&2
97 # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :