Search code examples
waf

Supporting arbitrary user specified compiler in waf


Is it possible to provide a general compiler support with waf? Suppose, I download a software package which uses the waf build system, and would like to compile it with a compiler, which the authors of the package do not know / do not have / do not support for some reasons. Is there any way to use this compiler for building the software package without having to program an extra python module for it?

For example, for a test (Fortran) project, trying

FC=nagfor waf configure

results in

could not configure a fortran compiler!

although the compiler is available on my system. (I know that nagfor support can theoretically be enabled in waf, but the question is about compilers which were not explicitely considered by the software package authors.) The wscript fo the test project is the following trivial one:

top = "."
build = "build"

def options(opt):
    opt.load("compiler_fc")

def configure(conf):
    conf.load("compiler_fc")

def build(bld):
    bld(
        features="fc fcprogram",
        source="schrodinger.f90",
        target="schrodinger",
        use=[ "schlib" ])

    bld.stlib(
        features="fc",
        source=[ "calculator.f90", "output.f90", "lapack_interface.f90",
                 "spline.f90", "accuracy.f90", ],
        target="schlib")

Solution

  • Probably you already found a solution, but in any case, this might still be interesting. I recently added the option to specify a Fortran compiler explicitly in our projects by a separate Python script that contains the various settings, with the idea to fill this as needed. I put this bench_compiler.py alongside with the wscript and call it when the option --bench is set in the configure step.

    Still the best option is to get the compiler support upstream.