Clean up the %build section

- Add more explanatory comments, remove historical notes
- Put configuration options in %%global
- Shell: use $() instead of backticks
- Remove unused aruments to BuildPython()! (fun fact: most were *never* used!)
This commit is contained in:
Petr Viktorin 2017-08-31 15:27:20 +02:00
parent e441743e28
commit db2797c8b7

View File

@ -644,42 +644,50 @@ rm configure pyconfig.h.in
autoconf autoconf
autoheader autoheader
# Remember the current directory (which has sources and the configure script),
# so we can refer to it after we "cd" elsewhere.
topdir=$(pwd) topdir=$(pwd)
# Get proper option names from bconds
%if %{with computed_gotos}
%global computed_gotos_flag yes
%else
%global computed_gotos_flag no
%endif
%if %{with optimizations}
%global optimizations_flag "--enable-optimizations"
%else
%global optimizations_flag "--disable-optimizations"
%endif
# Set common compiler/linker flags
export CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC -fwrapv" export CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC -fwrapv"
export CXXFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC -fwrapv" export CXXFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC -fwrapv"
export CPPFLAGS="`pkg-config --cflags-only-I libffi`" export CPPFLAGS="$(pkg-config --cflags-only-I libffi)"
export OPT="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC -fwrapv" export OPT="$RPM_OPT_FLAGS -D_GNU_SOURCE -fPIC -fwrapv"
export LINKCC="gcc" export LINKCC="gcc"
export CFLAGS="$CFLAGS `pkg-config --cflags openssl`" export CFLAGS="$CFLAGS $(pkg-config --cflags openssl)"
export LDFLAGS="$RPM_LD_FLAGS `pkg-config --libs-only-L openssl`" export LDFLAGS="$RPM_LD_FLAGS $(pkg-config --libs-only-L openssl)"
# We can build several different configurations of Python: regular and debug.
# Define a function, for how to perform a "build" of python for a given # Define a common function that does one build:
# configuration:
BuildPython() { BuildPython() {
ConfName=$1 ConfName=$1
BinaryName=$2 ExtraConfigArgs=$2
SymlinkName=$3 MoreCFlags=$3
ExtraConfigArgs=$4
PathFixWithThisBinary=$5
MoreCFlags=$6
# Each build is done in its own directory
ConfDir=build/$ConfName ConfDir=build/$ConfName
echo STARTING: BUILD OF PYTHON FOR CONFIGURATION: $ConfName
echo STARTING: BUILD OF PYTHON FOR CONFIGURATION: $ConfName - %{_bindir}/$BinaryName
mkdir -p $ConfDir mkdir -p $ConfDir
pushd $ConfDir pushd $ConfDir
# Use the freshly created "configure" script, but in the directory two above: # Normally, %%configure looks for the "configure" script in the current
# directory.
# Since we changed directories, we need to tell %%configure where to look.
%global _configure $topdir/configure %global _configure $topdir/configure
%if %{with computed_gotos}
%global computed_gotos_flag yes
%else
%global computed_gotos_flag no
%endif
%configure \ %configure \
--enable-ipv6 \ --enable-ipv6 \
--enable-shared \ --enable-shared \
@ -699,45 +707,24 @@ BuildPython() {
$ExtraConfigArgs \ $ExtraConfigArgs \
%{nil} %{nil}
# Set EXTRA_CFLAGS to our CFLAGS (rather than overriding OPT, as we've done # Invoke the build
# in the past).
# This should fix a problem with --with-valgrind where it adds
# -DDYNAMIC_ANNOTATIONS_ENABLED=1
# to OPT which must be passed to all compilation units in the build,
# otherwise leading to linker errors, e.g.
# missing symbol AnnotateRWLockDestroy
#
# Invoke the build:
make EXTRA_CFLAGS="$CFLAGS $MoreCFlags" %{?_smp_mflags} make EXTRA_CFLAGS="$CFLAGS $MoreCFlags" %{?_smp_mflags}
popd popd
echo FINISHED: BUILD OF PYTHON FOR CONFIGURATION: $ConfDir echo FINISHED: BUILD OF PYTHON FOR CONFIGURATION: $ConfName
} }
# Use "BuildPython" to support building with different configurations: # Call the above to build each configuration.
%if %{with debug_build} %if %{with debug_build}
BuildPython debug \ BuildPython debug \
python-debug \ "--without-ensurepip --with-pydebug" \
python%{pybasever}-debug \ "-O0"
%ifarch %{ix86} x86_64 ppc %{power64}
"--with-pydebug --without-ensurepip" \
%else
"--with-pydebug --without-ensurepip" \
%endif
false \
-O0
%endif # with debug_build %endif # with debug_build
BuildPython optimized \ BuildPython optimized \
python \ "--without-ensurepip %{optimizations_flag}" \
python%{pybasever} \ ""
%if %{with optimizations}
"--without-ensurepip --enable-optimizations" \
%else
"--without-ensurepip --disable-optimizations" \
%endif # with optimizations
true
# ====================================================== # ======================================================
# Installing the built code: # Installing the built code: