This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Equivalent to gcc -M to build a list of *objects*
Nick Patavalis <npat@inaccessnetworks.com> writes:
> Runnning gcc -M on a ".c" file, gives you a list of all header files
> it includes, directly or indirectly. What other kind of dependency
> would you like to detect? This whole description is very fuzzy.
If you know Ada, I want the equivalent of gnatmake.
In the following schema :
file2.h file1.h file3.h
| \ | |
| \ | |
file2.c file1.c file3.c
main()
If we follow the convention that any function declared in XXX.h is
implemented in XXX.c, then it is easy to deduce that to build a
project for wich the main function is in file1.c, then, we have to
compile file1.c and file2.c. The list of object files to build is
"file1.o file2.o". Therefore, the rule is easy to generate for a
Makefile.
In this example, gcc -M file1.c | sed s/.[ch]\>/.o/ will give the right
list.
But in the following case, it doesn't :
file3.h file2.h file1.h
| \ | \ |
| \ | \ |
file3.c file2.c file1.c
main()
because file1.c doesn't include either directly or indirectly file3.h,
but file2.c will contain references to symbols defined in file3.o.
--
Matthieu