Add support for built-in kernel build
authorMichael Jeanson <mjeanson@efficios.com>
Fri, 11 Dec 2015 21:33:09 +0000 (16:33 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 18 Dec 2015 21:41:50 +0000 (16:41 -0500)
To build the LTTng modules as builtins in a kernel image, simply run
the "built-in.sh" script with the path to you kernel source directory
as an argument. Then configure your kernel build and add the "CONFIG_LTTNG"
option. Build as usual and voila!

This is an early implementation with a single configuration option that
enables or disables everything, We could add fine grained config options
for each modules or group of modules.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Kconfig [new file with mode: 0644]
README.md
built-in.sh [new file with mode: 0755]

diff --git a/Kconfig b/Kconfig
new file mode 100644 (file)
index 0000000..9ed539e
--- /dev/null
+++ b/Kconfig
@@ -0,0 +1,11 @@
+config LTTNG
+       tristate "LTTng support"
+       depends on TRACEPOINTS
+       help
+         LTTng is an open source tracing framework for Linux.
+
+         See https://lttng.org/
+
+         To compile as a module, choose M here.
+
+         If unsure, say N.
index 9934d2ef35eb3fb6a604d444ce09328e436da01e..e3842d5958db43f5722fd4e900f2722fdeb5e2a2 100644 (file)
--- a/README.md
+++ b/README.md
@@ -42,6 +42,16 @@ kernel, do:
     sudo depmod -a kernel_version
 
 
+### Kernel built-in support
+
+It is also possible to build these modules as part of a kernel image. Simply
+run the [`built-in.sh`](built-in.sh) script with the path to your kernel
+source directory as an argument.  It will symlink the lttng-modules directory
+in the kernel sources and add an include in the kernel Makefile.
+
+Then configure your kernel as usual and enable the `CONFIG_LTTNG` option.
+
+
 ### Required kernel config options
 
 Make sure your target kernel has the following config options enabled:
@@ -83,7 +93,7 @@ available from LTTng:
     number and name
 
 
-Using
+Usage
 -----
 
 Use [LTTng-tools](https://lttng.org/download) to control the tracer.
diff --git a/built-in.sh b/built-in.sh
new file mode 100755 (executable)
index 0000000..782985f
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+set -e
+
+usage() {
+       echo "usage: $0 <kernel source tree>" >&2
+       exit 1
+}
+
+[ "$#" -eq 1 ] || usage
+KERNEL_DIR="$(readlink --canonicalize-existing "$1")"
+
+# Symlink the lttng-modules directory in the kernel source
+ln -sf "$(pwd)" "${KERNEL_DIR}/lttng"
+
+# Graft ourself to the kernel build system
+echo 'source "lttng/Kconfig"' >> "${KERNEL_DIR}/Kconfig"
+sed -i 's#+= kernel/#+= kernel/ lttng/#' "${KERNEL_DIR}/Makefile"
+
+echo >&2
+echo "    $0: done." >&2
+echo "    $0: now you can build the kernel with LTTng support." >&2
+echo "    $0: make sure you enable it (CONFIG_LTTNG) before building." >&2
+echo >&2
This page took 0.026693 seconds and 4 git commands to generate.