title: Makefile only works on terminal, fails when using Emacs
body: <p>I am currently trying to write basic kernel module on linux. I can compile the source code on terminal without any error</p>
  <pre class="lang-shell prettyprint-override"><code>~/Desktop/kernelDriver$ make
  make -C /lib/modules/5.8.0-7642-generic/build M=/home/cryonayes/Desktop/kernelDriver modules
  make[1]: Entering directory '/usr/src/linux-headers-5.8.0-7642-generic'
  CC [M]  /home/cryonayes/Desktop/kernelDriver/basicModule.o
  MODPOST /home/cryonayes/Desktop/kernelDriver/Module.symvers
  CC [M]  /home/cryonayes/Desktop/kernelDriver/basicModule.mod.o
  LD [M]  /home/cryonayes/Desktop/kernelDriver/basicModule.ko
  make[1]: Leaving directory '/usr/src/linux-headers-5.8.0-7642-generic'
  </code></pre>
  <p>But when I try to compile with same files on Emacs I get this error</p>
  <pre class="lang-shell prettyprint-override"><code>-*- mode: compilation; default-directory: &quot;~/Desktop/kernelDriver/&quot; -*-
  Compilation started at Wed Mar  3 20:42:07
     
  make
  make -C /lib/modules/5.8.0-7642-generic/build M=/home/cryonayes/Desktop/kernelDriver modules
  make[1]: *** /lib/modules/5.8.0-7642-generic/build: No such file or directory.  Stop.
  make: *** [Makefile:7: all] Error 2    
  Compilation exited abnormally with code 2 at Wed Mar  3 20:42:07
  </code></pre>
  <p>It says <strong>No such file or directory.</strong> but it actually exists.</p>
  <p>Here is the content of my Makefile</p>
  <pre class="lang-makefile prettyprint-override"><code>obj-m += basicModule.o
      
  KERNEL_DIR ?= /lib/modules/$(shell uname -r)/build
  PWD := $(shell pwd)
      
  all:
      $(MAKE) -C $(KERNEL_DIR) M=$(PWD) modules
      
  clean:
      $(MAKE) -C $(KERNEL_DIR) M=$(PWD) clean
  </code></pre>
  <p>What causes this error ?</p>