David Wuertele wrote :
I want my makefile to behave as follows: 1. if I type "make" with no "-j", I want all builds to be sequential, including the glibc submake 2. if I type "make -j N", I want the total number of parallel jobs to be at least N, but I can tolerate it being larger than N.
I had exactly the same wish, and here is how I did it. I have a "top-level" Makefile, which is able to build "modules" (= library or executable). It can scan for dependencies, and recursively calls itself to build dependencies, and dependencies's dependencies. This top-level Makefile doesn't support yet parallel building itself, but each module does. I wanted to be able to run the top level Makefile with "-j N" (despite the fact that it does not support parallel build !), and if this option is present, then all modules would be built with "-j N". In the top-level Makefile, I have an empty ".NOTPARALLEL:" target, so that it disables parrallel build for top-level. Each time it has to call a sub-make, it calls : $(MAKE) $(if $(findstring j,$(MAKEFLAGS)),-j8,) -C /path/to/Makefile a) if /path/to/Makefile is the top-level Makefile, then it ensures that parallel build information is kept between all recursive calls of the top-level Makefile b) if /path/to/Makefile is a module, then it is build with parallel option. Note that the "N" value of the initial invokation of Make is lost because as far as I know, a Makefile can't read it (unless you use some trick like "make JOBS=8 -j8", which I don't want). The tricky part was here : when you dump $(MAKEFLAGS) somewhere *NOT* in a command, then it *NEVER* shows the "-j" otpion. If you dump it *IN A COMMAND* for some target, then it shows the "-j" option (forced to "-j 1" on win32"). Regards, -- Fabrice GIRARDOT _______________________________________________ Help-make mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-make
