18c2ecf20Sopenharmony_ci#!/bin/sh 28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 38c2ecf20Sopenharmony_ci# 48c2ecf20Sopenharmony_ci# clang-version clang-command 58c2ecf20Sopenharmony_ci# 68c2ecf20Sopenharmony_ci# Print the compiler version of `clang-command' in a 5 or 6-digit form 78c2ecf20Sopenharmony_ci# such as `50001' for clang-5.0.1 etc. 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_cicompiler="$*" 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ciif ! ( $compiler --version | grep -q clang) ; then 128c2ecf20Sopenharmony_ci echo 0 138c2ecf20Sopenharmony_ci exit 1 148c2ecf20Sopenharmony_cifi 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ciMAJOR=$(echo __clang_major__ | $compiler -E -x c - | tail -n 1) 178c2ecf20Sopenharmony_ciMINOR=$(echo __clang_minor__ | $compiler -E -x c - | tail -n 1) 188c2ecf20Sopenharmony_ciPATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1) 198c2ecf20Sopenharmony_ciprintf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL 20