blob: a39a3d97db4ece4e40d80561cf57618742d99238 [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útia2947ac2020-08-19 16:37:36 +02005# Copyright The Mbed TLS Contributors
Bence Szépkútif744bd72020-06-05 13:02:18 +02006# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
7#
8# This file is provided under the Apache License 2.0, or the
9# GNU General Public License v2.0 or later.
10#
11# **********
12# Apache License 2.0:
Bence Szépkúti51b41d52020-05-26 01:54:15 +020013#
14# Licensed under the Apache License, Version 2.0 (the "License"); you may
15# not use this file except in compliance with the License.
16# You may obtain a copy of the License at
17#
18# http://www.apache.org/licenses/LICENSE-2.0
19#
20# Unless required by applicable law or agreed to in writing, software
21# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
22# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23# See the License for the specific language governing permissions and
24# limitations under the License.
25#
Bence Szépkútif744bd72020-06-05 13:02:18 +020026# **********
27#
28# **********
29# GNU General Public License v2.0 or later:
30#
31# This program is free software; you can redistribute it and/or modify
32# it under the terms of the GNU General Public License as published by
33# the Free Software Foundation; either version 2 of the License, or
34# (at your option) any later version.
35#
36# This program is distributed in the hope that it will be useful,
37# but WITHOUT ANY WARRANTY; without even the implied warranty of
38# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
39# GNU General Public License for more details.
40#
41# You should have received a copy of the GNU General Public License along
42# with this program; if not, write to the Free Software Foundation, Inc.,
43# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
44#
45# **********
46#
Janos Follathb72c6782016-07-19 14:54:17 +010047# Purpose
48#
49# To print out all the relevant information about the development environment.
50#
51# This includes:
52# - architecture of the system
53# - type and version of the operating system
Ronald Cron2eefeee2020-05-25 13:11:32 +020054# - version of make and cmake
Simon Butcher3ac07672016-09-04 14:28:44 +030055# - version of armcc, clang, gcc-arm and gcc compilers
56# - version of libc, clang, asan and valgrind if installed
Janos Follathb72c6782016-07-19 14:54:17 +010057# - version of gnuTLS and OpenSSL
58
Andres AG31f9b5b2016-10-04 17:14:38 +010059print_version()
60{
61 BIN="$1"
62 shift
63 ARGS="$1"
64 shift
Simon Butcher85c4c862020-03-05 15:18:53 +000065 VARIANT="$1"
Andres AG31f9b5b2016-10-04 17:14:38 +010066 shift
Andres AG7a63eaf2016-09-05 12:24:47 +010067
Simon Butcher679d2de2020-02-27 12:58:27 +000068 if [ -n "$VARIANT" ]; then
Simon Butcher3104eec2020-02-26 15:29:40 +000069 VARIANT=" ($VARIANT)"
70 fi
71
Simon Butcher679d2de2020-02-27 12:58:27 +000072 if ! type "$BIN" > /dev/null 2>&1; then
Simon Butcher3104eec2020-02-26 15:29:40 +000073 echo " * ${BIN##*/}$VARIANT: Not found."
Andres AG31f9b5b2016-10-04 17:14:38 +010074 return 0
Andres AG87bb5772016-09-27 15:05:15 +010075 fi
Andres AG87bb5772016-09-27 15:05:15 +010076
Andres AG31f9b5b2016-10-04 17:14:38 +010077 BIN=`which "$BIN"`
78 VERSION_STR=`$BIN $ARGS 2>&1`
Janos Follathb72c6782016-07-19 14:54:17 +010079
Andres AG31f9b5b2016-10-04 17:14:38 +010080 # Apply all filters
81 while [ $# -gt 0 ]; do
82 FILTER="$1"
83 shift
84 VERSION_STR=`echo "$VERSION_STR" | $FILTER`
85 done
86
Simon Butcher85c4c862020-03-05 15:18:53 +000087 if [ -z "$VERSION_STR" ]; then
88 VERSION_STR="Version could not be determined."
89 fi
90
Simon Butcher3104eec2020-02-26 15:29:40 +000091 echo " * ${BIN##*/}$VARIANT: ${BIN} : ${VERSION_STR} "
Andres AG31f9b5b2016-10-04 17:14:38 +010092}
93
Simon Butcher679d2de2020-02-27 12:58:27 +000094echo "** Platform:"
95echo
96
97if [ `uname -s` = "Linux" ]; then
Simon Butcher3104eec2020-02-26 15:29:40 +000098 echo "Linux variant"
99 lsb_release -d -c
100else
101 echo "Unknown Unix variant"
102fi
103
Janos Follathb72c6782016-07-19 14:54:17 +0100104echo
Janos Follathb72c6782016-07-19 14:54:17 +0100105
Simon Butcher3104eec2020-02-26 15:29:40 +0000106print_version "uname" "-a" ""
Simon Butcher85c4c862020-03-05 15:18:53 +0000107
Simon Butcher679d2de2020-02-27 12:58:27 +0000108echo
109echo
110echo "** Tool Versions:"
111echo
Simon Butcher3104eec2020-02-26 15:29:40 +0000112
Ronald Cron2eefeee2020-05-25 13:11:32 +0200113print_version "make" "--version" "" "head -n 1"
114echo
115
116print_version "cmake" "--version" "" "head -n 1"
117echo
118
Gilles Peskine26232962018-03-21 08:35:07 +0100119if [ "${RUN_ARMCC:-1}" -ne 0 ]; then
120 : "${ARMC5_CC:=armcc}"
Simon Butcher3104eec2020-02-26 15:29:40 +0000121 print_version "$ARMC5_CC" "--vsn" "" "head -n 2"
Gilles Peskine26232962018-03-21 08:35:07 +0100122 echo
Janos Follathb72c6782016-07-19 14:54:17 +0100123
Gilles Peskine26232962018-03-21 08:35:07 +0100124 : "${ARMC6_CC:=armclang}"
Simon Butcher3104eec2020-02-26 15:29:40 +0000125 print_version "$ARMC6_CC" "--vsn" "" "head -n 2"
Gilles Peskine26232962018-03-21 08:35:07 +0100126 echo
127fi
Janos Follathb72c6782016-07-19 14:54:17 +0100128
Simon Butcher3104eec2020-02-26 15:29:40 +0000129print_version "arm-none-eabi-gcc" "--version" "" "head -n 1"
Janos Follathb72c6782016-07-19 14:54:17 +0100130echo
Janos Follathb72c6782016-07-19 14:54:17 +0100131
Simon Butcher3104eec2020-02-26 15:29:40 +0000132print_version "gcc" "--version" "" "head -n 1"
Janos Follathb72c6782016-07-19 14:54:17 +0100133echo
Janos Follathb72c6782016-07-19 14:54:17 +0100134
Simon Butcher3104eec2020-02-26 15:29:40 +0000135print_version "clang" "--version" "" "head -n 2"
Janos Follathb72c6782016-07-19 14:54:17 +0100136echo
Andres AG7a63eaf2016-09-05 12:24:47 +0100137
Simon Butcher3104eec2020-02-26 15:29:40 +0000138print_version "ldd" "--version" "" "head -n 1"
Andres AG31f9b5b2016-10-04 17:14:38 +0100139echo
140
Simon Butcher3104eec2020-02-26 15:29:40 +0000141print_version "valgrind" "--version" ""
142echo
143
144print_version "gdb" "--version" "" "head -n 1"
Andres AG31f9b5b2016-10-04 17:14:38 +0100145echo
146
Simon Butcher85c4c862020-03-05 15:18:53 +0000147print_version "perl" "--version" "" "head -n 2" "grep ."
148echo
149
150print_version "python" "--version" "" "head -n 1"
151echo
152
Ronald Cron06656772020-05-25 13:55:21 +0200153print_version "python3" "--version" "" "head -n 1"
154echo
155
Simon Butcher47f72872020-03-16 11:30:46 +0000156# Find the installed version of Pylint. Installed as a distro package this can
157# be pylint3 and as a PEP egg, pylint. In test scripts We prefer pylint over
158# pylint3
159if type pylint >/dev/null 2>/dev/null; then
160 print_version "pylint" "--version" "" "sed /^.*config/d" "grep pylint"
161elif type pylint3 >/dev/null 2>/dev/null; then
162 print_version "pylint3" "--version" "" "sed /^.*config/d" "grep pylint"
163else
164 echo " * pylint or pylint3: Not found."
165fi
Simon Butcher85c4c862020-03-05 15:18:53 +0000166echo
167
Andres AG31f9b5b2016-10-04 17:14:38 +0100168: ${OPENSSL:=openssl}
Simon Butcher3104eec2020-02-26 15:29:40 +0000169print_version "$OPENSSL" "version" "default"
Andres AG31f9b5b2016-10-04 17:14:38 +0100170echo
Andres AG7a63eaf2016-09-05 12:24:47 +0100171
172if [ -n "${OPENSSL_LEGACY+set}" ]; then
Simon Butcher3104eec2020-02-26 15:29:40 +0000173 print_version "$OPENSSL_LEGACY" "version" "legacy"
174else
175 echo " * openssl (legacy): Not configured."
Janos Follathb72c6782016-07-19 14:54:17 +0100176fi
Simon Butcher3104eec2020-02-26 15:29:40 +0000177echo
Janos Follathb72c6782016-07-19 14:54:17 +0100178
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100179if [ -n "${OPENSSL_NEXT+set}" ]; then
Simon Butcher3104eec2020-02-26 15:29:40 +0000180 print_version "$OPENSSL_NEXT" "version" "next"
181else
182 echo " * openssl (next): Not configured."
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100183fi
Simon Butcher3104eec2020-02-26 15:29:40 +0000184echo
Manuel Pégourié-Gonnard6b368922018-02-20 12:02:07 +0100185
Andres AG31f9b5b2016-10-04 17:14:38 +0100186: ${GNUTLS_CLI:=gnutls-cli}
Simon Butcher3104eec2020-02-26 15:29:40 +0000187print_version "$GNUTLS_CLI" "--version" "default" "head -n 1"
Janos Follathb72c6782016-07-19 14:54:17 +0100188echo
Janos Follathb72c6782016-07-19 14:54:17 +0100189
Andres AG31f9b5b2016-10-04 17:14:38 +0100190: ${GNUTLS_SERV:=gnutls-serv}
Simon Butcher3104eec2020-02-26 15:29:40 +0000191print_version "$GNUTLS_SERV" "--version" "default" "head -n 1"
Janos Follathb72c6782016-07-19 14:54:17 +0100192echo
Andres AG7a63eaf2016-09-05 12:24:47 +0100193
194if [ -n "${GNUTLS_LEGACY_CLI+set}" ]; then
Simon Butcher3104eec2020-02-26 15:29:40 +0000195 print_version "$GNUTLS_LEGACY_CLI" "--version" "legacy" "head -n 1"
196else
197 echo " * gnutls-cli (legacy): Not configured."
Andres AG7a63eaf2016-09-05 12:24:47 +0100198fi
Simon Butcher3104eec2020-02-26 15:29:40 +0000199echo
Andres AG7a63eaf2016-09-05 12:24:47 +0100200
201if [ -n "${GNUTLS_LEGACY_SERV+set}" ]; then
Simon Butcher3104eec2020-02-26 15:29:40 +0000202 print_version "$GNUTLS_LEGACY_SERV" "--version" "legacy" "head -n 1"
203else
204 echo " * gnutls-serv (legacy): Not configured."
Janos Follathb72c6782016-07-19 14:54:17 +0100205fi
Simon Butcher3104eec2020-02-26 15:29:40 +0000206echo
Janos Follathb72c6782016-07-19 14:54:17 +0100207
Simon Butcher3104eec2020-02-26 15:29:40 +0000208echo " * Installed asan versions:"
Simon Butcher679d2de2020-02-27 12:58:27 +0000209if type dpkg-query >/dev/null 2>/dev/null; then
210 if ! dpkg-query -f '${Status} ${Package}: ${Version}\n' -W 'libasan*' |
211 awk '$3 == "installed" && $4 !~ /-/ {print $4, $5}' |
212 grep .
213 then
214 echo " No asan versions installed."
215 fi
Janos Follathb72c6782016-07-19 14:54:17 +0100216else
Simon Butcher679d2de2020-02-27 12:58:27 +0000217 echo " Unable to determine the asan version without dpkg."
Janos Follathb72c6782016-07-19 14:54:17 +0100218fi
Janos Follathb72c6782016-07-19 14:54:17 +0100219echo