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