From 256856a3cc3f350d94d9e1ffb5c62e81802d51cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jani=20V=C3=A4limaa?= Date: Sat, 28 Dec 2019 22:04:54 +0200 Subject: build.macros: add build_* flags and set_build_flags macro from upstream rpm %build_cflags %build_cxxflags %build_fflags %build_ldflags --- NEWS | 1 + build.macros.in | 40 ++++++++++++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index ee5f275..2005603 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ +- build.macros: add build_* flags from upstream rpm - build.macros: add __global_* macros for compatibility with Fedora - build.macros: drop deprecated and unused macros - __chkconfig diff --git a/build.macros.in b/build.macros.in index 9c93cc5..6000cbd 100644 --- a/build.macros.in +++ b/build.macros.in @@ -152,6 +152,40 @@ GCONF_CONFIG_SOURCE=`%{_gconftool_bin} --get-default-source` %{_gconftool_bin} - # C compiler flags. This is traditionally called CFLAGS in makefiles. # Historically also available as %%{optflags}, and %%build sets the # environment variable RPM_OPT_FLAGS to this value. +%build_cflags %{optflags} + +# C++ compiler flags. This is traditionally called CXXFLAGS in makefiles. +%build_cxxflags %{optflags} + +# Fortran compiler flags. Makefiles use both FFLAGS and FCFLAGS as +# the corresponding variable names. +%build_fflags %{optflags} %{?_fmoddir:-I%_fmoddir} + +# Link editor flags. This is usually called LDFLAGS in makefiles. +# (Some makefiles use LFLAGS instead.) The default value assumes that +# the flags, while intended for ld, are still passed through the gcc +# compiler driver. At the beginning of %%build, the environment +# variable RPM_LD_FLAGS to this value. +%build_ldflags %{?!_disable_ld_as_needed: -Wl,--as-needed}%{?!_disable_ld_no_undefined: -Wl,--no-undefined}%{?!_disable_ld_relro: -Wl,-z,relro}%{?!_disable_ld_O1: -Wl,-O1}%{?!_disable_ld_build_id: -Wl,--build-id}%{?!_disable_ld_enable_new_dtags: -Wl,--enable-new-dtags} + +# For compatibility +%ldflags %build_ldflags + +# Expands to shell code to seot the compiler/linker environment +# variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, LDFLAGS if they have +# not been set already. RPM_OPT_FLAGS and RPM_LD_FLAGS have already +# been set implicitly at the start of the %%build section. +%set_build_flags \ + CFLAGS="${CFLAGS:-%{build_cflags}}" ; export CFLAGS ; \ + CXXFLAGS="${CXXFLAGS:-%{build_cxxflags}}" ; export CXXFLAGS ; \ + FFLAGS="${FFLAGS:-%{build_fflags}}" ; export FFLAGS ; \ + FCFLAGS="${FCFLAGS:-%{build_fflags}}" ; export FCFLAGS ; \ + LDFLAGS="${LDFLAGS:-%{build_ldflags}}" ; export LDFLAGS + +# For compatibility +%setup_compile_flags \ + %{warn:%%setup_compile_flags is deprecated, use %%set_build_flags instead} \ + %set_build_flags %debugcflags %{?_enable_debug_packages:-g} @@ -187,12 +221,6 @@ export CFLAGS="%optflags"; export CXXFLAGS="%optflags"; export RPM_OPT_FLAGS="%o %__libtoolize_configure %{?__libtoolize:(cd $CONFIGURE_TOP; [ ! -f configure.in -a ! -f configure.ac ] || %{__libtoolize} --copy --force)} -%ldflags %{?!_disable_ld_as_needed: -Wl,--as-needed}%{?!_disable_ld_no_undefined: -Wl,--no-undefined}%{?!_disable_ld_relro: -Wl,-z,relro}%{?!_disable_ld_O1: -Wl,-O1}%{?!_disable_ld_build_id: -Wl,--build-id}%{?!_disable_ld_enable_new_dtags: -Wl,--enable-new-dtags} - -%setup_compile_flags \ - %{warn:%%setup_compile_flags is deprecated, use %%set_build_flags instead} \ - %set_build_flags - %before_configure \ %set_build_flags \ CONFIGURE_TOP="${CONFIGURE_TOP:-.}"; \ -- cgit v1.2.1