blob: ce2c5006564f7d697f909c3f1e97c2d96dc21c6c [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
Gowtham Suresh Kumara12baf82023-07-19 08:39:20 +0100108print_version "gcc-earliest" "--version" "" "head -n 1"
109echo
110
111print_version "gcc-latest" "--version" "" "head -n 1"
112echo
113
Simon Butcher07d5a472020-02-26 15:29:40 +0000114print_version "clang" "--version" "" "head -n 2"
Janos Follathb72c6782016-07-19 14:54:17 +0100115echo
Andres AG7a63eaf2016-09-05 12:24:47 +0100116
Gowtham Suresh Kumara12baf82023-07-19 08:39:20 +0100117print_version "clang-earliest" "--version" "" "head -n 2"
118echo
119
120print_version "clang-latest" "--version" "" "head -n 2"
121echo
122
Simon Butcher07d5a472020-02-26 15:29:40 +0000123print_version "ldd" "--version" "" "head -n 1"
Andres AG31f9b5b2016-10-04 17:14:38 +0100124echo
125
Simon Butcher07d5a472020-02-26 15:29:40 +0000126print_version "valgrind" "--version" ""
127echo
128
129print_version "gdb" "--version" "" "head -n 1"
Andres AG31f9b5b2016-10-04 17:14:38 +0100130echo
131
Simon Butcher69101222020-03-05 15:18:53 +0000132print_version "perl" "--version" "" "head -n 2" "grep ."
133echo
134
135print_version "python" "--version" "" "head -n 1"
136echo
137
Ronald Cron87e658d2020-05-25 13:55:21 +0200138print_version "python3" "--version" "" "head -n 1"
139echo
140
Simon Butchere30d03e2020-03-16 11:30:46 +0000141# Find the installed version of Pylint. Installed as a distro package this can
142# be pylint3 and as a PEP egg, pylint. In test scripts We prefer pylint over
143# pylint3
144if type pylint >/dev/null 2>/dev/null; then
145 print_version "pylint" "--version" "" "sed /^.*config/d" "grep pylint"
146elif type pylint3 >/dev/null 2>/dev/null; then
147 print_version "pylint3" "--version" "" "sed /^.*config/d" "grep pylint"
148else
149 echo " * pylint or pylint3: Not found."
150fi
Simon Butcher69101222020-03-05 15:18:53 +0000151echo
152
Andres AG31f9b5b2016-10-04 17:14:38 +0100153: ${OPENSSL:=openssl}
Simon Butcher07d5a472020-02-26 15:29:40 +0000154print_version "$OPENSSL" "version" "default"
Andres AG31f9b5b2016-10-04 17:14:38 +0100155echo
Andres AG7a63eaf2016-09-05 12:24:47 +0100156
157if [ -n "${OPENSSL_LEGACY+set}" ]; then
Simon Butcher07d5a472020-02-26 15:29:40 +0000158 print_version "$OPENSSL_LEGACY" "version" "legacy"
159else
160 echo " * openssl (legacy): Not configured."
Janos Follathb72c6782016-07-19 14:54:17 +0100161fi
Simon Butcher07d5a472020-02-26 15:29:40 +0000162echo
Janos Follathb72c6782016-07-19 14:54:17 +0100163
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100164if [ -n "${OPENSSL_NEXT+set}" ]; then
Simon Butcher07d5a472020-02-26 15:29:40 +0000165 print_version "$OPENSSL_NEXT" "version" "next"
166else
167 echo " * openssl (next): Not configured."
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100168fi
Simon Butcher07d5a472020-02-26 15:29:40 +0000169echo
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100170
Andres AG31f9b5b2016-10-04 17:14:38 +0100171: ${GNUTLS_CLI:=gnutls-cli}
Simon Butcher07d5a472020-02-26 15:29:40 +0000172print_version "$GNUTLS_CLI" "--version" "default" "head -n 1"
Janos Follathb72c6782016-07-19 14:54:17 +0100173echo
Janos Follathb72c6782016-07-19 14:54:17 +0100174
Andres AG31f9b5b2016-10-04 17:14:38 +0100175: ${GNUTLS_SERV:=gnutls-serv}
Simon Butcher07d5a472020-02-26 15:29:40 +0000176print_version "$GNUTLS_SERV" "--version" "default" "head -n 1"
Janos Follathb72c6782016-07-19 14:54:17 +0100177echo
Andres AG7a63eaf2016-09-05 12:24:47 +0100178
179if [ -n "${GNUTLS_LEGACY_CLI+set}" ]; then
Simon Butcher07d5a472020-02-26 15:29:40 +0000180 print_version "$GNUTLS_LEGACY_CLI" "--version" "legacy" "head -n 1"
181else
182 echo " * gnutls-cli (legacy): Not configured."
Andres AG7a63eaf2016-09-05 12:24:47 +0100183fi
Simon Butcher07d5a472020-02-26 15:29:40 +0000184echo
Andres AG7a63eaf2016-09-05 12:24:47 +0100185
186if [ -n "${GNUTLS_LEGACY_SERV+set}" ]; then
Simon Butcher07d5a472020-02-26 15:29:40 +0000187 print_version "$GNUTLS_LEGACY_SERV" "--version" "legacy" "head -n 1"
188else
189 echo " * gnutls-serv (legacy): Not configured."
Janos Follathb72c6782016-07-19 14:54:17 +0100190fi
Simon Butcher07d5a472020-02-26 15:29:40 +0000191echo
Janos Follathb72c6782016-07-19 14:54:17 +0100192
Simon Butcher07d5a472020-02-26 15:29:40 +0000193echo " * Installed asan versions:"
Simon Butcher7bfeb662020-02-27 12:58:27 +0000194if type dpkg-query >/dev/null 2>/dev/null; then
195 if ! dpkg-query -f '${Status} ${Package}: ${Version}\n' -W 'libasan*' |
196 awk '$3 == "installed" && $4 !~ /-/ {print $4, $5}' |
197 grep .
198 then
199 echo " No asan versions installed."
200 fi
Janos Follathb72c6782016-07-19 14:54:17 +0100201else
Simon Butcher7bfeb662020-02-27 12:58:27 +0000202 echo " Unable to determine the asan version without dpkg."
Janos Follathb72c6782016-07-19 14:54:17 +0100203fi
Janos Follathb72c6782016-07-19 14:54:17 +0100204echo