Complete redit:
You could modify the Make process in the kernel source to use
-n, --just-print, --dry-run, --recon
The net result of this is that the compiler or any executable is never invoked. It just fakes it and tells you what it would do.
Options and grep the files from that without building the source. This might be as simple as setting the MAKE environment in the shell to use the options above. Then just grep out all the compiler commands involving .c and .h files. Downloading the kernel source for 2.6.29.2 to have a peek at how you can do this. Edit to come.
good luck
Post back how you get on. Maybe post the shell-script! :)
followup:
Line 13 of the 2.6.29.2 Kernel source-code includes in /2.6.19.2/Makefile
# Do not:
# o use make's built-in rules and variables
# (this increases performance and avoids hard-to-debug behaviour);
# o print "Entering directory ...";
MAKEFLAGS += -rR --no-print-directory
# We are using a recursive build, so we need to do a little thinking
# to get the ordering right.
Editing the MAKEFLAGS
variable to include the dryrun flags should allow you to save the output of a particular make configuration and then grep it later. ala make > save.txt
I changed mine to
MAKEFLAGS += -rR --no-print-directory --just-print
For example (Could be much better):
[aiden@host linux-2.6.29.2]$ \
make > build_out.txt; grep -o -E "[a-zA-Z0-9_-]+\.[ch]" build_out.txt
Not perfect, but worked for me in a hackish way and should get you going. The same basic process will hopefully apply past a blind-make with a configured kernel.
warning
Without maintaining architecture specific toolchains or running Make on the target architecture some of the ASM and architecture specific files make differ to a true build.
edit from comment
To supress the ld failure, you need to find the following section (or similar) in your kernel make file.
# Make variables (CC, etc...)
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
CPP = $(CC) -E
AR = $(CROSS_COMPILE)ar
You need to run the configuration steps to configure the source before you attempt to enumerate the source files used in the prior steps (piping and grepping from dry-run), so you could do your edits in Makefile.enum
and use that after you run the normal configuration steps (regardless of architecture, some config.h-type files need generating. So get the kernel source to the point where you are about to do an actual compilation, modules and all). Whew!
Now when you are doing your fake-make to enumerate the source files, post kernel source configuration (which specifies the drivers/modules, whatever) LD will fail as you discovered. You can alter LD from the
LD = $(CROSS_COMPILE)ld
to
LD = -$(CROSS_COMPILE)ld
Notice the '-' character. This tells the Makefile to ignore warnings. Obviously what you are attempting to do is unusual, but quite cool :) Further errors can be supressed by finding the Makefile section and adjusting the executed commands. I suggest you get very friendly with Makefiles, as you may need to alter IF statements later down the line. Once you have sorted everything out, you will have a 'dumb' makefile that will spit out the .c files so you can do
make | grep -E "[a-zA-Z0-9_-]+\.[ch]"
Or whatever.
I also have a cool suggestion for validating your results ... actually build the kernel ... but use Linux's inotify API (you can get the Python bindings here http://pyinotify.sourceforge.net/) and watch for filesystem events in the compilation window (such as .c files being read by gcc). Then compare this to your list from the 'dumb' makefile.
Ok, I hope that isn't too much of a waffle! good luck