add basic support for the Magicbox boards
[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,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
37 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) oldconfig include/linux/compile.h include/linux/version.h
38 touch $@
39
40 $(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
41 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(LINUX_KARCH) dep
42 touch $@
43
44 $(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.depend_done
45 else
46 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
47 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) oldconfig prepare scripts
48 touch $@
49 endif
50
51 ramdisk-config: $(LINUX_DIR)/.configured FORCE
52 mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old
53 grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config
54 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
55 echo 'CONFIG_INITRAMFS_SOURCE="../../root"' >> $(LINUX_DIR)/.config
56 echo 'CONFIG_INITRAMFS_ROOT_UID=0' >> $(LINUX_DIR)/.config
57 echo 'CONFIG_INITRAMFS_ROOT_GID=0' >> $(LINUX_DIR)/.config
58 mkdir -p $(BUILD_DIR)/root/etc/init.d
59 $(CP) ../generic-2.6/files/init $(BUILD_DIR)/root/
60 else
61 rm -f $(BUILD_DIR)/root/init $(BUILD_DIR)/root/etc/init.d/S00initramfs
62 echo 'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR)/.config
63 endif
64
65 $(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.linux-compile pkg-install ramdisk-config
66 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) $(KERNELNAME)
67
68 $(LINUX_KERNEL): $(LINUX_DIR)/vmlinux
69 $(KERNEL_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $< $@
70 touch -c $(LINUX_KERNEL)
71
72 $(LINUX_DIR)/.modules_done:
73 rm -rf $(KERNEL_BUILD_DIR)/modules
74 $(MAKE) -C "$(LINUX_DIR)" CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) modules
75 $(MAKE) -C "$(LINUX_DIR)" CROSS_COMPILE="$(KERNEL_CROSS)" CC="$(KERNEL_CC)" ARCH=$(LINUX_KARCH) DEPMOD=true INSTALL_MOD_PATH=$(KERNEL_BUILD_DIR)/modules modules_install
76 touch $(LINUX_DIR)/.modules_done
77
78 modules: $(LINUX_DIR)/.modules_done
79 packages: $(TARGETS)
80
81 $(LINUX_DIR)/.linux-compile:
82 @rm -f $(BUILD_DIR)/linux
83 ln -sf $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) $(BUILD_DIR)/linux
84 @$(MAKE) modules
85 @$(MAKE) packages
86 touch $@
87
88 $(KERNEL_IPKG):
89 rm -rf $(KERNEL_IDIR)
90 mkdir -p $(KERNEL_IDIR)/etc
91 $(SCRIPT_DIR)/make-ipkg-dir.sh $(KERNEL_IDIR) ../control/kernel.control $(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE) $(ARCH)
92 if [ -f ./config/$(BOARD).modules ]; then \
93 cp ./config/$(BOARD).modules $(KERNEL_IDIR)/etc/modules; \
94 fi
95 $(IPKG_BUILD) $(KERNEL_IDIR) $(KERNEL_BUILD_DIR)
96
97 $(TOPDIR)/.kernel.mk: $(TOPDIR)/target/linux/$(BOARD)-$(KERNEL)/Makefile
98 echo "CONFIG_BOARD:=$(BOARD)" > $@
99 echo "CONFIG_KERNEL:=$(KERNEL)" >> $@
100 echo "CONFIG_LINUX_VERSION:=$(LINUX_VERSION)" >> $@
101 echo "CONFIG_LINUX_RELEASE:=$(LINUX_RELEASE)" >> $@
102
103 pkg-install: FORCE
104 @for pkg in $(INSTALL_TARGETS); do \
105 $(IPKG) install $$pkg || echo; \
106 done
107
108 download: $(DL_DIR)/$(LINUX_SOURCE)
109 prepare: $(LINUX_DIR)/.configured
110 @mkdir -p $(LINUX_DIR) $(PACKAGE_DIR)
111
112 compile: prepare $(LINUX_DIR)/.linux-compile
113
114 install: compile $(LINUX_KERNEL)
115
116 mostlyclean: FORCE
117 rm -f $(LINUX_DIR)/.linux-compile
118 rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.modules_done
119 rm -f $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION)/.drivers-unpacked
120 $(MAKE) -C $(KERNEL_BUILD_DIR)/linux-$(LINUX_VERSION) clean
121 rm -f $(LINUX_KERNEL)
122
123 rebuild: FORCE
124 -$(MAKE) mostlyclean
125 if [ -f $(LINUX_KERNEL) ]; then \
126 $(MAKE) clean; \
127 fi
128 $(MAKE) compile $(MAKE_TRACE)
129
130 clean: FORCE
131 rm -f $(STAMP_DIR)/.linux-compile
132 rm -rf $(KERNEL_BUILD_DIR)
133 rm -f $(TARGETS)
134
This page took 0.047038 seconds and 5 git commands to generate.