Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dependency checking - how to clean up a project with bad makefiles

I have a very large C project with many separate C files and headers and many dozens of contributors. Many contributors do not have a strong knowledge of makefiles and dependencies, resulting in the not uncommon problem where you almost always have to "make clean" before you can trust "make" to have produced correct output.

If make took minutes, this wouldn't be an issue, but it's nearly 2 hours on a fast machine now, and people are starting to check in code that works when they make, but they don't clean first and their code ultimately breaks the build. Don't ask why these aren't caught by the build manager before a new baseline is cut...

Yes, we shouldn't have let it go this far.

Yes, we're educating our developers.

As usual, we don't have time to stop everything and fix it by hand.

I'm thinking there are tools along these lines:

  • Are there automated tools to help build correct dependency information for an existing project from the C and H files?
  • Are there automated tools to describe dependency information according to the makefiles?
  • Is there a holy grail of a tool to describe the differences between the above two dependency trees?

But what else can/should be done to resolve this issue?

Thanks in advance...

-Adam

like image 236
Adam Davis Avatar asked Oct 27 '08 14:10

Adam Davis


1 Answers

It might be easiest to switch from Make to a tool which automatically detects dependencies. For example, SCons doesn't make you list dependencies but instead automatically parses the files being compiled and looks for includes. You simply specify which files should be compiled and which files go into which executables. Switching build systems will be easier for the fact that your developers aren't really Make experts.

Another alternative if you stick with Make is to use the gcc -M option to automatically detect dependencies. The answer to the Automatically discovering C dependencies question has an example of how to have your makefiles automatically discover dependencies so that you don't need to specify them by hand.

like image 153
Eli Courtwright Avatar answered Sep 21 '22 02:09

Eli Courtwright