move jffs2 end-of-filesystem detection to the generic 2.6 patches
[openwrt.git] / include / kernel-build.mk
1 include $(INCLUDE_DIR)/modules-$(KERNEL).mk
2
3 LINUX_SOURCE:=linux-$(LINUX_VERSION).tar.bz2
4 LINUX_SITE=http://www.us.kernel.org/pub/linux/kernel/v$(KERNEL) \
5 http://www.us.kernel.org/pub/linux/kernel/v$(KERNEL) \
6 http://www.kernel.org/pub/linux/kernel/v$(KERNEL) \
7 http://www.de.kernel.org/pub/linux/kernel/v$(KERNEL)
8
9 KERNEL_IDIR:=$(KERNEL_BUILD_DIR)/kernel-ipkg
10 KERNEL_IPKG:=$(KERNEL_BUILD_DIR)/kernel_$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)_$(ARCH).ipk
11 INSTALL_TARGETS += $(KERNEL_IPKG)
12
13 $(TARGETS): $(PACKAGE_DIR)
14
15 $(LINUX_DIR):
16 mkdir -p $@
17
18 $(PACKAGE_DIR):
19 mkdir -p $@
20
21 $(DL_DIR)/$(LINUX_SOURCE):
22 -mkdir -p $(DL_DIR)
23 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE)
24
25 $(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE)
26 -mkdir -p $(KERNEL_BUILD_DIR)
27 bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS) -
28 touch $@
29
30 ifeq ($(KERNEL),2.4)
31 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
32 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" \
33 $(LINUX_DIR)/Makefile \
34 $(LINUX_DIR)/arch/*/Makefile
35 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
36 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) oldconfig include/linux/compile.h include/linux/version.h
37 touch $@
38
39 $(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
40 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(LINUX_KARCH) dep
41 touch $@
42
43 $(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.depend_done
44 else
45 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
46 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(LINUX_KARCH) oldconfig prepare scripts
47 touch $@
48 endif
49
50 ramdisk-config: $(LINUX_DIR)/.configured FORCE
51 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
52 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
53 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
54 echo 'CONFIG_INITRAMFS_SOURCE="../../root"' >> $(LINUX_DIR)/.config
55 echo 'CONFIG_INITRAMFS_ROOT_UID=0' >> $(LINUX_DIR)/.config
56 echo 'CONFIG_INITRAMFS_ROOT_GID=0' >> $(LINUX_DIR)/.config
57 mkdir -p $(BUILD_DIR)/root/etc/init.d
58 $(CP) ../generic-2.6/files/init $(BUILD_DIR)/root/
59 else
60 rm -f $(BUILD_DIR)/root/init $(BUILD_DIR)/root/etc/init.d/S00initramfs
61 echo 'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR)/.config
62 endif
63
64 $(LINUX_DIR)/vmlinux: $(STAMP_DIR)/.linux-compile pkg-install ramdisk-config
65 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH)
66
67 $(LINUX_KERNEL): $(LINUX_DIR)/vmlinux
68 $(TARGET_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $< $@
69 touch -c $(LINUX_KERNEL)
70
71 $(LINUX_DIR)/.modules_done:
72 rm -rf $(KERNEL_BUILD_DIR)/modules
73 $(MAKE) -C "$(LINUX_DIR)" CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(LINUX_KARCH) PATH="$(TARGET_PATH)" modules
74 $(MAKE) -C "$(LINUX_DIR)" CROSS_COMPILE="$(KERNEL_CROSS)" DEPMOD=true INSTALL_MOD_PATH=$(KERNEL_BUILD_DIR)/modules modules_install
75 touch $(LINUX_DIR)/.modules_done
76
77 $(STAMP_DIR)/.linux-compile:
78 @$(MAKE) $(LINUX_DIR)/.modules_done $(TARGETS) $(KERNEL_IPKG)
79 ln -sf $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) $(BUILD_DIR)/linux
80 touch $@
81
82 $(KERNEL_IPKG):
83 rm -rf $(KERNEL_IDIR)
84 mkdir -p $(KERNEL_IDIR)/etc
85 $(SCRIPT_DIR)/make-ipkg-dir.sh $(KERNEL_IDIR) ../control/kernel.control $(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE) $(ARCH)
86 if [ -f ./config/$(BOARD).modules ]; then \
87 cp ./config/$(BOARD).modules $(KERNEL_IDIR)/etc/modules; \
88 fi
89 $(IPKG_BUILD) $(KERNEL_IDIR) $(KERNEL_BUILD_DIR)
90
91 $(TOPDIR)/.kernel.mk:
92 echo "BOARD:=$(BOARD)" > $@
93 echo "LINUX_VERSION:=$(LINUX_VERSION)" >> $@
94 echo "LINUX_RELEASE:=$(LINUX_RELEASE)" >> $@
95
96 pkg-install: FORCE
97 @{ [ "$(INSTALL_TARGETS)" != "" ] && $(IPKG) install $(INSTALL_TARGETS) || true; }
98
99 source: $(DL_DIR)/$(LINUX_SOURCE)
100 prepare:
101 @mkdir -p $(STAMP_DIR) $(PACKAGE_DIR)
102 @$(MAKE) $(LINUX_DIR)/.configured
103
104 compile: prepare $(STAMP_DIR)/.linux-compile
105
106 install: compile $(LINUX_KERNEL)
107
108 mostlyclean: FORCE
109 rm -f $(STAMP_DIR)/.linux-compile
110 rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.modules_done
111 rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.drivers-unpacked
112 $(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean
113 rm -f $(LINUX_KERNEL)
114
115 rebuild: FORCE
116 -$(MAKE) mostlyclean
117 if [ -f $(LINUX_KERNEL) ]; then \
118 $(MAKE) clean; \
119 fi
120 $(MAKE) compile $(MAKE_TRACE)
121
122 clean: FORCE
123 rm -f $(STAMP_DIR)/.linux-compile
124 rm -rf $(KERNEL_BUILD_DIR)
125 rm -f $(TARGETS)
This page took 0.048439 seconds and 5 git commands to generate.