title: Make/build multiple kernel modules in different sub directories
body: <p>I want to make multiple kernel modules by executing one Makefile.</p>
  
  <p>I have following directories and files:</p>
  
  <ul>
  <li>top level directory:
  
  <ul>
  <li>subdir0:
  
  <ul>
  <li>module0.c</li>
  <li>Makefile</li>
  </ul></li>
  <li>subdir1:
  
  <ul>
  <li>module1.c</li>
  <li>Makefile</li>
  </ul></li>
  <li>subdir2:
  
  <ul>
  <li>module2.c</li>
  <li>Makefile</li>
  </ul></li>
  <li>Makefile (I want to execute this)</li>
  </ul></li>
  </ul>
  
  <p>I want to execute only the Makefile in the top level directory and all subdir Makefiles should be executed. I want to get one kernel module for each subdirectory.</p>
  
  <p>This is my current setting but it does not work. If I execute make inside of a subdir, it builds the correct *.ko files. But if I execute the top level Makefile it just generates Module.symvers and modules.order and the output looks like every Makefile would be executed, but nothing is created inside of the subdirectories.</p>
  
  <p>My top level Makefile has the following contents:</p>
  
  <pre><code>TARGETS := all clean
  SUBDIRS := subdir0 subdir1 subdir2
  
  .PHONY: $(TARGETS) $(SUBDIRS)
  
  $(TARGETS): $(SUBDIRS)
  
  $(SUBDIRS):
      $(MAKE) -C $@ $(MAKECMDGOALS)
  </code></pre>
  
  <p>My subdirectory Makefiles have the following code:</p>
  
  <pre><code>obj-m += module0.o
  
  all:
      $(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
  
  clean:
      $(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
  </code></pre>
  
  <p>I would be glad if someone could help me.</p>
  
  <p>Thanks,
  micha</p>