kbuild: Split Makefile into needs / needs not .config
The current top-level Makefile has a fundamental problem which makes "make oldconfig vmlinux" impossible: It includes .config, which is changed by "oldconfig". So after "oldconfig" .config has changed and the .config the Makefile had read is obsolete. make provides a mechanism to cope with this, it'll restart automatically if any of the files it included changed, if you let it know that you changed it, just using a normal rule which has .config as its target. However, once you tell make that "make oldconfig" changes .config, you have another problem: oldconfig always uses .config to be remade, there's no mechanism to tell if it's up to date. So makes notices that .config has changed, restarts, makes oldconfig again, notices that .config has changed, restarts, ... you get the picture. The way to solve this is to do a proper two-stage approach: If you just say "make oldconfig", there's no need for the Makefile to even read the .config. If it does not, it won't restart and recurse infintely. So we divide the Makefile into two sections: One for targets which don't need the variables from .config, like *config, clean, mrproper and one section which does the actual build, which needs to know the CONFIG_ options. If one of the "noconfig" targets is given, we handle those, without reading .config. From there, we call make again, filtering out the already handled targets, to do the main work. The fact that this actually works correctly can be seen by trying "make vmlinux oldconfig" which will execute things in the right order - and this is not just nitpicking, it means that "-j" will get this case right, too. The $(CONFIGURATION) hack used to start "make config" automatically can go away now, too. Since we don't know which of make *config the user prefers, we'll just ask him call "make whatever-config" himself, instead of forcing "make config" on him.
Showing
Please register or sign in to comment