title: How do I compile a linux kernel module
body: <p>I am unable to compile a linux kernel module,</p>
  
  <p>Given the following source:</p>
  
  <pre><code>/* hello.c */
  
  #include &lt;linux/module.h&gt;
  #include &lt;linux/kernel.h&gt;
  
  int init_module(void)
  {
  printk(KERN_INFO "Hello world\n");
  return 0;
  }
  
  void cleanup_module(void)
  {
  printk(KERN_INFO "Goodbye world\n");
  }
  
  /* end of hello.c */
  </code></pre>
  
  <p>and the following Makefile:</p>
  
  <pre><code>obj-m += hello.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>When I type make while in the same directory as the source and make files, I get the message: 'Nothing to be done for `all'
  The compilation seems to stop here and no object file is created.</p>
  
  <p>Now just for testing, I tried a new simpler Makefile:
      TARGET  := hello
      ${TARGET}.o: ${TARGET}.c</p>
  
  <p>Running make gives me the new error:hello.c:1:    fatal error: linux/module.h: No such file or directory.</p>
  
  <p>however this file IS available in the folder:</p>
  
  <pre><code>/usr/src/linux-headers-2.6.35-22/include/linux 
  </code></pre>
  
  <p>and also in</p>
  
  <pre><code>/usr/src/linux-headers-2.6.35-22-generic/include/linux
  </code></pre>
  
  <p>as is the kernel.h file</p>
  
  <p>What am I missing, any ideas?</p>
  
  <p>Thanks in advance</p>