[PATCH v2 17/29] ktap: add Makefile for kernel module(kernel/trace/ktap/Makefile)

From: Jovi Zhangwei
Date: Sat Mar 29 2014 - 11:26:57 EST


This Makefile compiles kernel module and generate ktapvm.ko.

Signed-off-by: Jovi Zhangwei <jovi.zhangwei@xxxxxxxxx>
---
kernel/trace/ktap/Makefile | 50 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
create mode 100644 kernel/trace/ktap/Makefile

diff --git a/kernel/trace/ktap/Makefile b/kernel/trace/ktap/Makefile
new file mode 100644
index 0000000..6168ac2
--- /dev/null
+++ b/kernel/trace/ktap/Makefile
@@ -0,0 +1,50 @@
+# Define amalg to enable amalgamation build, This compiles the ktapvm as
+# one huge C file and allows GCC to generate faster and shorter code. Also,
+# this requires lots of memory during the build.
+# Recommend to use amalgmation build as default.
+amalg = 1
+
+# Do not instrument the tracer itself:
+ifdef CONFIG_FUNCTION_TRACER
+ORIG_CFLAGS := $(KBUILD_CFLAGS)
+KBUILD_CFLAGS = $(subst -pg,,$(ORIG_CFLAGS))
+endif
+
+all: mod
+
+KTAP_LIBS = -lpthread
+
+LIB_OBJS += lib_base.o lib_kdebug.o lib_timer.o lib_ansi.o lib_table.o \
+ lib_net.o
+
+ifndef amalg
+RUNTIME_OBJS += ktap.o kp_bcread.o kp_obj.o kp_str.o kp_mempool.o \
+ kp_tab.o kp_vm.o kp_transport.o kp_events.o $(LIB_OBJS)
+else
+RUNTIME_OBJS += amalg.o
+endif
+
+obj-m += ktapvm.o
+ktapvm-y := $(RUNTIME_OBJS)
+
+KVERSION ?= $(shell uname -r)
+KERNEL_SRC ?= /lib/modules/$(KVERSION)/build
+PWD := $(shell pwd)
+mod:
+ $(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules
+
+modules_install:
+ $(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules_install
+
+load:
+ insmod ktapvm.ko
+
+unload:
+ rmmod ktapvm
+
+reload:
+ make unload; make load
+
+clean:
+ $(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean
+
--
1.8.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/