platform.in (%configure): pass --runstatedir=%_runstatedir

During %configure, the --runstatedir option will be automatically passed
to the configure script if it is supported.  However, in certain
scenarios where the package contains multiple configure scripts that
invoke each other, the detection of --runstatedir support may fail.
This can happen when only some of the scripts support the --runstatedir
option.  To address this issue and prevent the automatic passing of
--runstatedir, you can use the following in the spec file of the package
specfile:
%undefine _configure_use_runstatedir

This change is inspired by Fedora's redhat-rpm-config package,
specifically from the following commits:
* c0d2923: Added the "runstatedir" option to configure macros (authored
  by Frederic Berat).
* f857d65: Introduced %_configure_use_runstatedir to disable the usage
  of --runstatedir during configuration (authored by Florian Weimer).

The key distinction in this implementation is that it will issue a
warning in case the configure script doesn't support the --runstatedir
argument.
This commit is contained in:
Gleb Fotengauer-Malinovskiy 2023-07-23 05:00:00 +00:00
parent e8f7583644
commit e96f79a7d0

View File

@ -47,6 +47,14 @@
%_configure_target --build=%{_configure_platform} --host=%{_configure_platform}
%_configure_gettext --without-included-gettext
%_configure_update_config readlink -e -- '%{_configure_script}' |xargs -ri dirname -- '{}' |xargs -ri find '{}' -type f '(' -name config.sub -or -name config.guess ')' -printf '%%h/\\n' |sort -u |xargs -rn1 install -pm755 -- /usr/share/gnu-config/config.{sub,guess}
%_configure_use_runstatedir 1
%_configure_detect_runstatedir \
if grep -qF 'runstatedir=DIR' '%{_configure_script}'; then \
configure_runstatedir_flags='--runstatedir=%{_runstatedir}' \
else \
echo >&2 'rpm-build: warning: %{_configure_script} script does not support --runstatedir' \
fi
%configure \
CFLAGS="${CFLAGS:-%optflags}"; export CFLAGS; \
CXXFLAGS="${CXXFLAGS:-%optflags}"; export CXXFLAGS; \
@ -57,6 +65,8 @@
%{?_enable_static:export lt_cv_prog_cc_static_works=yes ;} \
export lt_cv_deplibs_check_method=pass_all ; \
%{_configure_update_config}; \
configure_runstatedir_flags= ; \
%{?_configure_use_runstatedir:%{_configure_detect_runstatedir}} \
%{_configure_script} %{?_configure_target:%{_configure_target}} \\\
--prefix=%{_prefix} \\\
--exec-prefix=%{_exec_prefix} \\\
@ -73,6 +83,7 @@
--infodir=%{_infodir} \\\
--disable-dependency-tracking \\\
--disable-silent-rules \\\
$configure_runstatedir_flags \\\
%{?_configure_gettext:%{_configure_gettext}}
%_makeinstall_target install
@ -88,6 +99,7 @@
libdir=%{?buildroot:%{buildroot}}%{_libdir} \\\
libexecdir=%{?buildroot:%{buildroot}}%{_libexecdir} \\\
localstatedir=%{?buildroot:%{buildroot}}%{_localstatedir} \\\
runstatedir=%{?buildroot:%{buildroot}}%{_runstatedir} \\\
sharedstatedir=%{?buildroot:%{buildroot}}%{_sharedstatedir} \\\
mandir=%{?buildroot:%{buildroot}}%{_mandir} \\\
infodir=%{?buildroot:%{buildroot}}%{_infodir} \\\