• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /usr/bin/env sh
2
3# output_env.sh
4#
5# Copyright The Mbed TLS Contributors
6# 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:
13#
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#
26# **********
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#
47# 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
54#   - version of make and cmake
55#   - version of armcc, clang, gcc-arm and gcc compilers
56#   - version of libc, clang, asan and valgrind if installed
57#   - version of gnuTLS and OpenSSL
58
59print_version()
60{
61    BIN="$1"
62    shift
63    ARGS="$1"
64    shift
65    VARIANT="$1"
66    shift
67
68    if [ -n "$VARIANT" ]; then
69        VARIANT=" ($VARIANT)"
70    fi
71
72    if ! type "$BIN" > /dev/null 2>&1; then
73        echo " * ${BIN##*/}$VARIANT: Not found."
74        return 0
75    fi
76
77    BIN=`which "$BIN"`
78    VERSION_STR=`$BIN $ARGS 2>&1`
79
80    # Apply all filters
81    while [ $# -gt 0 ]; do
82        FILTER="$1"
83        shift
84        VERSION_STR=`echo "$VERSION_STR" | $FILTER`
85    done
86
87    if [ -z "$VERSION_STR" ]; then
88        VERSION_STR="Version could not be determined."
89    fi
90
91    echo " * ${BIN##*/}$VARIANT: ${BIN} : ${VERSION_STR} "
92}
93
94echo "** Platform:"
95echo
96
97if [ `uname -s` = "Linux" ]; then
98    echo "Linux variant"
99    lsb_release -d -c
100else
101    echo "Unknown Unix variant"
102fi
103
104echo
105
106print_version "uname" "-a" ""
107
108echo
109echo
110echo "** Tool Versions:"
111echo
112
113print_version "make" "--version" "" "head -n 1"
114echo
115
116print_version "cmake" "--version" "" "head -n 1"
117echo
118
119if [ "${RUN_ARMCC:-1}" -ne 0 ]; then
120    : "${ARMC5_CC:=armcc}"
121    print_version "$ARMC5_CC" "--vsn" "" "head -n 2"
122    echo
123
124    : "${ARMC6_CC:=armclang}"
125    print_version "$ARMC6_CC" "--vsn" "" "head -n 2"
126    echo
127fi
128
129print_version "arm-none-eabi-gcc" "--version" "" "head -n 1"
130echo
131
132print_version "gcc" "--version" "" "head -n 1"
133echo
134
135print_version "clang" "--version" "" "head -n 2"
136echo
137
138print_version "ldd" "--version" "" "head -n 1"
139echo
140
141print_version "valgrind" "--version" ""
142echo
143
144print_version "gdb" "--version" "" "head -n 1"
145echo
146
147print_version "perl" "--version" "" "head -n 2" "grep ."
148echo
149
150print_version "python" "--version" "" "head -n 1"
151echo
152
153print_version "python3" "--version" "" "head -n 1"
154echo
155
156# 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
166echo
167
168: ${OPENSSL:=openssl}
169print_version "$OPENSSL" "version" "default"
170echo
171
172if [ -n "${OPENSSL_LEGACY+set}" ]; then
173    print_version "$OPENSSL_LEGACY" "version" "legacy"
174else
175    echo " * openssl (legacy): Not configured."
176fi
177echo
178
179if [ -n "${OPENSSL_NEXT+set}" ]; then
180    print_version "$OPENSSL_NEXT" "version" "next"
181else
182    echo " * openssl (next): Not configured."
183fi
184echo
185
186: ${GNUTLS_CLI:=gnutls-cli}
187print_version "$GNUTLS_CLI" "--version" "default" "head -n 1"
188echo
189
190: ${GNUTLS_SERV:=gnutls-serv}
191print_version "$GNUTLS_SERV" "--version" "default" "head -n 1"
192echo
193
194if [ -n "${GNUTLS_LEGACY_CLI+set}" ]; then
195    print_version "$GNUTLS_LEGACY_CLI" "--version" "legacy" "head -n 1"
196else
197     echo " * gnutls-cli (legacy): Not configured."
198fi
199echo
200
201if [ -n "${GNUTLS_LEGACY_SERV+set}" ]; then
202    print_version "$GNUTLS_LEGACY_SERV" "--version" "legacy" "head -n 1"
203else
204    echo " * gnutls-serv (legacy): Not configured."
205fi
206echo
207
208echo " * Installed asan versions:"
209if 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
216else
217    echo "  Unable to determine the asan version without dpkg."
218fi
219echo
220