devtools: add libelf dependency to build test
[dpdk.git] / devtools / test-build.sh
1 #! /bin/sh -e
2 # SPDX-License-Identifier: BSD-3-Clause
3 # Copyright 2015 6WIND S.A.
4
5 default_path=$PATH
6
7 # Load config options:
8 # - ARMV8_CRYPTO_LIB_PATH
9 # - DPDK_BUILD_TEST_CONFIGS (defconfig1+option1+option2 defconfig2)
10 # - DPDK_DEP_ARCHIVE
11 # - DPDK_DEP_CFLAGS
12 # - DPDK_DEP_ELF (y/[n])
13 # - DPDK_DEP_ISAL (y/[n])
14 # - DPDK_DEP_JSON (y/[n])
15 # - DPDK_DEP_LDFLAGS
16 # - DPDK_DEP_MLX (y/[n])
17 # - DPDK_DEP_NUMA ([y]/n)
18 # - DPDK_DEP_PCAP (y/[n])
19 # - DPDK_DEP_SSL (y/[n])
20 # - DPDK_DEP_IPSEC_MB (y/[n])
21 # - DPDK_DEP_SZE (y/[n])
22 # - DPDK_DEP_ZLIB (y/[n])
23 # - DPDK_MAKE_JOBS (int)
24 # - DPDK_NOTIFY (notify-send)
25 # - FLEXRAN_SDK
26 # - LIBMUSDK_PATH
27 # - LIBSSO_SNOW3G_PATH
28 # - LIBSSO_KASUMI_PATH
29 # - LIBSSO_ZUC_PATH
30 . $(dirname $(readlink -e $0))/load-devel-config
31
32 print_usage () {
33         echo "usage: $(basename $0) [-h] [-jX] [-s] [config1 [config2] ...]]"
34 }
35
36 print_help () {
37         echo 'Test building several targets with different options'
38         echo
39         print_usage
40         cat <<- END_OF_HELP
41
42         options:
43                 -h    this help
44                 -jX   use X parallel jobs in "make"
45                 -s    short test only first config without tests|examples|doc
46                 -v    verbose build
47
48         config: defconfig[[~][+]option1[[~][+]option2...]]
49                 Example: x86_64-native-linuxapp-gcc+debug~RXTX_CALLBACKS
50                 The lowercase options are defined inside $(basename $0).
51                 The uppercase options can be the end of a defconfig option
52                 to enable if prefixed with '+' or to disable if prefixed with '~'.
53                 Default is to automatically enable most of the options.
54                 The external dependencies are setup with DPDK_DEP_* variables.
55                 If no config on command line, DPDK_BUILD_TEST_CONFIGS is used.
56         END_OF_HELP
57 }
58
59 J=$DPDK_MAKE_JOBS
60 short=false
61 unset verbose
62 maxerr=-Wfatal-errors
63 while getopts hj:sv ARG ; do
64         case $ARG in
65                 j ) J=$OPTARG ;;
66                 s ) short=true ;;
67                 v ) verbose='V=1' ;;
68                 h ) print_help ; exit 0 ;;
69                 ? ) print_usage ; exit 1 ;;
70         esac
71 done
72 shift $(($OPTIND - 1))
73 configs=${*:-$DPDK_BUILD_TEST_CONFIGS}
74
75 success=false
76 on_exit ()
77 {
78         if $success ; then
79                 [ "$DPDK_NOTIFY" != notify-send ] || \
80                         notify-send -u low --icon=dialog-information 'DPDK build' 'finished'
81         elif [ -z "$signal" ] ; then
82                 [ -z "$dir" ] || echo "failed to build $dir" >&2
83                 [ "$DPDK_NOTIFY" != notify-send ] || \
84                         notify-send -u low --icon=dialog-error 'DPDK build' 'failed'
85         fi
86 }
87 # catch manual interrupt to ignore notification
88 trap "signal=INT ; trap - INT ; kill -INT $$" INT
89 # notify result on exit
90 trap on_exit EXIT
91
92 cd $(dirname $(readlink -m $0))/..
93
94 reset_env ()
95 {
96         export PATH=$default_path
97         unset CROSS
98         unset DPDK_DEP_ARCHIVE
99         unset DPDK_DEP_CFLAGS
100         unset DPDK_DEP_ELF
101         unset DPDK_DEP_ISAL
102         unset DPDK_DEP_JSON
103         unset DPDK_DEP_LDFLAGS
104         unset DPDK_DEP_MLX
105         unset DPDK_DEP_NUMA
106         unset DPDK_DEP_PCAP
107         unset DPDK_DEP_SSL
108         unset DPDK_DEP_IPSEC_MB
109         unset DPDK_DEP_SZE
110         unset DPDK_DEP_ZLIB
111         unset ARMV8_CRYPTO_LIB_PATH
112         unset FLEXRAN_SDK
113         unset LIBMUSDK_PATH
114         unset LIBSSO_SNOW3G_PATH
115         unset LIBSSO_KASUMI_PATH
116         unset LIBSSO_ZUC_PATH
117         unset PQOS_INSTALL_PATH
118 }
119
120 config () # <directory> <target> <options>
121 {
122         reconfig=false
123         if git rev-parse 2>&- && [ -n "$(git diff HEAD~ -- config)" ] ; then
124                 echo 'Default config may have changed'
125                 reconfig=true
126         fi
127         if [ ! -e $1/.config ] || $reconfig ; then
128                 echo "================== Configure $1"
129                 make T=$2 O=$1 config
130
131                 echo 'Customize configuration'
132                 # Built-in options (lowercase)
133                 ! echo $3 | grep -q '+default' || \
134                 sed -ri 's,(RTE_MACHINE=")native,\1default,' $1/.config
135                 echo $3 | grep -q '+next' || \
136                 sed -ri           's,(NEXT_ABI=)y,\1n,' $1/.config
137                 ! echo $3 | grep -q '+shared' || \
138                 sed -ri         's,(SHARED_LIB=)n,\1y,' $1/.config
139                 ! echo $3 | grep -q '+debug' || ( \
140                 sed -ri  's,(RTE_LOG_DP_LEVEL=).*,\1RTE_LOG_DEBUG,' $1/.config
141                 sed -ri           's,(_DEBUG.*=)n,\1y,' $1/.config
142                 sed -ri            's,(_STAT.*=)n,\1y,' $1/.config
143                 sed -ri 's,(TEST_PMD_RECORD_.*=)n,\1y,' $1/.config )
144
145                 # Automatic configuration
146                 test "$DPDK_DEP_NUMA" != n || \
147                 sed -ri             's,(NUMA.*=)y,\1n,' $1/.config
148                 sed -ri    's,(LIBRTE_IEEE1588=)n,\1y,' $1/.config
149                 sed -ri             's,(BYPASS=)n,\1y,' $1/.config
150                 test "$DPDK_DEP_ARCHIVE" != y || \
151                 sed -ri       's,(RESOURCE_TAR=)n,\1y,' $1/.config
152                 test "$DPDK_DEP_ISAL" != y || \
153                 sed -ri           's,(ISAL_PMD=)n,\1y,' $1/.config
154                 test "$DPDK_DEP_MLX" != y || \
155                 sed -ri           's,(MLX._PMD=)n,\1y,' $1/.config
156                 test "$DPDK_DEP_SZE" != y || \
157                 sed -ri       's,(PMD_SZEDATA2=)n,\1y,' $1/.config
158                 test "$DPDK_DEP_ZLIB" != y || \
159                 sed -ri          's,(BNX2X_PMD=)n,\1y,' $1/.config
160                 test "$DPDK_DEP_ZLIB" != y || \
161                 sed -ri   's,(COMPRESSDEV_TEST=)n,\1y,' $1/.config
162                 test "$DPDK_DEP_PCAP" != y || \
163                 sed -ri               's,(PCAP=)n,\1y,' $1/.config
164                 test -z "$ARMV8_CRYPTO_LIB_PATH" || \
165                 sed -ri   's,(PMD_ARMV8_CRYPTO=)n,\1y,' $1/.config
166                 test "$DPDK_DEP_IPSEC_MB" != y || \
167                 sed -ri       's,(PMD_AESNI_MB=)n,\1y,' $1/.config
168                 test "$DPDK_DEP_IPSEC_MB" != y || \
169                 sed -ri      's,(PMD_AESNI_GCM=)n,\1y,' $1/.config
170                 test -z "$LIBSSO_SNOW3G_PATH" || \
171                 sed -ri         's,(PMD_SNOW3G=)n,\1y,' $1/.config
172                 test -z "$LIBSSO_KASUMI_PATH" || \
173                 sed -ri         's,(PMD_KASUMI=)n,\1y,' $1/.config
174                 test -z "$LIBSSO_ZUC_PATH" || \
175                 sed -ri            's,(PMD_ZUC=)n,\1y,' $1/.config
176                 test "$DPDK_DEP_SSL" != y || \
177                 sed -ri            's,(PMD_CCP=)n,\1y,' $1/.config
178                 test "$DPDK_DEP_SSL" != y || \
179                 sed -ri        's,(PMD_OPENSSL=)n,\1y,' $1/.config
180                 test "$DPDK_DEP_SSL" != y || \
181                 sed -ri            's,(PMD_QAT=)n,\1y,' $1/.config
182                 test -z "$FLEXRAN_SDK" || \
183                 sed -ri     's,(BBDEV_TURBO_SW=)n,\1y,' $1/.config
184                 sed -ri           's,(SCHED_.*=)n,\1y,' $1/.config
185                 test -z "$LIBMUSDK_PATH" || \
186                 sed -ri   's,(PMD_MVSAM_CRYPTO=)n,\1y,' $1/.config
187                 test -z "$LIBMUSDK_PATH" || \
188                 sed -ri          's,(MVPP2_PMD=)n,\1y,' $1/.config
189                 test -z "$LIBMUSDK_PATH" || \
190                 sed -ri         's,(MVNETA_PMD=)n,\1y,' $1/.config
191                 test "$DPDK_DEP_ELF" != y || \
192                 sed -ri            's,(BPF_ELF=)n,\1y,' $1/.config
193                 test -z "$DPDK_DEP_JSON" || \
194                 sed -ri          's,(TELEMETRY=)n,\1y,' $1/.config
195                 build_config_hook $1 $2 $3
196
197                 # Explicit enabler/disabler (uppercase)
198                 for option in $(echo $3 | sed 's,[~+], &,g') ; do
199                         pattern=$(echo $option | cut -c2-)
200                         if echo $option | grep -q '^~' ; then
201                                 sed -ri "s,($pattern=)y,\1n," $1/.config
202                         elif echo $option | grep -q '^+' ; then
203                                 sed -ri "s,($pattern=)n,\1y," $1/.config
204                         fi
205                 done
206         fi
207 }
208
209 # default empty hook to override in devel config
210 build_config_hook () # <directory> <target> <options>
211 {
212         :
213 }
214
215 for conf in $configs ; do
216         target=$(echo $conf | sed 's,[~+].*,,')
217         # reload config with DPDK_TARGET set
218         DPDK_TARGET=$target
219         reset_env
220         . $(dirname $(readlink -e $0))/load-devel-config
221
222         options=$(echo $conf | sed 's,[^~+]*,,')
223         dir=$conf
224         config $dir $target $options
225
226         echo "================== Build $dir"
227         make -j$J EXTRA_CFLAGS="$maxerr $DPDK_DEP_CFLAGS" \
228                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose O=$dir
229         ! $short || break
230         echo "================== Build tests for $dir"
231         make test-build -j$J EXTRA_CFLAGS="$maxerr $DPDK_DEP_CFLAGS" \
232                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose O=$dir
233         echo "================== Build examples for $dir"
234         export RTE_SDK=$(pwd)
235         export RTE_TARGET=$dir
236         make -j$J -sC examples \
237                 EXTRA_LDFLAGS="$DPDK_DEP_LDFLAGS" $verbose \
238                 O=$(readlink -m $dir/examples)
239         unset RTE_TARGET
240         echo "################## $dir done."
241         unset dir
242 done
243
244 if ! $short ; then
245         mkdir -p .check
246         echo "================== Build doxygen HTML API"
247         make doc-api-html >/dev/null 2>.check/doc.txt
248         echo "================== Build sphinx HTML guides"
249         make doc-guides-html >/dev/null 2>>.check/doc.txt
250         echo "================== Check docs"
251         diff -u /dev/null .check/doc.txt
252 fi
253
254 success=true