as you all probably know the 'perfect dependency checker' in Dev-cpp is terribly slow. Because I'm developing a rather large project this time, I went to look for a faster (but still 'perfect') solution.
And I found one, good enough to share :).
Solution to faster dependency checking:
Download sed (http://gnuwin32.sourceforge.net/packages/sed.htm) binaries and dependencies, and extract sed.exe, libiconv2.dll and libintl3.dll from the bin directory to somewhere on your path (I used the dev-cpp\bin directory), or alternatively extract it somewhere and add the bin directory to your path.
Create a new file in your project directory using notepad, named 'makefile.dep' (or anything you like), and insert the following (replace %.cpp with %.c for C projects), make sure the indent on the second line is a TAB!:
%.d: %.cpp
$(CC) -MM $(CPPFLAGS) $< | sed "s/($(subst /,\/,$)).o[ :]/\1.o $(subst /,\/,$@) : /g" > $@
include $(OBJ:.o=.d)
In Dev-cpp go to the makefile tab in 'Project -> Project Options' and add 'makefile.dep' to the "Include the following files into the Makefile" list.
In 'Tools -> Compiler Options', enable 'fast but imperfect dependency checking' if it wasn't already.
Compile your project. The first time it will give a bunch of 'no such file' errors, but it will also generate a .d file for every source file in your project. The next time you compile the .d files are used for dependency checking, and if necessary they are updated.
So, what it does: makefile.dep is automatically added as an include by Dev-cpp. In makefile.dep there are two additions:
1. A rule to create a .d file from a .cpp file. The .d file is in fact another makefile, which uses one new rule generated by GCC ('gcc -MM file.cpp' will generate 'file.o : file.cpp <dependencies>', where <dependencies> is a list of all headers included by file.cpp, with system headers excluded (change it to -M to also include system headers)).
The results of this are passed to sed to change the generated string to 'file.o file.d : file.cpp <dependencies>', which is output into file.d. This will make the dependency makefile depend on all files the source file depends on. So if one of those files is changed the dependency makefile will also be automatically rebuilt.
2. A rule that includes all .d files as makefiles, adding the dependencies to the source files.
Regards,
Frank Zijlstra
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
as you all probably know the 'perfect dependency checker' in Dev-cpp is terribly slow. Because I'm developing a rather large project this time, I went to look for a faster (but still 'perfect') solution.
And I found one, good enough to share :).
Solution to faster dependency checking:
Download sed (http://gnuwin32.sourceforge.net/packages/sed.htm) binaries and dependencies, and extract sed.exe, libiconv2.dll and libintl3.dll from the bin directory to somewhere on your path (I used the dev-cpp\bin directory), or alternatively extract it somewhere and add the bin directory to your path.
Create a new file in your project directory using notepad, named 'makefile.dep' (or anything you like), and insert the following (replace %.cpp with %.c for C projects), make sure the indent on the second line is a TAB!:
%.d: %.cpp
$(CC) -MM $(CPPFLAGS) $< | sed "s/($(subst /,\/,$)).o[ :]/\1.o $(subst /,\/,$@) : /g" > $@
include $(OBJ:.o=.d)
In Dev-cpp go to the makefile tab in 'Project -> Project Options' and add 'makefile.dep' to the "Include the following files into the Makefile" list.
In 'Tools -> Compiler Options', enable 'fast but imperfect dependency checking' if it wasn't already.
Compile your project. The first time it will give a bunch of 'no such file' errors, but it will also generate a .d file for every source file in your project. The next time you compile the .d files are used for dependency checking, and if necessary they are updated.
How it works:
The main idea for this came from http://theoryx5.uwinnipeg.ca/gnu/make/make_43.html, but adapted in such a way that it will work in cooperation with the Dev-cpp makefile generation.
So, what it does: makefile.dep is automatically added as an include by Dev-cpp. In makefile.dep there are two additions:
1. A rule to create a .d file from a .cpp file. The .d file is in fact another makefile, which uses one new rule generated by GCC ('gcc -MM file.cpp' will generate 'file.o : file.cpp <dependencies>', where <dependencies> is a list of all headers included by file.cpp, with system headers excluded (change it to -M to also include system headers)).
The results of this are passed to sed to change the generated string to 'file.o file.d : file.cpp <dependencies>', which is output into file.d. This will make the dependency makefile depend on all files the source file depends on. So if one of those files is changed the dependency makefile will also be automatically rebuilt.
2. A rule that includes all .d files as makefiles, adding the dependencies to the source files.
Regards,
Frank Zijlstra
I noticed the indent on the second line of the file is gone (stupid forums! :P), so, indent the second line with a tab :).