2 # Linux 2.6 kernel target for the OpenWRT project
4 include $(TOPDIR)/rules.mk
8 LINUX_VERSION:=2.6.12.5
9 LINUX_KERNEL_MD5SUM:=076f0dc714112c764c790fbaef19e228
10 LINUX_SITE=http://www.fi.kernel.org/pub/linux/kernel/v2.6 \
11 http://www.fr.kernel.org/pub/linux/kernel/v2.6 \
12 http://www.kernel.org/pub/linux/kernel/v2.6 \
13 http://www.de.kernel.org/pub/linux/kernel/v2.6
14 MODULES_SUBDIR:=lib/modules/$(LINUX_VERSION)
15 LINUX_KCONFIG:=./config/$(BOARD)
16 LINUX_BUILD_DIR:=$(BUILD_DIR)/linux-2.6-$(BOARD)
17 LINUX_TARGET_DIR:=$(LINUX_BUILD_DIR)/root
18 LINUX_KERNEL:=$(LINUX_BUILD_DIR)/vmlinux
19 LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
25 LINUX_SOURCE := linux-$(LINUX_VERSION).tar.bz2
26 LINUX_SOURCE_DIR := $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)
27 MODULES_DIR := $(LINUX_BUILD_DIR)/modules/$(MODULES_SUBDIR)
28 TARGET_MODULES_DIR := $(LINUX_TARGET_DIR)/lib/modules/$(LINUX_VERSION)
29 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
31 PKG_BUILD_DIR := $(LINUX_BUILD_DIR)/linux-modules
34 KERNEL_IPKG:=$(LINUX_BUILD_DIR)/kernel-$(LINUX_VERSION)-$(BOARD)_$(PKG_RELEASE)_$(ARCH).ipk
35 KERNEL_IDIR:=$(LINUX_BUILD_DIR)/kernel-ipkg
37 KPKG_MAKEOPTS:= IPKG="$(IPKG_KERNEL)" \
39 TARGET_DIR="$(LINUX_TARGET_DIR)" \
40 BUILD_DIR="$(LINUX_BUILD_DIR)" \
41 KERNEL_DIR="$(LINUX_SOURCE_DIR)" \
42 LINUX_VERSION="$(LINUX_VERSION)" \
43 KERNEL_RELEASE="$(PKG_RELEASE)"
45 include $(LINUX_KCONFIG)
47 INSTALL_TARGETS := $(KERNEL_IPKG)
53 $(eval $(call KMOD_template,ATM,atm,\
54 $(MODULES_DIR)/kernel/net/atm/atm.ko \
55 $(MODULES_DIR)/kernel/net/atm/br2684.ko \
58 $(eval $(call KMOD_template,GRE,gre,\
59 $(MODULES_DIR)/kernel/net/ipv4/ip_gre.ko \
62 $(eval $(call KMOD_template,IPV6,ipv6,\
63 $(MODULES_DIR)/kernel/net/ipv6/ipv6.ko \
64 ,CONFIG_IPV6,,20,ipv6))
66 $(eval $(call KMOD_template,PPP,ppp,\
67 $(MODULES_DIR)/kernel/drivers/net/ppp_async.ko \
68 $(MODULES_DIR)/kernel/drivers/net/ppp_generic.ko \
69 $(MODULES_DIR)/kernel/drivers/net/slhc.ko \
72 $(eval $(call KMOD_template,MPPE,mppe,\
73 $(MODULES_DIR)/kernel/drivers/net/ppp_mppe_mppc.ko \
74 ,CONFIG_PPP_MPPE_MPPC))
76 $(eval $(call KMOD_template,PPPOATM,pppoatm,\
77 $(MODULES_DIR)/kernel/net/atm/pppoatm.ko \
80 $(eval $(call KMOD_template,PPPOE,pppoe,\
81 $(MODULES_DIR)/kernel/drivers/net/pppoe.ko \
82 $(MODULES_DIR)/kernel/drivers/net/pppox.ko \
85 $(eval $(call KMOD_template,SCHED,sched,\
86 $(MODULES_DIR)/kernel/net/sched/*.ko \
89 $(eval $(call KMOD_template,TUN,tun,\
90 $(MODULES_DIR)/kernel/drivers/net/tun.ko \
94 # Filtering / Firewalling
96 $(eval $(call KMOD_template,ARPTABLES,arptables,\
97 $(MODULES_DIR)/kernel/net/ipv4/netfilter/arp*.ko \
98 ,CONFIG_IP_NF_ARPTABLES))
100 $(eval $(call KMOD_template,EBTABLES,ebtables,\
101 $(MODULES_DIR)/kernel/net/bridge/netfilter/*.ko \
102 ,CONFIG_BRIDGE_NF_EBTABLES))
104 $(eval $(call KMOD_template,IPTABLES_V4_EXTRA,iptables-extra,\
105 $(MODULES_DIR)/kernel/net/ipv4/netfilter/ip*.ko \
108 $(eval $(call KMOD_template,IPTABLES_V6,ip6tables,\
109 $(MODULES_DIR)/kernel/net/ipv6/netfilter/ip*.ko \
110 ,CONFIG_IP6_NF_IPTABLES,kmod-ipv6))
115 $(eval $(call KMOD_template,IDE,ide,\
116 $(MODULES_DIR)/kernel/drivers/ide/*.ko \
117 $(MODULES_DIR)/kernel/drivers/ide/*/*.ko \
120 $(eval $(call KMOD_template,LOOP,loop,\
121 $(MODULES_DIR)/kernel/drivers/block/loop.ko \
122 ,CONFIG_BLK_DEV_LOOP,,20,loop))
124 $(eval $(call KMOD_template,NBD,nbd,\
125 $(MODULES_DIR)/kernel/drivers/block/nbd.ko \
126 ,CONFIG_BLK_DEV_NBD,,20,nbd))
131 $(eval $(call KMOD_template,CRYPTO,crypto,\
132 $(MODULES_DIR)/kernel/crypto/*.ko \
138 $(eval $(call KMOD_template,FS_CIFS,fs-cifs,\
139 $(MODULES_DIR)/kernel/fs/cifs/cifs.ko \
140 ,CONFIG_CIFS,kmod-nls-base,30,cifs))
142 $(eval $(call KMOD_template,FS_EXT2,fs-ext2,\
143 $(MODULES_DIR)/kernel/fs/ext2/ext2.ko \
144 ,CONFIG_EXT2_FS,,30,ext2))
146 $(eval $(call KMOD_template,FS_EXT3,fs-ext3,\
147 $(MODULES_DIR)/kernel/fs/ext3/ext3.ko \
148 $(MODULES_DIR)/kernel/fs/jbd/jbd.ko \
149 ,CONFIG_EXT3_FS,,30,jbd ext3))
151 $(eval $(call KMOD_template,FS_HFSPLUS,fs-hfsplus,\
152 $(MODULES_DIR)/kernel/fs/hfsplus/hfsplus.ko \
153 ,CONFIG_HFSPLUS_FS,kmod-nls-base,30,hfsplus))
155 $(eval $(call KMOD_template,FS_NFS,fs-nfs,\
156 $(MODULES_DIR)/kernel/fs/lockd/lockd.ko \
157 $(MODULES_DIR)/kernel/fs/nfs/nfs.ko \
158 $(MODULES_DIR)/kernel/net/sunrpc/sunrpc.ko \
159 ,CONFIG_NFS_FS,,30,sunrpc lockd nfs))
161 $(eval $(call KMOD_template,FS_VFAT,fs-vfat,\
162 $(MODULES_DIR)/kernel/fs/fat/fat.ko \
163 $(MODULES_DIR)/kernel/fs/vfat/vfat.ko \
164 ,CONFIG_VFAT_FS,kmod-nls-base,30,fat vfat))
166 $(eval $(call KMOD_template,FS_XFS,fs-xfs,\
167 $(MODULES_DIR)/kernel/fs/xfs/xfs.ko \
168 ,CONFIG_XFS_FS,,30,xfs))
173 $(eval $(call KMOD_template,PWC,pwc,\
174 $(MODULES_DIR)/kernel/drivers/usb/pwc.ko \
175 ,CONFIG_USB_PWC,kmod-videodev,63,pwc))
177 $(eval $(call KMOD_template,SOUNDCORE,soundcore,\
178 $(MODULES_DIR)/kernel/sound/soundcore.ko \
179 ,CONFIG_SOUND,,30,soundcore))
181 $(eval $(call KMOD_template,VIDEODEV,videodev,\
182 $(MODULES_DIR)/kernel/drivers/media/video/v4l1-compat.ko \
183 $(MODULES_DIR)/kernel/drivers/media/video/v4l2-common.ko \
184 $(MODULES_DIR)/kernel/drivers/media/video/videodev.ko \
185 ,CONFIG_VIDEO_DEV,,62,videodev))
190 $(eval $(call KMOD_template,NLS_BASE,nls-base,\
191 $(MODULES_DIR)/kernel/fs/nls/nls_base.ko \
192 ,CONFIG_NLS,,20,nls_base))
194 $(eval $(call KMOD_template,NLS_CP437,nls-cp437,\
195 $(MODULES_DIR)/kernel/fs/nls/nls_cp437.ko \
196 ,CONFIG_NLS_CODEPAGE_437,,20,nls_cp437))
198 $(eval $(call KMOD_template,NLS_CP850,nls-cp850,\
199 $(MODULES_DIR)/kernel/fs/nls/nls_cp850.ko \
200 ,CONFIG_NLS_CODEPAGE_850,,20,nls_cp850))
202 $(eval $(call KMOD_template,NLS_ISO8859_1,nls-iso8859-1,\
203 $(MODULES_DIR)/kernel/fs/nls/nls_iso8859-1.ko \
204 ,CONFIG_NLS_ISO8859_1,,20,nls_iso8859-1))
206 $(eval $(call KMOD_template,NLS_ISO8859_15,nls-iso8859-15,\
207 $(MODULES_DIR)/kernel/fs/nls/nls_iso8859-15.ko \
208 ,CONFIG_NLS_ISO8859_15,,20,nls_iso8859-15))
210 $(eval $(call KMOD_template,NLS_UTF8,nls-utf8,\
211 $(MODULES_DIR)/kernel/fs/nls/nls_utf8.ko \
212 ,CONFIG_NLS_UTF8,,20,nls_utf8))
217 $(eval $(call KMOD_template,NET_3C59X,net-3c59x,\
218 $(MODULES_DIR)/kernel/drivers/net/3c59x.ko \
219 ,CONFIG_VORTEX,,10,3c59x))
221 $(eval $(call KMOD_template,NET_8139TOO,net-8139too,\
222 $(MODULES_DIR)/kernel/drivers/net/8139too.ko \
223 ,CONFIG_8139TOO,,10,8139too))
225 $(eval $(call KMOD_template,NET_AIRO,net-airo,\
226 $(MODULES_DIR)/kernel/drivers/net/wireless/airo.ko \
227 ,CONFIG_AIRO,,10,airo))
229 $(eval $(call KMOD_template,NET_B44,net-b44,\
230 $(MODULES_DIR)/kernel/drivers/net/b44.ko \
231 ,CONFIG_B44,,10,b44))
233 $(eval $(call KMOD_template,NET_E100,net-e100,\
234 $(MODULES_DIR)/kernel/drivers/net/e100.ko \
235 ,CONFIG_E100,,10,e100))
237 $(eval $(call KMOD_template,NET_HERMES,net-hermes,\
238 $(MODULES_DIR)/kernel/drivers/net/wireless/hermes.ko \
239 $(MODULES_DIR)/kernel/drivers/net/wireless/orinoco.ko \
240 ,CONFIG_HERMES,,10,hermes orinoco))
242 $(eval $(call KMOD_template,NET_HERMES_PCI,net-hermes-pci,\
243 $(MODULES_DIR)/kernel/drivers/net/wireless/orinoco_pci.ko \
244 ,CONFIG_PCI_HERMES,kmod-net-hermes,11,orinoco_pci))
246 $(eval $(call KMOD_template,NET_HERMES_PCI,net-hermes-plx,\
247 $(MODULES_DIR)/kernel/drivers/net/wireless/orinoco_plx.ko \
248 ,CONFIG_PLX_HERMES,kmod-net-hermes,11,orinoco_plx))
250 $(eval $(call KMOD_template,NET_NATSEMI,net-natsemi,\
251 $(MODULES_DIR)/kernel/drivers/net/natsemi.ko \
252 ,CONFIG_NATSEMI,,10,natsemi))
254 $(eval $(call KMOD_template,NET_PRISM54,net-prism54,\
255 $(MODULES_DIR)/kernel/drivers/net/wireless/prism54/prism54.ko \
256 ,CONFIG_PRISM54,,10,prism54))
261 $(eval $(call KMOD_template,PCMCIA_CORE,pcmcia-core,\
262 $(MODULES_DIR)/kernel/drivers/pcmcia/pcmcia_core.ko \
263 $(MODULES_DIR)/kernel/drivers/pcmcia/yenta_socket.ko \
264 ,CONFIG_PCMCIA,,50,pcmcia_core))
269 $(eval $(call KMOD_template,USB,usb-core,\
270 $(MODULES_DIR)/kernel/drivers/usb/core/usbcore.ko \
271 ,CONFIG_USB,,50,usbcore))
273 $(eval $(call KMOD_template,USB_OHCI,usb-ohci,\
274 $(MODULES_DIR)/kernel/drivers/usb/host/ohci-hcd.ko \
275 ,CONFIG_USB_OHCI_HCD,kmod-usb-core,60,ohci-hcd))
277 $(eval $(call KMOD_template,USB_UHCI,usb-uhci,\
278 $(MODULES_DIR)/kernel/drivers/usb/host/uhci.ko \
279 ,CONFIG_USB_UHCI_ALT,kmod-usb-core,60,uhci))
281 $(eval $(call KMOD_template,USB2,usb2,\
282 $(MODULES_DIR)/kernel/drivers/usb/host/ehci-hcd.ko \
283 ,CONFIG_USB_EHCI_HCD,kmod-usb-core,60,ehci-hcd))
285 $(eval $(call KMOD_template,USB_ACM,usb-acm,\
286 $(MODULES_DIR)/kernel/drivers/usb/class/cdc-acm.ko \
289 $(eval $(call KMOD_template,USB_AUDIO,usb-audio,\
290 $(MODULES_DIR)/kernel/drivers/sound/usb/snd-usb-audio.ko \
291 $(MODULES_DIR)/kernel/drivers/sound/usb/snd-usb-lib.ko \
292 ,CONFIG_USB_AUDIO,kmod-soundcore kmod-usb-core,61,snd-usb-lib snd-usb-audio))
294 $(eval $(call KMOD_template,USB_PRINTER,usb-printer,\
295 $(MODULES_DIR)/kernel/drivers/usb/class/usblp.ko \
296 ,CONFIG_USB_PRINTER,kmod-usb-core,60,usblp))
298 $(eval $(call KMOD_template,USB_SERIAL,usb-serial,\
299 $(MODULES_DIR)/kernel/drivers/usb/serial/usbserial.ko \
300 ,CONFIG_USB_SERIAL,kmod-usb-core,60,usbserial))
302 $(eval $(call KMOD_template,USB_SERIAL_BELKIN,usb-serial-belkin,\
303 $(MODULES_DIR)/kernel/drivers/usb/serial/belkin_sa.ko \
304 ,CONFIG_USB_SERIAL_BELKIN,kmod-usb-serial,61,belkin_sa))
306 $(eval $(call KMOD_template,USB_SERIAL_FTDI,usb-serial-ftdi,\
307 $(MODULES_DIR)/kernel/drivers/usb/serial/ftdi_sio.ko \
308 ,CONFIG_USB_SERIAL_FTDI_SIO,kmod-usb-serial,61,ftdi_sio))
310 $(eval $(call KMOD_template,USB_SERIAL_MCT_U232,usb-serial-mct-u232,\
311 $(MODULES_DIR)/kernel/drivers/usb/serial/mct_u232.ko \
312 ,CONFIG_USB_SERIAL_MCT_U232,kmod-usb-serial,61,mct_u232))
314 $(eval $(call KMOD_template,USB_SERIAL_PL2303,usb-serial-pl2303,\
315 $(MODULES_DIR)/kernel/drivers/usb/serial/pl2303.ko \
316 ,CONFIG_USB_SERIAL_PL2303,kmod-usb-serial,61,pl2303))
318 $(eval $(call KMOD_template,USB_STORAGE,usb-storage,\
319 $(MODULES_DIR)/kernel/drivers/scsi/scsi_mod.ko \
320 $(MODULES_DIR)/kernel/drivers/scsi/sd_mod.ko \
321 $(MODULES_DIR)/kernel/drivers/usb/storage/usb-storage.ko \
322 ,CONFIG_USB_STORAGE,kmod-usb-core,60,scsi_mod sd_mod usb-storage))
327 $(eval $(call KMOD_template,AX25,ax25,\
328 $(MODULES_DIR)/kernel/net/ax25/ax25.ko \
329 $(MODULES_DIR)/kernel/drivers/net/hamradio/mkiss.ko \
330 ,CONFIG_AX25,,90,ax25 mkiss))
332 $(eval $(call KMOD_template,BLUETOOTH,bluetooth,\
333 $(MODULES_DIR)/kernel/net/bluetooth/bluetooth.ko \
334 $(MODULES_DIR)/kernel/net/bluetooth/l2cap.ko \
335 $(MODULES_DIR)/kernel/net/bluetooth/sco.ko \
336 $(MODULES_DIR)/kernel/net/bluetooth/rfcomm/rfcomm.ko \
337 $(MODULES_DIR)/kernel/drivers/bluetooth/hci_uart.ko \
341 $(TARGETS): $(PACKAGE_DIR)
344 mkdir -p $(PACKAGE_DIR)
346 $(DL_DIR)/$(LINUX_SOURCE):
348 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE) $(MAKE_TRACE)
350 $(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE)
351 -mkdir -p $(LINUX_BUILD_DIR)
352 bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(LINUX_BUILD_DIR) $(TAR_OPTIONS) -
354 ln -s $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(LINUX_DIR)
355 touch $(LINUX_DIR)/.unpacked
357 $(LINUX_DIR)/.patched: $(LINUX_DIR)/.unpacked
358 $(PATCH) $(LINUX_DIR) ./patches/generic $(MAKE_TRACE)
359 [ -d ./patches/$(BOARD) ] && $(PATCH) $(LINUX_DIR) ./patches/$(BOARD) $(MAKE_TRACE)
360 touch $(LINUX_DIR)/.patched
362 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
363 -cp $(LINUX_KCONFIG) $(LINUX_DIR)/.config
364 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) oldconfig $(MAKE_TRACE)
365 touch $(LINUX_DIR)/.configured
367 $(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.configured
368 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE=$(TARGET_CROSS) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) $(MAKE_TRACE)
370 $(LINUX_KERNEL): $(LINUX_DIR)/vmlinux
371 $(TARGET_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $< $@ $(MAKE_TRACE)
372 touch -c $(LINUX_KERNEL)
374 $(LINUX_DIR)/.modules_done: $(LINUX_KERNEL) $(LINUX_IMAGE)
375 rm -rf $(LINUX_BUILD_DIR)/modules
376 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE=$(TARGET_CROSS) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) modules $(MAKE_TRACE)
377 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE=$(TARGET_CROSS) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) DEPMOD=true INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules modules_install $(MAKE_TRACE)
378 touch $(LINUX_DIR)/.modules_done
380 $(STAGING_DIR)/include/linux/version.h: $(LINUX_DIR)/.configured
381 mkdir -p $(STAGING_DIR)/include
382 tar -ch -C $(LINUX_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
383 tar -ch -C $(LINUX_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/
385 $(TARGET_MODULES_DIR):
386 -mkdir -p $(TARGET_MODULES_DIR)
389 rm -rf $(KERNEL_IDIR)
390 mkdir -p $(KERNEL_IDIR)/etc
391 $(SCRIPT_DIR)/make-ipkg-dir.sh $(KERNEL_IDIR) ../control/kernel.control $(PKG_RELEASE) $(ARCH)
392 echo 'Package: kernel-$(LINUX_VERSION)-$(BOARD)' >> $(KERNEL_IDIR)/CONTROL/control
393 if [ -f ./config/$(BOARD).modules ]; then \
394 cp ./config/$(BOARD).modules $(KERNEL_IDIR)/etc/modules; \
396 $(IPKG_BUILD) $(KERNEL_IDIR) $(LINUX_BUILD_DIR) $(MAKE_TRACE)
398 $(STAMP_DIR)/.linux-compile: $(LINUX_DIR)/.modules_done
399 @mkdir -p $(STAMP_DIR)
401 ln -sf $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(LINUX_DIR)
402 @$(TRACE) target/linux/package
403 $(MAKE) -C $(TOPDIR)/target/linux/package \
408 source: $(DL_DIR)/$(LINUX_SOURCE)
409 prepare: $(LINUX_DIR)/.configured
411 $(MAKE) $(STAMP_DIR)/.linux-compile $(MAKE_TRACE)
413 install: compile $(TARGET_MODULES_DIR) $(KERNEL_IPKG)
414 rm -rf $(LINUX_BUILD_DIR)/root*
415 cp -fpR $(BUILD_DIR)/root $(LINUX_BUILD_DIR)/
416 echo -e 'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR)/ipkg.conf
417 $(MAKE) -C $(TOPDIR)/target/linux/package \
420 @{ [ "$(INSTALL_TARGETS)" != "" ] && $(IPKG_KERNEL) install $(INSTALL_TARGETS) || true; } $(MAKE_TRACE)
423 rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.modules_done
424 rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.drivers-unpacked
425 $(MAKE) -C $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) clean
426 rm -f $(LINUX_KERNEL) $(LINUX_IMAGE)
430 if [ -f $(LINUX_KERNEL) ]; then \
436 rm -f $(STAMP_DIR)/.linux-compile
437 rm -rf $(LINUX_BUILD_DIR)