From 3a9e6ae3993f3809e2bd5faa8ccb36896d3cb01b Mon Sep 17 00:00:00 2001
From: Manuel Traut <manut@linutronix.de>
Date: Thu, 19 Apr 2018 21:46:26 +0200
Subject: kernel-basics/module work in linux source tree

instead of having a out-of-tree kernel module (i hate them).

Signed-off-by: Manuel Traut <manut@linutronix.de>
---
 .../module-basics/pres_module-basics_en.tex        | 56 +++++++++++++++++-----
 1 file changed, 45 insertions(+), 11 deletions(-)

(limited to 'kernel-devel/module-basics/pres_module-basics_en.tex')

diff --git a/kernel-devel/module-basics/pres_module-basics_en.tex b/kernel-devel/module-basics/pres_module-basics_en.tex
index 6ee58f5..2c41d49 100644
--- a/kernel-devel/module-basics/pres_module-basics_en.tex
+++ b/kernel-devel/module-basics/pres_module-basics_en.tex
@@ -65,11 +65,43 @@ MODULE_VERSION("0815");
 \end{tiny}
 \end{frame}
 
-\subsubsection{Makefile}
+\subsubsection{Kernel Build System}
+\begin{frame}[fragile]
+\frametitle{Kconfig}
+drivers/staging/Kconfig:
+\begin{scriptsize}
+	\begin{lstlisting}
+..
+source "drivers/staging/vain/Kconfig"
+..
+	\end{lstlisting}
+\end{scriptsize}
+drivers/staging/vain/Kconfig:
+\begin{scriptsize}
+	\begin{lstlisting}
+config VAIN
+       tristate "vain test driver"
+       ---help---
+         Say Y here if you want the VAIN Test Driver in your kernel.
+	\end{lstlisting}
+\end{scriptsize}
+results in CONFIG\_VAIN = ['y'|'n'|'m']
+\end{frame}
 \begin{frame}[fragile]
 \frametitle{Makefile}
+drivers/staging/Makefile:
+\begin{scriptsize}
+	\begin{lstlisting}
+..
+obj-$(CONFIG_VAIN) += vain/
+..
+	\end{lstlisting}
+\end{scriptsize}
+drivers/staging/vain/Makefile:
 \begin{scriptsize}
-\lstinputlisting[language=make]{kernel-devel/module-basics/vain/Makefile}
+	\begin{lstlisting}
+obj-$(CONFIG_VAIN) += vain.o
+	\end{lstlisting}
 \end{scriptsize}
 \end{frame}
 
@@ -79,23 +111,25 @@ MODULE_VERSION("0815");
 \item Build
 \begin{tiny}
 \begin{verbatim}
-$ make
-make -C /lib/modules/2.6.30/build M=/path/to/vain modules
-make[1]: Entering directory `/usr/src/linux-2.6.30'
-  CC [M]  /path/to/vain/vain.o
+$ make menuconfig
+\end{verbatim}
+and select Drivers / Staging / vain test driver with 'm' to be built as a
+module.
+\begin{verbatim}
+...
+  CC [M]  vain.o
   Building modules, stage 2.
   MODPOST 1 modules
-  CC      /path/to/vain/vain.mod.o
-  LD [M]  /path/to/vain/vain.ko
-make[1]: Leaving directory `/usr/src/linux-2.6.30'
-$
+  CC      vain.mod.o
+  LD [M]  vain.ko
+...
 \end{verbatim}
 \end{tiny}
 \pause
 \item Load
 \begin{tiny}
 \begin{verbatim}
-# insmod ./vain.ko
+# insmod drivers/staging/vain/vain.ko
 vain_init: done
 #
 \end{verbatim}
-- 
cgit v1.2.3

