blob: 1d9e0faebea17439b96d5ce6f77a19b0a7058c83 [file] [log] [blame]
Andres AG31f9b5b2016-10-04 17:14:38 +01001#! /usr/bin/env sh
2
Janos Follathb72c6782016-07-19 14:54:17 +01003# output_env.sh
4#
Bence Szépkúti1e148272020-08-07 13:07:28 +02005# Copyright The Mbed TLS Contributors
Bence Szépkútic7da1fe2020-05-26 01:54:15 +02006# SPDX-License-Identifier: Apache-2.0
7#
8# Licensed under the Apache License, Version 2.0 (the "License"); you may
9# not use this file except in compliance with the License.
10# You may obtain a copy of the License at
11#
12# http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing, software
15# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17# See the License for the specific language governing permissions and
18# limitations under the License.
19#
Janos Follathb72c6782016-07-19 14:54:17 +010020# Purpose
21#
22# To print out all the relevant information about the development environment.
23#
24# This includes:
25# - architecture of the system
26# - type and version of the operating system
Ronald Cron2c1a1f02020-05-25 13:11:32 +020027# - version of make and cmake
Simon Butcher3ac07672016-09-04 14:28:44 +030028# - version of armcc, clang, gcc-arm and gcc compilers
29# - version of libc, clang, asan and valgrind if installed
Janos Follathb72c6782016-07-19 14:54:17 +010030# - version of gnuTLS and OpenSSL
31
Andres AG31f9b5b2016-10-04 17:14:38 +010032print_version()
33{
34 BIN="$1"
35 shift
36 ARGS="$1"
37 shift
Simon Butcher69101222020-03-05 15:18:53 +000038 VARIANT="$1"
Andres AG31f9b5b2016-10-04 17:14:38 +010039 shift
Andres AG7a63eaf2016-09-05 12:24:47 +010040
Simon Butcher7bfeb662020-02-27 12:58:27 +000041 if [ -n "$VARIANT" ]; then
Simon Butcher07d5a472020-02-26 15:29:40 +000042 VARIANT=" ($VARIANT)"
43 fi
44
Simon Butcher7bfeb662020-02-27 12:58:27 +000045 if ! type "$BIN" > /dev/null 2>&1; then
Simon Butcher07d5a472020-02-26 15:29:40 +000046 echo " * ${BIN##*/}$VARIANT: Not found."
Andres AG31f9b5b2016-10-04 17:14:38 +010047 return 0
Andres AG87bb5772016-09-27 15:05:15 +010048 fi
Andres AG87bb5772016-09-27 15:05:15 +010049
Andres AG31f9b5b2016-10-04 17:14:38 +010050 BIN=`which "$BIN"`
51 VERSION_STR=`$BIN $ARGS 2>&1`
Janos Follathb72c6782016-07-19 14:54:17 +010052
Andres AG31f9b5b2016-10-04 17:14:38 +010053 # Apply all filters
54 while [ $# -gt 0 ]; do
55 FILTER="$1"
56 shift
57 VERSION_STR=`echo "$VERSION_STR" | $FILTER`
58 done
59
Simon Butcher69101222020-03-05 15:18:53 +000060 if [ -z "$VERSION_STR" ]; then
61 VERSION_STR="Version could not be determined."
62 fi
63
Simon Butcher07d5a472020-02-26 15:29:40 +000064 echo " * ${BIN##*/}$VARIANT: ${BIN} : ${VERSION_STR} "
Andres AG31f9b5b2016-10-04 17:14:38 +010065}
66
Simon Butcher7bfeb662020-02-27 12:58:27 +000067echo "** Platform:"
68echo
69
70if [ `uname -s` = "Linux" ]; then
Simon Butcher07d5a472020-02-26 15:29:40 +000071 echo "Linux variant"
72 lsb_release -d -c
73else
74 echo "Unknown Unix variant"
75fi
76
Janos Follathb72c6782016-07-19 14:54:17 +010077echo
Janos Follathb72c6782016-07-19 14:54:17 +010078
Simon Butcher07d5a472020-02-26 15:29:40 +000079print_version "uname" "-a" ""
Simon Butcher69101222020-03-05 15:18:53 +000080
Simon Butcher7bfeb662020-02-27 12:58:27 +000081echo
82echo
83echo "** Tool Versions:"
84echo
Simon Butcher07d5a472020-02-26 15:29:40 +000085
Ronald Cron2c1a1f02020-05-25 13:11:32 +020086print_version "make" "--version" "" "head -n 1"
87echo
88
89print_version "cmake" "--version" "" "head -n 1"
90echo
91
Gilles Peskine26232962018-03-21 08:35:07 +010092if [ "${RUN_ARMCC:-1}" -ne 0 ]; then
93 : "${ARMC5_CC:=armcc}"
Simon Butcher07d5a472020-02-26 15:29:40 +000094 print_version "$ARMC5_CC" "--vsn" "" "head -n 2"
Gilles Peskine26232962018-03-21 08:35:07 +010095 echo
Janos Follathb72c6782016-07-19 14:54:17 +010096
Gilles Peskine26232962018-03-21 08:35:07 +010097 : "${ARMC6_CC:=armclang}"
Simon Butcher07d5a472020-02-26 15:29:40 +000098 print_version "$ARMC6_CC" "--vsn" "" "head -n 2"
Gilles Peskine26232962018-03-21 08:35:07 +010099 echo
100fi
Janos Follathb72c6782016-07-19 14:54:17 +0100101
Simon Butcher07d5a472020-02-26 15:29:40 +0000102print_version "arm-none-eabi-gcc" "--version" "" "head -n 1"
Janos Follathb72c6782016-07-19 14:54:17 +0100103echo
Janos Follathb72c6782016-07-19 14:54:17 +0100104
Simon Butcher07d5a472020-02-26 15:29:40 +0000105print_version "gcc" "--version" "" "head -n 1"
Janos Follathb72c6782016-07-19 14:54:17 +0100106echo
Janos Follathb72c6782016-07-19 14:54:17 +0100107
Simon Butcher07d5a472020-02-26 15:29:40 +0000108print_version "clang" "--version" "" "head -n 2"
Janos Follathb72c6782016-07-19 14:54:17 +0100109echo
Andres AG7a63eaf2016-09-05 12:24:47 +0100110
Simon Butcher07d5a472020-02-26 15:29:40 +0000111print_version "ldd" "--version" "" "head -n 1"
Andres AG31f9b5b2016-10-04 17:14:38 +0100112echo
113
Simon Butcher07d5a472020-02-26 15:29:40 +0000114print_version "valgrind" "--version" ""
115echo
116
117print_version "gdb" "--version" "" "head -n 1"
Andres AG31f9b5b2016-10-04 17:14:38 +0100118echo
119
Simon Butcher69101222020-03-05 15:18:53 +0000120print_version "perl" "--version" "" "head -n 2" "grep ."
121echo
122
123print_version "python" "--version" "" "head -n 1"
124echo
125
Ronald Cron87e658d2020-05-25 13:55:21 +0200126print_version "python3" "--version" "" "head -n 1"
127echo
128
Simon Butchere30d03e2020-03-16 11:30:46 +0000129# Find the installed version of Pylint. Installed as a distro package this can
130# be pylint3 and as a PEP egg, pylint. In test scripts We prefer pylint over
131# pylint3
132if type pylint >/dev/null 2>/dev/null; then
133 print_version "pylint" "--version" "" "sed /^.*config/d" "grep pylint"
134elif type pylint3 >/dev/null 2>/dev/null; then
135 print_version "pylint3" "--version" "" "sed /^.*config/d" "grep pylint"
136else
137 echo " * pylint or pylint3: Not found."
138fi
Simon Butcher69101222020-03-05 15:18:53 +0000139echo
140
Andres AG31f9b5b2016-10-04 17:14:38 +0100141: ${OPENSSL:=openssl}
Simon Butcher07d5a472020-02-26 15:29:40 +0000142print_version "$OPENSSL" "version" "default"
Andres AG31f9b5b2016-10-04 17:14:38 +0100143echo
Andres AG7a63eaf2016-09-05 12:24:47 +0100144
145if [ -n "${OPENSSL_LEGACY+set}" ]; then
Simon Butcher07d5a472020-02-26 15:29:40 +0000146 print_version "$OPENSSL_LEGACY" "version" "legacy"
147else
148 echo " * openssl (legacy): Not configured."
Janos Follathb72c6782016-07-19 14:54:17 +0100149fi
Simon Butcher07d5a472020-02-26 15:29:40 +0000150echo
Janos Follathb72c6782016-07-19 14:54:17 +0100151
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100152if [ -n "${OPENSSL_NEXT+set}" ]; then
Simon Butcher07d5a472020-02-26 15:29:40 +0000153 print_version "$OPENSSL_NEXT" "version" "next"
154else
155 echo " * openssl (next): Not configured."
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100156fi
Simon Butcher07d5a472020-02-26 15:29:40 +0000157echo
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100158
Andres AG31f9b5b2016-10-04 17:14:38 +0100159: ${GNUTLS_CLI:=gnutls-cli}
Simon Butcher07d5a472020-02-26 15:29:40 +0000160print_version "$GNUTLS_CLI" "--version" "default" "head -n 1"
Janos Follathb72c6782016-07-19 14:54:17 +0100161echo
Janos Follathb72c6782016-07-19 14:54:17 +0100162
Andres AG31f9b5b2016-10-04 17:14:38 +0100163: ${GNUTLS_SERV:=gnutls-serv}
Simon Butcher07d5a472020-02-26 15:29:40 +0000164print_version "$GNUTLS_SERV" "--version" "default" "head -n 1"
Janos Follathb72c6782016-07-19 14:54:17 +0100165echo
Andres AG7a63eaf2016-09-05 12:24:47 +0100166
167if [ -n "${GNUTLS_LEGACY_CLI+set}" ]; then
Simon Butcher07d5a472020-02-26 15:29:40 +0000168 print_version "$GNUTLS_LEGACY_CLI" "--version" "legacy" "head -n 1"
169else
170 echo " * gnutls-cli (legacy): Not configured."
Andres AG7a63eaf2016-09-05 12:24:47 +0100171fi
Simon Butcher07d5a472020-02-26 15:29:40 +0000172echo
Andres AG7a63eaf2016-09-05 12:24:47 +0100173
174if [ -n "${GNUTLS_LEGACY_SERV+set}" ]; then
Simon Butcher07d5a472020-02-26 15:29:40 +0000175 print_version "$GNUTLS_LEGACY_SERV" "--version" "legacy" "head -n 1"
176else
177 echo " * gnutls-serv (legacy): Not configured."
Janos Follathb72c6782016-07-19 14:54:17 +0100178fi
Simon Butcher07d5a472020-02-26 15:29:40 +0000179echo
Janos Follathb72c6782016-07-19 14:54:17 +0100180
Simon Butcher07d5a472020-02-26 15:29:40 +0000181echo " * Installed asan versions:"
Simon Butcher7bfeb662020-02-27 12:58:27 +0000182if type dpkg-query >/dev/null 2>/dev/null; then
183 if ! dpkg-query -f '${Status} ${Package}: ${Version}\n' -W 'libasan*' |
184 awk '$3 == "installed" && $4 !~ /-/ {print $4, $5}' |
185 grep .
186 then
187 echo " No asan versions installed."
188 fi
Janos Follathb72c6782016-07-19 14:54:17 +0100189else
Simon Butcher7bfeb662020-02-27 12:58:27 +0000190 echo " Unable to determine the asan version without dpkg."
Janos Follathb72c6782016-07-19 14:54:17 +0100191fi
Janos Follathb72c6782016-07-19 14:54:17 +0100192echo