Advanced usage

You can specify preprocessor macros with -D and search paths with -I:

fortdepend -DMACRO=42 -Isome/include/dir -o Makefile.dep

will replace instances of MACRO with 42 according to the usual C99 preprocessor rules. This can be used to conditionally use some modules or change which module is used at compile time.

Full command line arguments:

Generate Fortran dependencies

usage: fortdepend [-h] [-f FILES [FILES ...]] [-D NAME[=DESCRIPTION]
                  [NAME[=DESCRIPTION] ...]] [-I dir] [-b BUILD] [-o OUTPUT]
                  [-g] [-v] [-w] [-c] [-e EXCLUDE_FILES [EXCLUDE_FILES ...]]
                  [-i IGNORE_MODULES [IGNORE_MODULES ...]] [-s] [-n]

Named Arguments

-f, --files Files to process
-D Preprocessor define statements
-I Add dir to the preprocessor search path
-b, --build

Build Directory (prepended to all files in output)

Default: “”

-o, --output Output file
-g, --graph

Make a graph of the project

Default: False

-v, --verbose

explain what is done

Default: False

-w, --overwrite

Overwrite output file without warning

Default: False

-c, --colour

Print in colour

Default: False

-e, --exclude-files
 Files to exclude
-i, --ignore-modules
 Modules to ignore
-s, --skip-programs

Don’t include programs in the output file

Default: False

-n, --no-preprocessor

Don’t use the preprocessor

Default: False

--version show program’s version number and exit

Here’s a slightly more advanced example of how to use fortdepend in your makefiles:

# Script to generate the dependencies

# $(DEP_FILE) is a .dep file generated by fortdepend
DEP_FILE = my_project.dep

# Preprocessor flags
CPPFLAGS = -DFEATURE -Iinclude/dir

# Source files to compile
OBJECTS = mod_file1.f90 \

# Make sure everything depends on the .dep file
all: $(actual_executable) $(DEP_FILE)

# Make dependencies
.PHONY: depend
depend: $(DEP_FILE)

# The .dep file depends on the source files, so it automatically gets updated
# when you change your source
    @echo "Making dependencies!"
    cd $(SRCPATH) && $(MAKEDEPEND) -w -o /path/to/$(DEP_FILE) $(CPPFLAGS) -f $(OBJECTS)

include $(DEP_FILE)

This will automatically rebuild the dependency file if any of the source files change. You might not like to do this if you have a lot of files and need to preprocess them!