Quick Start
Your first build
Given a project tree:
└── src
├── main.f90
└── nested-1
├── first_dep.f90
└── nested-2
└── second_dep.incwhere main.f90 contains a Fortran program that uses nested_1, and first_dep.f90 defines module nested_1 which includes second_dep.inc.
Just run:
FoBiS.py buildFoBiS.py will:
- Recursively scan
./for all Fortran source files - Parse each file, extracting
use,include, andmodulestatements - Resolve the full dependency hierarchy automatically
- Compile in the correct order (include → module → program)
- Place compiled objects in
./obj/, module interfaces in./mod/, and the executable in./
After the build your tree looks like:
├── main ← the executable
├── mod/
│ └── nested_1.mod
├── obj/
│ ├── first_dep.o
│ └── main.o
└── src/
├── main.f90
└── nested-1/
├── first_dep.f90
└── nested-2/
└── second_dep.incCustomising output directories
Override any directory with CLI flags:
FoBiS.py build -dobj my-objs -dmod my-mods -dbld my-buildThe obj and mod directories are always relative to the build directory, so the tree becomes:
└── my-build/
├── my-mods/
├── my-objs/
└── mainCleaning the project
FoBiS.py cleanThis removes all compiled objects (*.o) and module files (*.mod) from the obj/ and mod/ directories. If you used custom paths during the build, repeat them:
FoBiS.py clean -dobj my-objs -dmod my-mods -dbld my-buildClean only compiled objects (keep executable):
FoBiS.py clean -only_objClean only the executable (keep objects for faster incremental rebuild):
FoBiS.py clean -only_targetParsed file extensions
By default FoBiS.py parses files with these extensions:
| Category | Extensions |
|---|---|
| Modern Fortran | .f90 .F90 .f95 .F95 .f03 .F03 .f08 .F08 .f2k .F2K |
| Legacy Fortran | .f .F .for .FOR .fpp .FPP .fortran .f77 .F77 |
| Include files | .inc .INC .h .H |
Add custom include extensions:
FoBiS.py build -inc .cmn .icpSelecting a specific target
Build only one program instead of all programs found:
FoBiS.py build -t src/main.f90With a custom output name:
FoBiS.py build -t src/main.f90 -o myappUsing a fobos configuration file
For anything beyond a one-off build, create a fobos file in the project root. FoBiS.py loads it automatically:
[default]
compiler = gnu
cflags = -c -O2
src = ./src/
build_dir = ./build/
obj_dir = ./obj/
mod_dir = ./mod/
target = src/main.f90
output = myappThen simply:
FoBiS.py build
FoBiS.py cleanSee the fobos section for the full reference.
Quoted string arguments
argparse can misinterpret flags beginning with - that are passed as quoted strings. Prefix such values with a leading space:
# problematic:
FoBiS.py build -cflags "-c -fPIC"
# correct:
FoBiS.py build -cflags " -c -fPIC"