18c2ecf20Sopenharmony_ci#!/bin/sh
28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
38c2ecf20Sopenharmony_ci#
48c2ecf20Sopenharmony_ci# gcc-version gcc-command
58c2ecf20Sopenharmony_ci#
68c2ecf20Sopenharmony_ci# Print the gcc version of `gcc-command' in a 5 or 6-digit form
78c2ecf20Sopenharmony_ci# such as `29503' for gcc-2.95.3, `30301' for gcc-3.3.1, etc.
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_cicompiler="$*"
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ciif [ ${#compiler} -eq 0 ]; then
128c2ecf20Sopenharmony_ci	echo "Error: No compiler specified." >&2
138c2ecf20Sopenharmony_ci	printf "Usage:\n\t$0 <gcc-command>\n" >&2
148c2ecf20Sopenharmony_ci	exit 1
158c2ecf20Sopenharmony_cifi
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ciMAJOR=$(echo __GNUC__ | $compiler -E -x c - | tail -n 1)
188c2ecf20Sopenharmony_ciMINOR=$(echo __GNUC_MINOR__ | $compiler -E -x c - | tail -n 1)
198c2ecf20Sopenharmony_ciPATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1)
208c2ecf20Sopenharmony_ciprintf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
21