diff options
author | Thomas Deutschmann <whissi@gentoo.org> | 2019-08-30 18:07:50 +0200 |
---|---|---|
committer | Thomas Deutschmann <whissi@gentoo.org> | 2019-08-30 18:07:50 +0200 |
commit | 9a057f02f055237593d0b29fcc9357786a659195 (patch) | |
tree | c137f45da9c12dfc9259e0b45eb4838b7a7cc90f /gen_funcs.sh | |
parent | gkbuild.sh: _initialize(): Append $BROOT/usr/include to CXXFLAGS by default (diff) | |
download | genkernel-9a057f02f055237593d0b29fcc9357786a659195.tar.gz genkernel-9a057f02f055237593d0b29fcc9357786a659195.tar.bz2 genkernel-9a057f02f055237593d0b29fcc9357786a659195.zip |
gen_funcs.sh: Import gcc-* functions from toolchain eclass
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'gen_funcs.sh')
-rwxr-xr-x | gen_funcs.sh | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gen_funcs.sh b/gen_funcs.sh index 3f285e33..381c6459 100755 --- a/gen_funcs.sh +++ b/gen_funcs.sh @@ -321,6 +321,41 @@ kv_replace() { var_replace "KV" "${KV}" "${1}" } +# Internal func. The first argument is the version info to expand. +# Query the preprocessor to improve compatibility across different +# compilers rather than maintaining a --version flag matrix. #335943 +_gcc_fullversion() { + local ver="$1"; shift + set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__") + eval echo "$ver" +} + +# @FUNCTION: gcc-fullversion +# @RETURN: compiler version (major.minor.micro: [3.4.6]) +gcc-fullversion() { + _gcc_fullversion '$1.$2.$3' "$@" +} +# @FUNCTION: gcc-version +# @RETURN: compiler version (major.minor: [3.4].6) +gcc-version() { + _gcc_fullversion '$1.$2' "$@" +} +# @FUNCTION: gcc-major-version +# @RETURN: major compiler version (major: [3].4.6) +gcc-major-version() { + _gcc_fullversion '$1' "$@" +} +# @FUNCTION: gcc-minor-version +# @RETURN: minor compiler version (minor: 3.[4].6) +gcc-minor-version() { + _gcc_fullversion '$2' "$@" +} +# @FUNCTION: gcc-micro-version +# @RETURN: micro compiler version (micro: 3.4.[6]) +gcc-micro-version() { + _gcc_fullversion '$3' "$@" +} + gen_die() { set +x |