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