2020-10-30 13:12:35 +01:00
|
|
|
#!/usr/bin/env bash
|
2017-01-17 12:46:04 +01:00
|
|
|
|
2020-07-07 18:57:16 +02:00
|
|
|
MAKE=${MAKE:-make}
|
|
|
|
|
2018-03-02 09:24:24 +01:00
|
|
|
get_cmd_version() {
|
2017-01-17 12:46:04 +01:00
|
|
|
if [ -z "$1" ]; then
|
2018-03-02 09:24:24 +01:00
|
|
|
return
|
2017-01-17 12:46:04 +01:00
|
|
|
fi
|
2018-03-02 09:24:24 +01:00
|
|
|
|
2018-10-26 11:28:04 +02:00
|
|
|
VERSION_RAW=$( ($@ --version) 2>&1)
|
|
|
|
ERR=$?
|
|
|
|
VERSION=$(echo "$VERSION_RAW" | head -n 1)
|
|
|
|
|
|
|
|
if [ $ERR -eq 127 ] ; then # 127 means command not found
|
|
|
|
VERSION="missing"
|
|
|
|
elif [ $ERR -ne 0 ] ; then
|
|
|
|
VERSION="error: ${VERSION}"
|
2017-01-17 12:46:04 +01:00
|
|
|
fi
|
2018-03-02 09:24:24 +01:00
|
|
|
|
2018-10-26 11:28:04 +02:00
|
|
|
printf "%s" "$VERSION"
|
2017-01-17 12:46:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
get_define() {
|
|
|
|
local cc="$1"
|
|
|
|
local line=
|
|
|
|
if command -v "$cc" 2>&1 >/dev/null; then
|
2023-02-23 23:51:25 +01:00
|
|
|
line=$(echo "$3" | "$cc" -x c -include "$2" -E -o - - 2>/dev/null | sed -e '/^[ ]*#/d' -e '/^[ ]*$/d')
|
2017-01-17 12:46:04 +01:00
|
|
|
fi
|
|
|
|
if [ -z "$line" ]; then
|
2018-03-02 09:24:24 +01:00
|
|
|
line=missing
|
2017-01-17 12:46:04 +01:00
|
|
|
fi
|
|
|
|
printf "%s" "$line"
|
|
|
|
}
|
|
|
|
|
2018-09-19 15:41:01 +02:00
|
|
|
get_kernel_info() {
|
|
|
|
uname -mprs
|
|
|
|
}
|
|
|
|
|
|
|
|
get_os_info() {
|
|
|
|
local os="$(uname -s)"
|
|
|
|
local osname="unknown"
|
|
|
|
local osvers="unknown"
|
|
|
|
if [ "$os" = "Linux" ]; then
|
|
|
|
osname="$(cat /etc/os-release | grep ^NAME= | awk -F'=' '{print $2}')"
|
|
|
|
osvers="$(cat /etc/os-release | grep ^VERSION= | awk -F'=' '{print $2}')"
|
|
|
|
elif [ "$os" = "Darwin" ]; then
|
|
|
|
osname="$(sw_vers -productName)"
|
|
|
|
osvers="$(sw_vers -productVersion)"
|
2019-12-18 10:25:26 +01:00
|
|
|
elif [ "$os" = "FreeBSD" ]; then
|
|
|
|
osname="$os"
|
|
|
|
osvers="$(freebsd-version)"
|
2018-09-19 15:41:01 +02:00
|
|
|
fi
|
|
|
|
printf "%s %s" "$osname" "$osvers"
|
|
|
|
}
|
|
|
|
|
2019-02-11 16:44:59 +01:00
|
|
|
extract_shell_version() {
|
|
|
|
SHELL_NAME=$"(basename $1)"
|
|
|
|
SHELL_VERSION="$($1 --version 2>/dev/null)"
|
|
|
|
ERR=$?
|
|
|
|
if [ $ERR -ne 0 ] ; then # if it does not like the --version switch, it is probably dash
|
|
|
|
printf "%s" "$1"
|
|
|
|
# we do not say "probably dash" if we are sure it IS dash
|
|
|
|
if [ "$SHELL_NAME" != dash ] ; then
|
|
|
|
printf " (probably dash)"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
printf "%s" "$(echo "$SHELL_VERSION" | head -n 1)"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
get_sys_shell() {
|
|
|
|
case "$(uname -s)" in
|
|
|
|
MINGW*)
|
|
|
|
# MINGW has no realpath, but also no (meaningful) symlinks
|
|
|
|
SH_PATH=/bin/sh
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
SH_PATH="$(realpath /bin/sh)"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
extract_shell_version "$SH_PATH"
|
|
|
|
}
|
|
|
|
|
|
|
|
_get_make_shell() {
|
2020-11-03 21:20:47 +01:00
|
|
|
${MAKE} -sf - --no-print-directory 2>/dev/null <<MAKEFILE
|
2019-02-11 16:44:59 +01:00
|
|
|
\$(info \$(realpath \$(SHELL)))
|
|
|
|
MAKEFILE
|
|
|
|
}
|
|
|
|
|
|
|
|
get_make_shell() {
|
|
|
|
extract_shell_version "$(_get_make_shell)"
|
|
|
|
}
|
|
|
|
|
2017-01-17 12:46:04 +01:00
|
|
|
newlib_version() {
|
|
|
|
if [ -z "$1" ]; then
|
2018-03-02 09:24:24 +01:00
|
|
|
printf "%s" "error"
|
2017-01-17 12:46:04 +01:00
|
|
|
else
|
2018-03-02 09:24:24 +01:00
|
|
|
local cc="$1"
|
|
|
|
printf "%s" "$(get_define "$cc" newlib.h _NEWLIB_VERSION)"
|
2017-01-17 12:46:04 +01:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
avr_libc_version() {
|
|
|
|
if [ -z "$1" ]; then
|
2018-03-02 09:24:24 +01:00
|
|
|
printf "%s" "error"
|
2017-05-11 14:12:35 +02:00
|
|
|
else
|
2018-03-02 09:24:24 +01:00
|
|
|
local cc="$1"
|
|
|
|
printf "%s (%s)" "$(get_define "$cc" avr/version.h __AVR_LIBC_VERSION_STRING__)" "$(get_define "$cc" avr/version.h __AVR_LIBC_DATE_STRING__)"
|
2017-05-11 14:12:35 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-09-19 15:41:01 +02:00
|
|
|
printf "\n"
|
|
|
|
# print operating system information
|
|
|
|
printf "%s\n" "Operating System Environment"
|
2020-02-13 10:54:42 +01:00
|
|
|
printf "%s\n" "----------------------------"
|
2020-01-04 17:23:20 +01:00
|
|
|
printf "%25s: %s\n" "Operating System" "$(get_os_info)"
|
|
|
|
printf "%25s: %s\n" "Kernel" "$(get_kernel_info)"
|
2019-02-11 16:44:59 +01:00
|
|
|
printf "%25s: %s\n" "System shell" "$(get_sys_shell)"
|
|
|
|
printf "%25s: %s\n" "make's shell" "$(get_make_shell)"
|
2018-09-19 15:41:01 +02:00
|
|
|
printf "\n"
|
|
|
|
|
2018-09-19 14:45:52 +02:00
|
|
|
printf "%s\n" "Installed compiler toolchains"
|
2018-03-02 09:24:24 +01:00
|
|
|
printf "%s\n" "-----------------------------"
|
2020-01-04 17:23:20 +01:00
|
|
|
printf "%25s: %s\n" "native gcc" "$(get_cmd_version gcc)"
|
2018-12-29 14:26:26 +01:00
|
|
|
for p in \
|
|
|
|
arm-none-eabi \
|
2022-09-06 10:48:58 +02:00
|
|
|
avr \
|
2019-10-18 23:29:53 +02:00
|
|
|
msp430-elf \
|
2020-09-07 22:21:42 +02:00
|
|
|
riscv-none-elf \
|
|
|
|
riscv64-unknown-elf \
|
2023-02-23 23:48:52 +01:00
|
|
|
riscv32-esp-elf \
|
2018-12-29 14:28:08 +01:00
|
|
|
xtensa-esp32-elf \
|
2023-02-23 23:48:52 +01:00
|
|
|
xtensa-esp32s2-elf \
|
|
|
|
xtensa-esp32s3-elf \
|
2020-01-04 17:23:20 +01:00
|
|
|
xtensa-esp8266-elf \
|
2018-12-29 14:26:26 +01:00
|
|
|
; do
|
2020-01-04 17:23:20 +01:00
|
|
|
printf "%25s: %s\n" "$p-gcc" "$(get_cmd_version ${p}-gcc)"
|
2017-01-17 12:46:04 +01:00
|
|
|
done
|
2020-01-04 17:23:20 +01:00
|
|
|
printf "%25s: %s\n" "clang" "$(get_cmd_version clang)"
|
2018-03-02 09:24:24 +01:00
|
|
|
printf "\n"
|
|
|
|
printf "%s\n" "Installed compiler libs"
|
|
|
|
printf "%s\n" "-----------------------"
|
|
|
|
# platform specific newlib version
|
2018-12-29 14:26:26 +01:00
|
|
|
for p in \
|
|
|
|
arm-none-eabi \
|
2019-10-18 23:29:53 +02:00
|
|
|
msp430-elf \
|
2020-09-07 22:21:42 +02:00
|
|
|
riscv-none-elf \
|
|
|
|
riscv64-unknown-elf \
|
2023-02-23 23:48:52 +01:00
|
|
|
riscv32-esp-elf \
|
2018-12-29 15:25:57 +01:00
|
|
|
xtensa-esp32-elf \
|
2023-02-23 23:48:52 +01:00
|
|
|
xtensa-esp32s2-elf \
|
|
|
|
xtensa-esp32s3-elf \
|
2020-01-04 17:23:20 +01:00
|
|
|
xtensa-esp8266-elf \
|
2018-12-29 14:26:26 +01:00
|
|
|
; do
|
2020-01-04 17:23:20 +01:00
|
|
|
printf "%25s: %s\n" "$p-newlib" "$(newlib_version ${p}-gcc)"
|
2017-01-17 12:46:04 +01:00
|
|
|
done
|
2018-03-02 09:24:24 +01:00
|
|
|
# avr libc version
|
2020-01-04 17:23:20 +01:00
|
|
|
printf "%25s: %s\n" "avr-libc" "$(avr_libc_version avr-gcc)"
|
2018-03-02 09:24:24 +01:00
|
|
|
# tools
|
|
|
|
printf "\n"
|
|
|
|
printf "%s\n" "Installed development tools"
|
|
|
|
printf "%s\n" "---------------------------"
|
2018-12-29 14:26:26 +01:00
|
|
|
for c in \
|
2019-11-26 09:28:28 +01:00
|
|
|
ccache \
|
2018-12-29 14:26:26 +01:00
|
|
|
cmake \
|
|
|
|
cppcheck \
|
|
|
|
doxygen \
|
|
|
|
git \
|
2020-07-07 18:57:16 +02:00
|
|
|
${MAKE} \
|
2018-12-29 14:26:26 +01:00
|
|
|
openocd \
|
|
|
|
python \
|
|
|
|
python2 \
|
|
|
|
python3 \
|
|
|
|
; do
|
2020-01-04 17:23:20 +01:00
|
|
|
printf "%25s: %s\n" "$c" "$(get_cmd_version "${c}")"
|
2017-01-17 12:46:04 +01:00
|
|
|
done
|
2020-01-04 17:23:20 +01:00
|
|
|
printf "%25s: %s\n" "flake8" "$(get_cmd_version "python3 -Wignore -m flake8")"
|
|
|
|
printf "%25s: %s\n" "coccinelle" "$(get_cmd_version spatch)"
|
2018-03-02 09:24:24 +01:00
|
|
|
|
2017-01-17 12:46:04 +01:00
|
|
|
exit 0
|