Noame has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I would like to write Perl script to generate dependencies files based + on cpp files. The script have to run on all *.cpp files under current directory and +for each of them to retrieve his dependencies list. The script should to look for the other header files according to $INC +LUDE variable. Finally, the script should to write the result to make.dep (namke form +at) file as describe below .\FILE1.CPP : \ "..\..\inc\ADVISOR.H"\ "..\..\inc\audittrail.h"\ "..\..\inc\Cimr.h"\ .\FILE2.CPP : \ "..\..\inc\corba\corbastructdefs.h"\ "..\..\inc\DBFCLASS.H"\ "..\..\INC\dbfs.h"\ .\FILE3.CPP : \ "..\..\INC\dbfs_c_struct.h"\ "..\..\inc\dynadbfs.h"\ "..\..\inc\errorlog.h"\ "..\..\INC\FSP.H"\ The file.dep will include information about all the *.cpp files under +the current directory.I need to automatically build the list of depen +dency files, for nmake so I don't need to recompile everything when I + change a header file. Please let me know if you have any script to implement it, or any algo +rithm to perform it.... Thank you for your help, Jona.

my Question is more complicated.I've wrote Perl script to build my applications using 'nmake' command and base on 'MAK' and 'DEP' files that were generated from Visual C++ based on 'DSP' files. Today, I'm generating 'MAK' and 'DEP' files from Visual C++ to my project and then using them to build my application with 'nmake' command from Unix The 'MAK' is product of 'DSP' files and I don't have problem to generate from Visual C++ to my requirement.I found that Visual C++ can generated 'DEP' file as well, but it generate it just if the project was compiled and already has 'vc60.idb' file.'vc60.idb' file is an internal DB file of Visual C++ that include information about the project like the dependency relations...I don't want to compile each time my project via Visual C++ and then generate the DEP file - I would like to avoid from my dependence in that tool...Therefore, I would like to write or use any tool to generate 'DEP' files independently that 'nmake' command can use/read them.I Hope that my explanations are clear enough and you can help me or give me any idea...Thanks
Replies are listed 'Best First'.
Re: Generate dep file from CPP file- to use with nmake
by roboticus (Chancellor) on Apr 13, 2008 at 14:11 UTC
    Noame:

    If you're wanting to write it to learn more perl and C++, then have fun. But if you're just interested in having a tool to do the job, you might want to download gcc--it already has a command-line option to generate dependency files (the -M series, IIRC). If your format constraints are particular enough you could follow it with a perl script to clean it up.

    ...roboticus

    Re: Generate dep file from CPP file- to use with nmake
    by moritz (Cardinal) on Apr 13, 2008 at 14:59 UTC
      If you want fast results, check automake.
    Re: Generate dep file from CPP file- to use with nmake
    by tinita (Parson) on Apr 13, 2008 at 14:09 UTC
      as suggested before, please put only the code part of your posting into code-tags.