blob: 6fabf0695761977631bb044c1db44f2d464a45f8 [file] [log] [blame]
Sami Tolvanenae0c5532017-11-30 15:38:26 -08001#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3#
Masahiro Yamada00250b5212019-03-01 16:10:20 +09004# clang-version clang-command
Sami Tolvanenae0c5532017-11-30 15:38:26 -08005#
Masahiro Yamada00250b5212019-03-01 16:10:20 +09006# 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 Tolvanenae0c5532017-11-30 15:38:26 -08008
Sami Tolvanenae0c5532017-11-30 15:38:26 -08009compiler="$*"
10
Michael Forneyb5f8cb92018-08-15 17:13:50 -070011if ! ( $compiler --version | grep -q clang) ; then
Masahiro Yamada469cb732018-05-28 18:22:02 +090012 echo 0
Sami Tolvanenae0c5532017-11-30 15:38:26 -080013 exit 1
14fi
15
16MAJOR=$(echo __clang_major__ | $compiler -E -x c - | tail -n 1)
17MINOR=$(echo __clang_minor__ | $compiler -E -x c - | tail -n 1)
Masahiro Yamada469cb732018-05-28 18:22:02 +090018PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1)
19printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL