System info:
root@zaidi:/home/uzair# uname -a
Linux zaidi 3.11.0-26-generic #45~precise1-Ubuntu SMP Tue Jul 15 04:04:35 UTC 2014 i686 i686 i386 GNU/Linux
I am trying to write a simple device driver. For that I need to download the source code of the kernel I am running (right?)
I found following two methods:
apt-get install linux-source-$(uname -r)
apt-get source linux-image-$(uname -r)
What is the difference between these two commands? Which one is actually required for building the driver. I have a make file like this:
# Makefile – makefile of our first driver
# if KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
ifneq (${KERNELRELEASE},)
obj-m := ofd.o
# Otherwise we were called directly from the command line.
# Invoke the kernel build system.
else
KERNEL_SOURCE := /usr/src/linux
PWD := $(shell pwd)
default:
${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} modules
clean:
${MAKE} -C ${KERNEL_SOURCE} SUBDIRS=${PWD} clean
endif
I would like to have the source code in /usr/src/linux