1 #############################################################
4 # Linux 2.4 kernel target for the OpenWRT project
6 # patches are sorted by numbers
7 # 0xx needed patches for board, cpu, filesystem
8 # 1xx addon patches for new features (netfilter, ebtables, cifs,..)
9 # 2xx compile fixes, driver fixes
11 #############################################################
13 include $(TOPDIR
)/rules.mk
22 MODULES_SUBDIR
:=lib
/modules
/$(LINUX_VERSION
)
23 LINUX_KCONFIG
:=.
/config
/$(BOARD
)
24 LINUX_BUILD_DIR
:=$(BUILD_DIR
)/linux-2.4
-$(BOARD
)
25 LINUX_TARGET_DIR
:=$(LINUX_BUILD_DIR
)/root
26 LINUX_KERNEL
:=$(LINUX_BUILD_DIR
)/vmlinux
27 LINUX_KARCH
:=$(shell echo
$(ARCH
) | sed
-e
's/i[3-9]86/i386/' \
33 LINUX_BINARY_DRIVER_SITE
:= http
://openwrt.org
/downloads
/sources
/
34 LINUX_SOURCE
:= linux-
$(LINUX_VERSION
).
tar.bz2
35 LINUX_SOURCE_DIR
:= $(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
)
36 MODULES_DIR
:= $(LINUX_BUILD_DIR
)/modules
/$(MODULES_SUBDIR
)
37 TARGET_MODULES_DIR
:= $(TARGET_DIR
)/lib
/modules
/$(LINUX_VERSION
)
38 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
40 PKG_BUILD_DIR
:= $(LINUX_BUILD_DIR
)/linux-modules
43 KERNEL_IPKG
:=$(LINUX_BUILD_DIR
)/kernel-
$(LINUX_VERSION
)-$(BOARD
)_
$(PKG_RELEASE
)_
$(ARCH
).ipk
44 KERNEL_IDIR
:=$(LINUX_BUILD_DIR
)/kernel-ipkg
46 include $(LINUX_KCONFIG
)
48 INSTALL_TARGETS
:= $(KERNEL_IPKG
)
59 $(eval
$(call KMOD_template
,ATM
,atm
,\
60 $(MODULES_DIR
)/kernel
/net
/atm
/atm.o \
61 $(MODULES_DIR
)/kernel
/net
/atm
/br2684.o \
63 $(eval
$(call KMOD_template
,PPPOATM
,pppoatm
,\
64 $(MODULES_DIR
)/kernel
/net
/atm
/pppoatm.o \
66 $(eval
$(call KMOD_template
,USB_ACM
,usb-acm
,\
67 $(MODULES_DIR
)/kernel
/drivers
/usb
/acm.o \
69 $(eval
$(call KMOD_template
,B44
,b44
,\
70 $(MODULES_DIR
)/kernel
/drivers
/net
/b44.o \
72 $(eval
$(call KMOD_template
,BLUETOOTH
,bluetooth
,\
73 $(MODULES_DIR
)/kernel
/net
/bluetooth
/*.o \
74 $(MODULES_DIR
)/kernel
/drivers
/bluetooth
/*.o \
76 $(eval
$(call KMOD_template
,ARPT
,arptables
,\
77 $(MODULES_DIR
)/kernel
/net
/ipv4
/netfilter
/arp
*.o \
78 ,CONFIG_IP_NF_ARPTABLES
))
79 $(eval
$(call KMOD_template
,EBT
,ebtables
,\
80 $(MODULES_DIR
)/kernel
/net
/bridge
/netfilter
/*.o \
81 ,CONFIG_BRIDGE_NF_EBTABLES
))
82 $(eval
$(call KMOD_template
,IPTABLES_V4_EXTRA
,iptables-extra
,\
83 $(MODULES_DIR
)/kernel
/net
/ipv4
/netfilter
/ip
*.o \
85 $(eval
$(call KMOD_template
,IPTABLES_V6
,ip6tables
,\
86 $(MODULES_DIR
)/kernel
/net
/ipv6
/netfilter
/ip
*.o \
87 ,CONFIG_IP6_NF_IPTABLES
,kmod-ipv6
))
88 $(eval
$(call KMOD_template
,IPV6
,ipv6
,\
89 $(MODULES_DIR
)/kernel
/net
/ipv6
/ipv6.o \
90 ,CONFIG_IPV6
,,20,ipv6
))
91 $(eval
$(call KMOD_template
,CIFS
,cifs
,\
92 $(MODULES_DIR
)/kernel
/fs
/cifs
/cifs.o \
93 ,CONFIG_CIFS
,,30,cifs
))
94 $(eval
$(call KMOD_template
,NFS
,nfs
,\
95 $(MODULES_DIR
)/kernel
/fs
/lockd
/*.o \
96 $(MODULES_DIR
)/kernel
/fs
/nfs
/*.o \
97 $(MODULES_DIR
)/kernel
/net
/sunrpc
/*.o \
98 ,CONFIG_NFS_FS
,,30,sunrpc lockd nfs
))
99 $(eval
$(call KMOD_template
,USB
,usb-core
,\
100 $(MODULES_DIR
)/kernel
/drivers
/usb
/usbcore.o \
101 ,CONFIG_USB
,,50,usbcore
))
102 $(eval
$(call KMOD_template
,USB_UHCI
,usb-uhci
,\
103 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/uhci.o \
104 ,CONFIG_USB_UHCI_ALT
,kmod-usb-core
,60,uhci
))
105 $(eval
$(call KMOD_template
,USB_OHCI
,usb-ohci
,\
106 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/usb-ohci.o \
107 ,CONFIG_USB_OHCI
,kmod-usb-core
,60,ohci
))
108 $(eval
$(call KMOD_template
,USB2
,usb2
,\
109 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/ehci-hcd.o \
110 ,CONFIG_USB_EHCI_HCD
,kmod-usb-core
,60,ehci-hcd
))
111 $(eval
$(call KMOD_template
,USB_STORAGE
,usb-storage
,\
112 $(MODULES_DIR
)/kernel
/drivers
/scsi
/*.o \
113 $(MODULES_DIR
)/kernel
/drivers
/usb
/storage
/*.o \
114 ,CONFIG_USB_STORAGE
,kmod-usb-core
,60,scsi_mod sd_mod usb-storage
))
115 $(eval
$(call KMOD_template
,USB_PRINTER
,usb-printer
,\
116 $(MODULES_DIR
)/kernel
/drivers
/usb
/printer.o \
117 ,CONFIG_USB_PRINTER
,kmod-usb-core
,60,printer
))
118 $(eval
$(call KMOD_template
,IDE
,ide
,\
119 $(MODULES_DIR
)/kernel
/drivers
/ide
/*.o \
120 $(MODULES_DIR
)/kernel
/drivers
/ide
/*/*.o \
122 $(eval
$(call KMOD_template
,LOOP
,loop
,\
123 $(MODULES_DIR
)/kernel
/drivers
/block
/loop.o \
124 ,CONFIG_BLK_DEV_LOOP
,,20,loop
))
125 $(eval
$(call KMOD_template
,EXT2
,ext2
,\
126 $(MODULES_DIR
)/kernel
/fs
/ext2
/*.o \
127 ,CONFIG_EXT2_FS
,,30,ext2
))
128 $(eval
$(call KMOD_template
,EXT3
,ext3
,\
129 $(MODULES_DIR
)/kernel
/fs
/ext3
/*.o \
130 $(MODULES_DIR
)/kernel
/fs
/jbd
/*.o \
131 ,CONFIG_EXT3_FS
,,30,jbd ext3
))
132 $(eval
$(call KMOD_template
,XFS
,xfs
,\
133 $(MODULES_DIR
)/kernel
/fs
/xfs
/*.o \
134 ,CONFIG_XFS_FS
,,30,xfs
))
135 $(eval
$(call KMOD_template
,HFSPLUS
,hfsplus
,\
136 $(MODULES_DIR
)/kernel
/fs
/hfsplus
/*.o \
137 ,CONFIG_HFSPLUS_FS
,,30,hfsplus
))
138 $(eval
$(call KMOD_template
,VFAT
,vfat
,\
139 $(MODULES_DIR
)/kernel
/fs
/vfat
/vfat.o \
140 $(MODULES_DIR
)/kernel
/fs
/fat
/fat.o \
141 ,CONFIG_VFAT_FS
,,30,fat vfat
))
142 $(eval
$(call KMOD_template
,CRYPTO
,crypto
,\
143 $(MODULES_DIR
)/kernel
/crypto
/*.o \
145 $(eval
$(call KMOD_template
,PPP
,ppp
,\
146 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_async.o \
147 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_generic.o \
148 $(MODULES_DIR
)/kernel
/drivers
/net
/slhc.o \
150 $(eval
$(call KMOD_template
,MPPE
,mppe
,\
151 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_mppe_mppc.o \
152 ,CONFIG_PPP_MPPE_MPPC
))
153 $(eval
$(call KMOD_template
,PPPOE
,pppoe
,\
154 $(MODULES_DIR
)/kernel
/drivers
/net
/pppoe.o \
155 $(MODULES_DIR
)/kernel
/drivers
/net
/pppox.o \
157 $(eval
$(call KMOD_template
,TUN
,tun
,\
158 $(MODULES_DIR
)/kernel
/drivers
/net
/tun.o \
159 ,CONFIG_TUN
,,20,tun
))
160 $(eval
$(call KMOD_template
,GRE
,gre
,\
161 $(MODULES_DIR
)/kernel
/net
/ipv4
/ip_gre.o \
162 ,CONFIG_NET_IPGRE
,,30,ip_gre
))
163 $(eval
$(call KMOD_template
,SCHED
,sched
,\
164 $(MODULES_DIR
)/kernel
/net
/sched
/*.o \
167 $(TARGETS
): $(PACKAGE_DIR
)
170 mkdir
-p
$(PACKAGE_DIR
)
172 $(LINUX_DIR
)/.unpacked
: $(DL_DIR
)/$(LINUX_SOURCE
)
173 -mkdir
-p
$(LINUX_BUILD_DIR
)
174 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
tar -C
$(LINUX_BUILD_DIR
) $(TAR_OPTIONS
) -
176 ln
-s
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(LINUX_DIR
)
177 touch
$(LINUX_DIR
)/.unpacked
179 $(LINUX_DIR
)/.patched
: $(LINUX_DIR
)/.unpacked
180 $(PATCH
) $(LINUX_DIR
) .
/patches
/generic
181 [ -d .
/patches
/$(BOARD
) ] && $(PATCH
) $(LINUX_DIR
) .
/patches
/$(BOARD
)
182 touch
$(LINUX_DIR
)/.patched
184 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.patched
185 -cp
$(LINUX_KCONFIG
) $(LINUX_DIR
)/.config
186 $(SED
) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" \
187 $(LINUX_DIR
)/Makefile \
188 $(LINUX_DIR
)/arch
/mips
/Makefile
189 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
190 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) oldconfig
include/linux
/version.h
191 touch
$(LINUX_DIR
)/.configured
193 $(LINUX_DIR
)/.depend_done
: $(LINUX_DIR
)/.configured
194 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) dep
195 touch
$(LINUX_DIR
)/.depend_done
197 $(LINUX_DIR
)/vmlinux
: $(LINUX_DIR
)/.depend_done
198 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) PATH
=$(TARGET_PATH
)
200 $(LINUX_KERNEL
): $(LINUX_DIR
)/vmlinux
201 $(TARGET_CROSS
)objcopy
-O binary
-R .reginfo
-R .note
-R .comment
-R .mdebug
-S
$< $@
202 touch
-c
$(LINUX_KERNEL
)
204 $(LINUX_DIR
)/.modules_done
: $(LINUX_KERNEL
) $(LINUX_IMAGE
)
205 rm -rf
$(LINUX_BUILD_DIR
)/modules
206 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) PATH
=$(TARGET_PATH
) modules
207 $(MAKE
) -C
$(LINUX_DIR
) DEPMOD
=true INSTALL_MOD_PATH
=$(LINUX_BUILD_DIR
)/modules modules_install
208 touch
$(LINUX_DIR
)/.modules_done
210 $(STAGING_DIR
)/include/linux
/version.h
: $(LINUX_DIR
)/.configured
211 mkdir
-p
$(STAGING_DIR
)/include
212 tar -ch
-C
$(LINUX_DIR
)/include -f
- linux |
tar -xf
- -C
$(STAGING_DIR
)/include/
213 tar -ch
-C
$(LINUX_DIR
)/include -f
- asm |
tar -xf
- -C
$(STAGING_DIR
)/include/
215 $(TARGET_MODULES_DIR
):
216 -mkdir
-p
$(TARGET_MODULES_DIR
)
219 rm -rf
$(KERNEL_IDIR
)
220 mkdir
-p
$(KERNEL_IDIR
)/etc
221 $(SCRIPT_DIR
)/make-ipkg-dir.sh
$(KERNEL_IDIR
) ..
/control
/kernel.control
$(PKG_RELEASE
) $(ARCH
)
222 echo
'Package: kernel-$(LINUX_VERSION)-$(BOARD)' >> $(KERNEL_IDIR
)/CONTROL
/control
223 if
[ -f .
/config
/$(BOARD
).modules
]; then \
224 cp .
/config
/$(BOARD
).modules
$(KERNEL_IDIR
)/etc
/modules
; \
226 $(IPKG_BUILD
) $(KERNEL_IDIR
) $(LINUX_BUILD_DIR
)
228 source
: $(DL_DIR
)/$(LINUX_SOURCE
)
229 prepare
: $(LINUX_DIR
)/.configured
230 compile
: $(LINUX_DIR
)/.modules_done
$(TARGETS
)
231 ln
-sf
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(LINUX_DIR
)
232 $(MAKE
) -C
$(TOPDIR
)/target
/linux
/package \
234 TARGET_DIR
="$(LINUX_TARGET_DIR)" \
235 BUILD_DIR
="$(LINUX_BUILD_DIR)" \
236 KERNEL_DIR
="$(LINUX_SOURCE_DIR)" \
237 LINUX_VERSION
="$(LINUX_VERSION)" \
238 KERNEL_RELEASE
="$(PKG_RELEASE)"
240 install: compile
$(TARGET_MODULES_DIR
) $(KERNEL_IPKG
)
241 rm -rf
$(LINUX_BUILD_DIR
)/root
*
242 cp
-a
$(BUILD_DIR
)/root
$(LINUX_BUILD_DIR
)/
243 echo
-e
'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR
)/ipkg.conf
244 [ "$(INSTALL_TARGETS)" != "" ] && $(IPKG_KERNEL
) install $(INSTALL_TARGETS
) || true
247 rm -f
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.
{drivers-unpacked
,modules_done
}
248 $(MAKE
) -C
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean
249 rm -f
$(LINUX_KERNEL
) $(LINUX_IMAGE
)
253 if
[ -f
$(LINUX_KERNEL
) ]; then \
259 rm -rf
$(LINUX_BUILD_DIR
)