I do not believe that users will cleanup kernelsource, when switching
[openwrt.git] / package / linux / linux.mk
1 #############################################################
2 #
3 # Linux kernel target for the OpenWRT project
4 #
5 # patches are sorted by numbers
6 # 000 patch between linux-2.4.29 and linux-mips-cvs
7 # 0xx linksys patches
8 # 1xx OpenWRT patches (diag,compressed,..)
9 # 2xx fixes for 2.4.29 integration (wl driver)
10 # 3xx kernel feature patches (squashfs,jffs2 compression,..)
11 # 4xx patches needed to integrate feature patches
12 #
13 #############################################################
14 ifneq ($(filter $(TARGETS),linux),)
15
16 LINUX_FORMAT=zImage
17 LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
18 -e 's/mipsel/mips/' \
19 -e 's/powerpc/ppc/' \
20 -e 's/sh[234]/sh/' \
21 )
22
23 LINUX_VERSION=2.4.29
24 LINUX_DIR=$(BUILD_DIR)/linux-$(LINUX_VERSION)
25 LINUX_SITE=http://www.kernel.org/pub/linux/kernel/v2.4
26 LINUX_SOURCE=linux-$(LINUX_VERSION).tar.bz2
27 LINUX_KCONFIG=package/linux/linux.config
28 LINUX_KERNEL=$(BUILD_DIR)/buildroot-kernel
29 LINUX_PATCHES=$(PACKAGE_DIR)/linux/kernel-patches
30 LINUX_BINLOC=arch/$(LINUX_KARCH)/brcm-boards/bcm947xx/compressed/vmlinuz
31 # Used by pcmcia-cs and others
32 LINUX_SOURCE_DIR=$(LINUX_DIR)
33
34 # kernel stuff extracted from linksys firmware GPL sourcetree
35 # WRT54GS_3_37_2_1109_US (shared,include,wl,et)
36 LINKSYS_KERNEL_SITE=http://openwrt.openbsd-geek.de
37 LINKSYS_KERNEL_TGZ=linksys-kernel.tar.gz
38
39 TARGET_MODULES_DIR=$(TARGET_DIR)/lib/modules/$(LINUX_VERSION)
40
41 $(DL_DIR)/$(LINKSYS_KERNEL_TGZ):
42 $(WGET) -P $(DL_DIR) $(LINKSYS_KERNEL_SITE)/$(LINKSYS_KERNEL_TGZ)
43
44 $(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE) $(DL_DIR)/$(LINKSYS_KERNEL_TGZ)
45 -mkdir -p $(BUILD_DIR)
46 bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
47 # extract linksys binary kernel stuff and include/shared files
48 zcat $(DL_DIR)/$(LINKSYS_KERNEL_TGZ) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
49 touch $(LINUX_DIR)/.unpacked
50
51 $(LINUX_DIR)/.patched: $(LINUX_DIR)/.unpacked
52 $(PATCH) $(LINUX_DIR) $(LINUX_PATCHES)
53 ifeq ($(BR2_TARGET_ROOTFS_SQUASHFS_LZMA),y)
54 $(PATCH) $(LINUX_DIR) target/squashfs-lzma/kernel-patch
55 endif
56 touch $(LINUX_DIR)/.patched
57
58 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
59 -cp $(LINUX_KCONFIG) $(LINUX_DIR)/.config
60 ifeq ($(BR2_TARGET_ROOTFS_SQUASHFS_LZMA),y)
61 $(SED) "s,rootfstype=jffs2,rootfstype=squashfs," $(LINUX_DIR)/.config
62 endif
63 ifeq ($(BR2_TARGET_ROOTFS_SQUASHFS),y)
64 $(SED) "s,rootfstype=jffs2,rootfstype=squashfs," $(LINUX_DIR)/.config
65 endif
66 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" $(LINUX_DIR)/Makefile
67 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" $(LINUX_DIR)/arch/mips/Makefile
68 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
69 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) oldconfig include/linux/version.h
70 touch $(LINUX_DIR)/.configured
71
72 $(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
73 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) dep
74 touch $(LINUX_DIR)/.depend_done
75
76 $(LINUX_DIR)/$(LINUX_BINLOC): $(LINUX_DIR)/.depend_done
77 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) $(LINUX_FORMAT)
78 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) modules
79
80 $(LINUX_KERNEL): $(LINUX_DIR)/$(LINUX_BINLOC)
81 cp -fa $(LINUX_DIR)/$(LINUX_BINLOC) $(LINUX_KERNEL)
82 touch -c $(LINUX_KERNEL)
83
84 $(LINUX_DIR)/.modules_done: $(LINUX_KERNEL)
85 rm -rf $(BUILD_DIR)/modules
86 $(MAKE) -C $(LINUX_DIR) DEPMOD=true INSTALL_MOD_PATH=$(BUILD_DIR)/modules modules_install
87 tar -C $(BUILD_DIR)/modules/lib -cjf openwrt-kmodules.tar.bz2 modules
88 touch $(LINUX_DIR)/.modules_done
89
90 $(STAGING_DIR)/include/linux/version.h: $(LINUX_DIR)/.configured
91 mkdir -p $(STAGING_DIR)/include
92 tar -ch -C $(LINUX_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
93 tar -ch -C $(LINUX_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/
94
95 $(TARGET_MODULES_DIR):
96 -mkdir -p $(TARGET_MODULES_DIR)
97 cp $(LINUX_DIR)/drivers/net/wl/wl.o $(TARGET_MODULES_DIR)
98 cp $(LINUX_DIR)/drivers/net/et/et.o $(TARGET_MODULES_DIR)
99 cp $(LINUX_DIR)/drivers/net/diag/diag.o $(TARGET_MODULES_DIR)
100
101 linux: $(LINUX_DIR)/.modules_done $(TARGET_MODULES_DIR)
102
103 linux-source: $(DL_DIR)/$(LINUX_SOURCE)
104
105 # This has been renamed so we do _NOT_ by default run this on 'make clean'
106 linuxclean: clean
107 rm -f $(LINUX_KERNEL)
108 -$(MAKE) -C $(LINUX_DIR) clean
109
110 linux-dirclean:
111 rm -rf $(LINUX_DIR)
112
113 endif
114
115 #############################################################
116 #
117 # Toplevel Makefile options
118 #
119 ##############################################################
120 ifeq ($(strip $(BR2_PACKAGE_LINUX)),y)
121 TARGETS+=linux
122 endif
This page took 0.043446 seconds and 5 git commands to generate.