Skip to content

fobos — the FoBiS makefile

A fobos file is FoBiS.py's project configuration file. It replaces makefiles entirely, using a simple INI-like syntax.

Overview

When FoBiS.py runs, it automatically looks for a file named fobos in the current working directory. Options in the fobos file override the CLI defaults, and for cflags, lflags, and preproc they are combined with any additional values passed on the command line.

Design principle

Brevity is a design parameter. The fobos file uses the same option names as the CLI switches — there is nothing new to learn.

Basic structure

A minimal single-mode fobos file:

ini
[default]
compiler  = gnu
cflags    = -c -O2
src       = ./src/
build_dir = ./build/
obj_dir   = ./obj/
mod_dir   = ./mod/
target    = src/main.f90
output    = myapp

A multi-mode fobos file:

ini
[modes]
modes = debug release

[debug]
compiler  = gnu
cflags    = -c -O0 -g -Wall
build_dir = ./build/debug/

[release]
compiler  = gnu
cflags    = -c -O3
build_dir = ./build/release/

Loading a fobos file

ScenarioCommand
Default name and locationLoaded automatically
Custom name or pathfobis build -f /path/to/my_fobos
Select a specific modefobis build -mode release
List available modesfobis build -lmodes

Case sensitivity

By default fobos option names are case-sensitive. To make them case-insensitive:

bash
fobis build -fci

Or in the fobos file itself, this is implicit for the option names (values remain as written).

Available options

All CLI options accepted by build and clean are available in a fobos mode section with identical names (using the long form without the leading --). A representative set:

OptionDescription
compilerCompiler identifier (gnu, intel, …)
fcCompiler executable (for custom compiler)
cflagsCompilation flags
lflagsLinking flags
preprocPreprocessor macro flags
srcRoot source directory (space-separated list)
build_dirBuild output directory
obj_dirCompiled objects directory
mod_dirModule interface files directory
lib_dirExternal library search directories
includeInclude files search directories
targetBuild target file
outputOutput executable name
excludeFiles to exclude from the build
libsExternal libraries (full paths)
vlibsVolatile external libraries (full paths)
ext_libsExternal libraries (by name, in linker path)
ext_vlibsVolatile external libraries (by name)
dependonInterdependent external fobos files
mklibBuild a library: static or shared
arArchiver executable for static libraries (default: ar)
arflagsArchiver flags (default: -rcs)
ranlibRanlib executable; set to empty string to skip (default: ranlib)
mpiEnable MPI compiler variant
openmpEnable OpenMP
coarrayEnable coarrays
coverageEnable coverage instrumentation
jobsNumber of parallel compile jobs
colorsColoured terminal output
quietSuppress verbose output
logWrite build log file
cflags_heritageTrack flag changes and force rebuild on change
build_profileNamed compiler flag preset: debug, release, asan, coverage
cache_dirBuild cache directory (default: .fobis_cache)
no_cacheDisable build cache (true/false)
no_auto_discoverDisable convention-based source discovery (true/false)
pre_buildShell command to run before the build
post_buildShell command to run after a successful build

Special sections

Beyond the mode sections, a fobos file can contain several top-level sections with fixed names:

SectionPurposeDocumentation
[modes]Lists the available named mode sectionsMany-mode fobos
[project]Project metadata: name, version, authors, …Project metadata
[features]Named compile-time option sets, activated with --featuresFeature Flags
[dependencies]GitHub-hosted build dependenciesFetch Dependencies
[test]Test runner defaults: suite, timeout, jobsTest Runner
[coverage]Coverage report settings: output dir, fail threshold, excludesCoverage
[externals]External library flags via pkg-config and MPI auto-detectionExternal Libraries
[pkgconfig]Generate a .pc file for your own projectExternal Libraries
[target.NAME]Named build target with per-target flag overridesbuild reference
[example.NAME]Named example target (same syntax as target.NAME)build reference
[rule-NAME]Custom shell-command rulesRules

[features] section

Defines named compile-time option sets that map to flags:

ini
[features]
default = mpi                     ; active when none are explicitly requested
mpi     = -DUSE_MPI
hdf5    = -DUSE_HDF5 -I/opt/hdf5/include
omp_defs = -DUSE_OMP              ; define only — pair with --features openmp

Flags are routed to cflags or lflags automatically by pattern.

Well-known compiler capabilities (openmp/omp, mpi, coarray, coverage, profile) are implicit features — they work without a [features] section and resolve to the correct compiler-specific flag automatically. See Feature Flags.

[dependencies] section

Declares GitHub-hosted dependencies. Each entry maps a short name to a repository spec:

ini
[dependencies]
deps_dir = .fobis_deps          # optional: where to clone deps (same as --deps-dir)
penf     = https://github.com/szaghi/PENF :: tag=v1.5.0
stdlib   = https://github.com/fortran-lang/stdlib :: semver=>=0.5,<1.0 :: use=fobos :: mode=gnu

The use= field selects the integration mode:

  • sources (default) — dependency sources are compiled inline with your project
  • fobos — dependency is built as a separate library and linked

See Fetch Dependencies and Lock File & Semver for the full syntax and workflow.

[test] section

Sets defaults for fobis test:

ini
[test]
suite   = unit     ; only run tests tagged with this suite
timeout = 120      ; seconds per test
jobs    = 4        ; parallel compile jobs

[coverage] section

Sets defaults for fobis coverage:

ini
[coverage]
output_dir = coverage/
source_dir = src/
fail_under = 75
exclude    = test/*
            examples/*

[target.NAME] and [example.NAME] sections

Named targets allow per-target flag overrides without separate fobos modes:

ini
[target.solver]
target = src/solver.F90
output = solver
cflags = -c -O3 -DSOLVER

[example.demo]
target = examples/demo.F90
output = demo
bash
fobis build --target-filter solver
fobis build --examples

Comments

Lines beginning with # are ignored:

ini
[default]
# This is a comment
compiler = gnu  # inline comments are also supported
cflags   = -c -O2

Further reading