ArcCore Refactoring - Makefile Modular

Based on official arc-stable-9c57d86f66be, AUTOSAR version 3.1.5
 
fundamental issue
2. Whether the code files in the compilation system are compiled and the target files are centrally defined in boards/board_common.mk instead of belonging to their respective modules;
 
Each module should have its own folder and its own Makefile. In this Makefile, according to the configuration switches related to the module, it is decided whether to compile some object files. There are only relevant configuration switches related to each module in the global scope. This reduces coupling and makes code modularity cleaner.
 
The structure is as follows:
 
The Makefile for each module looks like this:
If the object file is in a subdirectory, it ends with a slash (/).
If it is the target file, it can be followed directly.
 
So how to import the Makefile in each module directory? Makefile code needs to be written. as follows:
 
You can refer to the writing method of the Linux kernel. However, multiple Makefiles and sub-make processes are required.
Here we choose a simple implementation and import all the required Makefiles in one Makefile.
 
First, a lot of use of eval is required to execute Makefile code snippets;
Second, faced with the problem of changing the recursion to a loop. It is necessary to adapt the recursive method of the Linux kernel to circular import. That is, the depth-first traversal is changed to breadth-first traversal. The number of loops is the depth of traversal.
 
So find the deepest Makefile first. Then each time the Makefile file in the next directory is introduced.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325361938&siteId=291194637