Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically extracting gcc -I paths for indexing source code in Emacs

After reading:

  • A Gentle Introduction to CEDET
  • A Functional Introduction to CEDET-EDE

I learn that when creating a project folder with an existing make file and source code, I can have semantic index the files by either:

  1. defining a simple EDE project with:

    (ede-cpp-root-project ... :system-include-path '( "~/exp/include/boost_1_37" )

  2. or by specifying the include paths to semantic directly with

    (semantic-add-system-include "~/exp/include/boost_1_37" 'c++-mode)

But this still requires me to type the paths manually. Is there any way to automatically extract the include paths for semantic from an existing make file?

Background: Some IDEs have a function to autodiscover gcc -I paths from an existing make file. For example, in Eclipse, you can create a project on a path with an existing make file and source code, and Eclipse would infer the include paths for its "intellisense" when building the project (I presume Eclipse parses the output of GNU make to do this). I would like to do the same in Emacs.

like image 715
Amelio Vazquez-Reina Avatar asked Oct 11 '12 23:10

Amelio Vazquez-Reina


1 Answers

The answer is "yes": There's a way to discover this include path. AFAIK the code for it hasn't been written yet (tho I may be mistaken on this one). All you need to do is to run make -n and look for the "-I" in the output. Of course, the devil is in the details, but it should be possible to write a proof-of-concept fairly easily.

like image 181
Stefan Avatar answered Oct 24 '22 10:10

Stefan