making a script to auto get depndencies to make a makefile

I havent gotten really far enough to the point where i have multiple headers and cpp files as a dependency to compile, except for tutorials. But i like vim editor. The negative of the vim editor is that i have to make a makefile for my programs to compile (once i get to that point), as opposed to just using an IDE to do it all for me. So i was just thinking, hey stupid instead of going through the whole program trying to figure out which file is dependant on which, i could just make a script to make the makefile for me. So my question is 1) is this bad practice 2) should i bother. 3) is my theory correct in the process of doing it right?

So my theory was to:

1) have the script go through main
--if line start with '#' //get only includes
-- if line has "some_file" // get line with " " to get own includes
2) file with " " is dependent on this include
3) and yatta yatta yatta go through the whole program accounting for which file is dependent on which header, etc.
4) have script write the makefile
5) enjoy my free time i saved by the script doing all that for me


also from what i understand the includes with "" are you own headers files, and then it checks the STD, and the inlcudes with <> are the STD. So assuming that you wrote your own inlcuded headers with " ", the script should correctly find the dependencies. I also thought that this would be good practice and in addition the script would also help in the future, quite often too.


So my overall question is: is this possible and/or the problems with it, or am i just thinking too much into it?



EDIT:
now i think about it this thread would be more appropriate in linux threads, not beginner
Last edited on
oh haha, thats already a compiler arg
Thanks
Topic archived. No new replies allowed.