Blob Blame History Raw
# These RPM macros are used in packages containing Ada code.
# Copyright 2009 - 2024 B. Persson, Bjorn@Rombobeorn.se
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice and
# this notice are preserved. This file is offered as-is, without any warranty.

%_GNAT_project_dir @GNAT_project_dir@
# _GNAT_project_dir is the directory where GNAT project files shall be.

%GNAT_builder_concurrency_flags %{?_smp_build_ncpus:-j%{_smp_build_ncpus}}
# GNAT_builder_concurrency_flags controls how many compilations the builder
# runs in parallel.
# Gnatmake and GPRbuild have a -j parameter just like Make, but they might not
# understand any other Make parameter that might appear in _smp_mflags some
# day, so we take the value from _smp_build_ncpus instead.

%GNAT_builder_rpath_flags %{?!GNAT_add_rpath:-R}
# GNAT_builder_rpath_flags controls the inclusion of a runtime library search
# path (runpath) in the built binaries.
# By default -R is passed to avoid an unnecessary runpath. The builder's
# computed runpath can be enabled by defining GNAT_add_rpath.

# Note: Gnatmake currently ignores -R when it builds shared libraries, and
# always adds a runpath. Libraries need to be post-processed with chrpath, or
# GPRbuild can be used instead.

%GNAT_builder_flags %{GNAT_builder_concurrency_flags} %{GNAT_builder_rpath_flags} -p -vl -XHARDWARE_PLATFORM=%{_arch}
# GNAT_builder_flags contains only parameters for the builder, that is either
# Gnatmake or GPRbuild. It does not include flags for the tools that the builder
# invokes.
# -p creates directories specified in project files.
# -vl shows the command lines for tools that the builder invokes, making build
# logs more useful.
# HARDWARE_PLATFORM is used by directories.gpr.

%build_adaflags %{optflags} -gnatn -gnat-p -gnatVd -gnatwn -gnatyN -Wtrampolines
# build_adaflags contains parameters to be passed to the compiler, GCC, when the
# language to be compiled is Ada.
# -gnatn enables pragma Inline.
# -gnat-p and -gnatVd try to prevent dangerous suppression of important checks.
# -gnatwn means don't treat warnings as errors (and also don't suppress them).
# (Otherwise -gnatwe could turn quite harmless conditions into build failures.)
# -gnatyN turns off style checks. They are irrelevant to packagers.
# -Wtrampolines turns on a warning when the compiler needs to generate a
# trampoline – executable code generated at run time on the stack. It should
# help with diagnosing build failures caused by Fedora's restrictions on
# executable stacks.

%Gnatlink_flags %{build_ldflags} -g
# -g makes Gnatlink refrain from deleting binder files so that they can be
# included in debuginfo packages.

%Gnatmake_flags -cargs %{build_adaflags} -largs %{Gnatlink_flags} -margs %{GNAT_builder_flags}
%GPRbuild_flags -cargs:Ada %{build_adaflags} -cargs:C %{build_cflags} -cargs:C++ %{build_cxxflags} -cargs:Fortran %{build_fflags} -largs %{build_ldflags} -gargs %{GNAT_builder_flags}
# Gnatmake_flags and GPRbuild_flags contain both the parameters for the
# builder itself and parameters that the builder shall pass to the tools it
# invokes. -margs and -gargs must be used after all other mode switches to
# restore the mode, so that other parameters will work as intended when these
# macros are included in longer command lines.

%Comfignat_make %{__make} GNAT_BUILDER_FLAGS="${GNAT_BUILDER_FLAGS:-%{GNAT_builder_flags}}" \\\
                          ADAFLAGS="${ADAFLAGS:-%{build_adaflags}}" \\\
                          CFLAGS="${CFLAGS:-%{build_cflags}}" \\\
                          CXXFLAGS="${CXXFLAGS:-%{build_cxxflags}}" \\\
                          FFLAGS="${FFLAGS:-%{build_fflags}}" \\\
                          LDFLAGS="${LDFLAGS:-%{build_ldflags}}" \\\
                          GNATLINKFLAGS="${GNATLINKFLAGS:--g}" \\\
                          dirgpr=directories.gpr \\\
                          prefix=%{_prefix} \\\
                          exec_prefix=%{_exec_prefix} \\\
                          datarootdir=%{_datarootdir} \\\
                          localstatedir=%{_localstatedir} \\\
                          datadir=%{_datadir} \\\
                          sysconfdir=%{_sysconfdir} \\\
                          gprdir=%{_GNAT_project_dir} \\\
                          mandir=%{_mandir} \\\
                          infodir=%{_infodir}
# Comfignat_make is the command for building a package whose build system uses
# Comfignat. It passes the standard parameters for the build tools, the
# directories project and the installation pathnames to Make. A goal for Make
# may be appended on the command line.

%GPRinstall_flags --create-missing-dirs \\\
                  --no-manifest \\\
                  --sources-subdir=%{buildroot}/%{_includedir}/%{name} \\\
                  --project-subdir=%{buildroot}/%{_GNAT_project_dir} \\\
                  --exec-subdir=%{buildroot}/%{_bindir} \\\
                  --ali-subdir=%{buildroot}/%{_libdir}/%{name} \\\
                  --lib-subdir=%{buildroot}/%{_libdir} \\\
                  --link-lib-subdir=%{buildroot}/%{_libdir}
# GPRinstall_flags contains parameters for GPRinstall that specify the standard
# pathnames for programs and libraries in Fedora. It is for use by packages that
# use GPRinstall to copy files and generate a usage project file. (Note that
# project files generated by GPRinstall don't use directories.gpr. They are
# therefore architecture-specific and don't support multilib.)
#
# It would have been good to include -m to install only the interface files
# instead of all the source files – but it has a bug that makes libraries
# unusable, several Adacore libraries contain filenames that trigger the bug,
# and Adacore is not in any hurry to fix the bug:
# https://github.com/AdaCore/gprbuild/issues/138

# These deprecated macro names are retained for compatibility:
%GPRbuild_optflags %{GPRbuild_flags}
%Gnatmake_optflags %{Gnatmake_flags}
%GNAT_optflags %{Gnatmake_flags}