complex custom makefiles in kdevelop4

Thomas Neumann tneumann at users.sourceforge.net
Sat Sep 5 23:13:20 UTC 2009


Hi,

I would like to use KDevelop4 with a reasonably complex makefile (with 
conditionals, include statements etc.). The basic functionality is there, of 
course, but KDevelop does not pick up the required include path.

After looking at CustomMakeManager::includeDirectories I see why (the 
function is empty ;), but after some more browsing around and looking at 
CustomMakeManager::parseCustomMakeFile I think that the current approach is 
not suited for complex makefiles. KDevelop tries to parse and analyze the 
makefiles itself, but this will not work for non-trivial makefiles (and 
complexity is usually the reason that people use hand-written makefiles).

IMHO KDevelop should instead call

   make -n -p

and analyze the output of this call. This basically uses make as a pre-
processor to expand macros, conditionals, include statements etc. The result 
is then easy to parse, and includes both targets and variable definitions. 
KDevelop should examine the definitions of CFLAGS/CXXFLAGS/IFLAGS to locate 
-I statements that give the include directories.

This would make handling of complex makefiles much more robust, but of 
course has the disadvantage of calling an external program and probably 
tying oneself to GNU make (I don't know how portable -n -p is).
Therefore I do not want to implement a patch without getting some feedback. 
Do you think this is right way to approach the problem? Should KDevelop fall 
back to custom parsing if GNU make is not available?

Thomas






More information about the KDevelop-devel mailing list