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 $(eval
$(call KMOD_template
,ATM
,atm
,\
54 $(MODULES_DIR
)/kernel
/net
/atm
/atm.o \
55 $(MODULES_DIR
)/kernel
/net
/atm
/br2684.o \
57 $(eval
$(call KMOD_template
,PPPOATM
,pppoatm
,\
58 $(MODULES_DIR
)/kernel
/net
/atm
/pppoatm.o \
60 $(eval
$(call KMOD_template
,ARPT
,arptables
,\
61 $(MODULES_DIR
)/kernel
/net
/ipv4
/netfilter
/arp
*.o \
62 ,CONFIG_IP_NF_ARPTABLES
))
63 $(eval
$(call KMOD_template
,EBT
,ebtables
,\
64 $(MODULES_DIR
)/kernel
/net
/bridge
/netfilter
/*.o \
65 ,CONFIG_BRIDGE_NF_EBTABLES
))
66 $(eval
$(call KMOD_template
,IPTABLES_V4_EXTRA
,iptables-extra
,\
67 $(MODULES_DIR
)/kernel
/net
/ipv4
/netfilter
/ip
*.o \
69 $(eval
$(call KMOD_template
,IPTABLES_V6
,ip6tables
,\
70 $(MODULES_DIR
)/kernel
/net
/ipv6
/netfilter
/ip
*.o \
71 ,CONFIG_IP6_NF_IPTABLES
,kmod-ipv6
))
72 $(eval
$(call KMOD_template
,IPV6
,ipv6
,\
73 $(MODULES_DIR
)/kernel
/net
/ipv6
/ipv6.o \
74 ,CONFIG_IPV6
,,20,ipv6
))
75 $(eval
$(call KMOD_template
,IDE
,ide
,\
76 $(MODULES_DIR
)/kernel
/drivers
/ide
/*.o \
77 $(MODULES_DIR
)/kernel
/drivers
/ide
/*/*.o \
79 $(eval
$(call KMOD_template
,LOOP
,loop
,\
80 $(MODULES_DIR
)/kernel
/drivers
/block
/loop.o \
81 ,CONFIG_BLK_DEV_LOOP
,,20,loop
))
83 ifneq ($(wildcard $(MODULES_DIR
)/kernel
/crypto
/*.o
),)
86 $(eval
$(call KMOD_template
,CRYPTO
,crypto
,\
87 $(MODULES_DIR
)/kernel
/crypto
/*.o \
89 $(eval
$(call KMOD_template
,PPP
,ppp
,\
90 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_async.o \
91 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_generic.o \
92 $(MODULES_DIR
)/kernel
/drivers
/net
/slhc.o \
93 $(MODULES_DIR
)/kernel
/drivers
/net
/pppox.o \
95 $(eval
$(call KMOD_template
,MPPE
,mppe
,\
96 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_mppe_mppc.o \
97 ,CONFIG_PPP_MPPE_MPPC
))
98 $(eval
$(call KMOD_template
,PPPOE
,pppoe
,\
99 $(MODULES_DIR
)/kernel
/drivers
/net
/pppoe.o \
101 $(eval
$(call KMOD_template
,TUN
,tun
,\
102 $(MODULES_DIR
)/kernel
/drivers
/net
/tun.o \
103 ,CONFIG_TUN
,,20,tun
))
104 $(eval
$(call KMOD_template
,GRE
,gre
,\
105 $(MODULES_DIR
)/kernel
/net
/ipv4
/ip_gre.o \
107 ifneq ($(wildcard $(MODULES_DIR
)/kernel
/net
/sched
/*.o
),)
110 $(eval
$(call KMOD_template
,SCHED
,sched
,\
111 $(MODULES_DIR
)/kernel
/net
/sched
/*.o \
117 $(eval
$(call KMOD_template
,FS_CIFS
,fs-cifs
,\
118 $(MODULES_DIR
)/kernel
/fs
/cifs
/cifs.o \
119 ,CONFIG_CIFS
,,30,cifs
))
121 $(eval
$(call KMOD_template
,FS_EXT2
,fs-ext2
,\
122 $(MODULES_DIR
)/kernel
/fs
/ext2
/*.o \
123 ,CONFIG_EXT2_FS
,,30,ext2
))
125 $(eval
$(call KMOD_template
,FS_EXT3
,fs-ext3
,\
126 $(MODULES_DIR
)/kernel
/fs
/ext3
/*.o \
127 $(MODULES_DIR
)/kernel
/fs
/jbd
/*.o \
128 ,CONFIG_EXT3_FS
,,30,jbd ext3
))
130 $(eval
$(call KMOD_template
,FS_HFSPLUS
,fs-hfsplus
,\
131 $(MODULES_DIR
)/kernel
/fs
/hfsplus
/*.o \
132 ,CONFIG_HFSPLUS_FS
,,30,hfsplus
))
134 $(eval
$(call KMOD_template
,FS_NFS
,fs-nfs
,\
135 $(MODULES_DIR
)/kernel
/fs
/lockd
/*.o \
136 $(MODULES_DIR
)/kernel
/fs
/nfs
/*.o \
137 $(MODULES_DIR
)/kernel
/net
/sunrpc
/*.o \
138 ,CONFIG_NFS_FS
,,30,sunrpc lockd nfs
))
140 $(eval
$(call KMOD_template
,FS_VFAT
,fs-vfat
,\
141 $(MODULES_DIR
)/kernel
/fs
/vfat
/vfat.o \
142 $(MODULES_DIR
)/kernel
/fs
/fat
/fat.o \
143 ,CONFIG_VFAT_FS
,,30,fat vfat
))
145 $(eval
$(call KMOD_template
,FS_XFS
,fs-xfs
,\
146 $(MODULES_DIR
)/kernel
/fs
/xfs
/*.o \
147 ,CONFIG_XFS_FS
,,30,xfs
))
152 $(eval
$(call KMOD_template
,PWC
,pwc
,\
153 $(MODULES_DIR
)/kernel
/drivers
/usb
/pwc.o \
154 ,CONFIG_USB_PWC
,kmod-videodev
,63,pwc
))
156 $(eval
$(call KMOD_template
,SOUNDCORE
,soundcore
,\
157 $(MODULES_DIR
)/kernel
/drivers
/sound
/soundcore.o \
158 ,CONFIG_SOUND
,,30,soundcore
))
160 $(eval
$(call KMOD_template
,VIDEODEV
,videodev
,\
161 $(MODULES_DIR
)/kernel
/drivers
/media
/video
/videodev.o \
162 ,CONFIG_VIDEO_DEV
,,62,videodev
))
167 $(eval
$(call KMOD_template
,NET_3C59X
,net-3c59x
,\
168 $(MODULES_DIR
)/kernel
/drivers
/net
/3c59x.o \
169 ,CONFIG_VORTEX
,,10,3c59x
))
171 $(eval
$(call KMOD_template
,NET_8139TOO
,net-8139too
,\
172 $(MODULES_DIR
)/kernel
/drivers
/net
/8139too.o \
173 $(MODULES_DIR
)/kernel
/drivers
/net
/mii.o \
174 ,CONFIG_VORTEX
,,10,mii
8139too
))
176 $(eval
$(call KMOD_template
,NET_AIRO
,net-airo
,\
177 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/airo.o \
178 ,CONFIG_AIRO
,,10,airo
))
180 $(eval
$(call KMOD_template
,NET_B44
,net-b44
,\
181 $(MODULES_DIR
)/kernel
/drivers
/net
/b44.o \
182 ,CONFIG_B44
,,10,b44
))
184 $(eval
$(call KMOD_template
,NET_HERMES
,net-hermes
,\
185 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/hermes.o \
186 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/orinoco.o \
187 ,CONFIG_HERMES
,,10,hermes orinoco
))
189 $(eval
$(call KMOD_template
,NET_HERMES_PCI
,net-hermes-pci
,\
190 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/orinoco_pci.o \
191 ,CONFIG_PCI_HERMES
,kmod-net-hermes
,11,orinoco_pci
))
193 $(eval
$(call KMOD_template
,NET_HERMES_PCI
,net-hermes-plx
,\
194 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/orinoco_plx.o \
195 ,CONFIG_PLX_HERMES
,kmod-net-hermes
,11,orinoco_plx
))
197 $(eval
$(call KMOD_template
,NET_NATSEMI
,net-natsemi
,\
198 $(MODULES_DIR
)/kernel
/drivers
/net
/natsemi.o \
199 ,CONFIG_NATSEMI
,,10,natsemi
))
201 $(eval
$(call KMOD_template
,NET_PRISM54
,net-prism54
,\
202 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/prism54
/prism54.o \
203 ,CONFIG_PRISM54
,,10,prism54
))
208 $(eval
$(call KMOD_template
,USB
,usb-core
,\
209 $(MODULES_DIR
)/kernel
/drivers
/usb
/usbcore.o \
210 ,CONFIG_USB
,,50,usbcore
))
212 $(eval
$(call KMOD_template
,USB_UHCI
,usb-uhci
,\
213 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/uhci.o \
214 ,CONFIG_USB_UHCI_ALT
,kmod-usb-core
,60,uhci
))
216 $(eval
$(call KMOD_template
,USB_OHCI
,usb-ohci
,\
217 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/usb-ohci.o \
218 ,CONFIG_USB_OHCI
,kmod-usb-core
,60,usb-ohci
))
220 $(eval
$(call KMOD_template
,USB2
,usb2
,\
221 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/ehci-hcd.o \
222 ,CONFIG_USB_EHCI_HCD
,kmod-usb-core
,60,ehci-hcd
))
224 $(eval
$(call KMOD_template
,USB_ACM
,usb-acm
,\
225 $(MODULES_DIR
)/kernel
/drivers
/usb
/acm.o \
228 $(eval
$(call KMOD_template
,USB_AUDIO
,usb-audio
,\
229 $(MODULES_DIR
)/kernel
/drivers
/usb
/audio.o \
230 ,CONFIG_USB_AUDIO
,kmod-soundcore kmod-usb-core
,61,audio
))
232 $(eval
$(call KMOD_template
,USB_PRINTER
,usb-printer
,\
233 $(MODULES_DIR
)/kernel
/drivers
/usb
/printer.o \
234 ,CONFIG_USB_PRINTER
,kmod-usb-core
,60,printer
))
236 $(eval
$(call KMOD_template
,USB_SERIAL
,usb-serial
,\
237 $(MODULES_DIR
)/kernel
/drivers
/usb
/serial
/usbserial.o \
238 ,CONFIG_USB_SERIAL
,kmod-usb-core
,60,usbserial
))
240 $(eval
$(call KMOD_template
,USB_SERIAL_BELKIN
,usb-serial-belkin
,\
241 $(MODULES_DIR
)/kernel
/drivers
/usb
/serial
/belkin_sa.o \
242 ,CONFIG_USB_SERIAL_BELKIN
,kmod-usb-serial
,61,belkin_sa
))
244 $(eval
$(call KMOD_template
,USB_SERIAL_FTDI
,usb-serial-ftdi
,\
245 $(MODULES_DIR
)/kernel
/drivers
/usb
/serial
/ftdi_sio.o \
246 ,CONFIG_USB_SERIAL_IR
,kmod-usb-serial
,61,ftdi_usb
))
248 $(eval
$(call KMOD_template
,USB_SERIAL_MCT_U232
,usb-serial-mct-u232
,\
249 $(MODULES_DIR
)/kernel
/drivers
/usb
/serial
/mct_u232.o \
250 ,CONFIG_USB_SERIAL_MCT_U232
,kmod-usb-serial
,61,mct_u232
))
252 $(eval
$(call KMOD_template
,USB_SERIAL_PL2303
,usb-serial-pl2303
,\
253 $(MODULES_DIR
)/kernel
/drivers
/usb
/serial
/pl2303.o \
254 ,CONFIG_USB_SERIAL_PL2303
,kmod-usb-serial
,61,pl2303
))
256 $(eval
$(call KMOD_template
,USB_STORAGE
,usb-storage
,\
257 $(MODULES_DIR
)/kernel
/drivers
/scsi
/*.o \
258 $(MODULES_DIR
)/kernel
/drivers
/usb
/storage
/*.o \
259 ,CONFIG_USB_STORAGE
,kmod-usb-core
,60,scsi_mod sd_mod usb-storage
))
264 $(eval
$(call KMOD_template
,AX25
,ax25
,\
265 $(MODULES_DIR
)/kernel
/net
/ax25
/ax25.o \
266 $(MODULES_DIR
)/kernel
/drivers
/net
/hamradio
/mkiss.o \
267 ,CONFIG_AX25
,,90,ax25 mkiss
))
269 $(eval
$(call KMOD_template
,BLUETOOTH
,bluetooth
,\
270 $(MODULES_DIR
)/kernel
/net
/bluetooth
/*.o \
271 $(MODULES_DIR
)/kernel
/net
/bluetooth
/rfcomm
/*.o \
272 $(MODULES_DIR
)/kernel
/drivers
/bluetooth
/*.o \
276 $(TARGETS
): $(PACKAGE_DIR
)
279 mkdir
-p
$(PACKAGE_DIR
)
281 $(LINUX_DIR
)/.unpacked
: $(DL_DIR
)/$(LINUX_SOURCE
)
282 -mkdir
-p
$(LINUX_BUILD_DIR
)
283 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
tar -C
$(LINUX_BUILD_DIR
) $(TAR_OPTIONS
) -
285 ln
-s
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(LINUX_DIR
)
286 touch
$(LINUX_DIR
)/.unpacked
288 $(LINUX_DIR
)/.patched
: $(LINUX_DIR
)/.unpacked
289 $(PATCH
) $(LINUX_DIR
) .
/patches
/generic
$(MAKE_TRACE
)
290 [ -d .
/patches
/$(BOARD
) ] && $(PATCH
) $(LINUX_DIR
) .
/patches
/$(BOARD
) $(MAKE_TRACE
)
291 touch
$(LINUX_DIR
)/.patched
293 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.patched
294 -cp
$(LINUX_KCONFIG
) $(LINUX_DIR
)/.config
295 $(SED
) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" \
296 $(LINUX_DIR
)/Makefile \
297 $(LINUX_DIR
)/arch
/*/Makefile
298 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
299 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) oldconfig
include/linux
/version.h
$(MAKE_TRACE
)
300 touch
$(LINUX_DIR
)/.configured
302 $(LINUX_DIR
)/.depend_done
: $(LINUX_DIR
)/.configured
303 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) dep
$(MAKE_TRACE
)
304 touch
$(LINUX_DIR
)/.depend_done
306 $(LINUX_DIR
)/vmlinux
: $(LINUX_DIR
)/.depend_done
307 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) PATH
=$(TARGET_PATH
) $(MAKE_TRACE
)
309 $(LINUX_KERNEL
): $(LINUX_DIR
)/vmlinux
310 $(TARGET_CROSS
)objcopy
-O binary
-R .reginfo
-R .note
-R .comment
-R .mdebug
-S
$< $@
$(MAKE_TRACE
)
311 touch
-c
$(LINUX_KERNEL
)
313 $(LINUX_DIR
)/.modules_done
: $(LINUX_KERNEL
) $(LINUX_IMAGE
)
314 rm -rf
$(LINUX_BUILD_DIR
)/modules
315 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) PATH
=$(TARGET_PATH
) modules
$(MAKE_TRACE
)
316 $(MAKE
) -C
$(LINUX_DIR
) DEPMOD
=true INSTALL_MOD_PATH
=$(LINUX_BUILD_DIR
)/modules modules_install
$(MAKE_TRACE
)
317 touch
$(LINUX_DIR
)/.modules_done
319 $(STAGING_DIR
)/include/linux
/version.h
: $(LINUX_DIR
)/.configured
320 mkdir
-p
$(STAGING_DIR
)/include
321 tar -ch
-C
$(LINUX_DIR
)/include -f
- linux |
tar -xf
- -C
$(STAGING_DIR
)/include/
322 tar -ch
-C
$(LINUX_DIR
)/include -f
- asm |
tar -xf
- -C
$(STAGING_DIR
)/include/
324 $(STAMP_DIR
)/.linux-compile
: $(LINUX_DIR
)/.modules_done
325 @mkdir
-p
$(STAMP_DIR
)
327 ln
-sf
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(LINUX_DIR
)
328 @
$(TRACE
) target
/linux
/package
329 $(MAKE
) -C
$(TOPDIR
)/target
/linux
/package \
334 $(TARGET_MODULES_DIR
):
335 -mkdir
-p
$(TARGET_MODULES_DIR
)
338 rm -rf
$(KERNEL_IDIR
)
339 mkdir
-p
$(KERNEL_IDIR
)/etc
340 $(SCRIPT_DIR
)/make-ipkg-dir.sh
$(KERNEL_IDIR
) ..
/control
/kernel.control
$(PKG_RELEASE
) $(ARCH
)
341 echo
'Package: kernel-$(LINUX_VERSION)-$(BOARD)' >> $(KERNEL_IDIR
)/CONTROL
/control
342 if
[ -f .
/config
/$(BOARD
).modules
]; then \
343 cp .
/config
/$(BOARD
).modules
$(KERNEL_IDIR
)/etc
/modules
; \
345 $(IPKG_BUILD
) $(KERNEL_IDIR
) $(LINUX_BUILD_DIR
) $(MAKE_TRACE
)
347 source
: $(DL_DIR
)/$(LINUX_SOURCE
)
348 prepare
: $(LINUX_DIR
)/.configured
350 $(MAKE
) $(STAMP_DIR
)/.linux-compile
$(MAKE_TRACE
)
352 install: compile
$(TARGET_MODULES_DIR
) $(KERNEL_IPKG
)
353 rm -rf
$(LINUX_BUILD_DIR
)/root
*
354 cp
-fpR
$(BUILD_DIR
)/root
$(LINUX_BUILD_DIR
)/
355 echo
-e
'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR
)/ipkg.conf
356 $(MAKE
) -C
$(TOPDIR
)/target
/linux
/package \
359 @
{ [ "$(INSTALL_TARGETS)" != "" ] && $(IPKG_KERNEL
) install $(INSTALL_TARGETS
) || true
; } $(MAKE_TRACE
)
362 rm -f
$(STAMP_DIR
)/.linux-compile
363 rm -f
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.modules_done
364 rm -f
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.drivers-unpacked
365 $(MAKE
) -C
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean $(MAKE_TRACE
)
366 rm -f
$(LINUX_KERNEL
) $(LINUX_IMAGE
)
370 if
[ -f
$(LINUX_KERNEL
) ]; then \
371 $(MAKE
) clean $(MAKE_TRACE
); \
373 $(MAKE
) compile
$(MAKE_TRACE
)
376 rm -f
$(STAMP_DIR
)/.linux-compile
377 rm -rf
$(LINUX_BUILD_DIR
)