From 848a0e95c775f75fc3281ff222a77f229dfb813e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jani=20V=C3=A4limaa?= Date: Sat, 30 Mar 2024 11:40:13 +0200 Subject: macros: add support for toolchain selection (GCC/Clang) --- NEWS | 2 ++ macros.in | 27 ++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 8d6718e..34cc601 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +- macros: add support for toolchain selection (GCC/Clang) + Version 2.75.1 - 24 March 2024, by Jani Välimaa - configure: force armv7hl target arch when building for armv7hl with armv8l/aarch64 host machine - macros: make _host_cpu identical with _target_cpu as ATM rpm uses real build diff --git a/macros.in b/macros.in index bea66b9..c9acf17 100644 --- a/macros.in +++ b/macros.in @@ -192,6 +192,29 @@ GCONF_CONFIG_SOURCE=`%{_gconftool_bin} --get-default-source` %{_gconftool_bin} - # '%{version}-%{release}', ie. to automatically add distepoch or epoch if present %EVRD %{?epoch:%{epoch}:}%{?version:%{version}}%{?release:-%{release}}%{?distepoch::%{distepoch}} +# GCC toolchain +%__cc_gcc gcc +%__cxx_gcc g++ +%__cpp_gcc gcc -E + +# Clang toolchain +%__cc_clang clang +%__cxx_clang clang++ +%__cpp_clang clang-cpp + +# Default to the GCC toolchain +%toolchain gcc + +%__cc %{expand:%%{__cc_%{toolchain}}} +%__cxx %{expand:%%{__cxx_%{toolchain}}} +%__cpp %{expand:%%{__cpp_%{toolchain}}} + +# Compiler macros to use for invoking compilers in spec files for packages that +# want to use the default compiler and don't care which compiler that is. +%build_cc %{__cc} +%build_cxx %{__cxx} +%build_cpp %{__cpp} + #============================================================================== # ---- compiler flags. @@ -237,7 +260,9 @@ GCONF_CONFIG_SOURCE=`%{_gconftool_bin} --get-default-source` %{_gconftool_bin} - VALAFLAGS="${VALAFLAGS:-%{build_valaflags}}" ; export VALAFLAGS ; \ RUSTFLAGS="${RUSTFLAGS:-%{build_rustflags}}" ; export RUSTFLAGS ; \ LDFLAGS="${LDFLAGS:-%{build_ldflags}}" ; export LDFLAGS ; \ - LT_SYS_LIBRARY_PATH="${LT_SYS_LIBRARY_PATH:-%_libdir:}" ; export LT_SYS_LIBRARY_PATH + LT_SYS_LIBRARY_PATH="${LT_SYS_LIBRARY_PATH:-%_libdir:}" ; export LT_SYS_LIBRARY_PATH \ + CC="${CC:-%{__cc}}" ; export CC ; \ + CXX="${CXX:-%{__cxx}}" ; export CXX # For compatibility %setup_compile_flags \ -- cgit v1.2.1