Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / scripts / clang-version.sh
blob6fabf0695761977631bb044c1db44f2d464a45f8
1 #!/bin/sh
2 # SPDX-License-Identifier: GPL-2.0
4 # clang-version clang-command
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.
9 compiler="$*"
11 if ! ( $compiler --version | grep -q clang) ; then
12 echo 0
13 exit 1
16 MAJOR=$(echo __clang_major__ | $compiler -E -x c - | tail -n 1)
17 MINOR=$(echo __clang_minor__ | $compiler -E -x c - | tail -n 1)
18 PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1)
19 printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL