title: Ubuntu 15.10 (Kernel 4.2): Hello world kernel module makefile error
body: <p>I have been trying for hours to create my first Hello World Kernel module, alas unsuccessfully. My simple C code (hello.c) and makefile are located in /Downloads on my system, if that should be of any importance.</p>
  
  <p>hello.c</p>
  
  <pre><code>#include &lt;linux/init.h&gt;
  #include &lt;linux/module.h&gt;
  
  MODULE_LICENSE("Dual BSD/GPL");
  
  static int hello_init(void) {
      printk(KERN_ALERT "Hello, world\n");
      return 0;
  }
  
  static void hello_exit(void) {
      printk(KERN_ALERT "Goodbye, cruel world\n");
  }
  
  module_init(hello_init);
  module_exit(hello_exit);
  </code></pre>
  
  <p>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>And this is the error message I'm receiving when I try to build the kernel module by entering "make" (without quotation marks) in the terminal:</p>
  
  <pre><code>make -C /lib/modules/4.2.0-16-generic/build
  M=/home/username/workspace/test/Module modules make[1]:
  Entering directory '/usr/src/linux-headers-4.2.0-16-generic'
  scripts/Makefile.build:44:
  /home/username/workspace/test/Module/Makefile: No such file or
  directory make[2]: *** No rule to make target
  '/home/username/workspace/test/Module/Makefile'.  Stop.
  Makefile:1398: recipe for target
  '_module_/home/username/workspace/test/Module' failed make[1]:
  *** [_module_/home/username/workspace/test/Module] Error 2 make[1]: Leaving directory '/usr/src/linux-headers-4.2.0-16-generic'
  makefile:4: recipe for target 'all' failed make: *** [all] Error 2
  </code></pre>
  
  <p>I have tried pretty much every single solution and have followed every suggestion regarding this problem that can be found on google. Nothing could solve my problem ...
  If anybody knows anything I could try, I would be very grateful!</p>
  
  <ul>
  <li>Should I move my hello.c and makefile to /usr/src?</li>
  <li>Are there any syntax errors in my files?</li>
  <li>Should it say hello.c instead of hello.o in the makefile?</li>
  <li>Might my Ubuntu be missing something?</li>
  <li>...</li>
  </ul>