SCons

SCons is an alternate build system often used by science projects. This small guide gives a developer PoV on SCons.

Using SCons in ebuilds
An example ebuild using SCons

The most important part here is inheriting the scons-utils eclass and using escons function. The eclass inherit is going to add SCons into DEPEND, and escons invokes SCons with ${MAKEOPTS} stripped down to ones suitable for SCons.

You should note the following, however:
 * 1) SConstruct files are always highly custom and the calling scheme above is just an example. Although using CC as variable is pretty common, the installation root may appear as DESTDIR or do not appear at all -- some packages will require hacking PREFIX or even patching;
 * 2) Although aliasing install to the install destination is very common, it's no rule either. Sometimes you may need to use escons "${D}" or escons /. Or install the package yourself if the author didn't provide any kind of installation rules;
 * 3) SCons has a tendency to reconfigure itself on each call. That's why we usually don't use src_configure and have to copy most of the args from src_compile to src_install -- otherwise SCons will re-configure and rebuild the package;
 * 4) Sometimes install destinations have to passed to the src_compile invocation as well so that package could hardcode appropriate paths. Otherwise package will partially rebuild itself during src_install;
 * 5) The default libdir is passed to autotools by econf function. As SCons doesn't use that, libdir has to passed manually using get_libdir function from multilib eclass. And yes, LIBDIR is a custom variable name as well.

Partial rebuilds in src_install
As mentioned above, SCons often requires passing the same arguments both to src_compile and src_install invocation. If a partial package rebuild occurs in src_install, it is likely that either:
 * an argument passed to src_compile was not repeated in src_install and SCons switched it back to the default,
 * a path passed to src_install is being hardcoded in program sources and needs to be passed in src_compile as well.

Of course, this could also be a case of a broken build system in which some target dependencies are always rebuilt.

Missing CC, CFLAGS, LDFLAGS
It is very common for SConstruct files to ignore variables like CC, CFLAGS and especially LDFLAGS. The first one needs to be always passed explicitly to the build system (that's what econf does); sometimes exporting it using tc-export will work as well. The latter ones are often missed by project developers and need patching to be set.