78c1a24a04dd08bd8ec073445cf9565ce8a7fe78
[openwrt/svn-archive/archive.git] / openwrt / target / linux / kernel.mk
1 LINUX_SOURCE:=linux-$(LINUX_VERSION).tar.bz2
2 LINUX_SITE=http://www.fi.kernel.org/pub/linux/kernel/v$(KERNEL) \
3 http://www.fr.kernel.org/pub/linux/kernel/v$(KERNEL) \
4 http://www.kernel.org/pub/linux/kernel/v$(KERNEL) \
5 http://www.de.kernel.org/pub/linux/kernel/v$(KERNEL)
6
7 KERNEL_IDIR:=$(LINUX_BUILD_DIR)/kernel-ipkg
8
9 $(TARGETS): $(PACKAGE_DIR)
10
11 $(PACKAGE_DIR):
12 mkdir -p $(PACKAGE_DIR)
13
14 $(DL_DIR)/$(LINUX_SOURCE):
15 -mkdir -p $(DL_DIR)
16 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE) $(MAKE_TRACE)
17
18 $(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE)
19 -mkdir -p $(LINUX_BUILD_DIR)
20 bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(LINUX_BUILD_DIR) $(TAR_OPTIONS) -
21 rm -f $(BUILD_DIR)/linux
22 ln -s $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(BUILD_DIR)/linux
23 touch $@
24
25 ifeq ($(KERNEL),2.4)
26 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
27 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" \
28 $(LINUX_DIR)/Makefile \
29 $(LINUX_DIR)/arch/*/Makefile
30 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
31 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) oldconfig include/linux/version.h $(MAKE_TRACE)
32 touch $@
33
34 $(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
35 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(LINUX_KARCH) dep $(MAKE_TRACE)
36 touch $@
37
38 $(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.depend_done
39 else
40 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
41 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(LINUX_KARCH) oldconfig $(MAKE_TRACE)
42 touch $@
43 endif
44
45 $(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.configured
46 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) $(MAKE_TRACE)
47
48 $(LINUX_KERNEL): $(LINUX_DIR)/vmlinux
49 $(TARGET_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $< $@ $(MAKE_TRACE)
50 touch -c $(LINUX_KERNEL)
51
52 $(LINUX_DIR)/.modules_done: $(LINUX_KERNEL) $(LINUX_IMAGE)
53 rm -rf $(LINUX_BUILD_DIR)/modules
54 $(MAKE) -C "$(LINUX_DIR)" CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(LINUX_KARCH) PATH="$(TARGET_PATH)" modules $(MAKE_TRACE)
55 $(MAKE) -C "$(LINUX_DIR)" CROSS_COMPILE="$(KERNEL_CROSS)" DEPMOD=true INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules modules_install $(MAKE_TRACE)
56 touch $(LINUX_DIR)/.modules_done
57
58 $(STAGING_DIR)/include/linux/version.h: $(LINUX_DIR)/.configured
59 mkdir -p $(STAGING_DIR)/include
60 tar -ch -C $(LINUX_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
61 tar -ch -C $(LINUX_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/
62
63 $(STAMP_DIR)/.linux-compile: $(LINUX_DIR)/.modules_done
64 @mkdir -p $(STAMP_DIR)
65 @$(MAKE) $(TARGETS)
66 ln -sf $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(BUILD_DIR)/linux
67 @$(TRACE) target/linux/package
68 $(MAKE) -C $(TOPDIR)/target/linux/package \
69 $(KPKG_MAKEOPTS) \
70 compile
71 touch $@
72
73 $(TARGET_MODULES_DIR):
74 -mkdir -p $(TARGET_MODULES_DIR)
75
76 $(KERNEL_IPKG):
77 rm -rf $(KERNEL_IDIR)
78 mkdir -p $(KERNEL_IDIR)/etc
79 $(SCRIPT_DIR)/make-ipkg-dir.sh $(KERNEL_IDIR) ../control/kernel.control $(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE) $(ARCH)
80 if [ -f ./config/$(BOARD).modules ]; then \
81 cp ./config/$(BOARD).modules $(KERNEL_IDIR)/etc/modules; \
82 fi
83 $(IPKG_BUILD) $(KERNEL_IDIR) $(LINUX_BUILD_DIR) $(MAKE_TRACE)
84
85 source: $(DL_DIR)/$(LINUX_SOURCE)
86 prepare: $(PACKAGE_DIR) $(LINUX_DIR)/.configured
87 compile:
88 $(MAKE) $(STAMP_DIR)/.linux-compile $(MAKE_TRACE)
89
90 install: compile $(TARGET_MODULES_DIR) $(KERNEL_IPKG)
91 rm -rf $(LINUX_BUILD_DIR)/root*
92 cp -fpR $(BUILD_DIR)/root $(LINUX_BUILD_DIR)/
93 echo -e 'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR)/ipkg.conf
94 $(MAKE) -C $(TOPDIR)/target/linux/package \
95 $(KPKG_MAKEOPTS) \
96 install
97 @{ [ "$(INSTALL_TARGETS)" != "" ] && $(IPKG_KERNEL) install $(INSTALL_TARGETS) || true; } $(MAKE_TRACE)
98
99 mostlyclean:
100 rm -f $(STAMP_DIR)/.linux-compile
101 rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.modules_done
102 rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.drivers-unpacked
103 $(MAKE) -C $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) clean $(MAKE_TRACE)
104 rm -f $(LINUX_KERNEL) $(LINUX_IMAGE)
105
106 rebuild:
107 -$(MAKE) mostlyclean
108 if [ -f $(LINUX_KERNEL) ]; then \
109 $(MAKE) clean $(MAKE_TRACE); \
110 fi
111 $(MAKE) compile $(MAKE_TRACE)
112
113 clean:
114 rm -f $(STAMP_DIR)/.linux-compile
115 rm -rf $(LINUX_BUILD_DIR)
116 rm -f $(TARGETS)