(Draft Compiler Flags changes) |
(Wording changes from scop) |
||
Line 7: | Line 7: | ||
=== Addition === | === Addition === | ||
Most C, C++, and Fortran programs will pick up the correct compiler | Most C, C++, and Fortran programs will pick up the correct compiler flags if you use a macro that automatically sets them to build the package, such as <code>%configure</code> or <code>%cmake</code> (If you're unsure whether a macro sets the flags, install redhat-rpm-config and the package that provides the macro in <code>/etc/rpm/*</code>. Then run "<code>rpm -E %somemacro</code>"). If there are no such macros that would apply to your package, the de facto standard is that C compiler flags are picked up via the <code>CFLAGS</code> make variable, C++ Compiler flags via the <code>CXXFLAGS</code> variable, and Fortran flags via <code>FFLAGS</code>. So, you could have something like this in your spec file: | ||
flags | |||
<code>% | |||
via the <code>CFLAGS</code> make variable, C++ Compiler flags via the <code>CXXFLAGS</code> | |||
variable, and Fortran flags via <code>FFLAGS</code>. So, you could have something | |||
like this in your spec file: | |||
<pre> | <pre> | ||
make CFLAGS=%{optflags} all | make CFLAGS="%{optflags}" all | ||
</pre> | </pre> | ||
Revision as of 16:47, 22 April 2009
Add a paragraph with instructions for adding compiler flags in common circumstances
Compiler flags
Current
Compilers used to build packages should honor the applicable compiler flags set in the system rpm configuration. As of Aug 2006, this means in practice $RPM_OPT_FLAGS/%{optflags} for C, C++, and Fortran compilers. Honoring means that the contents of that variable is used as the basis of the flags actually used by the compiler during the package build. Adding to and overriding or filtering parts of these flags is permitted if there's a good reason to do so; the rationale for doing so should be reviewed and documented in the specfile especially in the override and filter cases.
Addition
Most C, C++, and Fortran programs will pick up the correct compiler flags if you use a macro that automatically sets them to build the package, such as %configure
or %cmake
(If you're unsure whether a macro sets the flags, install redhat-rpm-config and the package that provides the macro in /etc/rpm/*
. Then run "rpm -E %somemacro
"). If there are no such macros that would apply to your package, the de facto standard is that C compiler flags are picked up via the CFLAGS
make variable, C++ Compiler flags via the CXXFLAGS
variable, and Fortran flags via FFLAGS
. So, you could have something like this in your spec file:
make CFLAGS="%{optflags}" all
If the build still does not pick up the proper compiler flags, you will have to look in the configure script or Makefiles to diagnose what's going on.