## 11 Using `cflow` in Makefiles. ¶

If you wish to use `cflow` to analyze your project sources, `Makefile` or `Makefile.am` is the right place to do so. In this chapter we will describe a generic rule for `Makefile.am`. If you do not use `automake`, you can deduce the rule for plain `Makefile` from this one.

Here is a check list of steps to do to set up a `Makefile.am` framework:

- If you use a configuration file, add it to `EXTRA_DIST` variable.
- Add variable `CFLOW_FLAGS` with any special `cflow` options you wish to use. The variable can be empty, its main purpose is making it possible to override `cflow` options by running `make CFLOW_FLAGS=… chart`.
- For each program from your `dir_PROGRAMS` list, for which you want to generate a flow chart, add the following statements:

      program_CFLOW_INPUT=$(program_OBJECTS:.$(OBJEXT)=.c)
      program.cflow: program_CFLOW_INPUT Makefile
              cflow -oprogram.cflow --profile=gcc $(CFLOW_FLAGS) $(DEFS) \
                          $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
                          $(CPPFLAGS) \
               $(program_CFLOW_INPUT)

  If you do not wish to use preprocessing, remove from the `cflow` command line all variables, except `CFLOW_FLAGS`.

  Instead of using a predefined profile (`gcc` in the example above), you may wish to supply a customized profile in your project. If so, use its filename as the argument to the `--profile` option. For example: ‘`--profile=$(srcdir)/foo.cfo`’.

- If there are several programs built by this `Makefile.am`, you may wish to add a special rule, allowing to create all flow charts with a single command, for example:

      flowcharts: prog1.cflow prog2.cflow ...

As an example, here are the relevant statements which we use in `cflow` `src/Makefile.am`:

    CFLOW_FLAGS=-i^s
    cflow_CFLOW_INPUT=$(cflow_OBJECTS:.$(OBJEXT)=.c)
    cflow.cflow: $(cflow_CFLOW_INPUT) Makefile
            cflow -ocflow.cflow -P$(srcdir)/init --profile=gcc \
                        $(CFLOW_FLAGS) $(DEFS) \
                        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
                        $(CPPFLAGS) \
             $(cflow_CFLOW_INPUT)