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