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: BUILD_LIBPCAP=$BUILD_LIBPCAP REMOTE=${REMOTE:-?} CC=$CC 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 # Cancel changes in configure 66 run_after_echo git checkout configure 67 done 68 done 69 done 70} 71 72touch .devel configure 73for CC in $MATRIX_CC; do 74 export CC 75 discard_cc_cache 76 if gcc_is_clang_in_disguise; then 77 echo '(skipped)' 78 continue 79 fi 80 for BUILD_LIBPCAP in $MATRIX_BUILD_LIBPCAP; do 81 export BUILD_LIBPCAP 82 if [ "$BUILD_LIBPCAP" = yes ]; then 83 for REMOTE in $MATRIX_REMOTE; do 84 export REMOTE 85 # Build libpcap with Autoconf. 86 echo_magenta "Build libpcap (CMAKE=no REMOTE=$REMOTE)" >&2 87 (cd ../libpcap && CMAKE=no ./build.sh) 88 # Set PKG_CONFIG_PATH for configure when building libpcap 89 if [ "$CMAKE" != no ]; then 90 PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig" 91 export PKG_CONFIG_PATH 92 fi 93 build_tcpdump 94 done 95 else 96 echo_magenta 'Use system libpcap' >&2 97 purge_directory "$PREFIX" 98 if [ -d ../libpcap ]; then 99 (cd ../libpcap; "$MAKE_BIN" distclean || echo '(Ignoring the make error.)') 100 fi 101 build_tcpdump 102 fi 103 done 104done 105 106run_after_echo rm -rf "$PREFIX" 107echo_magenta "Tested setup count: $COUNT" >&2 108# vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent : 109