Sami Tolvanen | ae0c553 | 2017-11-30 15:38:26 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: GPL-2.0 |
| 3 | # |
Masahiro Yamada | 00250b521 | 2019-03-01 16:10:20 +0900 | [diff] [blame] | 4 | # clang-version clang-command |
Sami Tolvanen | ae0c553 | 2017-11-30 15:38:26 -0800 | [diff] [blame] | 5 | # |
Masahiro Yamada | 00250b521 | 2019-03-01 16:10:20 +0900 | [diff] [blame] | 6 | # Print the compiler version of `clang-command' in a 5 or 6-digit form |
| 7 | # such as `50001' for clang-5.0.1 etc. |
Sami Tolvanen | ae0c553 | 2017-11-30 15:38:26 -0800 | [diff] [blame] | 8 | |
Sami Tolvanen | ae0c553 | 2017-11-30 15:38:26 -0800 | [diff] [blame] | 9 | compiler="$*" |
| 10 | |
Michael Forney | b5f8cb9 | 2018-08-15 17:13:50 -0700 | [diff] [blame] | 11 | if ! ( $compiler --version | grep -q clang) ; then |
Masahiro Yamada | 469cb73 | 2018-05-28 18:22:02 +0900 | [diff] [blame] | 12 | echo 0 |
Sami Tolvanen | ae0c553 | 2017-11-30 15:38:26 -0800 | [diff] [blame] | 13 | exit 1 |
| 14 | fi |
| 15 | |
| 16 | MAJOR=$(echo __clang_major__ | $compiler -E -x c - | tail -n 1) |
| 17 | MINOR=$(echo __clang_minor__ | $compiler -E -x c - | tail -n 1) |
Masahiro Yamada | 469cb73 | 2018-05-28 18:22:02 +0900 | [diff] [blame] | 18 | PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1) |
| 19 | printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL |