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)
35 $(call Kernel/CompileImage/Initramfs)
39 $(call Kernel/Clean/Default)
42 define Download/kernel
45 MD5SUM:=$(LINUX_KERNEL_MD5SUM)
48 ifdef CONFIG_COLLECT_KERNEL_DEBUG
49 define Kernel/CollectDebug
50 rm -rf $(KERNEL_BUILD_DIR)/debug
51 mkdir -p $(KERNEL_BUILD_DIR)/debug/modules
52 $(CP) $(LINUX_DIR)/vmlinux $(KERNEL_BUILD_DIR)/debug/
54 $(STAGING_DIR_ROOT)/lib/modules/$(LINUX_VERSION)/* \
55 $(KERNEL_BUILD_DIR)/debug/modules/
56 $(FIND) $(KERNEL_BUILD_DIR)/debug -type f | $(XARGS) $(KERNEL_CROSS)strip --only-keep-debug
57 $(TAR) c -C $(KERNEL_BUILD_DIR) debug | bzip2 -c -9 > $(BIN_DIR)/kernel-debug.tar.bz2
62 $(if $(QUILT),$(Build/Quilt))
63 $(if $(LINUX_SITE),$(call Download,kernel))
65 $(STAMP_PREPARED): $(if $(LINUX_SITE),$(DL_DIR)/$(LINUX_SOURCE))
66 -rm -rf $(KERNEL_BUILD_DIR)
67 -mkdir -p $(KERNEL_BUILD_DIR)
71 $(KERNEL_BUILD_DIR)/symtab.h: FORCE
72 rm -f $(KERNEL_BUILD_DIR)/symtab.h
73 touch $(KERNEL_BUILD_DIR)/symtab.h
74 +$(MAKE) $(KERNEL_MAKEOPTS) vmlinux
75 find $(LINUX_DIR) $(STAGING_DIR_ROOT)/lib/modules -name \*.ko | \
76 xargs $(TARGET_CROSS)nm | \
77 awk '$$$$1 == "U" { print $$$$2 } ' | \
78 sort -u > $(KERNEL_BUILD_DIR)/mod_symtab.txt
79 $(TARGET_CROSS)nm -n $(LINUX_DIR)/vmlinux.o | grep -F ' r __ksymtab' | sed -e 's,........ r __ksymtab_,,' > $(KERNEL_BUILD_DIR)/kernel_symtab.txt
80 grep -Ff $(KERNEL_BUILD_DIR)/mod_symtab.txt $(KERNEL_BUILD_DIR)/kernel_symtab.txt > $(KERNEL_BUILD_DIR)/sym_include.txt
81 grep -Fvf $(KERNEL_BUILD_DIR)/mod_symtab.txt $(KERNEL_BUILD_DIR)/kernel_symtab.txt > $(KERNEL_BUILD_DIR)/sym_exclude.txt
83 echo '#define SYMTAB_KEEP \'; \
84 cat $(KERNEL_BUILD_DIR)/sym_include.txt | \
85 awk '{print "KEEP(*(___ksymtab+" $$$$1 ")) \\" }'; \
87 echo '#define SYMTAB_KEEP_GPL \'; \
88 cat $(KERNEL_BUILD_DIR)/sym_include.txt | \
89 awk '{print "KEEP(*(___ksymtab_gpl+" $$$$1 ")) \\" }'; \
91 echo '#define SYMTAB_DISCARD \'; \
92 cat $(KERNEL_BUILD_DIR)/sym_exclude.txt | \
93 awk '{print "*(___ksymtab+" $$$$1 ") \\" }'; \
95 echo '#define SYMTAB_DISCARD_GPL \'; \
96 cat $(KERNEL_BUILD_DIR)/sym_exclude.txt | \
97 awk '{print "*(___ksymtab_gpl+" $$$$1 ") \\" }'; \
101 $(STAMP_CONFIGURED): $(STAMP_PREPARED) $(LINUX_KCONFIG_LIST) $(TOPDIR)/.config
105 $(LINUX_DIR)/.modules: $(STAMP_CONFIGURED) $(LINUX_DIR)/.config FORCE
106 $(Kernel/CompileModules)
109 $(LINUX_DIR)/.image: $(STAMP_CONFIGURED) $(if $(CONFIG_STRIP_KERNEL_EXPORTS),$(KERNEL_BUILD_DIR)/symtab.h) FORCE
110 $(Kernel/CompileImage)
111 $(Kernel/CollectDebug)
120 download: $(if $(LINUX_SITE),$(DL_DIR)/$(LINUX_SOURCE))
121 prepare: $(STAMP_CONFIGURED)
122 compile: $(LINUX_DIR)/.modules
123 $(MAKE) -C image compile TARGET_BUILD=
125 oldconfig menuconfig nconfig: $(STAMP_PREPARED) $(STAMP_CHECKED) FORCE
126 rm -f $(STAMP_CONFIGURED)
127 $(LINUX_RECONF_CMD) > $(LINUX_DIR)/.config
128 $(_SINGLE)$(MAKE) -C $(LINUX_DIR) $(KERNEL_MAKEOPTS) $$@
129 $(LINUX_RECONF_DIFF) $(LINUX_DIR)/.config > $(LINUX_RECONFIG_TARGET)
131 install: $(LINUX_DIR)/.image
132 +$(MAKE) -C image compile install TARGET_BUILD=
135 rm -rf $(KERNEL_BUILD_DIR)
138 @+$(NO_TRACE_MAKE) -s -C image prereq TARGET_BUILD=