2 # Linux 2.4 kernel target for the OpenWRT project
4 include $(TOPDIR)/rules.mk
9 MODULES_SUBDIR:=lib/modules/$(LINUX_VERSION)
10 LINUX_KCONFIG:=./config/$(BOARD)
11 LINUX_BUILD_DIR:=$(BUILD_DIR)/linux-2.4-$(BOARD)
12 LINUX_TARGET_DIR:=$(LINUX_BUILD_DIR)/root
13 LINUX_KERNEL:=$(LINUX_BUILD_DIR)/vmlinux
15 LINUX_BINARY_DRIVER_SITE := http://openwrt.org/downloads/sources/
16 LINUX_SOURCE := linux-$(LINUX_VERSION).tar.bz2
17 LINUX_SOURCE_DIR := $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)
18 MODULES_DIR := $(LINUX_BUILD_DIR)/modules/$(MODULES_SUBDIR)
19 TARGET_MODULES_DIR := $(LINUX_TARGET_DIR)/lib/modules/$(LINUX_VERSION)
20 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
22 PKG_BUILD_DIR := $(LINUX_BUILD_DIR)/linux-modules
25 KERNEL_IPKG:=$(LINUX_BUILD_DIR)/kernel_$(LINUX_VERSION)-$(BOARD)-$(PKG_RELEASE)_$(ARCH).ipk
26 KERNEL_IDIR:=$(LINUX_BUILD_DIR)/kernel-ipkg
28 KPKG_MAKEOPTS:= IPKG="$(IPKG_KERNEL)" \
30 TARGET_DIR="$(LINUX_TARGET_DIR)" \
31 BUILD_DIR="$(LINUX_BUILD_DIR)" \
32 KERNEL_DIR="$(LINUX_SOURCE_DIR)" \
33 LINUX_VERSION="$(LINUX_VERSION)" \
34 KERNEL_RELEASE="$(PKG_RELEASE)"
36 include $(LINUX_KCONFIG)
38 INSTALL_TARGETS := $(KERNEL_IPKG)
53 include ../netfilter.mk
57 $(eval $(call KMOD_template,ATM,atm,\
58 $(MODULES_DIR)/kernel/net/atm/atm.o \
59 $(MODULES_DIR)/kernel/net/atm/br2684.o \
62 $(eval $(call KMOD_template,GRE,gre,\
63 $(MODULES_DIR)/kernel/net/ipv4/ip_gre.o \
66 $(eval $(call KMOD_template,IMQ,imq,\
67 $(MODULES_DIR)/kernel/net/*/netfilter/*IMQ*.o \
68 $(MODULES_DIR)/kernel/drivers/net/imq.o \
71 $(eval $(call KMOD_template,IPV6,ipv6,\
72 $(MODULES_DIR)/kernel/net/ipv6/ipv6.o \
73 ,CONFIG_IPV6,,20,ipv6))
75 $(eval $(call KMOD_template,PPP,ppp,\
76 $(MODULES_DIR)/kernel/drivers/net/ppp_async.o \
77 $(MODULES_DIR)/kernel/drivers/net/ppp_generic.o \
78 $(MODULES_DIR)/kernel/drivers/net/slhc.o \
79 $(MODULES_DIR)/kernel/drivers/net/pppox.o \
82 $(eval $(call KMOD_template,MPPE,mppe,\
83 $(MODULES_DIR)/kernel/drivers/net/ppp_mppe_mppc.o \
84 ,CONFIG_PPP_MPPE_MPPC))
86 $(eval $(call KMOD_template,PPPOATM,pppoatm,\
87 $(MODULES_DIR)/kernel/net/atm/pppoatm.o \
90 $(eval $(call KMOD_template,PPPOE,pppoe,\
91 $(MODULES_DIR)/kernel/drivers/net/pppoe.o \
94 ifneq ($(wildcard $(MODULES_DIR)/kernel/net/sched/*.o),)
97 $(eval $(call KMOD_template,SCHED,sched,\
98 $(MODULES_DIR)/kernel/net/sched/*.o \
101 $(eval $(call KMOD_template,TUN,tun,\
102 $(MODULES_DIR)/kernel/drivers/net/tun.o \
103 ,CONFIG_TUN,,20,tun))
106 # Filtering / Firewalling
108 $(eval $(call KMOD_template,ARPTABLES,arptables,\
109 $(MODULES_DIR)/kernel/net/ipv4/netfilter/arp*.o \
110 ,CONFIG_IP_NF_ARPTABLES))
112 $(eval $(call KMOD_template,EBTABLES,ebtables,\
113 $(MODULES_DIR)/kernel/net/bridge/netfilter/*.o \
114 ,CONFIG_BRIDGE_NF_EBTABLES))
116 # metapackage for compatibility ...
117 $(eval $(call KMOD_template,IPTABLES_EXTRA,iptables-extra,\
118 ,,kmod-ipt-conntrack kmod-ipt-extra kmod-ipt-filter kmod-ipt-ipopt kmod-ipt-ipsec kmod-ipt-nat kmod-ipt-nat-extra kmod-ipt-queue kmod-ipt-ulogd))
120 $(eval $(call KMOD_template,IPT_CONNTRACK,ipt-conntrack,\
121 $(foreach mod,$(IPT_CONNTRACK-m),$(MODULES_DIR)/kernel/net/ipv4/netfilter/$(mod).o) \
124 $(eval $(call KMOD_template,IPT_EXTRA,ipt-extra,\
125 $(foreach mod,$(IPT_EXTRA-m),$(MODULES_DIR)/kernel/net/ipv4/netfilter/$(mod).o) \
128 $(eval $(call KMOD_template,IPT_FILTER,ipt-filter,\
129 $(foreach mod,$(IPT_FILTER-m),$(MODULES_DIR)/kernel/net/ipv4/netfilter/$(mod).o) \
132 $(eval $(call KMOD_template,IPT_IPOPT,ipt-ipopt,\
133 $(foreach mod,$(IPT_IPOPT-m),$(MODULES_DIR)/kernel/net/ipv4/netfilter/$(mod).o) \
136 $(eval $(call KMOD_template,IPT_IPSEC,ipt-ipsec,\
137 $(foreach mod,$(IPT_IPSEC-m),$(MODULES_DIR)/kernel/net/ipv4/netfilter/$(mod).o) \
140 $(eval $(call KMOD_template,IPT_NAT,ipt-nat,\
141 $(foreach mod,$(IPT_NAT-m),$(MODULES_DIR)/kernel/net/ipv4/netfilter/$(mod).o) \
144 $(eval $(call KMOD_template,IPT_NAT_EXTRA,ipt-nat-extra,\
145 $(foreach mod,$(IPT_NAT_EXTRA-m),$(MODULES_DIR)/kernel/net/ipv4/netfilter/$(mod).o) \
146 ,,,40,$(IPT_NAT_EXTRA-m)))
148 $(eval $(call KMOD_template,IPT_QUEUE,ipt-queue,\
149 $(foreach mod,$(IPT_QUEUE-m),$(MODULES_DIR)/kernel/net/ipv4/netfilter/$(mod).o) \
152 $(eval $(call KMOD_template,IPT_ULOG,ipt-ulog,\
153 $(foreach mod,$(IPT_ULOG-m),$(MODULES_DIR)/kernel/net/ipv4/netfilter/$(mod).o) \
156 $(eval $(call KMOD_template,IP6TABLES,ip6tables,\
157 $(MODULES_DIR)/kernel/net/ipv6/netfilter/ip*.o \
158 ,CONFIG_IP6_NF_IPTABLES,kmod-ipv6))
163 $(eval $(call KMOD_template,IDE,ide,\
164 $(MODULES_DIR)/kernel/drivers/ide/*.o \
165 $(MODULES_DIR)/kernel/drivers/ide/*/*.o \
168 $(eval $(call KMOD_template,LOOP,loop,\
169 $(MODULES_DIR)/kernel/drivers/block/loop.o \
170 ,CONFIG_BLK_DEV_LOOP,,20,loop))
172 $(eval $(call KMOD_template,NBD,nbd,\
173 $(MODULES_DIR)/kernel/drivers/block/nbd.o \
174 ,CONFIG_BLK_DEV_NBD,,20,nbd))
179 ifneq ($(wildcard $(MODULES_DIR)/kernel/crypto/*.o),)
182 $(eval $(call KMOD_template,CRYPTO,crypto,\
183 $(MODULES_DIR)/kernel/crypto/*.o \
189 $(eval $(call KMOD_template,FS_CIFS,fs-cifs,\
190 $(MODULES_DIR)/kernel/fs/cifs/cifs.o \
191 ,CONFIG_CIFS,,30,cifs))
193 $(eval $(call KMOD_template,FS_EXT2,fs-ext2,\
194 $(MODULES_DIR)/kernel/fs/ext2/*.o \
195 ,CONFIG_EXT2_FS,,30,ext2))
197 $(eval $(call KMOD_template,FS_EXT3,fs-ext3,\
198 $(MODULES_DIR)/kernel/fs/ext3/*.o \
199 $(MODULES_DIR)/kernel/fs/jbd/*.o \
200 ,CONFIG_EXT3_FS,,30,jbd ext3))
202 $(eval $(call KMOD_template,FS_HFSPLUS,fs-hfsplus,\
203 $(MODULES_DIR)/kernel/fs/hfsplus/*.o \
204 ,CONFIG_HFSPLUS_FS,,30,hfsplus))
206 $(eval $(call KMOD_template,FS_NFS,fs-nfs,\
207 $(MODULES_DIR)/kernel/fs/lockd/*.o \
208 $(MODULES_DIR)/kernel/fs/nfs/*.o \
209 $(MODULES_DIR)/kernel/net/sunrpc/*.o \
210 ,CONFIG_NFS_FS,,30,sunrpc lockd nfs))
212 $(eval $(call KMOD_template,FS_VFAT,fs-vfat,\
213 $(MODULES_DIR)/kernel/fs/vfat/vfat.o \
214 $(MODULES_DIR)/kernel/fs/fat/fat.o \
215 ,CONFIG_VFAT_FS,,30,fat vfat))
217 $(eval $(call KMOD_template,FS_XFS,fs-xfs,\
218 $(MODULES_DIR)/kernel/fs/xfs/*.o \
219 ,CONFIG_XFS_FS,,30,xfs))
224 $(eval $(call KMOD_template,PWC,pwc,\
225 $(MODULES_DIR)/kernel/drivers/usb/pwc.o \
226 ,CONFIG_USB_PWC,kmod-videodev,63,pwc))
228 $(eval $(call KMOD_template,SOUNDCORE,soundcore,\
229 $(MODULES_DIR)/kernel/drivers/sound/soundcore.o \
230 ,CONFIG_SOUND,,30,soundcore))
232 $(eval $(call KMOD_template,VIDEODEV,videodev,\
233 $(MODULES_DIR)/kernel/drivers/media/video/videodev.o \
234 ,CONFIG_VIDEO_DEV,,62,videodev))
239 $(eval $(call KMOD_template,NET_3C59X,net-3c59x,\
240 $(MODULES_DIR)/kernel/drivers/net/3c59x.o \
241 ,CONFIG_VORTEX,,10,3c59x))
243 $(eval $(call KMOD_template,NET_8139TOO,net-8139too,\
244 $(MODULES_DIR)/kernel/drivers/net/8139too.o \
245 $(MODULES_DIR)/kernel/drivers/net/mii.o \
246 ,CONFIG_8139TOO,,10,mii 8139too))
248 $(eval $(call KMOD_template,NET_AIRO,net-airo,\
249 $(MODULES_DIR)/kernel/drivers/net/wireless/airo.o \
250 ,CONFIG_AIRO,,10,airo))
252 $(eval $(call KMOD_template,NET_B44,net-b44,\
253 $(MODULES_DIR)/kernel/drivers/net/b44.o \
254 ,CONFIG_B44,,10,b44))
256 $(eval $(call KMOD_template,NET_E100,net-e100,\
257 $(MODULES_DIR)/kernel/drivers/net/e100.o \
258 ,CONFIG_E100,,10,e100))
260 $(eval $(call KMOD_template,NET_HERMES,net-hermes,\
261 $(MODULES_DIR)/kernel/drivers/net/wireless/hermes.o \
262 $(MODULES_DIR)/kernel/drivers/net/wireless/orinoco.o \
263 ,CONFIG_HERMES,,10,hermes orinoco))
265 $(eval $(call KMOD_template,NET_HERMES_PCI,net-hermes-pci,\
266 $(MODULES_DIR)/kernel/drivers/net/wireless/orinoco_pci.o \
267 ,CONFIG_PCI_HERMES,kmod-net-hermes,11,orinoco_pci))
269 $(eval $(call KMOD_template,NET_HERMES_PCI,net-hermes-plx,\
270 $(MODULES_DIR)/kernel/drivers/net/wireless/orinoco_plx.o \
271 ,CONFIG_PLX_HERMES,kmod-net-hermes,11,orinoco_plx))
273 $(eval $(call KMOD_template,NET_NATSEMI,net-natsemi,\
274 $(MODULES_DIR)/kernel/drivers/net/natsemi.o \
275 ,CONFIG_NATSEMI,,10,natsemi))
277 $(eval $(call KMOD_template,NET_PRISM54,net-prism54,\
278 $(MODULES_DIR)/kernel/drivers/net/wireless/prism54/prism54.o \
279 ,CONFIG_PRISM54,,10,prism54))
284 $(eval $(call KMOD_template,PCMCIA_CORE,pcmcia-core,\
285 $(MODULES_DIR)/kernel/drivers/pcmcia/pcmcia_core.o \
286 $(MODULES_DIR)/kernel/drivers/pcmcia/yenta_socket.o \
287 $(MODULES_DIR)/kernel/drivers/pcmcia/ds.o \
288 ,CONFIG_PCMCIA,,50,pcmcia_core yenta_socket ds))
290 $(eval $(call KMOD_template,PCMCIA_SERIAL,pcmcia-serial,\
291 $(MODULES_DIR)/kernel/drivers/char/pcmcia/serial_cs.o \
292 ,CONFIG_PCMCIA_SERIAL_CS,kmod-pcmcia-core,51,serial_cs))
297 $(eval $(call KMOD_template,USB,usb-core,\
298 $(MODULES_DIR)/kernel/drivers/usb/usbcore.o \
299 ,CONFIG_USB,,50,usbcore))
301 $(eval $(call KMOD_template,USB_OHCI,usb-ohci,\
302 $(MODULES_DIR)/kernel/drivers/usb/host/usb-ohci.o \
303 ,CONFIG_USB_OHCI,kmod-usb-core,60,usb-ohci))
305 $(eval $(call KMOD_template,USB_UHCI,usb-uhci,\
306 $(MODULES_DIR)/kernel/drivers/usb/host/uhci.o \
307 ,CONFIG_USB_UHCI_ALT,kmod-usb-core,60,uhci))
309 $(eval $(call KMOD_template,USB2,usb2,\
310 $(MODULES_DIR)/kernel/drivers/usb/host/ehci-hcd.o \
311 ,CONFIG_USB_EHCI_HCD,kmod-usb-core,60,ehci-hcd))
313 $(eval $(call KMOD_template,USB_ACM,usb-acm,\
314 $(MODULES_DIR)/kernel/drivers/usb/acm.o \
317 $(eval $(call KMOD_template,USB_AUDIO,usb-audio,\
318 $(MODULES_DIR)/kernel/drivers/usb/audio.o \
319 ,CONFIG_USB_AUDIO,kmod-soundcore kmod-usb-core,61,audio))
321 $(eval $(call KMOD_template,USB_PRINTER,usb-printer,\
322 $(MODULES_DIR)/kernel/drivers/usb/printer.o \
323 ,CONFIG_USB_PRINTER,kmod-usb-core,60,printer))
325 $(eval $(call KMOD_template,USB_SERIAL,usb-serial,\
326 $(MODULES_DIR)/kernel/drivers/usb/serial/usbserial.o \
327 ,CONFIG_USB_SERIAL,kmod-usb-core,60,usbserial))
329 $(eval $(call KMOD_template,USB_SERIAL_BELKIN,usb-serial-belkin,\
330 $(MODULES_DIR)/kernel/drivers/usb/serial/belkin_sa.o \
331 ,CONFIG_USB_SERIAL_BELKIN,kmod-usb-serial,61,belkin_sa))
333 $(eval $(call KMOD_template,USB_SERIAL_FTDI,usb-serial-ftdi,\
334 $(MODULES_DIR)/kernel/drivers/usb/serial/ftdi_sio.o \
335 ,CONFIG_USB_SERIAL_FTDI_SIO,kmod-usb-serial,61,ftdi_sio))
337 $(eval $(call KMOD_template,USB_SERIAL_MCT_U232,usb-serial-mct-u232,\
338 $(MODULES_DIR)/kernel/drivers/usb/serial/mct_u232.o \
339 ,CONFIG_USB_SERIAL_MCT_U232,kmod-usb-serial,61,mct_u232))
341 $(eval $(call KMOD_template,USB_SERIAL_PL2303,usb-serial-pl2303,\
342 $(MODULES_DIR)/kernel/drivers/usb/serial/pl2303.o \
343 ,CONFIG_USB_SERIAL_PL2303,kmod-usb-serial,61,pl2303))
345 $(eval $(call KMOD_template,USB_STORAGE,usb-storage,\
346 $(MODULES_DIR)/kernel/drivers/scsi/*.o \
347 $(MODULES_DIR)/kernel/drivers/usb/storage/*.o \
348 ,CONFIG_USB_STORAGE,kmod-usb-core,60,scsi_mod sd_mod usb-storage))
353 $(eval $(call KMOD_template,AX25,ax25,\
354 $(MODULES_DIR)/kernel/net/ax25/ax25.o \
355 $(MODULES_DIR)/kernel/drivers/net/hamradio/mkiss.o \
356 ,CONFIG_AX25,,90,ax25 mkiss))
358 $(eval $(call KMOD_template,BLUETOOTH,bluetooth,\
359 $(MODULES_DIR)/kernel/net/bluetooth/*.o \
360 $(MODULES_DIR)/kernel/net/bluetooth/rfcomm/*.o \
361 $(MODULES_DIR)/kernel/drivers/bluetooth/*.o \
365 $(TARGETS): $(PACKAGE_DIR)
368 mkdir -p $(PACKAGE_DIR)
370 $(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE)
371 -mkdir -p $(LINUX_BUILD_DIR)
372 bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(LINUX_BUILD_DIR) $(TAR_OPTIONS) -
374 ln -s $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(LINUX_DIR)
375 touch $(LINUX_DIR)/.unpacked
377 $(LINUX_DIR)/.patched: $(LINUX_DIR)/.unpacked
378 $(PATCH) $(LINUX_DIR) ./patches/generic $(MAKE_TRACE)
379 [ -d ./patches/$(BOARD) ] && $(PATCH) $(LINUX_DIR) ./patches/$(BOARD) $(MAKE_TRACE)
380 touch $(LINUX_DIR)/.patched
382 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
383 -cp $(LINUX_KCONFIG) $(LINUX_DIR)/.config
384 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" \
385 $(LINUX_DIR)/Makefile \
386 $(LINUX_DIR)/arch/*/Makefile
387 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
388 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) oldconfig include/linux/version.h $(MAKE_TRACE)
389 touch $(LINUX_DIR)/.configured
391 $(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
392 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) dep $(MAKE_TRACE)
393 touch $(LINUX_DIR)/.depend_done
395 $(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.depend_done
396 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) $(MAKE_TRACE)
398 $(LINUX_KERNEL): $(LINUX_DIR)/vmlinux
399 $(TARGET_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $< $@ $(MAKE_TRACE)
400 touch -c $(LINUX_KERNEL)
402 $(LINUX_DIR)/.modules_done: $(LINUX_KERNEL) $(LINUX_IMAGE)
403 rm -rf $(LINUX_BUILD_DIR)/modules
404 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) modules $(MAKE_TRACE)
405 $(MAKE) -C $(LINUX_DIR) DEPMOD=true INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules modules_install $(MAKE_TRACE)
406 touch $(LINUX_DIR)/.modules_done
408 $(STAGING_DIR)/include/linux/version.h: $(LINUX_DIR)/.configured
409 mkdir -p $(STAGING_DIR)/include
410 tar -ch -C $(LINUX_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
411 tar -ch -C $(LINUX_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/
413 $(STAMP_DIR)/.linux-compile: $(LINUX_DIR)/.modules_done
414 @mkdir -p $(STAMP_DIR)
416 ln -sf $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(LINUX_DIR)
417 @$(TRACE) target/linux/package
418 $(MAKE) -C $(TOPDIR)/target/linux/package \
423 $(TARGET_MODULES_DIR):
424 -mkdir -p $(TARGET_MODULES_DIR)
427 rm -rf $(KERNEL_IDIR)
428 mkdir -p $(KERNEL_IDIR)/etc
429 $(SCRIPT_DIR)/make-ipkg-dir.sh $(KERNEL_IDIR) ../control/kernel.control $(LINUX_VERSION)-$(BOARD)-$(PKG_RELEASE) $(ARCH)
430 if [ -f ./config/$(BOARD).modules ]; then \
431 cp ./config/$(BOARD).modules $(KERNEL_IDIR)/etc/modules; \
433 $(IPKG_BUILD) $(KERNEL_IDIR) $(LINUX_BUILD_DIR) $(MAKE_TRACE)
435 source: $(DL_DIR)/$(LINUX_SOURCE)
436 prepare: $(LINUX_DIR)/.configured
438 $(MAKE) $(STAMP_DIR)/.linux-compile $(MAKE_TRACE)
440 install: compile $(TARGET_MODULES_DIR) $(KERNEL_IPKG)
441 rm -rf $(LINUX_BUILD_DIR)/root*
442 cp -fpR $(BUILD_DIR)/root $(LINUX_BUILD_DIR)/
443 echo -e 'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR)/ipkg.conf
444 $(MAKE) -C $(TOPDIR)/target/linux/package \
447 @{ [ "$(INSTALL_TARGETS)" != "" ] && $(IPKG_KERNEL) install $(INSTALL_TARGETS) || true; } $(MAKE_TRACE)
450 rm -f $(STAMP_DIR)/.linux-compile
451 rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.modules_done
452 rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.drivers-unpacked
453 $(MAKE) -C $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) clean $(MAKE_TRACE)
454 rm -f $(LINUX_KERNEL) $(LINUX_IMAGE)
458 if [ -f $(LINUX_KERNEL) ]; then \
459 $(MAKE) clean $(MAKE_TRACE); \
461 $(MAKE) compile $(MAKE_TRACE)
464 rm -f $(STAMP_DIR)/.linux-compile
465 rm -rf $(LINUX_BUILD_DIR)