Ways to suppress Circularity

What type of “circularity” are we talking of?

1: actual circular dependencies among modules; these are not allowed AFAIK, but submodules can be used to bypass the issue in practice

module a
  use b
end module

module b
  use a
end module

2: build dependencies as required by (GNU) Make. For these you need a tool (let’s call it the module scanner) which determines the dependencies between modules and expresses them in the Make syntax:

target: ... dependencies...
    rule

For the second type of “circularity” you may want to review the following threads:

Edit: some compilers come with a built-in module scanner you can use

however, the output slightly differs which makes it harder to write a generic Makefile supporting multiple compilers.

For external scanners you could check the one at the links below (both are in Awk and use “dependency” files):

Since GNU Make 4.3 it is also possible define grouped targets with the &: syntax, which could be used instead of dependency files.

2 Likes