the file with the same name

Valdis.Kletnieks at vt.edu Valdis.Kletnieks at vt.edu
Sun Nov 23 12:31:52 EST 2014


On Sun, 23 Nov 2014 16:25:11 +0800, 孙建希 said:

> I found there's many files with same name in kernel.
> e.g:
> include/asm/linkage.h
> arch/x86/include/asm/linkage.h
>
> I know when compile for x86, kbuild will use x86 linkage.h.

The secret is in the -I include directives - it will search for linkage.h
in directories in order of -I on the compile command line, and use the first
one it finds.  So x86 gets built with "-I arch/x86/include/asm -I include/asm".

The neat thing is that this allows a generic version for each .h to live
in include/, and if a given architecthre FooVax doesn't use a custom version
of that header, it finds it in include/,and if it *does* have a custom
version, it finds it in -I arch/FooVax/include.

(A nice benefit when porting - it means that even if you know that eventually
you'll need a custom linkage.h due to the API, or whatever, you can still do
compile-testing of other code while you're still writing linkage.h)

To see the compile command line in gory detail, use 'make V=1'.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20141123/e5c0604f/attachment.bin 


More information about the Kernelnewbies mailing list