add Wi-viz
[openwrt.git] / openwrt / target / linux / linux-2.6 / Makefile
1 #############################################################
2 # $Id$
3 #
4 # Linux 2.6 kernel target for the OpenWRT project
5 #
6 #############################################################
7
8 include $(TOPDIR)/rules.mk
9 include ../rules.mk
10
11 LINUX_VERSION:=2.6.12.5
12 LINUX_KERNEL_MD5SUM:=x
13 LINUX_SITE=http://www.fi.kernel.org/pub/linux/kernel/v2.6 \
14 http://www.fr.kernel.org/pub/linux/kernel/v2.6 \
15 http://www.kernel.org/pub/linux/kernel/v2.6 \
16 http://www.de.kernel.org/pub/linux/kernel/v2.6
17 MODULES_SUBDIR:=lib/modules/$(LINUX_VERSION)
18 LINUX_KCONFIG:=./config/$(BOARD)
19 LINUX_BUILD_DIR:=$(BUILD_DIR)/linux-2.6-$(BOARD)
20 LINUX_TARGET_DIR:=$(LINUX_BUILD_DIR)/root
21 LINUX_KERNEL:=$(LINUX_BUILD_DIR)/vmlinux
22 LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
23 -e 's/mipsel/mips/' \
24 -e 's/powerpc/ppc/' \
25 -e 's/sh[234]/sh/' \
26 )
27
28 LINUX_SOURCE := linux-$(LINUX_VERSION).tar.bz2
29 LINUX_SOURCE_DIR := $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)
30 MODULES_DIR := $(LINUX_BUILD_DIR)/modules/$(MODULES_SUBDIR)
31 TARGET_MODULES_DIR := $(TARGET_DIR)/lib/modules/$(LINUX_VERSION)
32 IPKG_KERNEL:=IPKG_TMP=$(BUILD_DIR)/tmp IPKG_INSTROOT=$(LINUX_TARGET_DIR) IPKG_CONF_DIR=$(LINUX_BUILD_DIR) $(SCRIPT_DIR)/ipkg -force-defaults -force-depends
33
34 PKG_BUILD_DIR := $(LINUX_BUILD_DIR)/linux-modules
35 PKG_RELEASE := 1
36
37 KERNEL_IPKG:=$(LINUX_BUILD_DIR)/kernel-$(LINUX_VERSION)-$(BOARD)_$(PKG_RELEASE)_$(ARCH).ipk
38 KERNEL_IDIR:=$(LINUX_BUILD_DIR)/kernel-ipkg
39
40 KPKG_MAKEOPTS:= IPKG="$(IPKG_KERNEL)" \
41 BOARD="$(BOARD)" \
42 TARGET_DIR="$(LINUX_TARGET_DIR)" \
43 BUILD_DIR="$(LINUX_BUILD_DIR)" \
44 KERNEL_DIR="$(LINUX_SOURCE_DIR)" \
45 LINUX_VERSION="$(LINUX_VERSION)" \
46 KERNEL_RELEASE="$(PKG_RELEASE)"
47
48 include $(LINUX_KCONFIG)
49
50 INSTALL_TARGETS := $(KERNEL_IPKG)
51 TARGETS :=
52
53 ifeq ($(BOARD),brcm)
54 include ./broadcom.mk
55 endif
56
57 $(eval $(call KMOD_template,ATM,atm,\
58 $(MODULES_DIR)/kernel/net/atm/atm.ko \
59 $(MODULES_DIR)/kernel/net/atm/br2684.ko \
60 ,CONFIG_ATM,,50,atm))
61 $(eval $(call KMOD_template,PPPOATM,pppoatm,\
62 $(MODULES_DIR)/kernel/net/atm/pppoatm.ko \
63 ,CONFIG_PPPOATM))
64 $(eval $(call KMOD_template,USB_ACM,usb-acm,\
65 $(MODULES_DIR)/kernel/drivers/usb/acm.ko \
66 ,CONFIG_USB_ACM))
67 $(eval $(call KMOD_template,B44,b44,\
68 $(MODULES_DIR)/kernel/drivers/net/b44.ko \
69 ,CONFIG_B44))
70 $(eval $(call KMOD_template,BLUETOOTH,bluetooth,\
71 $(MODULES_DIR)/kernel/net/bluetooth/*.ko \
72 $(MODULES_DIR)/kernel/net/bluetooth/rfcomm/*.ko \
73 $(MODULES_DIR)/kernel/drivers/bluetooth/*.ko \
74 ,CONFIG_BLUEZ))
75 $(eval $(call KMOD_template,ARPT,arptables,\
76 $(MODULES_DIR)/kernel/net/ipv4/netfilter/arp*.ko \
77 ,CONFIG_IP_NF_ARPTABLES))
78 $(eval $(call KMOD_template,EBT,ebtables,\
79 $(MODULES_DIR)/kernel/net/bridge/netfilter/*.ko \
80 ,CONFIG_BRIDGE_NF_EBTABLES))
81 $(eval $(call KMOD_template,IPTABLES_V4_EXTRA,iptables-extra,\
82 $(MODULES_DIR)/kernel/net/ipv4/netfilter/ip*.ko \
83 ))
84 $(eval $(call KMOD_template,IPTABLES_V6,ip6tables,\
85 $(MODULES_DIR)/kernel/net/ipv6/netfilter/ip*.ko \
86 ,CONFIG_IP6_NF_IPTABLES,kmod-ipv6))
87 $(eval $(call KMOD_template,IPV6,ipv6,\
88 $(MODULES_DIR)/kernel/net/ipv6/ipv6.ko \
89 ,CONFIG_IPV6,,20,ipv6))
90 $(eval $(call KMOD_template,CIFS,cifs,\
91 $(MODULES_DIR)/kernel/fs/cifs/cifs.ko \
92 ,CONFIG_CIFS,,30,cifs))
93 $(eval $(call KMOD_template,NFS,nfs,\
94 $(MODULES_DIR)/kernel/fs/lockd/*.ko \
95 $(MODULES_DIR)/kernel/fs/nfs/*.ko \
96 $(MODULES_DIR)/kernel/net/sunrpc/*.ko \
97 ,CONFIG_NFS_FS,,30,sunrpc lockd nfs))
98 $(eval $(call KMOD_template,USB,usb-core,\
99 $(MODULES_DIR)/kernel/drivers/usb/usbcore.ko \
100 ,CONFIG_USB,,50,usbcore))
101 $(eval $(call KMOD_template,USB_UHCI,usb-uhci,\
102 $(MODULES_DIR)/kernel/drivers/usb/host/uhci.ko \
103 ,CONFIG_USB_UHCI_ALT,kmod-usb-core,60,uhci))
104 $(eval $(call KMOD_template,USB_OHCI,usb-ohci,\
105 $(MODULES_DIR)/kernel/drivers/usb/host/usb-ohci.ko \
106 ,CONFIG_USB_OHCI,kmod-usb-core,60,ohci))
107 $(eval $(call KMOD_template,USB2,usb2,\
108 $(MODULES_DIR)/kernel/drivers/usb/host/ehci-hcd.ko \
109 ,CONFIG_USB_EHCI_HCD,kmod-usb-core,60,ehci-hcd))
110 $(eval $(call KMOD_template,USB_STORAGE,usb-storage,\
111 $(MODULES_DIR)/kernel/drivers/scsi/*.ko \
112 $(MODULES_DIR)/kernel/drivers/usb/storage/*.ko \
113 ,CONFIG_USB_STORAGE,kmod-usb-core,60,scsi_mod sd_mod usb-storage))
114 $(eval $(call KMOD_template,USB_PRINTER,usb-printer,\
115 $(MODULES_DIR)/kernel/drivers/usb/class/usblp.ko \
116 ,CONFIG_USB_PRINTER,kmod-usb-core,60,usblp))
117 $(eval $(call KMOD_template,IDE,ide,\
118 $(MODULES_DIR)/kernel/drivers/ide/*.ko \
119 $(MODULES_DIR)/kernel/drivers/ide/*/*.ko \
120 ,CONFIG_IDE))
121 $(eval $(call KMOD_template,LOOP,loop,\
122 $(MODULES_DIR)/kernel/drivers/block/loop.ko \
123 ,CONFIG_BLK_DEV_LOOP,,20,loop))
124 $(eval $(call KMOD_template,EXT2,ext2,\
125 $(MODULES_DIR)/kernel/fs/ext2/*.ko \
126 ,CONFIG_EXT2_FS,,30,ext2))
127 $(eval $(call KMOD_template,EXT3,ext3,\
128 $(MODULES_DIR)/kernel/fs/ext3/*.ko \
129 $(MODULES_DIR)/kernel/fs/jbd/*.ko \
130 ,CONFIG_EXT3_FS,,30,jbd ext3))
131 $(eval $(call KMOD_template,XFS,xfs,\
132 $(MODULES_DIR)/kernel/fs/xfs/*.ko \
133 ,CONFIG_XFS_FS,,30,xfs))
134 $(eval $(call KMOD_template,HFSPLUS,hfsplus,\
135 $(MODULES_DIR)/kernel/fs/hfsplus/*.ko \
136 ,CONFIG_HFSPLUS_FS,,30,hfsplus))
137 $(eval $(call KMOD_template,VFAT,vfat,\
138 $(MODULES_DIR)/kernel/fs/vfat/vfat.ko \
139 $(MODULES_DIR)/kernel/fs/fat/fat.ko \
140 ,CONFIG_VFAT_FS,,30,fat vfat))
141 $(eval $(call KMOD_template,CRYPTO,crypto,\
142 $(MODULES_DIR)/kernel/crypto/*.ko \
143 ))
144 $(eval $(call KMOD_template,PPP,ppp,\
145 $(MODULES_DIR)/kernel/drivers/net/ppp_async.ko \
146 $(MODULES_DIR)/kernel/drivers/net/ppp_generic.ko \
147 $(MODULES_DIR)/kernel/drivers/net/slhc.ko \
148 ,CONFIG_PPP))
149 $(eval $(call KMOD_template,MPPE,mppe,\
150 $(MODULES_DIR)/kernel/drivers/net/ppp_mppe_mppc.ko \
151 ,CONFIG_PPP_MPPE_MPPC))
152 $(eval $(call KMOD_template,PPPOE,pppoe,\
153 $(MODULES_DIR)/kernel/drivers/net/pppoe.ko \
154 $(MODULES_DIR)/kernel/drivers/net/pppox.ko \
155 ,CONFIG_PPPOE))
156 $(eval $(call KMOD_template,TUN,tun,\
157 $(MODULES_DIR)/kernel/drivers/net/tun.ko \
158 ,CONFIG_TUN,,20,tun))
159 $(eval $(call KMOD_template,GRE,gre,\
160 $(MODULES_DIR)/kernel/net/ipv4/ip_gre.ko \
161 ,CONFIG_NET_IPGRE))
162 $(eval $(call KMOD_template,SCHED,sched,\
163 $(MODULES_DIR)/kernel/net/sched/*.ko \
164 ))
165
166 $(TARGETS): $(PACKAGE_DIR)
167
168 $(PACKAGE_DIR):
169 mkdir -p $(PACKAGE_DIR)
170
171 $(DL_DIR)/$(LINUX_SOURCE):
172 -mkdir -p $(DL_DIR)
173 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE)
174
175 $(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE)
176 -mkdir -p $(LINUX_BUILD_DIR)
177 bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(LINUX_BUILD_DIR) $(TAR_OPTIONS) -
178 rm -f $(LINUX_DIR)
179 ln -s $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(LINUX_DIR)
180 touch $(LINUX_DIR)/.unpacked
181
182 $(LINUX_DIR)/.patched: $(LINUX_DIR)/.unpacked
183 $(PATCH) $(LINUX_DIR) ./patches/generic
184 [ -d ./patches/$(BOARD) ] && $(PATCH) $(LINUX_DIR) ./patches/$(BOARD)
185 touch $(LINUX_DIR)/.patched
186
187 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
188 -cp $(LINUX_KCONFIG) $(LINUX_DIR)/.config
189 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) oldconfig
190 touch $(LINUX_DIR)/.configured
191
192 $(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.configured
193 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE=$(TARGET_CROSS) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH)
194
195 $(LINUX_KERNEL): $(LINUX_DIR)/vmlinux
196 $(TARGET_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $< $@
197 touch -c $(LINUX_KERNEL)
198
199 $(LINUX_DIR)/.modules_done: $(LINUX_KERNEL) $(LINUX_IMAGE)
200 rm -rf $(LINUX_BUILD_DIR)/modules
201 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE=$(TARGET_CROSS) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) modules
202 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE=$(TARGET_CROSS) DEPMOD=true INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules modules_install
203 touch $(LINUX_DIR)/.modules_done
204
205 $(STAGING_DIR)/include/linux/version.h: $(LINUX_DIR)/.configured
206 mkdir -p $(STAGING_DIR)/include
207 tar -ch -C $(LINUX_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
208 tar -ch -C $(LINUX_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/
209
210 $(TARGET_MODULES_DIR):
211 -mkdir -p $(TARGET_MODULES_DIR)
212
213 $(KERNEL_IPKG):
214 rm -rf $(KERNEL_IDIR)
215 mkdir -p $(KERNEL_IDIR)/etc
216 $(SCRIPT_DIR)/make-ipkg-dir.sh $(KERNEL_IDIR) ../control/kernel.control $(PKG_RELEASE) $(ARCH)
217 echo 'Package: kernel-$(LINUX_VERSION)-$(BOARD)' >> $(KERNEL_IDIR)/CONTROL/control
218 if [ -f ./config/$(BOARD).modules ]; then \
219 cp ./config/$(BOARD).modules $(KERNEL_IDIR)/etc/modules; \
220 fi
221 $(IPKG_BUILD) $(KERNEL_IDIR) $(LINUX_BUILD_DIR)
222
223
224 source: $(DL_DIR)/$(LINUX_SOURCE)
225 prepare: $(LINUX_DIR)/.configured
226 compile: $(LINUX_DIR)/.modules_done $(TARGETS)
227 ln -sf $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(LINUX_DIR)
228 $(MAKE) -C $(TOPDIR)/target/linux/package \
229 $(KPKG_MAKEOPTS) \
230 compile
231
232 install: compile $(TARGET_MODULES_DIR) $(KERNEL_IPKG)
233 rm -rf $(LINUX_BUILD_DIR)/root*
234 echo -e 'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR)/ipkg.conf
235 $(MAKE) -C $(TOPDIR)/package \
236 TARGET_DIR="$(LINUX_TARGET_DIR)" \
237 IPKG_CONF="$(LINUX_BUILD_DIR)" \
238 BOARD="$(BOARD)" \
239 install
240 $(MAKE) -C $(TOPDIR)/target/linux/package \
241 $(KPKG_MAKEOPTS) \
242 install
243 [ "$(INSTALL_TARGETS)" != "" ] && $(IPKG_KERNEL) install $(INSTALL_TARGETS) || true
244
245 mostlyclean:
246 rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.modules_done
247 rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.drivers-unpacked
248 $(MAKE) -C $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) clean
249 rm -f $(LINUX_KERNEL) $(LINUX_IMAGE)
250
251 rebuild:
252 -$(MAKE) mostlyclean
253 if [ -f $(LINUX_KERNEL) ]; then \
254 $(MAKE) clean; \
255 fi
256 $(MAKE) compile
257
258 clean:
259 rm -rf $(LINUX_BUILD_DIR)
260 rm -f $(TARGETS)
This page took 0.0684630000000001 seconds and 5 git commands to generate.