blob: 535613298eb3d6bc7b947ebf951b2e336b84b5df [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 Kumar6f1977b2023-07-28 17:04:47 +0100108if [ -n "${GCC_EARLIEST+set}" ]; then
109 print_version "${GCC_EARLIEST}" "--version" "" "head -n 1"
110else
111 echo " GCC_EARLIEST : Not configured."
112fi
Gowtham Suresh Kumara12baf82023-07-19 08:39:20 +0100113echo
114
Gowtham Suresh Kumar6f1977b2023-07-28 17:04:47 +0100115if [ -n "${GCC_LATEST+set}" ]; then
116 print_version "${GCC_LATEST}" "--version" "" "head -n 1"
117else
118 echo " GCC_LATEST : Not configured."
119fi
Gowtham Suresh Kumara12baf82023-07-19 08:39:20 +0100120echo
121
Simon Butcher07d5a472020-02-26 15:29:40 +0000122print_version "clang" "--version" "" "head -n 2"
Janos Follathb72c6782016-07-19 14:54:17 +0100123echo
Andres AG7a63eaf2016-09-05 12:24:47 +0100124
Gowtham Suresh Kumar6f1977b2023-07-28 17:04:47 +0100125if [ -n "${CLANG_EARLIEST+set}" ]; then
126 print_version "${CLANG_EARLIEST}" "--version" "" "head -n 2"
127else
128 echo " CLANG_EARLIEST : Not configured."
129fi
Gowtham Suresh Kumara12baf82023-07-19 08:39:20 +0100130echo
131
Gowtham Suresh Kumar6f1977b2023-07-28 17:04:47 +0100132if [ -n "${CLANG_LATEST+set}" ]; then
133 print_version "${CLANG_LATEST}" "--version" "" "head -n 2"
134else
135 echo " CLANG_LATEST : Not configured."
136fi
Gowtham Suresh Kumara12baf82023-07-19 08:39:20 +0100137echo
138
Simon Butcher07d5a472020-02-26 15:29:40 +0000139print_version "ldd" "--version" "" "head -n 1"
Andres AG31f9b5b2016-10-04 17:14:38 +0100140echo
141
Simon Butcher07d5a472020-02-26 15:29:40 +0000142print_version "valgrind" "--version" ""
143echo
144
145print_version "gdb" "--version" "" "head -n 1"
Andres AG31f9b5b2016-10-04 17:14:38 +0100146echo
147
Simon Butcher69101222020-03-05 15:18:53 +0000148print_version "perl" "--version" "" "head -n 2" "grep ."
149echo
150
151print_version "python" "--version" "" "head -n 1"
152echo
153
Ronald Cron87e658d2020-05-25 13:55:21 +0200154print_version "python3" "--version" "" "head -n 1"
155echo
156
Simon Butchere30d03e2020-03-16 11:30:46 +0000157# Find the installed version of Pylint. Installed as a distro package this can
158# be pylint3 and as a PEP egg, pylint. In test scripts We prefer pylint over
159# pylint3
160if type pylint >/dev/null 2>/dev/null; then
161 print_version "pylint" "--version" "" "sed /^.*config/d" "grep pylint"
162elif type pylint3 >/dev/null 2>/dev/null; then
163 print_version "pylint3" "--version" "" "sed /^.*config/d" "grep pylint"
164else
165 echo " * pylint or pylint3: Not found."
166fi
Simon Butcher69101222020-03-05 15:18:53 +0000167echo
168
Andres AG31f9b5b2016-10-04 17:14:38 +0100169: ${OPENSSL:=openssl}
Simon Butcher07d5a472020-02-26 15:29:40 +0000170print_version "$OPENSSL" "version" "default"
Andres AG31f9b5b2016-10-04 17:14:38 +0100171echo
Andres AG7a63eaf2016-09-05 12:24:47 +0100172
173if [ -n "${OPENSSL_LEGACY+set}" ]; then
Simon Butcher07d5a472020-02-26 15:29:40 +0000174 print_version "$OPENSSL_LEGACY" "version" "legacy"
175else
176 echo " * openssl (legacy): Not configured."
Janos Follathb72c6782016-07-19 14:54:17 +0100177fi
Simon Butcher07d5a472020-02-26 15:29:40 +0000178echo
Janos Follathb72c6782016-07-19 14:54:17 +0100179
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100180if [ -n "${OPENSSL_NEXT+set}" ]; then
Simon Butcher07d5a472020-02-26 15:29:40 +0000181 print_version "$OPENSSL_NEXT" "version" "next"
182else
183 echo " * openssl (next): Not configured."
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100184fi
Simon Butcher07d5a472020-02-26 15:29:40 +0000185echo
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100186
Andres AG31f9b5b2016-10-04 17:14:38 +0100187: ${GNUTLS_CLI:=gnutls-cli}
Simon Butcher07d5a472020-02-26 15:29:40 +0000188print_version "$GNUTLS_CLI" "--version" "default" "head -n 1"
Janos Follathb72c6782016-07-19 14:54:17 +0100189echo
Janos Follathb72c6782016-07-19 14:54:17 +0100190
Andres AG31f9b5b2016-10-04 17:14:38 +0100191: ${GNUTLS_SERV:=gnutls-serv}
Simon Butcher07d5a472020-02-26 15:29:40 +0000192print_version "$GNUTLS_SERV" "--version" "default" "head -n 1"
Janos Follathb72c6782016-07-19 14:54:17 +0100193echo
Andres AG7a63eaf2016-09-05 12:24:47 +0100194
195if [ -n "${GNUTLS_LEGACY_CLI+set}" ]; then
Simon Butcher07d5a472020-02-26 15:29:40 +0000196 print_version "$GNUTLS_LEGACY_CLI" "--version" "legacy" "head -n 1"
197else
198 echo " * gnutls-cli (legacy): Not configured."
Andres AG7a63eaf2016-09-05 12:24:47 +0100199fi
Simon Butcher07d5a472020-02-26 15:29:40 +0000200echo
Andres AG7a63eaf2016-09-05 12:24:47 +0100201
202if [ -n "${GNUTLS_LEGACY_SERV+set}" ]; then
Simon Butcher07d5a472020-02-26 15:29:40 +0000203 print_version "$GNUTLS_LEGACY_SERV" "--version" "legacy" "head -n 1"
204else
205 echo " * gnutls-serv (legacy): Not configured."
Janos Follathb72c6782016-07-19 14:54:17 +0100206fi
Simon Butcher07d5a472020-02-26 15:29:40 +0000207echo
Janos Follathb72c6782016-07-19 14:54:17 +0100208
Simon Butcher07d5a472020-02-26 15:29:40 +0000209echo " * Installed asan versions:"
Simon Butcher7bfeb662020-02-27 12:58:27 +0000210if type dpkg-query >/dev/null 2>/dev/null; then
211 if ! dpkg-query -f '${Status} ${Package}: ${Version}\n' -W 'libasan*' |
212 awk '$3 == "installed" && $4 !~ /-/ {print $4, $5}' |
213 grep .
214 then
215 echo " No asan versions installed."
216 fi
Janos Follathb72c6782016-07-19 14:54:17 +0100217else
Simon Butcher7bfeb662020-02-27 12:58:27 +0000218 echo " Unable to determine the asan version without dpkg."
Janos Follathb72c6782016-07-19 14:54:17 +0100219fi
Janos Follathb72c6782016-07-19 14:54:17 +0100220echo