LinuxCommandLibrary

gvgen

Generate graphs from grammar

TLDR

Generate a [c]ycle with 10 vertices and edges and write it to stdout

$ gvgen -c [10]
copy

Generate a 4×3 [g]rid
$ gvgen -g [4,3]
copy

Generate a binary [t]ree of height 5
$ gvgen -t [5]
copy

Generate a complete [b]ipartite graph with 3 and 4 vertices
$ gvgen -b [3,4]
copy

Create a [r]andom graph and [o]utput it to a file
$ gvgen -r [10,5] -o [random.gv]
copy

Generate a [d]irected graph with [v]erbose output
$ gvgen -d -v -c [6]
copy

Display help
$ gvgen -?
copy

SYNOPSIS

gvgen [OPTION]... [MAKEFILE]...

PARAMETERS

-o, --output=FILE
    Specify the output file name. If not provided, output is written to standard output.

-f, --format=FORMAT
    Specify the Graphviz layout engine to be used (e.g., dot, neato, twopi, circo, fdp, sfdp). This adds a layout attribute to the generated graph.

-a, --attributes=FILE
    Append global graph attributes from the specified FILE to the generated .gv file.

-e, --expressions=FILE
    Add extra edge and node expressions from the specified FILE to the generated .gv file.

-I, --include-dir=DIR
    Add DIR to the list of directories gvgen searches for included Makefiles.

-m, --make-option=OPTION
    Pass OPTION directly to make when gvgen invokes make to parse dependencies (e.g., make -p).

-V, --version
    Display version information of gvgen and exit.

-h, --help
    Display a help message and exit.

DESCRIPTION

gvgen is a utility distributed as part of GNU Autotools, primarily used within automake projects. Its main purpose is to generate Graphviz .gv (DOT language) files, which represent the dependencies and relationships implicitly defined within one or more input Makefiles.

By parsing Makefiles, gvgen can visualize the build structure, targets, and file dependencies, making it easier to understand complex build systems. The generated .gv file can then be processed by Graphviz tools (like dot) to produce various graphical output formats (e.g., PNG, SVG, PDF). This tool is particularly useful for developers and maintainers of large projects who need a visual representation of their build dependencies.

CAVEATS

gvgen is primarily designed for parsing GNU Makefiles and might not correctly interpret Makefiles written for other make implementations or highly customized build scripts. Its dependency analysis is based on make's internal representation, which might not always capture all implicit or dynamic dependencies. It's often used in conjunction with automake and Graphviz tools, meaning it generates intermediate data (.gv files) rather than final images.

USAGE CONTEXT

gvgen is typically invoked as a build tool or for documentation purposes within a Makefile or configure.ac script. For instance, a Makefile rule might generate a dependency graph like:
all.gv:
gvgen -o $@ $(MAKEFILES)
This all.gv file could then be rendered into an image using Graphviz's dot command, e.g., dot -Tpng all.gv -o all.png.

GRAPHVIZ INTEGRATION

While gvgen outputs a .gv file, it relies on the separate Graphviz package (which provides tools like dot, neato, etc.) to convert this text-based graph description into a visual image. Users must have Graphviz installed and accessible in their PATH to render the output of gvgen into graphical formats.

HISTORY

gvgen was developed as part of the GNU Automake project, which aims to simplify the creation of portable Makefiles. Its introduction provided a way for developers to visualize the often complex dependency graphs generated by automake and make, improving understanding and debugging of build processes. It has been a standard component of the automake distribution for many years, evolving alongside the main project.

SEE ALSO

automake(1), make(1), dot(1), graphviz(1)

Copied to clipboard