I wrote about SCons several weeks ago. It took some getting used to, but I'm very happy with the result! It's found it to be more expressive and flexible than Make. Or at least non-standard things are much more straightforward; I guess Make can do almost anything with enough recursion and voodoo. I can't really comment on the speed; it's plenty fast, but there are less than 50 files.
I took some time putting it together, partially because there aren't that many Fortran examples. So I figured I'll post mine (copied below & attached)! Some properties:
- The environments used are mostly isolated, for reproducibility across machines. The exception is that several PATHS are taken from the parent environment: it's not good for portability to hard-code those. PATH, LIBRARY_PATH and LD_LIBRARY_PATH are used from the environment. Notably FPATH can be used to help find Fortran dependencies (.so or .h files for example). Finally, INTEL_LICENSE_FILE is inherited.
- Dependencies are resolved automatically. All the code is organized into modules, which SCons automatically compiles in the correct order (also in parallel mode). This comes with SCons, the only thing I added is pre-processing for header files.
- Different builds don't interfere. For example, if you build an optimized version, which crashes or you change some code, and then you build a debug version the next time, Make might give you a mixed version but with SCons you'll get a complete debug version. This SConstruct goes a little further and uses VariantDir to build different versions in different directories, so you can even have different versions side-by-side (it also keeps all the derived files in one place). This applies not just for debug/optimized but also for compilers, math libraries, MPI(y/n) and for which potential (external function) to use.
When reading the file, note that SConstruct files are declarative: it specifies what you want (which targets etc); it's not a recipe of sequential steps. This is like Make but unlike most Python code.
The file adds several command-line options:
- --nompi - turn off MPI mode, which is on by default
- --opt - turn off debug mode, which is on by default
- --debug_subset=<name1.F,name2.F> - compile the named files in debug and the rest in optimized mode (comma-separated); balance between performance and helpful info
- --FC=<compiler> - specifies which compiler to use (see --help for options)
- --mathlib=<libname> - specifies which mathematics library to use (see --help for options); should fit the compiler
- --potential=<potential> - the potential to compile for (see --help for options)
- --warn-less - hide some subset of warnings that the code often throws in innocent (although outdated) situations
- --name=<name> - name of the symlink to the executable
- --cpp-define=<MYMODE,THING=val> - define these extra pre-processing constants (comma-separated); easily toggleable functionality without changing SConstruct
Also note that SCons offers several useful default options: --tree=prune (show dependencies); --clean (remove build/ etc); -j1 (serial)