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
,USB_ACM
,usb-acm
,\
61 $(MODULES_DIR
)/kernel
/drivers
/usb
/acm.o \
63 $(eval
$(call KMOD_template
,B44
,b44
,\
64 $(MODULES_DIR
)/kernel
/drivers
/net
/b44.o \
66 $(eval
$(call KMOD_template
,BLUETOOTH
,bluetooth
,\
67 $(MODULES_DIR
)/kernel
/net
/bluetooth
/*.o \
68 $(MODULES_DIR
)/kernel
/net
/bluetooth
/rfcomm
/*.o \
69 $(MODULES_DIR
)/kernel
/drivers
/bluetooth
/*.o \
71 $(eval
$(call KMOD_template
,ARPT
,arptables
,\
72 $(MODULES_DIR
)/kernel
/net
/ipv4
/netfilter
/arp
*.o \
73 ,CONFIG_IP_NF_ARPTABLES
))
74 $(eval
$(call KMOD_template
,EBT
,ebtables
,\
75 $(MODULES_DIR
)/kernel
/net
/bridge
/netfilter
/*.o \
76 ,CONFIG_BRIDGE_NF_EBTABLES
))
77 $(eval
$(call KMOD_template
,IPTABLES_V4_EXTRA
,iptables-extra
,\
78 $(MODULES_DIR
)/kernel
/net
/ipv4
/netfilter
/ip
*.o \
80 $(eval
$(call KMOD_template
,IPTABLES_V6
,ip6tables
,\
81 $(MODULES_DIR
)/kernel
/net
/ipv6
/netfilter
/ip
*.o \
82 ,CONFIG_IP6_NF_IPTABLES
,kmod-ipv6
))
83 $(eval
$(call KMOD_template
,IPV6
,ipv6
,\
84 $(MODULES_DIR
)/kernel
/net
/ipv6
/ipv6.o \
85 ,CONFIG_IPV6
,,20,ipv6
))
86 $(eval
$(call KMOD_template
,CIFS
,cifs
,\
87 $(MODULES_DIR
)/kernel
/fs
/cifs
/cifs.o \
88 ,CONFIG_CIFS
,,30,cifs
))
89 $(eval
$(call KMOD_template
,NFS
,nfs
,\
90 $(MODULES_DIR
)/kernel
/fs
/lockd
/*.o \
91 $(MODULES_DIR
)/kernel
/fs
/nfs
/*.o \
92 $(MODULES_DIR
)/kernel
/net
/sunrpc
/*.o \
93 ,CONFIG_NFS_FS
,,30,sunrpc lockd nfs
))
94 $(eval
$(call KMOD_template
,SOUNDCORE
,soundcore
,\
95 $(MODULES_DIR
)/kernel
/drivers
/sound
/soundcore.o \
96 ,CONFIG_SOUND
,,30,soundcore
))
97 $(eval
$(call KMOD_template
,USB
,usb-core
,\
98 $(MODULES_DIR
)/kernel
/drivers
/usb
/usbcore.o \
99 ,CONFIG_USB
,,50,usbcore
))
100 $(eval
$(call KMOD_template
,USB_UHCI
,usb-uhci
,\
101 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/uhci.o \
102 ,CONFIG_USB_UHCI_ALT
,kmod-usb-core
,60,uhci
))
103 $(eval
$(call KMOD_template
,USB_OHCI
,usb-ohci
,\
104 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/usb-ohci.o \
105 ,CONFIG_USB_OHCI
,kmod-usb-core
,60,usb-ohci
))
106 $(eval
$(call KMOD_template
,USB2
,usb2
,\
107 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/ehci-hcd.o \
108 ,CONFIG_USB_EHCI_HCD
,kmod-usb-core
,60,ehci-hcd
))
110 $(eval
$(call KMOD_template
,USB_SERIAL
,usb-serial
,\
111 $(MODULES_DIR
)/kernel
/drivers
/usb
/serial
/usbserial.o \
112 ,CONFIG_USB_SERIAL
,kmod-usb-core
,60,usbserial
))
113 $(eval
$(call KMOD_template
,USB_SERIAL_BELKIN
,usb-serial-belkin
,\
114 $(MODULES_DIR
)/kernel
/drivers
/usb
/serial
/belkin_sa.o \
115 ,CONFIG_USB_SERIAL_BELKIN
,kmod-usb-serial
,61,belkin_sa
))
116 $(eval
$(call KMOD_template
,USB_SERIAL_FTDI
,usb-serial-ftdi
,\
117 $(MODULES_DIR
)/kernel
/drivers
/usb
/serial
/ftdi_sio.o \
118 ,CONFIG_USB_SERIAL_IR
,kmod-usb-serial
,61,ftdi_usb
))
119 $(eval
$(call KMOD_template
,USB_SERIAL_MCT_U232
,usb-serial-mct-u232
,\
120 $(MODULES_DIR
)/kernel
/drivers
/usb
/serial
/mct_u232.o \
121 ,CONFIG_USB_SERIAL_MCT_U232
,kmod-usb-serial
,61,mct_u232
))
122 $(eval
$(call KMOD_template
,USB_SERIAL_PL2303
,usb-serial-pl2303
,\
123 $(MODULES_DIR
)/kernel
/drivers
/usb
/serial
/pl2303.o \
124 ,CONFIG_USB_SERIAL_PL2303
,kmod-usb-serial
,61,pl2303
))
126 $(eval
$(call KMOD_template
,USB_STORAGE
,usb-storage
,\
127 $(MODULES_DIR
)/kernel
/drivers
/scsi
/*.o \
128 $(MODULES_DIR
)/kernel
/drivers
/usb
/storage
/*.o \
129 ,CONFIG_USB_STORAGE
,kmod-usb-core
,60,scsi_mod sd_mod usb-storage
))
130 $(eval
$(call KMOD_template
,USB_PRINTER
,usb-printer
,\
131 $(MODULES_DIR
)/kernel
/drivers
/usb
/printer.o \
132 ,CONFIG_USB_PRINTER
,kmod-usb-core
,60,printer
))
133 $(eval
$(call KMOD_template
,USB_AUDIO
,usb-audio
,\
134 $(MODULES_DIR
)/kernel
/drivers
/usb
/audio.o \
135 ,CONFIG_USB_AUDIO
,kmod-soundcore kmod-usb-core
,61,audio
))
136 $(eval
$(call KMOD_template
,IDE
,ide
,\
137 $(MODULES_DIR
)/kernel
/drivers
/ide
/*.o \
138 $(MODULES_DIR
)/kernel
/drivers
/ide
/*/*.o \
140 $(eval
$(call KMOD_template
,LOOP
,loop
,\
141 $(MODULES_DIR
)/kernel
/drivers
/block
/loop.o \
142 ,CONFIG_BLK_DEV_LOOP
,,20,loop
))
143 $(eval
$(call KMOD_template
,EXT2
,ext2
,\
144 $(MODULES_DIR
)/kernel
/fs
/ext2
/*.o \
145 ,CONFIG_EXT2_FS
,,30,ext2
))
146 $(eval
$(call KMOD_template
,EXT3
,ext3
,\
147 $(MODULES_DIR
)/kernel
/fs
/ext3
/*.o \
148 $(MODULES_DIR
)/kernel
/fs
/jbd
/*.o \
149 ,CONFIG_EXT3_FS
,,30,jbd ext3
))
150 $(eval
$(call KMOD_template
,XFS
,xfs
,\
151 $(MODULES_DIR
)/kernel
/fs
/xfs
/*.o \
152 ,CONFIG_XFS_FS
,,30,xfs
))
153 $(eval
$(call KMOD_template
,HFSPLUS
,hfsplus
,\
154 $(MODULES_DIR
)/kernel
/fs
/hfsplus
/*.o \
155 ,CONFIG_HFSPLUS_FS
,,30,hfsplus
))
156 $(eval
$(call KMOD_template
,VFAT
,vfat
,\
157 $(MODULES_DIR
)/kernel
/fs
/vfat
/vfat.o \
158 $(MODULES_DIR
)/kernel
/fs
/fat
/fat.o \
159 ,CONFIG_VFAT_FS
,,30,fat vfat
))
160 ifneq ($(wildcard $(MODULES_DIR
)/kernel
/crypto
/*.o
),)
163 $(eval
$(call KMOD_template
,CRYPTO
,crypto
,\
164 $(MODULES_DIR
)/kernel
/crypto
/*.o \
166 $(eval
$(call KMOD_template
,PPP
,ppp
,\
167 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_async.o \
168 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_generic.o \
169 $(MODULES_DIR
)/kernel
/drivers
/net
/slhc.o \
170 $(MODULES_DIR
)/kernel
/drivers
/net
/pppox.o \
172 $(eval
$(call KMOD_template
,MPPE
,mppe
,\
173 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_mppe_mppc.o \
174 ,CONFIG_PPP_MPPE_MPPC
))
175 $(eval
$(call KMOD_template
,PPPOE
,pppoe
,\
176 $(MODULES_DIR
)/kernel
/drivers
/net
/pppoe.o \
178 $(eval
$(call KMOD_template
,TUN
,tun
,\
179 $(MODULES_DIR
)/kernel
/drivers
/net
/tun.o \
180 ,CONFIG_TUN
,,20,tun
))
181 $(eval
$(call KMOD_template
,GRE
,gre
,\
182 $(MODULES_DIR
)/kernel
/net
/ipv4
/ip_gre.o \
184 ifneq ($(wildcard $(MODULES_DIR
)/kernel
/net
/sched
/*.o
),)
187 $(eval
$(call KMOD_template
,SCHED
,sched
,\
188 $(MODULES_DIR
)/kernel
/net
/sched
/*.o \
191 $(eval
$(call KMOD_template
,VIDEODEV
,videodev
,\
192 $(MODULES_DIR
)/kernel
/drivers
/media
/video
/videodev.o \
193 ,CONFIG_VIDEO_DEV
,,62,videodev
))
195 $(eval
$(call KMOD_template
,PWC
,pwc
,\
196 $(MODULES_DIR
)/kernel
/drivers
/usb
/pwc.o \
197 ,CONFIG_USB_PWC
,kmod-videodev
,63,pwc
))
199 $(eval
$(call KMOD_template
,AX25
,ax25
,\
200 $(MODULES_DIR
)/kernel
/net
/ax25
/ax25.o \
201 $(MODULES_DIR
)/kernel
/drivers
/net
/hamradio
/mkiss.o \
202 ,CONFIG_AX25
,,90,ax25 mkiss
))
204 $(eval
$(call KMOD_template
,NET_3C59X
,net-3c59x
,\
205 $(MODULES_DIR
)/kernel
/drivers
/net
/3c59x.o \
206 ,CONFIG_VORTEX
,,10,3c59x
))
208 $(eval
$(call KMOD_template
,NET_8139TOO
,net-8139too
,\
209 $(MODULES_DIR
)/kernel
/drivers
/net
/8139too.o \
210 $(MODULES_DIR
)/kernel
/drivers
/net
/mii.o \
211 ,CONFIG_VORTEX
,,10,mii
8139too
))
213 $(eval
$(call KMOD_template
,NET_AIRO
,net-airo
,\
214 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/airo.o \
215 ,CONFIG_AIRO
,,10,airo
))
217 $(eval
$(call KMOD_template
,NET_HERMES
,net-hermes
,\
218 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/hermes.o \
219 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/orinoco.o \
220 ,CONFIG_HERMES
,,10,hermes orinoco
))
222 $(eval
$(call KMOD_template
,NET_HERMES_PCI
,net-hermes-pci
,\
223 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/orinoco_pci.o \
224 ,CONFIG_PCI_HERMES
,kmod-net-hermes
,11,orinoco_pci
))
226 $(eval
$(call KMOD_template
,NET_HERMES_PCI
,net-hermes-plx
,\
227 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/orinoco_plx.o \
228 ,CONFIG_PLX_HERMES
,kmod-net-hermes
,11,orinoco_plx
))
230 $(eval
$(call KMOD_template
,NET_NATSEMI
,net-natsemi
,\
231 $(MODULES_DIR
)/kernel
/drivers
/net
/natsemi.o \
232 ,CONFIG_NATSEMI
,,10,natsemi
))
234 $(eval
$(call KMOD_template
,NET_PRISM54
,net-prism54
,\
235 $(MODULES_DIR
)/kernel
/drivers
/net
/wireless
/prism54
/prism54.o \
236 ,CONFIG_PRISM54
,,10,prism54
))
238 $(TARGETS
): $(PACKAGE_DIR
)
241 mkdir
-p
$(PACKAGE_DIR
)
243 $(LINUX_DIR
)/.unpacked
: $(DL_DIR
)/$(LINUX_SOURCE
)
244 -mkdir
-p
$(LINUX_BUILD_DIR
)
245 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
tar -C
$(LINUX_BUILD_DIR
) $(TAR_OPTIONS
) -
247 ln
-s
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(LINUX_DIR
)
248 touch
$(LINUX_DIR
)/.unpacked
250 $(LINUX_DIR
)/.patched
: $(LINUX_DIR
)/.unpacked
251 $(PATCH
) $(LINUX_DIR
) .
/patches
/generic
$(MAKE_TRACE
)
252 [ -d .
/patches
/$(BOARD
) ] && $(PATCH
) $(LINUX_DIR
) .
/patches
/$(BOARD
) $(MAKE_TRACE
)
253 touch
$(LINUX_DIR
)/.patched
255 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.patched
256 -cp
$(LINUX_KCONFIG
) $(LINUX_DIR
)/.config
257 $(SED
) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" \
258 $(LINUX_DIR
)/Makefile \
259 $(LINUX_DIR
)/arch
/*/Makefile
260 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
261 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) oldconfig
include/linux
/version.h
$(MAKE_TRACE
)
262 touch
$(LINUX_DIR
)/.configured
264 $(LINUX_DIR
)/.depend_done
: $(LINUX_DIR
)/.configured
265 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) dep
$(MAKE_TRACE
)
266 touch
$(LINUX_DIR
)/.depend_done
268 $(LINUX_DIR
)/vmlinux
: $(LINUX_DIR
)/.depend_done
269 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) PATH
=$(TARGET_PATH
) $(MAKE_TRACE
)
271 $(LINUX_KERNEL
): $(LINUX_DIR
)/vmlinux
272 $(TARGET_CROSS
)objcopy
-O binary
-R .reginfo
-R .note
-R .comment
-R .mdebug
-S
$< $@
$(MAKE_TRACE
)
273 touch
-c
$(LINUX_KERNEL
)
275 $(LINUX_DIR
)/.modules_done
: $(LINUX_KERNEL
) $(LINUX_IMAGE
)
276 rm -rf
$(LINUX_BUILD_DIR
)/modules
277 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) PATH
=$(TARGET_PATH
) modules
$(MAKE_TRACE
)
278 $(MAKE
) -C
$(LINUX_DIR
) DEPMOD
=true INSTALL_MOD_PATH
=$(LINUX_BUILD_DIR
)/modules modules_install
$(MAKE_TRACE
)
279 touch
$(LINUX_DIR
)/.modules_done
281 $(STAGING_DIR
)/include/linux
/version.h
: $(LINUX_DIR
)/.configured
282 mkdir
-p
$(STAGING_DIR
)/include
283 tar -ch
-C
$(LINUX_DIR
)/include -f
- linux |
tar -xf
- -C
$(STAGING_DIR
)/include/
284 tar -ch
-C
$(LINUX_DIR
)/include -f
- asm |
tar -xf
- -C
$(STAGING_DIR
)/include/
286 $(STAMP_DIR
)/.linux-compile
: $(LINUX_DIR
)/.modules_done
287 @mkdir
-p
$(STAMP_DIR
)
289 ln
-sf
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(LINUX_DIR
)
290 @
$(TRACE
) target
/linux
/package
291 $(MAKE
) -C
$(TOPDIR
)/target
/linux
/package \
296 $(TARGET_MODULES_DIR
):
297 -mkdir
-p
$(TARGET_MODULES_DIR
)
300 rm -rf
$(KERNEL_IDIR
)
301 mkdir
-p
$(KERNEL_IDIR
)/etc
302 $(SCRIPT_DIR
)/make-ipkg-dir.sh
$(KERNEL_IDIR
) ..
/control
/kernel.control
$(PKG_RELEASE
) $(ARCH
)
303 echo
'Package: kernel-$(LINUX_VERSION)-$(BOARD)' >> $(KERNEL_IDIR
)/CONTROL
/control
304 if
[ -f .
/config
/$(BOARD
).modules
]; then \
305 cp .
/config
/$(BOARD
).modules
$(KERNEL_IDIR
)/etc
/modules
; \
307 $(IPKG_BUILD
) $(KERNEL_IDIR
) $(LINUX_BUILD_DIR
) $(MAKE_TRACE
)
309 source
: $(DL_DIR
)/$(LINUX_SOURCE
)
310 prepare
: $(LINUX_DIR
)/.configured
312 $(MAKE
) $(STAMP_DIR
)/.linux-compile
$(MAKE_TRACE
)
314 install: compile
$(TARGET_MODULES_DIR
) $(KERNEL_IPKG
)
315 rm -rf
$(LINUX_BUILD_DIR
)/root
*
316 cp
-fpR
$(BUILD_DIR
)/root
$(LINUX_BUILD_DIR
)/
317 echo
-e
'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR
)/ipkg.conf
318 $(MAKE
) -C
$(TOPDIR
)/target
/linux
/package \
321 @
{ [ "$(INSTALL_TARGETS)" != "" ] && $(IPKG_KERNEL
) install $(INSTALL_TARGETS
) || true
; } $(MAKE_TRACE
)
324 @
$(PKG_TRACE
) Cleaning...
325 rm -f
$(STAMP_DIR
)/.linux-compile
326 rm -f
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.modules_done
327 rm -f
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.drivers-unpacked
328 $(MAKE
) -C
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean $(MAKE_TRACE
)
329 rm -f
$(LINUX_KERNEL
) $(LINUX_IMAGE
)
333 if
[ -f
$(LINUX_KERNEL
) ]; then \
334 $(MAKE
) clean $(MAKE_TRACE
); \
336 $(MAKE
) compile
$(MAKE_TRACE
)
339 @
$(PKG_TRACE
) Cleaning...
340 rm -f
$(STAMP_DIR
)/.linux-compile
341 rm -rf
$(LINUX_BUILD_DIR
)