2 # Copyright (C) 2006-2007 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
7 include $(INCLUDE_DIR)/host.mk
8 include $(INCLUDE_DIR)/prereq.mk
15 STAMP_PREPARED:=$(LINUX_DIR)/.prepared
16 STAMP_CONFIGURED:=$(LINUX_DIR)/.configured
17 include $(INCLUDE_DIR)/download.mk
18 include $(INCLUDE_DIR)/quilt.mk
19 include $(INCLUDE_DIR)/kernel-defaults.mk
22 $(call Kernel/Prepare/Default)
25 define Kernel/Configure
26 $(call Kernel/Configure/Default)
29 define Kernel/CompileModules
30 $(call Kernel/CompileModules/Default)
33 define Kernel/CompileImage
34 $(call Kernel/CompileImage/Default)
38 $(call Kernel/Clean/Default)
41 define Download/kernel
44 MD5SUM:=$(LINUX_KERNEL_MD5SUM)
47 ifdef CONFIG_COLLECT_KERNEL_DEBUG
48 define Kernel/CollectDebug
49 rm -rf $(KERNEL_BUILD_DIR)/debug
50 mkdir -p $(KERNEL_BUILD_DIR)/debug/modules
51 $(CP) $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/debug/
53 $(STAGING_DIR_ROOT)/lib/modules/$(LINUX_VERSION)/* \
54 $(KERNEL_BUILD_DIR)/debug/modules/
55 $(FIND) $(KERNEL_BUILD_DIR)/debug -type f | $(XARGS) $(KERNEL_CROSS)strip --only-keep-debug
56 $(TAR) c -C $(KERNEL_BUILD_DIR) debug | bzip2 -c -9 > $(BIN_DIR)/kernel-debug.tar.bz2
61 $(if $(QUILT),$(Build/Quilt))
62 $(if $(LINUX_SITE),$(call Download,kernel))
64 $(STAMP_PREPARED): $(if $(LINUX_SITE),$(DL_DIR)/$(LINUX_SOURCE))
65 -rm -rf $(KERNEL_BUILD_DIR)
66 -mkdir -p $(KERNEL_BUILD_DIR)
70 $(KERNEL_BUILD_DIR)/symtab.h: FORCE
71 rm -f $(KERNEL_BUILD_DIR)/symtab.h
72 touch $(KERNEL_BUILD_DIR)/symtab.h
73 +$(MAKE) $(KERNEL_MAKEOPTS) vmlinux
74 find $(LINUX_DIR) $(STAGING_DIR_ROOT)/lib/modules -name \*.ko | \
75 xargs $(TARGET_CROSS)nm | \
76 awk '$$$$1 == "U" { print $$$$2 } ' | \
77 sort -u > $(KERNEL_BUILD_DIR)/mod_symtab.txt
78 $(TARGET_CROSS)nm -n $(LINUX_DIR)/vmlinux.o | grep ' r __ksymtab' | sed -e 's,........ r __ksymtab_,,' > $(KERNEL_BUILD_DIR)/kernel_symtab.txt
79 grep -f $(KERNEL_BUILD_DIR)/mod_symtab.txt $(KERNEL_BUILD_DIR)/kernel_symtab.txt > $(KERNEL_BUILD_DIR)/sym_include.txt
80 grep -vf $(KERNEL_BUILD_DIR)/mod_symtab.txt $(KERNEL_BUILD_DIR)/kernel_symtab.txt > $(KERNEL_BUILD_DIR)/sym_exclude.txt
82 echo '#define SYMTAB_KEEP \'; \
83 cat $(KERNEL_BUILD_DIR)/sym_include.txt | \
84 awk '{print "*(__ksymtab." $$$$1 ") \\" }'; \
86 echo '#define SYMTAB_KEEP_GPL \'; \
87 cat $(KERNEL_BUILD_DIR)/sym_include.txt | \
88 awk '{print "*(__ksymtab_gpl." $$$$1 ") \\" }'; \
90 echo '#define SYMTAB_KEEP_STR \'; \
91 cat $(KERNEL_BUILD_DIR)/sym_include.txt | \
92 awk '{print "*(__ksymtab_strings." $$$$1 ") \\" }'; \
94 echo '#define SYMTAB_DISCARD \'; \
95 cat $(KERNEL_BUILD_DIR)/sym_exclude.txt | \
96 awk '{print "*(__ksymtab." $$$$1 ") \\" }'; \
98 echo '#define SYMTAB_DISCARD_GPL \'; \
99 cat $(KERNEL_BUILD_DIR)/sym_exclude.txt | \
100 awk '{print "*(__ksymtab_gpl." $$$$1 ") \\" }'; \
102 echo '#define SYMTAB_DISCARD_STR \'; \
103 cat $(KERNEL_BUILD_DIR)/sym_exclude.txt | \
104 awk '{print "*(__ksymtab_strings." $$$$1 ") \\" }'; \
108 $(STAMP_CONFIGURED): $(STAMP_PREPARED) $(LINUX_KCONFIG_LIST) $(TOPDIR)/.config
112 $(LINUX_DIR)/.modules: $(STAMP_CONFIGURED) $(LINUX_DIR)/.config FORCE
113 $(Kernel/CompileModules)
116 $(LINUX_DIR)/.image: $(STAMP_CONFIGURED) $(if $(CONFIG_STRIP_KERNEL_EXPORTS),$(KERNEL_BUILD_DIR)/symtab.h) FORCE
117 $(Kernel/CompileImage)
118 $(Kernel/CollectDebug)
127 download: $(DL_DIR)/$(LINUX_SOURCE)
128 prepare: $(STAMP_CONFIGURED)
129 compile: $(LINUX_DIR)/.modules
130 $(MAKE) -C image compile TARGET_BUILD=
132 oldconfig menuconfig nconfig: $(STAMP_PREPARED) $(STAMP_CHECKED) FORCE
133 rm -f $(STAMP_CONFIGURED)
134 $(LINUX_RECONF_CMD) > $(LINUX_DIR)/.config
135 $(_SINGLE)$(MAKE) -C $(LINUX_DIR) $(KERNEL_MAKEOPTS) $$@
136 $(LINUX_RECONF_DIFF) $(LINUX_DIR)/.config > $(LINUX_RECONFIG_TARGET)
138 install: $(LINUX_DIR)/.image
139 +$(MAKE) -C image compile install TARGET_BUILD=
142 rm -rf $(KERNEL_BUILD_DIR)
145 @+$(NO_TRACE_MAKE) -s -C image prereq TARGET_BUILD=