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