# note: for new macos look into redhat-rpm-config rpm!

%_datarootdir %_datadir
%_metainfodir %_datadir/metainfo

%__fc_all_arches %ix86 x86_64 %arm aarch64 %{?e2k:%e2k} ia64 ppc ppc64 ppc64le alpha mips mipsel mips64el
%ghc_arches %__fc_all_arches
# see gcc-common
%GNAT_arches %ix86 x86_64
%GPRbuild_arches %__fc_all_arches
%mono_arches %__fc_all_arches
%ocaml_arches %__fc_all_arches
%openblas_arches %__fc_all_arches

%_vpath_srcdir .
%_vpath_builddir %{_target_platform}

#==============================================================================
# ---- compiler flags.

# 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.
#%build_ldflags -Wl,-z,relro

# Expands to shell code to seot the compiler/linker environment
# variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, LDFLAGS if they have
# not been set already.
%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

%__global_ldflags       -Wl,-z,relro
%build_ldflags     %__global_ldflags
#==============================================================================

%python_version_nodot   %(LC_ALL=C %__python -c 'import sys; print "%%u%%u" %% sys.version_info[0:2]' 2>/dev/null || echo 27)
%python3_pkgversion 3

%py_setup setup.py
%py2_shbang_opts -s
%py3_shbang_opts -s

%py2_build() \
CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \
CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \
FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ; \
%{__python} %{py_setup} %{?py_setup_args} build --executable="%{__python} %{py2_shbang_opts}" %{?*} \
sleep 1

%py2_install \
CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \
CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \
FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ; \
%{__python} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot}

%py3_build() \
CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \
CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \
FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ; \
%{__python3} %{py_setup} %{?py_setup_args} build --executable="%{__python3} %{py3_shbang_opts}" %{?*} \
sleep 1

%py3_install \
CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \
CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \
FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ; \
%{__python3} %{py_setup} %{?py_setup_args} install -O1 --skip-build --root %{buildroot}

%sugaractivitydir %_datadir/sugar/activities/
%sugarlibdir %{_libdir}/sugar/activities/

%_cups_serverbin /usr/lib/cups
%_rundir /run

#systemd_post_with_restart wicd.service
%_jsdir %_datadir/javascript

# until https://bugzilla.altlinux.org/show_bug.cgi?id=34684
%make_build %_make_bin -j${NPROCS:=%__nprocs}
