output_env.sh 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. #! /usr/bin/env sh
  2. # output_env.sh
  3. #
  4. # Copyright The Mbed TLS Contributors
  5. # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
  6. #
  7. # This file is provided under the Apache License 2.0, or the
  8. # GNU General Public License v2.0 or later.
  9. #
  10. # **********
  11. # Apache License 2.0:
  12. #
  13. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  14. # not use this file except in compliance with the License.
  15. # You may obtain a copy of the License at
  16. #
  17. # http://www.apache.org/licenses/LICENSE-2.0
  18. #
  19. # Unless required by applicable law or agreed to in writing, software
  20. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  21. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  22. # See the License for the specific language governing permissions and
  23. # limitations under the License.
  24. #
  25. # **********
  26. #
  27. # **********
  28. # GNU General Public License v2.0 or later:
  29. #
  30. # This program is free software; you can redistribute it and/or modify
  31. # it under the terms of the GNU General Public License as published by
  32. # the Free Software Foundation; either version 2 of the License, or
  33. # (at your option) any later version.
  34. #
  35. # This program is distributed in the hope that it will be useful,
  36. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  37. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  38. # GNU General Public License for more details.
  39. #
  40. # You should have received a copy of the GNU General Public License along
  41. # with this program; if not, write to the Free Software Foundation, Inc.,
  42. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  43. #
  44. # **********
  45. #
  46. # Purpose
  47. #
  48. # To print out all the relevant information about the development environment.
  49. #
  50. # This includes:
  51. # - architecture of the system
  52. # - type and version of the operating system
  53. # - version of make and cmake
  54. # - version of armcc, clang, gcc-arm and gcc compilers
  55. # - version of libc, clang, asan and valgrind if installed
  56. # - version of gnuTLS and OpenSSL
  57. print_version()
  58. {
  59. BIN="$1"
  60. shift
  61. ARGS="$1"
  62. shift
  63. VARIANT="$1"
  64. shift
  65. if [ -n "$VARIANT" ]; then
  66. VARIANT=" ($VARIANT)"
  67. fi
  68. if ! type "$BIN" > /dev/null 2>&1; then
  69. echo " * ${BIN##*/}$VARIANT: Not found."
  70. return 0
  71. fi
  72. BIN=`which "$BIN"`
  73. VERSION_STR=`$BIN $ARGS 2>&1`
  74. # Apply all filters
  75. while [ $# -gt 0 ]; do
  76. FILTER="$1"
  77. shift
  78. VERSION_STR=`echo "$VERSION_STR" | $FILTER`
  79. done
  80. if [ -z "$VERSION_STR" ]; then
  81. VERSION_STR="Version could not be determined."
  82. fi
  83. echo " * ${BIN##*/}$VARIANT: ${BIN} : ${VERSION_STR} "
  84. }
  85. echo "** Platform:"
  86. echo
  87. if [ `uname -s` = "Linux" ]; then
  88. echo "Linux variant"
  89. lsb_release -d -c
  90. else
  91. echo "Unknown Unix variant"
  92. fi
  93. echo
  94. print_version "uname" "-a" ""
  95. echo
  96. echo
  97. echo "** Tool Versions:"
  98. echo
  99. print_version "make" "--version" "" "head -n 1"
  100. echo
  101. print_version "cmake" "--version" "" "head -n 1"
  102. echo
  103. if [ "${RUN_ARMCC:-1}" -ne 0 ]; then
  104. : "${ARMC5_CC:=armcc}"
  105. print_version "$ARMC5_CC" "--vsn" "" "head -n 2"
  106. echo
  107. : "${ARMC6_CC:=armclang}"
  108. print_version "$ARMC6_CC" "--vsn" "" "head -n 2"
  109. echo
  110. fi
  111. print_version "arm-none-eabi-gcc" "--version" "" "head -n 1"
  112. echo
  113. print_version "gcc" "--version" "" "head -n 1"
  114. echo
  115. print_version "clang" "--version" "" "head -n 2"
  116. echo
  117. print_version "ldd" "--version" "" "head -n 1"
  118. echo
  119. print_version "valgrind" "--version" ""
  120. echo
  121. print_version "gdb" "--version" "" "head -n 1"
  122. echo
  123. print_version "perl" "--version" "" "head -n 2" "grep ."
  124. echo
  125. print_version "python" "--version" "" "head -n 1"
  126. echo
  127. print_version "python3" "--version" "" "head -n 1"
  128. echo
  129. # 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
  132. if type pylint >/dev/null 2>/dev/null; then
  133. print_version "pylint" "--version" "" "sed /^.*config/d" "grep pylint"
  134. elif type pylint3 >/dev/null 2>/dev/null; then
  135. print_version "pylint3" "--version" "" "sed /^.*config/d" "grep pylint"
  136. else
  137. echo " * pylint or pylint3: Not found."
  138. fi
  139. echo
  140. : ${OPENSSL:=openssl}
  141. print_version "$OPENSSL" "version" "default"
  142. echo
  143. if [ -n "${OPENSSL_LEGACY+set}" ]; then
  144. print_version "$OPENSSL_LEGACY" "version" "legacy"
  145. else
  146. echo " * openssl (legacy): Not configured."
  147. fi
  148. echo
  149. if [ -n "${OPENSSL_NEXT+set}" ]; then
  150. print_version "$OPENSSL_NEXT" "version" "next"
  151. else
  152. echo " * openssl (next): Not configured."
  153. fi
  154. echo
  155. : ${GNUTLS_CLI:=gnutls-cli}
  156. print_version "$GNUTLS_CLI" "--version" "default" "head -n 1"
  157. echo
  158. : ${GNUTLS_SERV:=gnutls-serv}
  159. print_version "$GNUTLS_SERV" "--version" "default" "head -n 1"
  160. echo
  161. if [ -n "${GNUTLS_LEGACY_CLI+set}" ]; then
  162. print_version "$GNUTLS_LEGACY_CLI" "--version" "legacy" "head -n 1"
  163. else
  164. echo " * gnutls-cli (legacy): Not configured."
  165. fi
  166. echo
  167. if [ -n "${GNUTLS_LEGACY_SERV+set}" ]; then
  168. print_version "$GNUTLS_LEGACY_SERV" "--version" "legacy" "head -n 1"
  169. else
  170. echo " * gnutls-serv (legacy): Not configured."
  171. fi
  172. echo
  173. echo " * Installed asan versions:"
  174. if type dpkg-query >/dev/null 2>/dev/null; then
  175. if ! dpkg-query -f '${Status} ${Package}: ${Version}\n' -W 'libasan*' |
  176. awk '$3 == "installed" && $4 !~ /-/ {print $4, $5}' |
  177. grep .
  178. then
  179. echo " No asan versions installed."
  180. fi
  181. else
  182. echo " Unable to determine the asan version without dpkg."
  183. fi
  184. echo