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
)
50 $(eval
$(call KMOD_template
,ATM
,atm
,\
51 $(MODULES_DIR
)/kernel
/net
/atm
/atm.ko \
52 $(MODULES_DIR
)/kernel
/net
/atm
/br2684.ko \
54 $(eval
$(call KMOD_template
,PPPOATM
,pppoatm
,\
55 $(MODULES_DIR
)/kernel
/net
/atm
/pppoatm.ko \
57 $(eval
$(call KMOD_template
,USB_ACM
,usb-acm
,\
58 $(MODULES_DIR
)/kernel
/drivers
/usb
/class
/cdc-acm.ko \
60 $(eval
$(call KMOD_template
,B44
,b44
,\
61 $(MODULES_DIR
)/kernel
/drivers
/net
/b44.ko \
63 $(eval
$(call KMOD_template
,BLUETOOTH
,bluetooth
,\
64 $(MODULES_DIR
)/kernel
/net
/bluetooth
/*.ko \
65 $(MODULES_DIR
)/kernel
/net
/bluetooth
/rfcomm
/*.ko \
66 $(MODULES_DIR
)/kernel
/drivers
/bluetooth
/*.ko \
68 $(eval
$(call KMOD_template
,ARPT
,arptables
,\
69 $(MODULES_DIR
)/kernel
/net
/ipv4
/netfilter
/arp
*.ko \
70 ,CONFIG_IP_NF_ARPTABLES
))
71 $(eval
$(call KMOD_template
,EBT
,ebtables
,\
72 $(MODULES_DIR
)/kernel
/net
/bridge
/netfilter
/*.ko \
73 ,CONFIG_BRIDGE_NF_EBTABLES
))
74 $(eval
$(call KMOD_template
,IPTABLES_V4_EXTRA
,iptables-extra
,\
75 $(MODULES_DIR
)/kernel
/net
/ipv4
/netfilter
/ip
*.ko \
77 $(eval
$(call KMOD_template
,IPTABLES_V6
,ip6tables
,\
78 $(MODULES_DIR
)/kernel
/net
/ipv6
/netfilter
/ip
*.ko \
79 ,CONFIG_IP6_NF_IPTABLES
,kmod-ipv6
))
80 $(eval
$(call KMOD_template
,IPV6
,ipv6
,\
81 $(MODULES_DIR
)/kernel
/net
/ipv6
/ipv6.ko \
82 ,CONFIG_IPV6
,,20,ipv6
))
83 $(eval
$(call KMOD_template
,CIFS
,cifs
,\
84 $(MODULES_DIR
)/kernel
/fs
/cifs
/cifs.ko \
85 ,CONFIG_CIFS
,,30,cifs
))
86 $(eval
$(call KMOD_template
,NFS
,nfs
,\
87 $(MODULES_DIR
)/kernel
/fs
/lockd
/*.ko \
88 $(MODULES_DIR
)/kernel
/fs
/nfs
/*.ko \
89 $(MODULES_DIR
)/kernel
/net
/sunrpc
/*.ko \
90 ,CONFIG_NFS_FS
,,30,sunrpc lockd nfs
))
91 $(eval
$(call KMOD_template
,USB
,usb-core
,\
92 $(MODULES_DIR
)/kernel
/drivers
/usb
/core
/usbcore.ko \
93 ,CONFIG_USB
,,50,usbcore
))
94 $(eval
$(call KMOD_template
,USB_UHCI
,usb-uhci
,\
95 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/uhci.ko \
96 ,CONFIG_USB_UHCI_ALT
,kmod-usb-core
,60,uhci
))
97 $(eval
$(call KMOD_template
,USB_OHCI
,usb-ohci
,\
98 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/ohci-hcd.ko \
99 ,CONFIG_USB_OHCI_HCD
,kmod-usb-core
,60,ohci-hcd
))
100 $(eval
$(call KMOD_template
,USB2
,usb2
,\
101 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/ehci-hcd.ko \
102 ,CONFIG_USB_EHCI_HCD
,kmod-usb-core
,60,ehci-hcd
))
103 $(eval
$(call KMOD_template
,USB_STORAGE
,usb-storage
,\
104 $(MODULES_DIR
)/kernel
/drivers
/scsi
/*.ko \
105 $(MODULES_DIR
)/kernel
/drivers
/usb
/storage
/*.ko \
106 ,CONFIG_USB_STORAGE
,kmod-usb-core
,60,scsi_mod sd_mod usb-storage
))
107 $(eval
$(call KMOD_template
,USB_PRINTER
,usb-printer
,\
108 $(MODULES_DIR
)/kernel
/drivers
/usb
/class
/usblp.ko \
109 ,CONFIG_USB_PRINTER
,kmod-usb-core
,60,usblp
))
110 $(eval
$(call KMOD_template
,IDE
,ide
,\
111 $(MODULES_DIR
)/kernel
/drivers
/ide
/*.ko \
112 $(MODULES_DIR
)/kernel
/drivers
/ide
/*/*.ko \
114 $(eval
$(call KMOD_template
,LOOP
,loop
,\
115 $(MODULES_DIR
)/kernel
/drivers
/block
/loop.ko \
116 ,CONFIG_BLK_DEV_LOOP
,,20,loop
))
117 $(eval
$(call KMOD_template
,EXT2
,ext2
,\
118 $(MODULES_DIR
)/kernel
/fs
/ext2
/*.ko \
119 ,CONFIG_EXT2_FS
,,30,ext2
))
120 $(eval
$(call KMOD_template
,EXT3
,ext3
,\
121 $(MODULES_DIR
)/kernel
/fs
/ext3
/*.ko \
122 $(MODULES_DIR
)/kernel
/fs
/jbd
/*.ko \
123 ,CONFIG_EXT3_FS
,,30,jbd ext3
))
124 $(eval
$(call KMOD_template
,XFS
,xfs
,\
125 $(MODULES_DIR
)/kernel
/fs
/xfs
/*.ko \
126 ,CONFIG_XFS_FS
,,30,xfs
))
127 $(eval
$(call KMOD_template
,HFSPLUS
,hfsplus
,\
128 $(MODULES_DIR
)/kernel
/fs
/hfsplus
/*.ko \
129 ,CONFIG_HFSPLUS_FS
,,30,hfsplus
))
130 $(eval
$(call KMOD_template
,VFAT
,vfat
,\
131 $(MODULES_DIR
)/kernel
/fs
/vfat
/vfat.ko \
132 $(MODULES_DIR
)/kernel
/fs
/fat
/fat.ko \
133 $(MODULES_DIR
)/kernel
/fs
/nls
/nls_base.ko \
134 ,CONFIG_VFAT_FS
,,30,fat vfat
))
135 $(eval
$(call KMOD_template
,NLS_BASE
,nls-base
,\
136 $(MODULES_DIR
)/kernel
/fs
/nls
/nls_base.ko \
137 ,CONFIG_NLS
,,20,nls_base
))
138 $(eval
$(call KMOD_template
,NLS_UTF8
,nls-utf8
,\
139 $(MODULES_DIR
)/kernel
/fs
/nls
/nls_utf8.ko \
140 ,CONFIG_NLS_UTF8
,,20,nls_utf8
))
141 $(eval
$(call KMOD_template
,NLS_ISO8859_1
,nls-iso8859-1
,\
142 $(MODULES_DIR
)/kernel
/fs
/nls
/nls_iso8859-1.ko \
143 ,CONFIG_NLS_ISO8859_1
,,20,nls_iso8859-1
))
144 $(eval
$(call KMOD_template
,NLS_CP437
,nls-cp437
,\
145 $(MODULES_DIR
)/kernel
/fs
/nls
/nls_cp437.ko \
146 ,CONFIG_NLS_CODEPAGE_437
,,20,nls_cp437
))
147 $(eval
$(call KMOD_template
,NLS_CP850
,nls-cp850
,\
148 $(MODULES_DIR
)/kernel
/fs
/nls
/nls_cp850.ko \
149 ,CONFIG_NLS_CODEPAGE_850
,,20,nls_cp850
))
150 $(eval
$(call KMOD_template
,CRYPTO
,crypto
,\
151 $(MODULES_DIR
)/kernel
/crypto
/*.ko \
153 $(eval
$(call KMOD_template
,PPP
,ppp
,\
154 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_async.ko \
155 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_generic.ko \
156 $(MODULES_DIR
)/kernel
/drivers
/net
/slhc.ko \
158 $(eval
$(call KMOD_template
,MPPE
,mppe
,\
159 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_mppe_mppc.ko \
160 ,CONFIG_PPP_MPPE_MPPC
))
161 $(eval
$(call KMOD_template
,PPPOE
,pppoe
,\
162 $(MODULES_DIR
)/kernel
/drivers
/net
/pppoe.ko \
163 $(MODULES_DIR
)/kernel
/drivers
/net
/pppox.ko \
165 $(eval
$(call KMOD_template
,TUN
,tun
,\
166 $(MODULES_DIR
)/kernel
/drivers
/net
/tun.ko \
167 ,CONFIG_TUN
,,20,tun
))
168 $(eval
$(call KMOD_template
,GRE
,gre
,\
169 $(MODULES_DIR
)/kernel
/net
/ipv4
/ip_gre.ko \
171 $(eval
$(call KMOD_template
,SCHED
,sched
,\
172 $(MODULES_DIR
)/kernel
/net
/sched
/*.ko \
175 $(TARGETS
): $(PACKAGE_DIR
)
178 mkdir
-p
$(PACKAGE_DIR
)
180 $(DL_DIR
)/$(LINUX_SOURCE
):
182 @
$(PKG_TRACE
) Downloading...
183 $(SCRIPT_DIR
)/download.pl
$(DL_DIR
) $(LINUX_SOURCE
) $(LINUX_KERNEL_MD5SUM
) $(LINUX_SITE
) $(MAKE_TRACE
)
185 $(LINUX_DIR
)/.unpacked
: $(DL_DIR
)/$(LINUX_SOURCE
)
186 @
$(PKG_TRACE
) Preparing...
187 -mkdir
-p
$(LINUX_BUILD_DIR
)
188 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
tar -C
$(LINUX_BUILD_DIR
) $(TAR_OPTIONS
) -
190 ln
-s
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(LINUX_DIR
)
191 touch
$(LINUX_DIR
)/.unpacked
193 $(LINUX_DIR
)/.patched
: $(LINUX_DIR
)/.unpacked
194 $(PATCH
) $(LINUX_DIR
) .
/patches
/generic
$(MAKE_TRACE
)
195 [ -d .
/patches
/$(BOARD
) ] && $(PATCH
) $(LINUX_DIR
) .
/patches
/$(BOARD
) $(MAKE_TRACE
)
196 touch
$(LINUX_DIR
)/.patched
198 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.patched
199 @
$(PKG_TRACE
) Configuring...
200 -cp
$(LINUX_KCONFIG
) $(LINUX_DIR
)/.config
201 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) oldconfig
$(MAKE_TRACE
)
202 touch
$(LINUX_DIR
)/.configured
204 $(LINUX_DIR
)/vmlinux
: $(LINUX_DIR
)/.configured
205 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
=$(TARGET_CROSS
) ARCH
=$(LINUX_KARCH
) PATH
=$(TARGET_PATH
) $(MAKE_TRACE
)
207 $(LINUX_KERNEL
): $(LINUX_DIR
)/vmlinux
208 $(TARGET_CROSS
)objcopy
-O binary
-R .reginfo
-R .note
-R .comment
-R .mdebug
-S
$< $@
$(MAKE_TRACE
)
209 touch
-c
$(LINUX_KERNEL
)
211 $(LINUX_DIR
)/.modules_done
: $(LINUX_KERNEL
) $(LINUX_IMAGE
)
212 rm -rf
$(LINUX_BUILD_DIR
)/modules
213 $(MAKE
) -C
$(LINUX_DIR
) CROSS_COMPILE
=$(TARGET_CROSS
) ARCH
=$(LINUX_KARCH
) PATH
=$(TARGET_PATH
) modules
$(MAKE_TRACE
)
214 $(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
)
215 touch
$(LINUX_DIR
)/.modules_done
217 $(STAGING_DIR
)/include/linux
/version.h
: $(LINUX_DIR
)/.configured
218 mkdir
-p
$(STAGING_DIR
)/include
219 tar -ch
-C
$(LINUX_DIR
)/include -f
- linux |
tar -xf
- -C
$(STAGING_DIR
)/include/
220 tar -ch
-C
$(LINUX_DIR
)/include -f
- asm |
tar -xf
- -C
$(STAGING_DIR
)/include/
222 $(TARGET_MODULES_DIR
):
223 -mkdir
-p
$(TARGET_MODULES_DIR
)
226 rm -rf
$(KERNEL_IDIR
)
227 mkdir
-p
$(KERNEL_IDIR
)/etc
228 $(SCRIPT_DIR
)/make-ipkg-dir.sh
$(KERNEL_IDIR
) ..
/control
/kernel.control
$(PKG_RELEASE
) $(ARCH
)
229 echo
'Package: kernel-$(LINUX_VERSION)-$(BOARD)' >> $(KERNEL_IDIR
)/CONTROL
/control
230 if
[ -f .
/config
/$(BOARD
).modules
]; then \
231 cp .
/config
/$(BOARD
).modules
$(KERNEL_IDIR
)/etc
/modules
; \
233 $(IPKG_BUILD
) $(KERNEL_IDIR
) $(LINUX_BUILD_DIR
)
235 $(STAMP_DIR
)/.linux-compile
: $(LINUX_DIR
)/.modules_done
236 @mkdir
-p
$(STAMP_DIR
)
240 source
: $(DL_DIR
)/$(LINUX_SOURCE
)
241 prepare
: $(LINUX_DIR
)/.configured
243 @
$(PKG_TRACE
) Compiling...
244 $(MAKE
) $(STAMP_DIR
)/.linux-compile
$(MAKE_TRACE
)
245 ln
-sf
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(LINUX_DIR
)
246 @
$(TRACE
) target
/linux
/package
247 $(MAKE
) -C
$(TOPDIR
)/target
/linux
/package \
251 install: compile
$(TARGET_MODULES_DIR
) $(KERNEL_IPKG
)
252 rm -rf
$(LINUX_BUILD_DIR
)/root
*
253 cp
-fpR
$(BUILD_DIR
)/root
$(LINUX_BUILD_DIR
)/
254 echo
-e
'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR
)/ipkg.conf
255 $(MAKE
) -C
$(TOPDIR
)/target
/linux
/package \
258 @
{ [ "$(INSTALL_TARGETS)" != "" ] && $(IPKG_KERNEL
) install $(INSTALL_TARGETS
) || true
} $(MAKE_TRACE
)
261 rm -f
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.modules_done
262 rm -f
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.drivers-unpacked
263 $(MAKE
) -C
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean
264 rm -f
$(LINUX_KERNEL
) $(LINUX_IMAGE
)
268 if
[ -f
$(LINUX_KERNEL
) ]; then \
274 @
$(PKG_TRACE
) Cleaning...
275 rm -f
$(STAMP_DIR
)/.linux-compile
276 rm -rf
$(LINUX_BUILD_DIR
)