Skip to content

fobos modes templates

Tomas Bylund edited this page Feb 10, 2015 · 2 revisions

If your modus_operandi consists on one fobos file with many (and many) modes, you surely like the possibility to define templates for the modes you define.

Let us consider the following fobos

[modes]
modes = shared-lib1 static-lib1
        shared-lib2 static-lib2

[shared-lib1]cflags = -c -fPIC -O2
lflags = -shared
build_dir = ./build/
…
target = lib1.f90

[static-lib1]cflags = -c -O2
build_dir = ./build/
…
target = lib1.f90

[shared-lib2]cflags = -c -fPIC -O2
lflags = -shared
build_dir = ./build/
…
target = lib2.f90

[static-lib2]cflags = -c -O2
build_dir = ./build/
…
target = lib2.f90

There are many repetitions! Defining two mode templates make our life simpler

[modes]
modes = shared-lib1 static-lib1
        shared-lib2 static-lib2

# main modes
[shared-lib1]
template = template-shared
target   = lib1.f90

[static-lib1]
template = template-static
target   = lib1.f90

[shared-lib2]
template = template-shared
target   = lib2.f90

[static-lib2]
template = template-static
target   = lib2.f90

# modes templates
[template-shared]cflags = -c -fPIC -O2
lflags = -shared
build_dir = ./build/
…

[template-static]cflags = -c -O2
build_dir = ./build/
…

Now there are less repetitions, thus mantaining the file is less errors-prone.

Note that for defining a mode template just add a new section named with the prefix template-. To add a template to one mode just add the template option (which value it the template name) to that mode: now all the options of the template are flushed to the mode.

This fobos feature can be coupled with the variables oing fobos very powerful.

Clone this wiki locally