49a12780936e5044777fa5ddce7d09744081acf0
[openwrt.git] / openwrt / package / linux / linux.mk
1 #############################################################
2 #
3 # Linux kernel targets
4 #
5 # Note: If you have any patches to apply, create the directory
6 # sources/kernel-patches and put your patches in there and number
7 # them in the order you wish to apply them... i.e.
8 #
9 # sources/kernel-patches/001-my-special-stuff.bz2
10 # sources/kernel-patches/003-gcc-Os.bz2
11 # sources/kernel-patches/004_no-warnings.bz2
12 # sources/kernel-patches/030-lowlatency-mini.bz2
13 # sources/kernel-patches/031-lowlatency-fixes-5.bz2
14 # sources/kernel-patches/099-shutup.bz2
15 # etc...
16 #
17 # these patches will all be applied by the patch-kernel.sh
18 # script (which will also abort the build if it finds rejects)
19 # -Erik
20 #
21 #############################################################
22 ifneq ($(filter $(TARGETS),linux),)
23
24 LINUX_FORMAT=zImage
25 LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
26 -e 's/mipsel/mips/' \
27 -e 's/powerpc/ppc/' \
28 -e 's/sh[234]/sh/' \
29 )
30
31 LINUX_VERSION=2.4.29
32 LINUX_CVS_DATE="2005-01-30"
33 LINUX_CVS_BRANCH=linux_2_4
34 LINUX_DIR=$(BUILD_DIR)/linux
35 LINUX_SITE=ftp.linux-mips.org
36 LINUX_KCONFIG=package/linux/linux.config
37 LINUX_KERNEL=$(BUILD_DIR)/buildroot-kernel
38 LINUX_BINLOC=arch/$(LINUX_KARCH)/brcm-boards/bcm947xx/compressed/vmlinuz
39 # Used by pcmcia-cs and others
40 LINUX_SOURCE_DIR=$(LINUX_DIR)
41
42 # kernel stuff extracted from linksys firmware GPL sourcetree
43 # WRT54GS_3_37_2_1109_US (shared,include,wl,et)
44 LINKSYS_KERNEL_TGZ=linksys-kernel.tar.gz
45
46 TARGET_MODULES_DIR=$(TARGET_DIR)/lib/modules/$(LINUX_VERSION)
47
48 $(DL_DIR)/linux.tar.bz2:
49 -mkdir -p $(DL_DIR)
50 (cd $(DL_DIR); cvs -d :pserver:cvs:cvs@$(LINUX_SITE):/home/cvs login)
51 (cd $(DL_DIR); cvs -z3 -d :pserver:cvs:cvs@$(LINUX_SITE):/home/cvs co -D $(LINUX_CVS_DATE) -r$(LINUX_CVS_BRANCH) linux)
52 (cd $(DL_DIR); tar jcvf linux.tar.bz2 linux && rm -rf linux)
53
54 $(DL_DIR)/$(LINKSYS_KERNEL_TGZ):
55 $(WGET) -P $(DL_DIR) $(LINKSYS_TGZ_SITE)/$(LINKSYS_KERNEL_TGZ)
56
57 $(LINUX_DIR)/.unpacked: $(DL_DIR)/linux.tar.bz2 $(DL_DIR)/$(LINKSYS_KERNEL_TGZ)
58 -mkdir -p $(BUILD_DIR)
59 (cd $(BUILD_DIR); tar jxvf $(DL_DIR)/linux.tar.bz2)
60 -mkdir -p $(TOOL_BUILD_DIR)
61 -(cd $(TOOL_BUILD_DIR); ln -sf $(BUILD_DIR)/linux linux)
62 toolchain/patch-kernel.sh $(LINUX_DIR) package/linux/kernel-patches
63 -cp $(LINUX_KCONFIG) $(LINUX_DIR)/.config
64 # extract linksys binary kernel stuff and include/shared files
65 zcat $(DL_DIR)/$(LINKSYS_KERNEL_TGZ) | tar -C $(BUILD_DIR) $(TAR_OPTIONS) -
66 touch $(LINUX_DIR)/.unpacked
67
68 $(LINUX_KCONFIG):
69 @if [ ! -f "$(LINUX_KCONFIG)" ] ; then \
70 echo ""; \
71 echo "You should create a .config for your kernel"; \
72 echo "and install it as $(LINUX_KCONFIG)"; \
73 echo ""; \
74 sleep 5; \
75 fi;
76
77 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.unpacked $(LINUX_KCONFIG)
78 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" $(LINUX_DIR)/Makefile
79 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" $(LINUX_DIR)/arch/mips/Makefile
80 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
81 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) oldconfig include/linux/version.h
82 touch $(LINUX_DIR)/.configured
83
84 $(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
85 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) dep
86 touch $(LINUX_DIR)/.depend_done
87
88 $(LINUX_DIR)/$(LINUX_BINLOC): $(LINUX_DIR)/.depend_done
89 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) $(LINUX_FORMAT)
90 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) modules
91
92 $(LINUX_KERNEL): $(LINUX_DIR)/$(LINUX_BINLOC)
93 cp -fa $(LINUX_DIR)/$(LINUX_BINLOC) $(LINUX_KERNEL)
94 touch -c $(LINUX_KERNEL)
95
96 $(LINUX_DIR)/.modules_done: $(LINUX_KERNEL)
97 rm -rf $(BUILD_DIR)/modules
98 $(MAKE) -C $(LINUX_DIR) DEPMOD=true INSTALL_MOD_PATH=$(BUILD_DIR)/modules modules_install
99 tar -C $(BUILD_DIR)/modules/lib -cjf openwrt-kmodules.tar.bz2 modules
100 touch $(LINUX_DIR)/.modules_done
101
102
103 $(STAGING_DIR)/include/linux/version.h: $(LINUX_DIR)/.configured
104 mkdir -p $(STAGING_DIR)/include
105 tar -ch -C $(LINUX_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
106 tar -ch -C $(LINUX_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/
107
108 linux: $(LINUX_DIR)/.modules_done $(TARGET_MODULES_DIR)
109
110 $(TARGET_MODULES_DIR):
111 -mkdir -p $(TARGET_MODULES_DIR)
112 cp $(LINUX_DIR)/drivers/net/wl/wl.o $(TARGET_MODULES_DIR)
113 cp $(LINUX_DIR)/drivers/net/et/et.o $(TARGET_MODULES_DIR)
114 cp $(LINUX_DIR)/drivers/net/diag/diag.o $(TARGET_MODULES_DIR)
115
116 linux-source: $(DL_DIR)/$(LINUX_SOURCE)
117
118 # This has been renamed so we do _NOT_ by default run this on 'make clean'
119 linuxclean: clean
120 rm -f $(LINUX_KERNEL)
121 -$(MAKE) -C $(LINUX_DIR) clean
122
123 linux-dirclean:
124 rm -rf $(LINUX_DIR)
125
126 linux-headers: $(LINUX_DIR)/.configured
127
128 endif
This page took 0.053013 seconds and 3 git commands to generate.