From: Herton R. Krzesinski <herton(a)redhat.com>
redhat: change tools_make macro to avoid full override of variables in Makefile
As was previously discussed in kernel-ark MR 1721, there is a difference
of calling "CFLAGS=(...) make" and "make CFLAGS=(...)", the latter
can
end up overriding Makefile defined values even if the makefile have eg.
"override CFLAGS +=". One example of such Makefile is
tools/power/x86/intel-speed-select/Makefile, where I tested both
invocations and indeed doing the second form overrides the cflags
including the needed included (-I) directives, which will make the build
fail.
So when building the tools, we don't want to ovewrite entirely the value the
Makefile provides. Instead, we want the default distro flags to be added to the
current defined values. This changes tools_make macro to do that. With
this we can also remove the workaround of having to specify same CFLAGS
again with intel-speed-select build.
Unfortunately, intel_sdsi tool Makefile overrides CFLAGS from the environment
entirely with a 'CFLAGS =' setting at its beginning. So until it's fixed, we
have to still do an workaround setting CFLAGS after make, otherwise build
fails with a relocation error when using the now provided LDFLAGS from
the distro.
Verified the changes here by doing a verbose eln build and checking
CFLAGS/LDFLAGS are being passed:
https://koji.fedoraproject.org/koji/taskinfo?taskID=88001746
Signed-off-by: Herton R. Krzesinski <herton(a)redhat.com>
diff --git a/redhat/kernel.spec.template b/redhat/kernel.spec.template
index blahblah..blahblah 100755
--- a/redhat/kernel.spec.template
+++ b/redhat/kernel.spec.template
@@ -2228,7 +2228,7 @@ chmod +x tools/perf/check-headers.sh
%endif
%global tools_make \
- %{make} CFLAGS="${RPM_OPT_FLAGS}" LDFLAGS="%{__global_ldflags}"
%{?make_opts}
+ CFLAGS="${RPM_OPT_FLAGS}" LDFLAGS="%{__global_ldflags}" %{make}
%{?make_opts}
%if %{with_tools}
%ifarch %{cpupowerarchs}
@@ -2249,10 +2249,10 @@ chmod +x tools/power/cpupower/utils/version-gen.sh
%{tools_make}
popd
pushd tools/power/x86/intel-speed-select
- %{make} CFLAGS+="-D_GNU_SOURCE -Iinclude -I/usr/include/libnl3"
+ %{tools_make}
popd
pushd tools/arch/x86/intel_sdsi
- %{tools_make}
+ %{tools_make} CFLAGS="${RPM_OPT_FLAGS}"
popd
%endif
%endif
@@ -2517,10 +2517,10 @@ install -m644 %{SOURCE2001}
%{buildroot}%{_sysconfdir}/sysconfig/cpupower
%{tools_make} DESTDIR=%{buildroot} install
popd
pushd tools/power/x86/intel-speed-select
- %{tools_make} CFLAGS+="-D_GNU_SOURCE -Iinclude -I/usr/include/libnl3"
DESTDIR=%{buildroot} install
+ %{tools_make} DESTDIR=%{buildroot} install
popd
pushd tools/arch/x86/intel_sdsi
- %{tools_make} DESTDIR=%{buildroot} install
+ %{tools_make} CFLAGS="${RPM_OPT_FLAGS}" DESTDIR=%{buildroot} install
popd
%endif
pushd tools/thermal/tmon
--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1857