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
)
56 $(eval
$(call KMOD_template
,ATM
,atm
,\
57 $(MODULES_DIR
)/kernel
/net
/atm
/atm.o \
58 $(MODULES_DIR
)/kernel
/net
/atm
/br2684.o \
61 $(eval
$(call KMOD_template
,GRE
,gre
,\
62 $(MODULES_DIR
)/kernel
/net
/ipv4
/ip_gre.o \
65 $(eval
$(call KMOD_template
,IPV6
,ipv6
,\
66 $(MODULES_DIR
)/kernel
/net
/ipv6
/ipv6.o \
67 ,CONFIG_IPV6
,,20,ipv6
))
69 $(eval
$(call KMOD_template
,PPP
,ppp
,\
70 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_async.o \
71 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_generic.o \
72 $(MODULES_DIR
)/kernel
/drivers
/net
/slhc.o \
73 $(MODULES_DIR
)/kernel
/drivers
/net
/pppox.o \
76 $(eval
$(call KMOD_template
,MPPE
,mppe
,\
77 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_mppe_mppc.o \
78 ,CONFIG_PPP_MPPE_MPPC
))
80 $(eval
$(call KMOD_template
,PPPOATM
,pppoatm
,\
81 $(MODULES_DIR
)/kernel
/net
/atm
/pppoatm.o \
84 $(eval
$(call KMOD_template
,PPPOE
,pppoe
,\
85 $(MODULES_DIR
)/kernel
/drivers
/net
/pppoe.o \
88 ifneq ($(wildcard $(MODULES_DIR
)/kernel
/net
/sched
/*.o
),)
91 $(eval
$(call KMOD_template
,SCHED
,sched
,\
92 $(MODULES_DIR
)/kernel
/net
/sched
/*.o \
95 $(eval
$(call KMOD_template
,TUN
,tun
,\
96 $(MODULES_DIR
)/kernel
/drivers
/net
/tun.o \
100 # Filtering / Firewalling
102 $(eval
$(call KMOD_template
,ARPTABLES
,arptables
,\
103 $(MODULES_DIR
)/kernel
/net
/ipv4
/netfilter
/arp
*.o \
104 ,CONFIG_IP_NF_ARPTABLES
))
106 $(eval
$(call KMOD_template
,EBTABLES
,ebtables
,\
107 $(MODULES_DIR
)/kernel
/net
/bridge
/netfilter
/*.o \
108 ,CONFIG_BRIDGE_NF_EBTABLES
))
110 $(eval
$(call KMOD_template
,IPTABLES_V4_EXTRA
,iptables-extra
,\
111 $(MODULES_DIR
)/kernel
/net
/ipv4
/netfilter
/ip
*.o \
114 $(eval
$(call KMOD_template
,IPTABLES_V6
,ip6tables
,\
115 $(MODULES_DIR
)/kernel
/net
/ipv6
/netfilter
/ip
*.o \
116 ,CONFIG_IP6_NF_IPTABLES
,kmod-ipv6
))
121 $(eval
$(call KMOD_template
,IDE
,ide
,\
122 $(MODULES_DIR
)/kernel
/drivers
/ide
/*.o \
123 $(MODULES_DIR
)/kernel
/drivers
/ide
/*/*.o \
126 $(eval
$(call KMOD_template
,LOOP
,loop
,\
127 $(MODULES_DIR
)/kernel
/drivers
/block
/loop.o \
128 ,CONFIG_BLK_DEV_LOOP
,,20,loop
))
130 $(eval
$(call KMOD_template
,NBD
,nbd
,\
131 $(MODULES_DIR
)/kernel
/drivers
/block
/nbd.o \
132 ,CONFIG_BLK_DEV_NBD
,,20,nbd
))
137 ifneq ($(wildcard $(MODULES_DIR
)/kernel
/crypto
/*.o
),)
140 $(eval
$(call KMOD_template
,CRYPTO
,crypto
,\
141 $(MODULES_DIR
)/kernel
/crypto
/*.o \
147 $(eval
$(call KMOD_template
,FS_CIFS
,fs-cifs
,\
148 $(MODULES_DIR
)/kernel
/fs
/cifs
/cifs.o \
149 ,CONFIG_CIFS
,,30,cifs
))
151 $(eval
$(call KMOD_template
,FS_EXT2
,fs-ext2
,\
152 $(MODULES_DIR
)/kernel
/fs
/ext2
/*.o \
153 ,CONFIG_EXT2_FS
,,30,ext2
))
155 $(eval
$(call KMOD_template
,FS_EXT3
,fs-ext3
,\
156 $(MODULES_DIR
)/kernel
/fs
/ext3
/*.o \
157 $(MODULES_DIR
)/kernel
/fs
/jbd
/*.o \
158 ,CONFIG_EXT3_FS
,,30,jbd ext3
))
160 $(eval
$(call KMOD_template
,FS_HFSPLUS
,fs-hfsplus
,\
161 $(MODULES_DIR
)/kernel
/fs
/hfsplus
/*.o \
162 ,CONFIG_HFSPLUS_FS
,,30,hfsplus
))
164 $(eval
$(call KMOD_template
,FS_NFS
,fs-nfs
,\
165 $(MODULES_DIR
)/kernel
/fs
/lockd
/*.o \
166 $(MODULES_DIR
)/kernel
/fs
/nfs
/*.o \
167 $(MODULES_DIR
)/kernel
/net
/sunrpc
/*.o \
168 ,CONFIG_NFS_FS
,,30,sunrpc lockd nfs
))
170 $(eval
$(call KMOD_template
,FS_VFAT
,fs-vfat
,\
171 $(MODULES_DIR
)/kernel
/fs
/vfat
/vfat.o \
172 $(MODULES_DIR
)/kernel
/fs
/fat
/fat.o \
173 ,CONFIG_VFAT_FS
,,30,fat vfat
))
175 $(eval
$(call KMOD_template
,FS_XFS
,fs-xfs
,\
176 $(MODULES_DIR
)/kernel
/fs
/xfs
/*.o \
177 ,CONFIG_XFS_FS
,,30,xfs
))
182 $(eval
$(call KMOD_template
,PWC
,pwc
,\
183 $(MODULES_DIR
)/kernel
/drivers
/usb
/pwc.o \
184 ,CONFIG_USB_PWC
,kmod-videodev
,63,pwc
))
186 $(eval
$(call KMOD_template
,SOUNDCORE
,soundcore
,\
187 $(MODULES_DIR
)/kernel
/drivers
/sound
/soundcore.o \
188 ,CONFIG_SOUND
,,30,soundcore
))
190 $(eval
$(call KMOD_template
,VIDEODEV
,videodev
,\
191 $(MODULES_DIR
)/kernel
/drivers
/media
/video
/videodev.o \
192 ,CONFIG_VIDEO_DEV
,,62,videodev
))
197 $(eval
$(call KMOD_template
,NET_3C59X
,net-3c59x
,\
198 $(MODULES_DIR
)/kernel
/drivers
/net
/3c59x.o \
199 ,CONFIG_VORTEX
,,10,3c59x
))
201 $(eval
$(call KMOD_template
,NET_8139TOO
,net-8139too
,\
202 $(MODULES_DIR
)/kernel
/drivers
/net
/8139too.o \
203 $(MODULES_DIR
)/kernel
/drivers
/net
/mii.o \
204 ,CONFIG_VORTEX
,,10,mii
8139too
))
206 $(eval
$(call KMOD_template
,NET_AIRO
,net-airo
,\
207 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/airo.o \
208 ,CONFIG_AIRO
,,10,airo
))
210 $(eval
$(call KMOD_template
,NET_B44
,net-b44
,\
211 $(MODULES_DIR
)/kernel
/drivers
/net
/b44.o \
212 ,CONFIG_B44
,,10,b44
))
214 $(eval
$(call KMOD_template
,NET_HERMES
,net-hermes
,\
215 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/hermes.o \
216 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/orinoco.o \
217 ,CONFIG_HERMES
,,10,hermes orinoco
))
219 $(eval
$(call KMOD_template
,NET_HERMES_PCI
,net-hermes-pci
,\
220 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/orinoco_pci.o \
221 ,CONFIG_PCI_HERMES
,kmod-net-hermes
,11,orinoco_pci
))
223 $(eval
$(call KMOD_template
,NET_HERMES_PCI
,net-hermes-plx
,\
224 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/orinoco_plx.o \
225 ,CONFIG_PLX_HERMES
,kmod-net-hermes
,11,orinoco_plx
))
227 $(eval
$(call KMOD_template
,NET_NATSEMI
,net-natsemi
,\
228 $(MODULES_DIR
)/kernel
/drivers
/net
/natsemi.o \
229 ,CONFIG_NATSEMI
,,10,natsemi
))
231 $(eval
$(call KMOD_template
,NET_PRISM54
,net-prism54
,\
232 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/prism54
/prism54.o \
233 ,CONFIG_PRISM54
,,10,prism54
))
238 $(eval
$(call KMOD_template
,USB
,usb-core
,\
239 $(MODULES_DIR
)/kernel
/drivers
/usb
/usbcore.o \
240 ,CONFIG_USB
,,50,usbcore
))
242 $(eval
$(call KMOD_template
,USB_UHCI
,usb-uhci
,\
243 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/uhci.o \
244 ,CONFIG_USB_UHCI_ALT
,kmod-usb-core
,60,uhci
))
246 $(eval
$(call KMOD_template
,USB_OHCI
,usb-ohci
,\
247 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/usb-ohci.o \
248 ,CONFIG_USB_OHCI
,kmod-usb-core
,60,usb-ohci
))
250 $(eval
$(call KMOD_template
,USB2
,usb2
,\
251 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/ehci-hcd.o \
252 ,CONFIG_USB_EHCI_HCD
,kmod-usb-core
,60,ehci-hcd
))
254 $(eval
$(call KMOD_template
,USB_ACM
,usb-acm
,\
255 $(MODULES_DIR
)/kernel
/drivers
/usb
/acm.o \
258 $(eval
$(call KMOD_template
,USB_AUDIO
,usb-audio
,\
259 $(MODULES_DIR
)/kernel
/drivers
/usb
/audio.o \
260 ,CONFIG_USB_AUDIO
,kmod-soundcore kmod-usb-core
,61,audio
))
262 $(eval
$(call KMOD_template
,USB_PRINTER
,usb-printer
,\
263 $(MODULES_DIR
)/kernel
/drivers
/usb
/printer.o \
264 ,CONFIG_USB_PRINTER
,kmod-usb-core
,60,printer
))
266 $(eval
$(call KMOD_template
,USB_SERIAL
,usb-serial
,\
267 $(MODULES_DIR
)/kernel
/drivers
/usb
/serial
/usbserial.o \
268 ,CONFIG_USB_SERIAL
,kmod-usb-core
,60,usbserial
))
270 $(eval
$(call KMOD_template
,USB_SERIAL_BELKIN
,usb-serial-belkin
,\
271 $(MODULES_DIR
)/kernel
/drivers
/usb
/serial
/belkin_sa.o \
272 ,CONFIG_USB_SERIAL_BELKIN
,kmod-usb-serial
,61,belkin_sa
))
274 $(eval
$(call KMOD_template
,USB_SERIAL_FTDI
,usb-serial-ftdi
,\
275 $(MODULES_DIR
)/kernel
/drivers
/usb
/serial
/ftdi_sio.o \
276 ,CONFIG_USB_SERIAL_IR
,kmod-usb-serial
,61,ftdi_usb
))
278 $(eval
$(call KMOD_template
,USB_SERIAL_MCT_U232
,usb-serial-mct-u232
,\
279 $(MODULES_DIR
)/kernel
/drivers
/usb
/serial
/mct_u232.o \
280 ,CONFIG_USB_SERIAL_MCT_U232
,kmod-usb-serial
,61,mct_u232
))
282 $(eval
$(call KMOD_template
,USB_SERIAL_PL2303
,usb-serial-pl2303
,\
283 $(MODULES_DIR
)/kernel
/drivers
/usb
/serial
/pl2303.o \
284 ,CONFIG_USB_SERIAL_PL2303
,kmod-usb-serial
,61,pl2303
))
286 $(eval
$(call KMOD_template
,USB_STORAGE
,usb-storage
,\
287 $(MODULES_DIR
)/kernel
/drivers
/scsi
/*.o \
288 $(MODULES_DIR
)/kernel
/drivers
/usb
/storage
/*.o \
289 ,CONFIG_USB_STORAGE
,kmod-usb-core
,60,scsi_mod sd_mod usb-storage
))
294 $(eval
$(call KMOD_template
,AX25
,ax25
,\
295 $(MODULES_DIR
)/kernel
/net
/ax25
/ax25.o \
296 $(MODULES_DIR
)/kernel
/drivers
/net
/hamradio
/mkiss.o \
297 ,CONFIG_AX25
,,90,ax25 mkiss
))
299 $(eval
$(call KMOD_template
,BLUETOOTH
,bluetooth
,\
300 $(MODULES_DIR
)/kernel
/net
/bluetooth
/*.o \
301 $(MODULES_DIR
)/kernel
/net
/bluetooth
/rfcomm
/*.o \
302 $(MODULES_DIR
)/kernel
/drivers
/bluetooth
/*.o \
306 $(TARGETS
): $(PACKAGE_DIR
)
309 mkdir
-p
$(PACKAGE_DIR
)
311 $(LINUX_DIR
)/.unpacked
: $(DL_DIR
)/$(LINUX_SOURCE
)
312 -mkdir
-p
$(LINUX_BUILD_DIR
)
313 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
tar -C
$(LINUX_BUILD_DIR
) $(TAR_OPTIONS
) -
315 ln
-s
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(LINUX_DIR
)
316 touch
$(LINUX_DIR
)/.unpacked
318 $(LINUX_DIR
)/.patched
: $(LINUX_DIR
)/.unpacked
319 $(PATCH
) $(LINUX_DIR
) .
/patches
/generic
$(MAKE_TRACE
)
320 [ -d .
/patches
/$(BOARD
) ] && $(PATCH
) $(LINUX_DIR
) .
/patches
/$(BOARD
) $(MAKE_TRACE
)
321 touch
$(LINUX_DIR
)/.patched
323 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.patched
324 -cp
$(LINUX_KCONFIG
) $(LINUX_DIR
)/.config
325 $(SED
) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" \
326 $(LINUX_DIR
)/Makefile \
327 $(LINUX_DIR
)/arch
/*/Makefile
328 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
329 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) oldconfig
include/linux
/version.h
$(MAKE_TRACE
)
330 touch
$(LINUX_DIR
)/.configured
332 $(LINUX_DIR
)/.depend_done
: $(LINUX_DIR
)/.configured
333 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) dep
$(MAKE_TRACE
)
334 touch
$(LINUX_DIR
)/.depend_done
336 $(LINUX_DIR
)/vmlinux
: $(LINUX_DIR
)/.depend_done
337 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) PATH
=$(TARGET_PATH
) $(MAKE_TRACE
)
339 $(LINUX_KERNEL
): $(LINUX_DIR
)/vmlinux
340 $(TARGET_CROSS
)objcopy
-O binary
-R .reginfo
-R .note
-R .comment
-R .mdebug
-S
$< $@
$(MAKE_TRACE
)
341 touch
-c
$(LINUX_KERNEL
)
343 $(LINUX_DIR
)/.modules_done
: $(LINUX_KERNEL
) $(LINUX_IMAGE
)
344 rm -rf
$(LINUX_BUILD_DIR
)/modules
345 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) PATH
=$(TARGET_PATH
) modules
$(MAKE_TRACE
)
346 $(MAKE
) -C
$(LINUX_DIR
) DEPMOD
=true INSTALL_MOD_PATH
=$(LINUX_BUILD_DIR
)/modules modules_install
$(MAKE_TRACE
)
347 touch
$(LINUX_DIR
)/.modules_done
349 $(STAGING_DIR
)/include/linux
/version.h
: $(LINUX_DIR
)/.configured
350 mkdir
-p
$(STAGING_DIR
)/include
351 tar -ch
-C
$(LINUX_DIR
)/include -f
- linux |
tar -xf
- -C
$(STAGING_DIR
)/include/
352 tar -ch
-C
$(LINUX_DIR
)/include -f
- asm |
tar -xf
- -C
$(STAGING_DIR
)/include/
354 $(STAMP_DIR
)/.linux-compile
: $(LINUX_DIR
)/.modules_done
355 @mkdir
-p
$(STAMP_DIR
)
357 ln
-sf
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(LINUX_DIR
)
358 @
$(TRACE
) target
/linux
/package
359 $(MAKE
) -C
$(TOPDIR
)/target
/linux
/package \
364 $(TARGET_MODULES_DIR
):
365 -mkdir
-p
$(TARGET_MODULES_DIR
)
368 rm -rf
$(KERNEL_IDIR
)
369 mkdir
-p
$(KERNEL_IDIR
)/etc
370 $(SCRIPT_DIR
)/make-ipkg-dir.sh
$(KERNEL_IDIR
) ..
/control
/kernel.control
$(PKG_RELEASE
) $(ARCH
)
371 echo
'Package: kernel-$(LINUX_VERSION)-$(BOARD)' >> $(KERNEL_IDIR
)/CONTROL
/control
372 if
[ -f .
/config
/$(BOARD
).modules
]; then \
373 cp .
/config
/$(BOARD
).modules
$(KERNEL_IDIR
)/etc
/modules
; \
375 $(IPKG_BUILD
) $(KERNEL_IDIR
) $(LINUX_BUILD_DIR
) $(MAKE_TRACE
)
377 source
: $(DL_DIR
)/$(LINUX_SOURCE
)
378 prepare
: $(LINUX_DIR
)/.configured
380 $(MAKE
) $(STAMP_DIR
)/.linux-compile
$(MAKE_TRACE
)
382 install: compile
$(TARGET_MODULES_DIR
) $(KERNEL_IPKG
)
383 rm -rf
$(LINUX_BUILD_DIR
)/root
*
384 cp
-fpR
$(BUILD_DIR
)/root
$(LINUX_BUILD_DIR
)/
385 echo
-e
'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR
)/ipkg.conf
386 $(MAKE
) -C
$(TOPDIR
)/target
/linux
/package \
389 @
{ [ "$(INSTALL_TARGETS)" != "" ] && $(IPKG_KERNEL
) install $(INSTALL_TARGETS
) || true
; } $(MAKE_TRACE
)
392 rm -f
$(STAMP_DIR
)/.linux-compile
393 rm -f
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.modules_done
394 rm -f
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.drivers-unpacked
395 $(MAKE
) -C
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean $(MAKE_TRACE
)
396 rm -f
$(LINUX_KERNEL
) $(LINUX_IMAGE
)
400 if
[ -f
$(LINUX_KERNEL
) ]; then \
401 $(MAKE
) clean $(MAKE_TRACE
); \
403 $(MAKE
) compile
$(MAKE_TRACE
)
406 rm -f
$(STAMP_DIR
)/.linux-compile
407 rm -rf
$(LINUX_BUILD_DIR
)