9a1670f2d3027959a169ab1441e17d31d68f520b
[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 LINKSYS_SITE=openwrt.openbsd-geek.de
43 LINKSYS_TGZ=linksys-3.37.2.tgz
44
45 TARGET_MODULES_DIR=$(TARGET_DIR)/lib/modules/$(LINUX_VERSION)
46
47 $(DL_DIR)/linux.tar.bz2:
48 -mkdir -p $(DL_DIR)
49 (cd $(DL_DIR); cvs -d :pserver:cvs:cvs@$(LINUX_SITE):/home/cvs login)
50 (cd $(DL_DIR); cvs -z3 -d :pserver:cvs:cvs@$(LINUX_SITE):/home/cvs co -D $(LINUX_CVS_DATE) -r$(LINUX_CVS_BRANCH) linux)
51 (cd $(DL_DIR); tar jcvf linux.tar.bz2 linux && rm -rf linux)
52 $(WGET) -P $(DL_DIR) $(LINKSYS_SITE)/$(LINKSYS_TGZ)
53
54 $(LINUX_DIR)/.unpacked: $(DL_DIR)/linux.tar.bz2
55 -mkdir -p $(BUILD_DIR)
56 #-(cp -a $(DL_DIR)/linux $(BUILD_DIR)/linux)
57 (cd $(BUILD_DIR); tar jxvf $(DL_DIR)/linux.tar.bz2)
58 -mkdir -p $(TOOL_BUILD_DIR)
59 -(cd $(TOOL_BUILD_DIR); ln -sf $(BUILD_DIR)/linux linux)
60 toolchain/patch-kernel.sh $(LINUX_DIR) package/linux/kernel-patches
61 -cp $(LINUX_KCONFIG) $(LINUX_DIR)/.config
62 # extract linksys binary kernel modules and include/shared files
63 -mkdir -p $(BUILD_DIR)/binary
64 tar -C $(BUILD_DIR)/binary -xzvf $(DL_DIR)/linksys-3.37.2.tgz
65 touch $(LINUX_DIR)/.unpacked
66
67 $(LINUX_KCONFIG):
68 @if [ ! -f "$(LINUX_KCONFIG)" ] ; then \
69 echo ""; \
70 echo "You should create a .config for your kernel"; \
71 echo "and install it as $(LINUX_KCONFIG)"; \
72 echo ""; \
73 sleep 5; \
74 fi;
75
76 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.unpacked $(LINUX_KCONFIG)
77 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" $(LINUX_DIR)/Makefile
78 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" $(LINUX_DIR)/arch/mips/Makefile
79 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
80 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) oldconfig include/linux/version.h
81 touch $(LINUX_DIR)/.configured
82
83 $(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
84 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) dep
85 touch $(LINUX_DIR)/.depend_done
86
87 $(LINUX_DIR)/$(LINUX_BINLOC): $(LINUX_DIR)/.depend_done
88 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) $(LINUX_FORMAT)
89 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) modules
90
91 $(LINUX_KERNEL): $(LINUX_DIR)/$(LINUX_BINLOC)
92 cp -fa $(LINUX_DIR)/$(LINUX_BINLOC) $(LINUX_KERNEL)
93 touch -c $(LINUX_KERNEL)
94
95 $(LINUX_DIR)/.modules_done: $(LINUX_KERNEL)
96 rm -rf $(BUILD_DIR)/modules
97 $(MAKE) -C $(LINUX_DIR) DEPMOD=true INSTALL_MOD_PATH=$(BUILD_DIR)/modules modules_install
98 tar -C $(BUILD_DIR)/modules/lib -cjf openwrt-kmodules.tar.bz2 modules
99 touch $(LINUX_DIR)/.modules_done
100
101
102 $(STAGING_DIR)/include/linux/version.h: $(LINUX_DIR)/.configured
103 mkdir -p $(STAGING_DIR)/include
104 tar -ch -C $(LINUX_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
105 tar -ch -C $(LINUX_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/
106
107 linux: $(LINUX_DIR)/.modules_done $(TARGET_MODULES_DIR)
108
109 $(TARGET_MODULES_DIR):
110 -mkdir -p $(TARGET_MODULES_DIR)
111 cp $(LINUX_DIR)/drivers/net/wl/wl.o $(TARGET_MODULES_DIR)
112 cp $(LINUX_DIR)/drivers/net/et/et.o $(TARGET_MODULES_DIR)
113 cp $(LINUX_DIR)/drivers/net/diag/diag.o $(TARGET_MODULES_DIR)
114
115 linux-source: $(DL_DIR)/$(LINUX_SOURCE)
116
117 # This has been renamed so we do _NOT_ by default run this on 'make clean'
118 linuxclean: clean
119 rm -f $(LINUX_KERNEL)
120 -$(MAKE) -C $(LINUX_DIR) clean
121
122 linux-dirclean:
123 rm -rf $(LINUX_DIR)
124
125 linux-headers: $(LINUX_DIR)/.configured
126
127 endif
This page took 0.052073 seconds and 3 git commands to generate.