Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I often find myself needing this:

Say you have a test.c file; it includes other files, say:

#include <stdio.h>
#include "mylib.h"
#include "../mylib_extra.h"
#include "../mylib_bonus.h"

... then, say, "mylib.h" in the same directory, loads also something else:

#include <special.h>
#include "/path/to/calculator.h"
#include "testing/tester.h"

... etc. Now, some of these statements refer to system directories, which one must know beforehand - but in principle, I guess it would be possible to write a tool, which given a pattern of the "include" statement, could recursively open all files referred to in the initial file, look for the same statements there, open files further - until it draws a tree map. Items it couldn't open without a knowledge of the path, would be marked.

I would imagine a tool like that working like this (where files found/opened are marked with a (*), and no markings otherwise)

$ ./getincludetree test.c

- <stdio.h> 
- "mylib.h" (*)
-- <special.h> 
-- "/path/to/calculator.h" (*)
--- ...
-- "testing/tester.h" (*)
--- ...
- "../mylib_extra.h" (*)
-- ...
- "../mylib_bonus.h" (*)
-- ...

Even better, if you could specify a pattern for the include statement, then instead of #include "...", one could use, say \input{...} and use the same tool for finding the include structure of a Latex document, as well.

Is there anything like that out there?

Many thanks in advance for any answers,

share|improve this question
Are you looking for a Makefile or something like that? I don't really get the problem? – Bernhard May 24 '12 at 11:12
@Bernhard - not a makefile, a command-line tool that can work under Linux (edited tags); I was just wandering if there are any existing command line programs which can do the above... Cheers! – sdaau May 24 '12 at 16:10

You want to implement an autoloader class, a file scanner with caching:

share|improve this answer
Thanks for that, @David - I was thinking more of something like a ready-made command line tool; this looks like it will need some coding to implement.. Great resource, though - cheers! – sdaau May 24 '12 at 14:01

Hmmm. Seems like you want:

Gnu global

Google those names, think that should help you. They are source indexers.

share|improve this answer
Many thanks for that, @chiggsy - looks like "source indexer" is what I was looking for - will report back once I get around to it. Cheers! – sdaau May 24 '12 at 18:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .