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