Skip to content

build command

Build all programs found in the source tree, or a specific target.

bash
fobis build [options]

Compiler options

OptionDescription
--compiler {gnu,intel,intel_nextgen,g95,opencoarrays-gnu,pgi,ibm,nag,nvfortran,amd,custom}Compiler (case-insensitive, default: gnu) — tab-completable
--fc FCCompiler executable — required for --compiler custom
--cflags CFLAGSCompilation flags
--lflags LFLAGSLinking flags
--modsw MODSWModule path switch — required for --compiler custom
--mpiMPI compiler variant
--openmpOpenMP
--openmp-offloadOpenMP offload
--coarrayCoarrays
--coverageCoverage instrumentation
--profileProfiling instrumentation
--mklib {static,shared}Build a library instead of a program (use with -t) — tab-completable
--ar ARArchiver executable for static libraries (default: ar)
--arflags ARFLAGSArchiver flags (default: -rcs)
--ranlib RANLIBRanlib executable for indexing static libraries (default: ranlib); set to empty string to skip
--ch, --cflags-heritageTrack flag changes; force full rebuild when they differ
--tb, --track-buildSave build info for use by install

Directory options

OptionDefaultDescription
-s, --src./Root source directory (repeatable: --src ./a --src ./b)
--dbld, --build-dir./Build output directory
--dobj, --obj-dir./obj/Compiled objects directory
--dmod, --mod-dir./mod/Module interface files directory
--dlib, --lib-dirLibrary search directories (repeatable)
-i, --includeInclude file search directories (repeatable)
--ed, --exclude-dirsDirectories to exclude from the build (repeatable)
--drs, --disable-recursive-searchFalseDo not recurse into subdirectories

File options

OptionDefaultDescription
-t, --targetAll programs foundSpecific target source file
-o, --outputBasename of targetOutput executable name
-e, --excludeSource files to exclude (repeatable)
--libsExternal libraries (full paths, repeatable)
--vlibsVolatile external libraries (full paths) — triggers rebuild on change
--ext-libsExternal libraries (by name, in linker path)
--ext-vlibsVolatile external libraries (by name)
--dependonInterdependent fobos files (path/fobos[:mode], repeatable)
--inc.inc .INC .h .HInclude file extensions — tab-completable
--extensions(all Fortran extensions)Parsed file extensions — tab-completable
--build-allFalseBuild all parsed sources, not just program files

fobos options

OptionDescription
-f, --fobosSpecify a fobos file with a different name or path
--fci, --fobos-case-insensitiveCase-insensitive fobos option parsing
--modeSelect a fobos mode — tab-completable from the active fobos file
--lmodesList available modes and exit
--print-fobos-templatePrint a fobos template with all current option values

Preprocessor options

OptionDescription
--preprocessor CMDEnable source preprocessing; specify preprocessor name (e.g. PreForM.py)
--preprocPreprocessor flags for the main compiler
--app, --preprocessor-argsFlags passed to the preprocessor
--npp, --preprocessor-no-oOmit -o from the preprocessor command line
--dpp, --preprocessor-dirDirectory for preprocessed sources (kept if set)
--epp, --preprocessor-extFile extensions to preprocess (repeatable)

Fancy options

OptionDescription
--force-compileForce recompilation of all sources
--colorsColoured terminal output
-l, --logWrite a build log file
--graphGenerate a graphviz dependency graph
-q, --quietLess verbose output
--verboseMaximum verbosity (for debugging FoBiS.py itself)
-j, --jobsNumber of parallel compile jobs (default: 1)
-m, --makefileExport a GNU Makefile instead of building
--jsonEmit structured JSON to stdout (see JSON output)

Examples

bash
# Build all programs with defaults
fobis build

# Build with GNU gfortran, parallel, debug flags
fobis build --compiler gnu --cflags " -c -O0 -g" -j 4

# Build a specific target
fobis build -t src/solver.f90 -o solver

# Build a static library
fobis build -t src/mylib.f90 --mklib static -o libmylib.a

![Static library build demo](/gifs/03_static_library.gif)

# Build a static library with LLVM tools
fobis build -t src/mylib.f90 --mklib static --ar llvm-ar --ranlib llvm-ranlib

# Build a static library skipping ranlib (llvm-ar updates the symbol table itself)
fobis build -t src/mylib.f90 --mklib static --ar llvm-ar --ranlib ""

# Use a fobos file and a specific mode
fobis build -f project.fobos --mode release

# Force full recompile
fobis build --force-compile

# Multiple source directories
fobis build --src ./src --src ./vendor/mylib/src

dependon build demo

Legacy single-dash options

All single-dash multi-character options from older versions (-compiler, -mode, -force_compile, etc.) are still accepted and normalised automatically. Both forms are equivalent:

bash
fobis build -compiler intel -mode release   # legacy style
fobis build --compiler intel --mode release  # current style