Recursive Makefile - Passing Variables to the Root Makefile
Currently i am having problems with a makefile due to some unexpected recursion and the neccessary collection of filenames. I want to call recursively a Makefile in the root folder of my project and that one should go through every possible subfolder (and their subfolders...) with the goal to collect all files and write them to a variable to be used as "targets" or dependent files.
For example: /Makefile
goes through /Source
, /Source/Boot
and finds /Source/Boot/Boot.s
(-> one target is therefore /Source/Boot/Boot.o
) and it goes on with /Source/Kernel
and finds /Source/Kernel/Foo.c
(-> second target is therefore /Source/Kernel/Foo.o
). I can compile these files in the Makefiles in the subfolders, but i need to link them whe开发者_开发百科n my root Makefile returns to the root.
So the question is, how can i pass adequately the paths to these object files to the root makefile to link them?
Recursively called makefiles can't pass info back to their caller (unless you resort to a hack, like using external files to collect the object file names). Have a look at the paper Mark linked to. It shows a way of organising your project to do what you want, in a maintainable way.
精彩评论