Is there a tool for creating makefiles and resolving dependencies?

I have a large source tree, and somewhere inside I have a file with the main function, and I want to generate a make file without resolving all the dependencies (including directories and necessary c files) manually. Therefore, the tool will need to be searched, starting from the main folder and climbing up and down the file tree to find the included files that are "closest" to the main file.

+1
c makefile
source share
3 answers

There is a free HWUT tool, a unit test tool that does the job! HWUT at Sourceforge

HWUT does this because of motivation to make it easy to set up unit tests. You can set "ctags" (hwut will use it automatically). Otherwise, the HWUT parses the code using the output file of the compiler object (which, as you know, is slow).

Once you have installed, you simply call it with

> hwut sos your.c --root some/root/dir another/root/dir --args -DMyCompilerArg -DAnother Arg -- 

He will start searching for the included files, source files, object files and libraries in "some / root / dir" and "another / root / dir". Starting with the file "your.c", it will search for all the necessary links and headers and create a well-formatted Makefile. If the project is still too large, you can specify sets of root directories to search for sources, inclusions, and libraries separately.

  • - root-sources ... for root directories where to look for sources
  • - root - includes ... where to look for include headers
  • - root-libraries ... where to look for libraries
  • - root objects ... where to look for objects

BTW: there is a "sols" mode (safe for our weak souls) that directly generates test files for all functions in the module, i.e.

hwut sols "module-to-test.c"

not only generates a Makefile, but also a battery of test files that serve as a starting point for writing tests.

+2
source share

Cmake will partially do what you ask. You can always start with a strong project template.

I suggest you take a look at the c-pattern.

http://c-template.readthedocs.org/en/latest/

https://github.com/redjack/c-template

+2
source share

Note: if you already have a gcc line to compile with the appropriate include paths, you can automatically generate a list of dependency compilers for the included .h files. See - MM option .

+2
source share

All Articles