wrt54g v2.2 documentation, 2.4.29 works okay.
[openwrt.git] / openwrt / 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_BINLOC=arch/$(LINUX_KARCH)/brcm-boards/bcm947xx/compressed/vmlinuz
30 # Used by pcmcia-cs and others
31 LINUX_SOURCE_DIR=$(LINUX_DIR)
32
33 # kernel stuff extracted from linksys firmware GPL sourcetree
34 # WRT54GS_3_37_2_1109_US (shared,include,wl,et)
35 LINKSYS_KERNEL_TGZ=linksys-kernel.tar.gz
36
37 TARGET_MODULES_DIR=$(TARGET_DIR)/lib/modules/$(LINUX_VERSION)
38
39 $(DL_DIR)/$(LINUX_SOURCE):
40 -mkdir -p $(DL_DIR)
41 $(WGET) -P $(DL_DIR) $(LINUX_SITE)/$(LINUX_SOURCE)
42
43 $(DL_DIR)/$(LINKSYS_KERNEL_TGZ):
44 $(WGET) -P $(DL_DIR) $(LINKSYS_TGZ_SITE)/$(LINKSYS_KERNEL_TGZ)
45
46 $(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE) $(DL_DIR)/$(LINKSYS_KERNEL_TGZ)
47 -mkdir -p $(BUILD_DIR)
48 (cd $(BUILD_DIR); tar jxvf $(DL_DIR)/$(LINUX_SOURCE))
49 -mkdir -p $(TOOL_BUILD_DIR)
50 -(cd $(TOOL_BUILD_DIR); ln -sf $(LINUX_DIR) linux)
51 toolchain/patch-kernel.sh $(LINUX_DIR) package/linux/kernel-patches
52 ifeq ($(BR2_TARGET_ROOTFS_SQUASHFS_LZMA),y)
53 toolchain/patch-kernel.sh $(LINUX_DIR) target/squashfs-lzma/kernel-patch
54 endif
55 -cp $(LINUX_KCONFIG) $(LINUX_DIR)/.config
56 # extract linksys binary kernel stuff and include/shared files
57 zcat $(DL_DIR)/$(LINKSYS_KERNEL_TGZ) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
58 touch $(LINUX_DIR)/.unpacked
59
60 $(LINUX_KCONFIG):
61 @if [ ! -f "$(LINUX_KCONFIG)" ] ; then \
62 echo ""; \
63 echo "You should create a .config for your kernel"; \
64 echo "and install it as $(LINUX_KCONFIG)"; \
65 echo ""; \
66 sleep 5; \
67 fi;
68
69 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.unpacked $(LINUX_KCONFIG)
70 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" $(LINUX_DIR)/Makefile
71 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" $(LINUX_DIR)/arch/mips/Makefile
72 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
73 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) oldconfig include/linux/version.h
74 touch $(LINUX_DIR)/.configured
75
76 $(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
77 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) dep
78 touch $(LINUX_DIR)/.depend_done
79
80 $(LINUX_DIR)/$(LINUX_BINLOC): $(LINUX_DIR)/.depend_done
81 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) $(LINUX_FORMAT)
82 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) modules
83
84 $(LINUX_KERNEL): $(LINUX_DIR)/$(LINUX_BINLOC)
85 cp -fa $(LINUX_DIR)/$(LINUX_BINLOC) $(LINUX_KERNEL)
86 touch -c $(LINUX_KERNEL)
87
88 $(LINUX_DIR)/.modules_done: $(LINUX_KERNEL)
89 rm -rf $(BUILD_DIR)/modules
90 $(MAKE) -C $(LINUX_DIR) DEPMOD=true INSTALL_MOD_PATH=$(BUILD_DIR)/modules modules_install
91 tar -C $(BUILD_DIR)/modules/lib -cjf openwrt-kmodules.tar.bz2 modules
92 touch $(LINUX_DIR)/.modules_done
93
94
95 $(STAGING_DIR)/include/linux/version.h: $(LINUX_DIR)/.configured
96 mkdir -p $(STAGING_DIR)/include
97 tar -ch -C $(LINUX_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
98 tar -ch -C $(LINUX_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/
99
100 linux: $(LINUX_DIR)/.modules_done $(TARGET_MODULES_DIR)
101
102 $(TARGET_MODULES_DIR):
103 -mkdir -p $(TARGET_MODULES_DIR)
104 cp $(LINUX_DIR)/drivers/net/wl/wl.o $(TARGET_MODULES_DIR)
105 cp $(LINUX_DIR)/drivers/net/et/et.o $(TARGET_MODULES_DIR)
106 cp $(LINUX_DIR)/drivers/net/diag/diag.o $(TARGET_MODULES_DIR)
107
108 linux-source: $(DL_DIR)/$(LINUX_SOURCE)
109
110 # This has been renamed so we do _NOT_ by default run this on 'make clean'
111 linuxclean: clean
112 rm -f $(LINUX_KERNEL)
113 -$(MAKE) -C $(LINUX_DIR) clean
114
115 linux-dirclean:
116 rm -rf $(LINUX_DIR)
117
118 linux-headers: $(LINUX_DIR)/.configured
119
120 endif
This page took 0.05958 seconds and 5 git commands to generate.