title: how to compile a kernel module
body: <p>I'm trying to compile a simple hello world module following this <a href="http://www.tldp.org/LDP/lkmpg/2.6/html/lkmpg.html#AEN121" rel="noreferrer">guide</a> and I'm confused about what the Makefile is actually doing.</p>
  
  <pre><code>obj-m += hello-1.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 understand that when i type the <code>make</code> command it will run the <code>all</code> recipe which runs <code>make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules</code>.  So now it runs the Makefile found at the path given after the <code>-C</code> flag but what does the <code>M=$(PWD) modules</code> do?</p>