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
17 MODULES_SUBDIR
:=lib
/modules
/$(LINUX_VERSION
)
18 LINUX_KCONFIG
:=.
/config
/$(BOARD
)
19 LINUX_BUILD_DIR
:=$(BUILD_DIR
)/linux-2.4
-$(BOARD
)
20 LINUX_TARGET_DIR
:=$(LINUX_BUILD_DIR
)/root
21 LINUX_KERNEL
:=$(LINUX_BUILD_DIR
)/vmlinux
22 LINUX_KARCH
:=$(shell echo
$(ARCH
) | sed
-e
's/i[3-9]86/i386/' \
28 LINUX_BINARY_DRIVER_SITE
:= http
://openwrt.org
/downloads
/sources
/
29 LINUX_SOURCE
:= linux-
$(LINUX_VERSION
).
tar.bz2
30 LINUX_SOURCE_DIR
:= $(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
)
31 MODULES_DIR
:= $(LINUX_BUILD_DIR
)/modules
/$(MODULES_SUBDIR
)
32 TARGET_MODULES_DIR
:= $(TARGET_DIR
)/lib
/modules
/$(LINUX_VERSION
)
33 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
35 PKG_BUILD_DIR
:= $(LINUX_BUILD_DIR
)/linux-modules
38 KERNEL_IPKG
:=$(LINUX_BUILD_DIR
)/kernel-
$(LINUX_VERSION
)-$(BOARD
)_
$(PKG_RELEASE
)_
$(ARCH
).ipk
39 KERNEL_IDIR
:=$(LINUX_BUILD_DIR
)/kernel-ipkg
41 KPKG_MAKEOPTS
:= IPKG
="$(IPKG_KERNEL)" \
43 TARGET_DIR
="$(LINUX_TARGET_DIR)" \
44 BUILD_DIR
="$(LINUX_BUILD_DIR)" \
45 KERNEL_DIR
="$(LINUX_SOURCE_DIR)" \
46 LINUX_VERSION
="$(LINUX_VERSION)" \
47 KERNEL_RELEASE
="$(PKG_RELEASE)"
49 include $(LINUX_KCONFIG
)
51 INSTALL_TARGETS
:= $(KERNEL_IPKG
)
58 ifeq ($(BOARD
),soekris
)
66 $(eval
$(call KMOD_template
,ATM
,atm
,\
67 $(MODULES_DIR
)/kernel
/net
/atm
/atm.o \
68 $(MODULES_DIR
)/kernel
/net
/atm
/br2684.o \
70 $(eval
$(call KMOD_template
,PPPOATM
,pppoatm
,\
71 $(MODULES_DIR
)/kernel
/net
/atm
/pppoatm.o \
73 $(eval
$(call KMOD_template
,USB_ACM
,usb-acm
,\
74 $(MODULES_DIR
)/kernel
/drivers
/usb
/acm.o \
76 $(eval
$(call KMOD_template
,B44
,b44
,\
77 $(MODULES_DIR
)/kernel
/drivers
/net
/b44.o \
79 $(eval
$(call KMOD_template
,BLUETOOTH
,bluetooth
,\
80 $(MODULES_DIR
)/kernel
/net
/bluetooth
/*.o \
81 $(MODULES_DIR
)/kernel
/drivers
/bluetooth
/*.o \
83 $(eval
$(call KMOD_template
,ARPT
,arptables
,\
84 $(MODULES_DIR
)/kernel
/net
/ipv4
/netfilter
/arp
*.o \
85 ,CONFIG_IP_NF_ARPTABLES
))
86 $(eval
$(call KMOD_template
,EBT
,ebtables
,\
87 $(MODULES_DIR
)/kernel
/net
/bridge
/netfilter
/*.o \
88 ,CONFIG_BRIDGE_NF_EBTABLES
))
89 $(eval
$(call KMOD_template
,IPTABLES_V4_EXTRA
,iptables-extra
,\
90 $(MODULES_DIR
)/kernel
/net
/ipv4
/netfilter
/ip
*.o \
92 $(eval
$(call KMOD_template
,IPTABLES_V6
,ip6tables
,\
93 $(MODULES_DIR
)/kernel
/net
/ipv6
/netfilter
/ip
*.o \
94 ,CONFIG_IP6_NF_IPTABLES
,kmod-ipv6
))
95 $(eval
$(call KMOD_template
,IPV6
,ipv6
,\
96 $(MODULES_DIR
)/kernel
/net
/ipv6
/ipv6.o \
97 ,CONFIG_IPV6
,,20,ipv6
))
98 $(eval
$(call KMOD_template
,CIFS
,cifs
,\
99 $(MODULES_DIR
)/kernel
/fs
/cifs
/cifs.o \
100 ,CONFIG_CIFS
,,30,cifs
))
101 $(eval
$(call KMOD_template
,NFS
,nfs
,\
102 $(MODULES_DIR
)/kernel
/fs
/lockd
/*.o \
103 $(MODULES_DIR
)/kernel
/fs
/nfs
/*.o \
104 $(MODULES_DIR
)/kernel
/net
/sunrpc
/*.o \
105 ,CONFIG_NFS_FS
,,30,sunrpc lockd nfs
))
106 $(eval
$(call KMOD_template
,USB
,usb-core
,\
107 $(MODULES_DIR
)/kernel
/drivers
/usb
/usbcore.o \
108 ,CONFIG_USB
,,50,usbcore
))
109 $(eval
$(call KMOD_template
,USB_UHCI
,usb-uhci
,\
110 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/uhci.o \
111 ,CONFIG_USB_UHCI_ALT
,kmod-usb-core
,60,uhci
))
112 $(eval
$(call KMOD_template
,USB_OHCI
,usb-ohci
,\
113 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/usb-ohci.o \
114 ,CONFIG_USB_OHCI
,kmod-usb-core
,60,ohci
))
115 $(eval
$(call KMOD_template
,USB2
,usb2
,\
116 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/ehci-hcd.o \
117 ,CONFIG_USB_EHCI_HCD
,kmod-usb-core
,60,ehci-hcd
))
118 $(eval
$(call KMOD_template
,USB_STORAGE
,usb-storage
,\
119 $(MODULES_DIR
)/kernel
/drivers
/scsi
/*.o \
120 $(MODULES_DIR
)/kernel
/drivers
/usb
/storage
/*.o \
121 ,CONFIG_USB_STORAGE
,kmod-usb-core
,60,scsi_mod sd_mod usb-storage
))
122 $(eval
$(call KMOD_template
,USB_PRINTER
,usb-printer
,\
123 $(MODULES_DIR
)/kernel
/drivers
/usb
/printer.o \
124 ,CONFIG_USB_PRINTER
,kmod-usb-core
,60,printer
))
125 $(eval
$(call KMOD_template
,IDE
,ide
,\
126 $(MODULES_DIR
)/kernel
/drivers
/ide
/*.o \
127 $(MODULES_DIR
)/kernel
/drivers
/ide
/*/*.o \
129 $(eval
$(call KMOD_template
,LOOP
,loop
,\
130 $(MODULES_DIR
)/kernel
/drivers
/block
/loop.o \
131 ,CONFIG_BLK_DEV_LOOP
,,20,loop
))
132 $(eval
$(call KMOD_template
,EXT2
,ext2
,\
133 $(MODULES_DIR
)/kernel
/fs
/ext2
/*.o \
134 ,CONFIG_EXT2_FS
,,30,ext2
))
135 $(eval
$(call KMOD_template
,EXT3
,ext3
,\
136 $(MODULES_DIR
)/kernel
/fs
/ext3
/*.o \
137 $(MODULES_DIR
)/kernel
/fs
/jbd
/*.o \
138 ,CONFIG_EXT3_FS
,,30,jbd ext3
))
139 $(eval
$(call KMOD_template
,XFS
,xfs
,\
140 $(MODULES_DIR
)/kernel
/fs
/xfs
/*.o \
141 ,CONFIG_XFS_FS
,,30,xfs
))
142 $(eval
$(call KMOD_template
,HFSPLUS
,hfsplus
,\
143 $(MODULES_DIR
)/kernel
/fs
/hfsplus
/*.o \
144 ,CONFIG_HFSPLUS_FS
,,30,hfsplus
))
145 $(eval
$(call KMOD_template
,VFAT
,vfat
,\
146 $(MODULES_DIR
)/kernel
/fs
/vfat
/vfat.o \
147 $(MODULES_DIR
)/kernel
/fs
/fat
/fat.o \
148 ,CONFIG_VFAT_FS
,,30,fat vfat
))
149 $(eval
$(call KMOD_template
,CRYPTO
,crypto
,\
150 $(MODULES_DIR
)/kernel
/crypto
/*.o \
152 $(eval
$(call KMOD_template
,PPP
,ppp
,\
153 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_async.o \
154 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_generic.o \
155 $(MODULES_DIR
)/kernel
/drivers
/net
/slhc.o \
157 $(eval
$(call KMOD_template
,MPPE
,mppe
,\
158 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_mppe_mppc.o \
159 ,CONFIG_PPP_MPPE_MPPC
))
160 $(eval
$(call KMOD_template
,PPPOE
,pppoe
,\
161 $(MODULES_DIR
)/kernel
/drivers
/net
/pppoe.o \
162 $(MODULES_DIR
)/kernel
/drivers
/net
/pppox.o \
164 $(eval
$(call KMOD_template
,TUN
,tun
,\
165 $(MODULES_DIR
)/kernel
/drivers
/net
/tun.o \
166 ,CONFIG_TUN
,,20,tun
))
167 $(eval
$(call KMOD_template
,GRE
,gre
,\
168 $(MODULES_DIR
)/kernel
/net
/ipv4
/ip_gre.o \
170 $(eval
$(call KMOD_template
,SCHED
,sched
,\
171 $(MODULES_DIR
)/kernel
/net
/sched
/*.o \
174 $(TARGETS
): $(PACKAGE_DIR
)
177 mkdir
-p
$(PACKAGE_DIR
)
179 $(LINUX_DIR
)/.unpacked
: $(DL_DIR
)/$(LINUX_SOURCE
)
180 -mkdir
-p
$(LINUX_BUILD_DIR
)
181 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
tar -C
$(LINUX_BUILD_DIR
) $(TAR_OPTIONS
) -
183 ln
-s
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(LINUX_DIR
)
184 touch
$(LINUX_DIR
)/.unpacked
186 $(LINUX_DIR
)/.patched
: $(LINUX_DIR
)/.unpacked
187 $(PATCH
) $(LINUX_DIR
) .
/patches
/generic
188 [ -d .
/patches
/$(BOARD
) ] && $(PATCH
) $(LINUX_DIR
) .
/patches
/$(BOARD
)
189 touch
$(LINUX_DIR
)/.patched
191 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.patched
192 -cp
$(LINUX_KCONFIG
) $(LINUX_DIR
)/.config
193 $(SED
) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" \
194 $(LINUX_DIR
)/Makefile \
195 $(LINUX_DIR
)/arch
/*/Makefile
196 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
197 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) oldconfig
include/linux
/version.h
198 touch
$(LINUX_DIR
)/.configured
200 $(LINUX_DIR
)/.depend_done
: $(LINUX_DIR
)/.configured
201 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) dep
202 touch
$(LINUX_DIR
)/.depend_done
204 $(LINUX_DIR
)/vmlinux
: $(LINUX_DIR
)/.depend_done
205 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) PATH
=$(TARGET_PATH
)
207 $(LINUX_KERNEL
): $(LINUX_DIR
)/vmlinux
208 $(TARGET_CROSS
)objcopy
-O binary
-R .reginfo
-R .note
-R .comment
-R .mdebug
-S
$< $@
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
) ARCH
=$(LINUX_KARCH
) PATH
=$(TARGET_PATH
) modules
214 $(MAKE
) -C
$(LINUX_DIR
) DEPMOD
=true INSTALL_MOD_PATH
=$(LINUX_BUILD_DIR
)/modules modules_install
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 source
: $(DL_DIR
)/$(LINUX_SOURCE
)
236 prepare
: $(LINUX_DIR
)/.configured
237 compile
: $(LINUX_DIR
)/.modules_done
$(TARGETS
)
238 ln
-sf
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(LINUX_DIR
)
239 $(MAKE
) -C
$(TOPDIR
)/target
/linux
/package \
243 install: compile
$(TARGET_MODULES_DIR
) $(KERNEL_IPKG
)
244 rm -rf
$(LINUX_BUILD_DIR
)/root
*
245 echo
-e
'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR
)/ipkg.conf
246 $(MAKE
) -C
$(TOPDIR
)/package \
247 TARGET_DIR
="$(LINUX_TARGET_DIR)" \
248 IPKG_CONF
="$(LINUX_BUILD_DIR)" \
251 $(MAKE
) -C
$(TOPDIR
)/target
/linux
/package \
254 [ "$(INSTALL_TARGETS)" != "" ] && $(IPKG_KERNEL
) install $(INSTALL_TARGETS
) || true
257 rm -f
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.modules_done
258 rm -f
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.drivers-unpacked
259 $(MAKE
) -C
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean
260 rm -f
$(LINUX_KERNEL
) $(LINUX_IMAGE
)
264 if
[ -f
$(LINUX_KERNEL
) ]; then \
270 rm -rf
$(LINUX_BUILD_DIR
)