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)
57 $(eval $(call KMOD_template,ATM,atm,\
58 $(MODULES_DIR)/kernel/net/atm/atm.ko \
59 $(MODULES_DIR)/kernel/net/atm/br2684.ko \
62 $(eval $(call KMOD_template,GRE,gre,\
63 $(MODULES_DIR)/kernel/net/ipv4/ip_gre.ko \
66 $(eval $(call KMOD_template,IPV6,ipv6,\
67 $(MODULES_DIR)/kernel/net/ipv6/ipv6.ko \
68 ,CONFIG_IPV6,,20,ipv6))
70 $(eval $(call KMOD_template,PPP,ppp,\
71 $(MODULES_DIR)/kernel/drivers/net/ppp_async.ko \
72 $(MODULES_DIR)/kernel/drivers/net/ppp_generic.ko \
73 $(MODULES_DIR)/kernel/drivers/net/slhc.ko \
76 $(eval $(call KMOD_template,MPPE,mppe,\
77 $(MODULES_DIR)/kernel/drivers/net/ppp_mppe_mppc.ko \
78 ,CONFIG_PPP_MPPE_MPPC))
80 $(eval $(call KMOD_template,PPPOATM,pppoatm,\
81 $(MODULES_DIR)/kernel/net/atm/pppoatm.ko \
84 $(eval $(call KMOD_template,PPPOE,pppoe,\
85 $(MODULES_DIR)/kernel/drivers/net/pppoe.ko \
86 $(MODULES_DIR)/kernel/drivers/net/pppox.ko \
89 $(eval $(call KMOD_template,SCHED,sched,\
90 $(MODULES_DIR)/kernel/net/sched/*.ko \
93 $(eval $(call KMOD_template,TUN,tun,\
94 $(MODULES_DIR)/kernel/drivers/net/tun.ko \
98 # Filtering / Firewalling
100 $(eval $(call KMOD_template,ARPTABLES,arptables,\
101 $(MODULES_DIR)/kernel/net/ipv4/netfilter/arp*.ko \
102 ,CONFIG_IP_NF_ARPTABLES))
104 $(eval $(call KMOD_template,EBTABLES,ebtables,\
105 $(MODULES_DIR)/kernel/net/bridge/netfilter/*.ko \
106 ,CONFIG_BRIDGE_NF_EBTABLES))
108 $(eval $(call KMOD_template,IPTABLES_V4_EXTRA,iptables-extra,\
109 $(MODULES_DIR)/kernel/net/ipv4/netfilter/ip*.ko \
112 $(eval $(call KMOD_template,IPTABLES_V6,ip6tables,\
113 $(MODULES_DIR)/kernel/net/ipv6/netfilter/ip*.ko \
114 ,CONFIG_IP6_NF_IPTABLES,kmod-ipv6))
119 $(eval $(call KMOD_template,IDE,ide,\
120 $(MODULES_DIR)/kernel/drivers/ide/*.ko \
121 $(MODULES_DIR)/kernel/drivers/ide/*/*.ko \
124 $(eval $(call KMOD_template,LOOP,loop,\
125 $(MODULES_DIR)/kernel/drivers/block/loop.ko \
126 ,CONFIG_BLK_DEV_LOOP,,20,loop))
128 $(eval $(call KMOD_template,NBD,nbd,\
129 $(MODULES_DIR)/kernel/drivers/block/nbd.ko \
130 ,CONFIG_BLK_DEV_NBD,,20,nbd))
135 $(eval $(call KMOD_template,CRYPTO,crypto,\
136 $(MODULES_DIR)/kernel/crypto/*.ko \
142 $(eval $(call KMOD_template,FS_CIFS,fs-cifs,\
143 $(MODULES_DIR)/kernel/fs/cifs/cifs.ko \
144 ,CONFIG_CIFS,kmod-nls-base,30,cifs))
146 $(eval $(call KMOD_template,FS_EXT2,fs-ext2,\
147 $(MODULES_DIR)/kernel/fs/ext2/ext2.ko \
148 ,CONFIG_EXT2_FS,,30,ext2))
150 $(eval $(call KMOD_template,FS_EXT3,fs-ext3,\
151 $(MODULES_DIR)/kernel/fs/ext3/ext3.ko \
152 $(MODULES_DIR)/kernel/fs/jbd/jbd.ko \
153 ,CONFIG_EXT3_FS,,30,jbd ext3))
155 $(eval $(call KMOD_template,FS_HFSPLUS,fs-hfsplus,\
156 $(MODULES_DIR)/kernel/fs/hfsplus/hfsplus.ko \
157 ,CONFIG_HFSPLUS_FS,kmod-nls-base,30,hfsplus))
159 $(eval $(call KMOD_template,FS_NFS,fs-nfs,\
160 $(MODULES_DIR)/kernel/fs/lockd/lockd.ko \
161 $(MODULES_DIR)/kernel/fs/nfs/nfs.ko \
162 $(MODULES_DIR)/kernel/net/sunrpc/sunrpc.ko \
163 ,CONFIG_NFS_FS,,30,sunrpc lockd nfs))
165 $(eval $(call KMOD_template,FS_VFAT,fs-vfat,\
166 $(MODULES_DIR)/kernel/fs/fat/fat.ko \
167 $(MODULES_DIR)/kernel/fs/vfat/vfat.ko \
168 ,CONFIG_VFAT_FS,kmod-nls-base,30,fat vfat))
170 $(eval $(call KMOD_template,FS_XFS,fs-xfs,\
171 $(MODULES_DIR)/kernel/fs/xfs/xfs.ko \
172 ,CONFIG_XFS_FS,,30,xfs))
177 $(eval $(call KMOD_template,PWC,pwc,\
178 $(MODULES_DIR)/kernel/drivers/usb/pwc.ko \
179 ,CONFIG_USB_PWC,kmod-videodev,63,pwc))
181 $(eval $(call KMOD_template,SOUNDCORE,soundcore,\
182 $(MODULES_DIR)/kernel/sound/soundcore.ko \
183 ,CONFIG_SOUND,,30,soundcore))
185 $(eval $(call KMOD_template,VIDEODEV,videodev,\
186 $(MODULES_DIR)/kernel/drivers/media/video/v4l1-compat.ko \
187 $(MODULES_DIR)/kernel/drivers/media/video/v4l2-common.ko \
188 $(MODULES_DIR)/kernel/drivers/media/video/videodev.ko \
189 ,CONFIG_VIDEO_DEV,,62,videodev))
194 $(eval $(call KMOD_template,NLS_BASE,nls-base,\
195 $(MODULES_DIR)/kernel/fs/nls/nls_base.ko \
196 ,CONFIG_NLS,,20,nls_base))
198 $(eval $(call KMOD_template,NLS_CP437,nls-cp437,\
199 $(MODULES_DIR)/kernel/fs/nls/nls_cp437.ko \
200 ,CONFIG_NLS_CODEPAGE_437,,20,nls_cp437))
202 $(eval $(call KMOD_template,NLS_CP850,nls-cp850,\
203 $(MODULES_DIR)/kernel/fs/nls/nls_cp850.ko \
204 ,CONFIG_NLS_CODEPAGE_850,,20,nls_cp850))
206 $(eval $(call KMOD_template,NLS_ISO8859_1,nls-iso8859-1,\
207 $(MODULES_DIR)/kernel/fs/nls/nls_iso8859-1.ko \
208 ,CONFIG_NLS_ISO8859_1,,20,nls_iso8859-1))
210 $(eval $(call KMOD_template,NLS_ISO8859_15,nls-iso8859-15,\
211 $(MODULES_DIR)/kernel/fs/nls/nls_iso8859-15.ko \
212 ,CONFIG_NLS_ISO8859_15,,20,nls_iso8859-15))
214 $(eval $(call KMOD_template,NLS_UTF8,nls-utf8,\
215 $(MODULES_DIR)/kernel/fs/nls/nls_utf8.ko \
216 ,CONFIG_NLS_UTF8,,20,nls_utf8))
221 $(eval $(call KMOD_template,NET_3C59X,net-3c59x,\
222 $(MODULES_DIR)/kernel/drivers/net/3c59x.ko \
223 ,CONFIG_VORTEX,,10,3c59x))
225 $(eval $(call KMOD_template,NET_8139TOO,net-8139too,\
226 $(MODULES_DIR)/kernel/drivers/net/8139too.ko \
227 ,CONFIG_8139TOO,,10,8139too))
229 $(eval $(call KMOD_template,NET_AIRO,net-airo,\
230 $(MODULES_DIR)/kernel/drivers/net/wireless/airo.ko \
231 ,CONFIG_AIRO,,10,airo))
233 $(eval $(call KMOD_template,NET_B44,net-b44,\
234 $(MODULES_DIR)/kernel/drivers/net/b44.ko \
235 ,CONFIG_B44,,10,b44))
237 $(eval $(call KMOD_template,NET_E100,net-e100,\
238 $(MODULES_DIR)/kernel/drivers/net/e100.ko \
239 ,CONFIG_E100,,10,e100))
241 $(eval $(call KMOD_template,NET_HERMES,net-hermes,\
242 $(MODULES_DIR)/kernel/drivers/net/wireless/hermes.ko \
243 $(MODULES_DIR)/kernel/drivers/net/wireless/orinoco.ko \
244 ,CONFIG_HERMES,,10,hermes orinoco))
246 $(eval $(call KMOD_template,NET_HERMES_PCI,net-hermes-pci,\
247 $(MODULES_DIR)/kernel/drivers/net/wireless/orinoco_pci.ko \
248 ,CONFIG_PCI_HERMES,kmod-net-hermes,11,orinoco_pci))
250 $(eval $(call KMOD_template,NET_HERMES_PCI,net-hermes-plx,\
251 $(MODULES_DIR)/kernel/drivers/net/wireless/orinoco_plx.ko \
252 ,CONFIG_PLX_HERMES,kmod-net-hermes,11,orinoco_plx))
254 $(eval $(call KMOD_template,NET_NATSEMI,net-natsemi,\
255 $(MODULES_DIR)/kernel/drivers/net/natsemi.ko \
256 ,CONFIG_NATSEMI,,10,natsemi))
258 $(eval $(call KMOD_template,NET_PRISM54,net-prism54,\
259 $(MODULES_DIR)/kernel/drivers/net/wireless/prism54/prism54.ko \
260 ,CONFIG_PRISM54,,10,prism54))
265 $(eval $(call KMOD_template,PCMCIA_CORE,pcmcia-core,\
266 $(MODULES_DIR)/kernel/drivers/pcmcia/pcmcia_core.ko \
267 $(MODULES_DIR)/kernel/drivers/pcmcia/yenta_socket.ko \
268 ,CONFIG_PCMCIA,,50,pcmcia_core))
273 $(eval $(call KMOD_template,USB,usb-core,\
274 $(MODULES_DIR)/kernel/drivers/usb/core/usbcore.ko \
275 ,CONFIG_USB,,50,usbcore))
277 $(eval $(call KMOD_template,USB_OHCI,usb-ohci,\
278 $(MODULES_DIR)/kernel/drivers/usb/host/ohci-hcd.ko \
279 ,CONFIG_USB_OHCI_HCD,kmod-usb-core,60,ohci-hcd))
281 $(eval $(call KMOD_template,USB_UHCI,usb-uhci,\
282 $(MODULES_DIR)/kernel/drivers/usb/host/uhci.ko \
283 ,CONFIG_USB_UHCI_ALT,kmod-usb-core,60,uhci))
285 $(eval $(call KMOD_template,USB2,usb2,\
286 $(MODULES_DIR)/kernel/drivers/usb/host/ehci-hcd.ko \
287 ,CONFIG_USB_EHCI_HCD,kmod-usb-core,60,ehci-hcd))
289 $(eval $(call KMOD_template,USB_ACM,usb-acm,\
290 $(MODULES_DIR)/kernel/drivers/usb/class/cdc-acm.ko \
293 $(eval $(call KMOD_template,USB_AUDIO,usb-audio,\
294 $(MODULES_DIR)/kernel/drivers/sound/usb/snd-usb-audio.ko \
295 $(MODULES_DIR)/kernel/drivers/sound/usb/snd-usb-lib.ko \
296 ,CONFIG_USB_AUDIO,kmod-soundcore kmod-usb-core,61,snd-usb-lib snd-usb-audio))
298 $(eval $(call KMOD_template,USB_PRINTER,usb-printer,\
299 $(MODULES_DIR)/kernel/drivers/usb/class/usblp.ko \
300 ,CONFIG_USB_PRINTER,kmod-usb-core,60,usblp))
302 $(eval $(call KMOD_template,USB_SERIAL,usb-serial,\
303 $(MODULES_DIR)/kernel/drivers/usb/serial/usbserial.ko \
304 ,CONFIG_USB_SERIAL,kmod-usb-core,60,usbserial))
306 $(eval $(call KMOD_template,USB_SERIAL_BELKIN,usb-serial-belkin,\
307 $(MODULES_DIR)/kernel/drivers/usb/serial/belkin_sa.ko \
308 ,CONFIG_USB_SERIAL_BELKIN,kmod-usb-serial,61,belkin_sa))
310 $(eval $(call KMOD_template,USB_SERIAL_FTDI,usb-serial-ftdi,\
311 $(MODULES_DIR)/kernel/drivers/usb/serial/ftdi_sio.ko \
312 ,CONFIG_USB_SERIAL_FTDI_SIO,kmod-usb-serial,61,ftdi_sio))
314 $(eval $(call KMOD_template,USB_SERIAL_MCT_U232,usb-serial-mct-u232,\
315 $(MODULES_DIR)/kernel/drivers/usb/serial/mct_u232.ko \
316 ,CONFIG_USB_SERIAL_MCT_U232,kmod-usb-serial,61,mct_u232))
318 $(eval $(call KMOD_template,USB_SERIAL_PL2303,usb-serial-pl2303,\
319 $(MODULES_DIR)/kernel/drivers/usb/serial/pl2303.ko \
320 ,CONFIG_USB_SERIAL_PL2303,kmod-usb-serial,61,pl2303))
322 $(eval $(call KMOD_template,USB_STORAGE,usb-storage,\
323 $(MODULES_DIR)/kernel/drivers/scsi/scsi_mod.ko \
324 $(MODULES_DIR)/kernel/drivers/scsi/sd_mod.ko \
325 $(MODULES_DIR)/kernel/drivers/usb/storage/usb-storage.ko \
326 ,CONFIG_USB_STORAGE,kmod-usb-core,60,scsi_mod sd_mod usb-storage))
331 $(eval $(call KMOD_template,AX25,ax25,\
332 $(MODULES_DIR)/kernel/net/ax25/ax25.ko \
333 $(MODULES_DIR)/kernel/drivers/net/hamradio/mkiss.ko \
334 ,CONFIG_AX25,,90,ax25 mkiss))
336 $(eval $(call KMOD_template,BLUETOOTH,bluetooth,\
337 $(MODULES_DIR)/kernel/net/bluetooth/bluetooth.ko \
338 $(MODULES_DIR)/kernel/net/bluetooth/l2cap.ko \
339 $(MODULES_DIR)/kernel/net/bluetooth/sco.ko \
340 $(MODULES_DIR)/kernel/net/bluetooth/rfcomm/rfcomm.ko \
341 $(MODULES_DIR)/kernel/drivers/bluetooth/hci_uart.ko \
345 $(TARGETS): $(PACKAGE_DIR)
348 mkdir -p $(PACKAGE_DIR)
350 $(DL_DIR)/$(LINUX_SOURCE):
352 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE) $(MAKE_TRACE)
354 $(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE)
355 -mkdir -p $(LINUX_BUILD_DIR)
356 bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(LINUX_BUILD_DIR) $(TAR_OPTIONS) -
358 ln -s $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(LINUX_DIR)
359 touch $(LINUX_DIR)/.unpacked
361 $(LINUX_DIR)/.patched: $(LINUX_DIR)/.unpacked
362 $(PATCH) $(LINUX_DIR) ./patches/generic $(MAKE_TRACE)
363 [ -d ./patches/$(BOARD) ] && $(PATCH) $(LINUX_DIR) ./patches/$(BOARD) $(MAKE_TRACE)
364 touch $(LINUX_DIR)/.patched
366 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
367 -cp $(LINUX_KCONFIG) $(LINUX_DIR)/.config
368 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) oldconfig $(MAKE_TRACE)
369 touch $(LINUX_DIR)/.configured
371 $(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.configured
372 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE=$(TARGET_CROSS) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) $(MAKE_TRACE)
374 $(LINUX_KERNEL): $(LINUX_DIR)/vmlinux
375 $(TARGET_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $< $@ $(MAKE_TRACE)
376 touch -c $(LINUX_KERNEL)
378 $(LINUX_DIR)/.modules_done: $(LINUX_KERNEL) $(LINUX_IMAGE)
379 rm -rf $(LINUX_BUILD_DIR)/modules
380 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE=$(TARGET_CROSS) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) modules $(MAKE_TRACE)
381 $(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)
382 touch $(LINUX_DIR)/.modules_done
384 $(STAGING_DIR)/include/linux/version.h: $(LINUX_DIR)/.configured
385 mkdir -p $(STAGING_DIR)/include
386 tar -ch -C $(LINUX_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
387 tar -ch -C $(LINUX_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/
389 $(TARGET_MODULES_DIR):
390 -mkdir -p $(TARGET_MODULES_DIR)
393 rm -rf $(KERNEL_IDIR)
394 mkdir -p $(KERNEL_IDIR)/etc
395 $(SCRIPT_DIR)/make-ipkg-dir.sh $(KERNEL_IDIR) ../control/kernel.control $(PKG_RELEASE) $(ARCH)
396 echo 'Package: kernel-$(LINUX_VERSION)-$(BOARD)' >> $(KERNEL_IDIR)/CONTROL/control
397 if [ -f ./config/$(BOARD).modules ]; then \
398 cp ./config/$(BOARD).modules $(KERNEL_IDIR)/etc/modules; \
400 $(IPKG_BUILD) $(KERNEL_IDIR) $(LINUX_BUILD_DIR) $(MAKE_TRACE)
402 $(STAMP_DIR)/.linux-compile: $(LINUX_DIR)/.modules_done
403 @mkdir -p $(STAMP_DIR)
405 ln -sf $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(LINUX_DIR)
406 @$(TRACE) target/linux/package
407 $(MAKE) -C $(TOPDIR)/target/linux/package \
412 source: $(DL_DIR)/$(LINUX_SOURCE)
413 prepare: $(LINUX_DIR)/.configured
415 $(MAKE) $(STAMP_DIR)/.linux-compile $(MAKE_TRACE)
417 install: compile $(TARGET_MODULES_DIR) $(KERNEL_IPKG)
418 rm -rf $(LINUX_BUILD_DIR)/root*
419 cp -fpR $(BUILD_DIR)/root $(LINUX_BUILD_DIR)/
420 echo -e 'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR)/ipkg.conf
421 $(MAKE) -C $(TOPDIR)/target/linux/package \
424 @{ [ "$(INSTALL_TARGETS)" != "" ] && $(IPKG_KERNEL) install $(INSTALL_TARGETS) || true; } $(MAKE_TRACE)
427 rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.modules_done
428 rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.drivers-unpacked
429 $(MAKE) -C $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) clean
430 rm -f $(LINUX_KERNEL) $(LINUX_IMAGE)
434 if [ -f $(LINUX_KERNEL) ]; then \
440 rm -f $(STAMP_DIR)/.linux-compile
441 rm -rf $(LINUX_BUILD_DIR)