]> The Tcpdump Group git mirrors - tcpdump/blob - build_matrix.sh
Restore the possibility of building when remote is enabled in libpcap
[tcpdump] / build_matrix.sh
1 #!/usr/bin/env bash
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 # (default: BUILD_LIBPCAP=no, REMOTE=no, CC=gcc, CMAKE=no, CRYPTO=no, SMB=no).
7 # The matrix can be configured with environment variables
8 # MATRIX_BUILD_LIBPCAP, MATRIX_REMOTE, MATRIX_CC, MATRIX_CMAKE, MATRIX_CRYPTO
9 # and MATRIX_SMB
10 # (default: MATRIX_BUILD_LIBPCAP='no yes', MATRIX_REMOTE='no yes',
11 # MATRIX_CC='gcc clang', MATRIX_CMAKE='no yes', MATRIX_CRYPTO='no yes',
12 # MATRIX_SMB='no yes').
13
14 set -e
15
16 # ANSI color escape sequences
17 ANSI_MAGENTA="\\033[35;1m"
18 ANSI_RESET="\\033[0m"
19 # Install directory prefix
20 PREFIX=/tmp/local
21 COUNT=0
22
23 travis_fold() {
24 local action="$1"
25 local name="$2"
26 if [ "$TRAVIS" != true ]; then return; fi
27 echo -ne "travis_fold:$action:$LABEL.script.$name\\r"
28 sleep 1
29 }
30
31 # Display text in magenta
32 echo_magenta() {
33 echo -ne "$ANSI_MAGENTA"
34 echo "$@"
35 echo -ne "$ANSI_RESET"
36 }
37
38 build_tcpdump() {
39 for CC in ${MATRIX_CC:-gcc clang}; do
40 export CC
41 # Exclude gcc on OSX (it is just an alias for clang)
42 if [ "$CC" = gcc ] && [ "$TRAVIS_OS_NAME" = osx ]; then continue; fi
43 for CMAKE in ${MATRIX_CMAKE:-no yes}; do
44 export CMAKE
45 for CRYPTO in ${MATRIX_CRYPTO:-no yes}; do
46 export CRYPTO
47 for SMB in ${MATRIX_SMB:-no yes}; do
48 export SMB
49 COUNT=$((COUNT+1))
50 echo_magenta "===== SETUP $COUNT: BUILD_LIBPCAP=$BUILD_LIBPCAP REMOTE=${REMOTE:-?} CC=$CC CMAKE=$CMAKE CRYPTO=$CRYPTO SMB=$SMB ====="
51 # LABEL is needed to build the travis fold labels
52 LABEL="$BUILD_LIBPCAP.$REMOTE.$CC.$CMAKE.$CRYPTO.$SMB"
53 # Run one build with setup environment variables:
54 # BUILD_LIBPCAP, REMOTE, CC, CMAKE, CRYPTO and SMB
55 ./build.sh
56 echo 'Cleaning...'
57 travis_fold start cleaning
58 if [ "$CMAKE" = yes ]; then rm -rf build; else make distclean; fi
59 rm -rf $PREFIX/bin/tcpdump*
60 git status -suall
61 # Cancel changes in configure
62 git checkout configure
63 travis_fold end cleaning
64 done
65 done
66 done
67 done
68 }
69
70 choose_libpcap() {
71 if [ "$BUILD_LIBPCAP" = no ]; then
72 echo_magenta 'Use system libpcap'
73 rm -rf /tmp/local
74 else
75 # Build libpcap with autoconf
76 CMAKE_SAVE=$CMAKE
77 CMAKE=no
78 echo_magenta "Build libpcap (CMAKE=$CMAKE REMOTE=$REMOTE)"
79 (cd ../libpcap && ./build.sh && make distclean)
80 CMAKE=$CMAKE_SAVE
81 fi
82 }
83
84 touch .devel configure
85 for BUILD_LIBPCAP in ${MATRIX_BUILD_LIBPCAP:-no yes}; do
86 export BUILD_LIBPCAP
87 if [ "$BUILD_LIBPCAP" = yes ]; then
88 for REMOTE in ${MATRIX_REMOTE:-no}; do
89 export REMOTE
90 choose_libpcap
91 # Set PKG_CONFIG_PATH for configure when building libpcap
92 if [ "$CMAKE" != no ]; then
93 export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
94 fi
95 build_tcpdump
96 done
97 else
98 choose_libpcap
99 build_tcpdump
100 fi
101 done
102
103 rm -rf $PREFIX
104 echo_magenta "Tested setup count: $COUNT"
105 # vi: set tabstop=4 softtabstop=0 expandtab shiftwidth=4 smarttab autoindent :