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
)
56 $(eval
$(call KMOD_template
,SANGAM_ATM
,sangam-atm
,\
57 $(MODULES_DIR
)/kernel
/drivers
/atm
/tiatm.o \
58 ,CONFIG_MIPS_SANGAM_ATM
))
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
,CPMAC
,cpmac
,\
67 $(MODULES_DIR
)/kernel
/drivers
/net
/avalanche_cpmac
/avalanche_cpmac.o \
68 ,CONFIG_MIPS_AVALANCHE_CPMAC
))
69 $(eval
$(call KMOD_template
,USB_ACM
,usb-acm
,\
70 $(MODULES_DIR
)/kernel
/drivers
/usb
/acm.o \
72 $(eval
$(call KMOD_template
,B44
,b44
,\
73 $(MODULES_DIR
)/kernel
/drivers
/net
/b44.o \
75 $(eval
$(call KMOD_template
,ARPT
,arptables
,\
76 $(MODULES_DIR
)/kernel
/net
/ipv4
/netfilter
/arp
*.o \
77 ,CONFIG_IP_NF_ARPTABLES
))
78 $(eval
$(call KMOD_template
,EBT
,ebtables
,\
79 $(MODULES_DIR
)/kernel
/net
/bridge
/netfilter
/*.o \
80 ,CONFIG_BRIDGE_NF_EBTABLES
))
81 $(eval
$(call KMOD_template
,IPTABLES_V4_EXTRA
,iptables-extra
,\
82 $(MODULES_DIR
)/kernel
/net
/ipv4
/netfilter
/ip
*.o \
84 $(eval
$(call KMOD_template
,IPTABLES_V6
,ip6tables
,\
85 $(MODULES_DIR
)/kernel
/net
/ipv6
/netfilter
/ip
*.o \
86 ,CONFIG_IP6_NF_IPTABLES
,kmod-ipv6
))
87 $(eval
$(call KMOD_template
,IPV6
,ipv6
,\
88 $(MODULES_DIR
)/kernel
/net
/ipv6
/ipv6.o \
90 $(eval
$(call KMOD_template
,CIFS
,cifs
,\
91 $(MODULES_DIR
)/kernel
/fs
/cifs
/cifs.o \
93 $(eval
$(call KMOD_template
,NFS
,nfs
,\
94 $(MODULES_DIR
)/kernel
/fs
/lockd
/*.o \
95 $(MODULES_DIR
)/kernel
/fs
/nfs
/*.o \
96 $(MODULES_DIR
)/kernel
/net
/sunrpc
/*.o \
98 $(eval
$(call KMOD_template
,USB
,usb-core
,\
99 $(MODULES_DIR
)/kernel
/drivers
/usb
/usbcore.o \
101 $(eval
$(call KMOD_template
,USB_UHCI
,usb-uhci
,\
102 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/uhci.o \
103 ,CONFIG_USB_UHCI_ALT
,kmod-usb-core
))
104 $(eval
$(call KMOD_template
,USB_OHCI
,usb-ohci
,\
105 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/usb-ohci.o \
106 ,CONFIG_USB_OHCI
,kmod-usb-core
))
107 $(eval
$(call KMOD_template
,USB2
,usb2
,\
108 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/ehci-hcd.o \
109 ,CONFIG_USB_EHCI_HCD
,kmod-usb-core
))
110 $(eval
$(call KMOD_template
,USB_STORAGE
,usb-storage
,\
111 $(MODULES_DIR
)/kernel
/drivers
/scsi
/*.o \
112 $(MODULES_DIR
)/kernel
/drivers
/usb
/storage
/*.o \
113 ,CONFIG_USB_STORAGE
))
114 $(eval
$(call KMOD_template
,USB_PRINTER
,usb-printer
,\
115 $(MODULES_DIR
)/kernel
/drivers
/usb
/printer.o \
116 ,CONFIG_USB_PRINTER
))
117 $(eval
$(call KMOD_template
,IDE
,ide
,\
118 $(MODULES_DIR
)/kernel
/drivers
/ide
/*.o \
119 $(MODULES_DIR
)/kernel
/drivers
/ide
/*/*.o \
121 $(eval
$(call KMOD_template
,EXT2
,ext2
,\
122 $(MODULES_DIR
)/kernel
/fs
/ext2
/*.o \
124 $(eval
$(call KMOD_template
,EXT3
,ext3
,\
125 $(MODULES_DIR
)/kernel
/fs
/ext3
/*.o \
126 $(MODULES_DIR
)/kernel
/fs
/jbd
/*.o \
128 $(eval
$(call KMOD_template
,XFS
,xfs
,\
129 $(MODULES_DIR
)/kernel
/fs
/xfs
/*.o \
131 $(eval
$(call KMOD_template
,HFSPLUS
,hfsplus
,\
132 $(MODULES_DIR
)/kernel
/fs
/hfsplus
/*.o \
134 $(eval
$(call KMOD_template
,VFAT
,vfat
,\
135 $(MODULES_DIR
)/kernel
/fs
/vfat
/vfat.o \
136 $(MODULES_DIR
)/kernel
/fs
/fat
/fat.o \
138 $(eval
$(call KMOD_template
,CRYPTO
,crypto
,\
139 $(MODULES_DIR
)/kernel
/crypto
/*.o \
141 $(eval
$(call KMOD_template
,PPP
,ppp
,\
142 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_async.o \
143 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_generic.o \
144 $(MODULES_DIR
)/kernel
/drivers
/net
/slhc.o \
146 $(eval
$(call KMOD_template
,MPPE
,mppe
,\
147 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_mppe_mppc.o \
148 ,CONFIG_PPP_MPPE_MPPC
))
149 $(eval
$(call KMOD_template
,PPPOE
,pppoe
,\
150 $(MODULES_DIR
)/kernel
/drivers
/net
/pppoe.o \
151 $(MODULES_DIR
)/kernel
/drivers
/net
/pppox.o \
153 $(eval
$(call KMOD_template
,TUN
,tun
,\
154 $(MODULES_DIR
)/kernel
/drivers
/net
/tun.o \
156 $(eval
$(call KMOD_template
,GRE
,gre
,\
157 $(MODULES_DIR
)/kernel
/net
/ipv4
/ip_gre.o \
159 $(eval
$(call KMOD_template
,SCHED
,sched
,\
160 $(MODULES_DIR
)/kernel
/net
/sched
/*.o \
163 $(TARGETS
): $(PACKAGE_DIR
)
166 mkdir
-p
$(PACKAGE_DIR
)
168 $(LINUX_DIR
)/.unpacked
: $(DL_DIR
)/$(LINUX_SOURCE
)
169 -mkdir
-p
$(LINUX_BUILD_DIR
)
170 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
tar -C
$(LINUX_BUILD_DIR
) $(TAR_OPTIONS
) -
172 ln
-s
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(LINUX_DIR
)
173 touch
$(LINUX_DIR
)/.unpacked
175 $(LINUX_DIR
)/.patched
: $(LINUX_DIR
)/.unpacked
176 $(PATCH
) $(LINUX_DIR
) .
/patches
/generic
177 [ -d .
/patches
/$(BOARD
) ] && $(PATCH
) $(LINUX_DIR
) .
/patches
/$(BOARD
)
178 touch
$(LINUX_DIR
)/.patched
180 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.patched
181 -cp
$(LINUX_KCONFIG
) $(LINUX_DIR
)/.config
182 $(SED
) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" \
183 $(LINUX_DIR
)/Makefile \
184 $(LINUX_DIR
)/arch
/mips
/Makefile
185 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
186 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) oldconfig
include/linux
/version.h
187 touch
$(LINUX_DIR
)/.configured
189 $(LINUX_DIR
)/.depend_done
: $(LINUX_DIR
)/.configured
190 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) dep
191 touch
$(LINUX_DIR
)/.depend_done
193 $(LINUX_DIR
)/vmlinux
: $(LINUX_DIR
)/.depend_done
194 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) PATH
=$(TARGET_PATH
)
196 $(LINUX_KERNEL
): $(LINUX_DIR
)/vmlinux
197 $(TARGET_CROSS
)objcopy
-O binary
-R .reginfo
-R .note
-R .comment
-R .mdebug
-S
$< $@
198 touch
-c
$(LINUX_KERNEL
)
200 $(LINUX_DIR
)/.modules_done
: $(LINUX_KERNEL
) $(LINUX_IMAGE
)
201 rm -rf
$(LINUX_BUILD_DIR
)/modules
202 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) PATH
=$(TARGET_PATH
) modules
203 $(MAKE
) -C
$(LINUX_DIR
) DEPMOD
=true INSTALL_MOD_PATH
=$(LINUX_BUILD_DIR
)/modules modules_install
204 touch
$(LINUX_DIR
)/.modules_done
206 $(STAGING_DIR
)/include/linux
/version.h
: $(LINUX_DIR
)/.configured
207 mkdir
-p
$(STAGING_DIR
)/include
208 tar -ch
-C
$(LINUX_DIR
)/include -f
- linux |
tar -xf
- -C
$(STAGING_DIR
)/include/
209 tar -ch
-C
$(LINUX_DIR
)/include -f
- asm |
tar -xf
- -C
$(STAGING_DIR
)/include/
211 $(TARGET_MODULES_DIR
):
212 -mkdir
-p
$(TARGET_MODULES_DIR
)
215 rm -rf
$(KERNEL_IDIR
)
216 mkdir
-p
$(KERNEL_IDIR
)/etc
217 $(SCRIPT_DIR
)/make-ipkg-dir.sh
$(KERNEL_IDIR
) ..
/control
/kernel.control
$(PKG_RELEASE
) $(ARCH
)
218 echo
'Package: kernel-$(LINUX_VERSION)-$(BOARD)' >> $(KERNEL_IDIR
)/CONTROL
/control
219 if
[ -f .
/config
/$(BOARD
).modules
]; then \
220 cp .
/config
/$(BOARD
).modules
$(KERNEL_IDIR
)/etc
/modules
; \
222 $(IPKG_BUILD
) $(KERNEL_IDIR
) $(LINUX_BUILD_DIR
)
224 source
: $(DL_DIR
)/$(LINUX_SOURCE
)
225 prepare
: $(LINUX_DIR
)/.configured
226 compile
: $(LINUX_DIR
)/.modules_done
$(TARGETS
)
227 ln
-sf
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(LINUX_DIR
)
228 $(MAKE
) -C
$(TOPDIR
)/target
/linux
/package \
230 TARGET_DIR
="$(LINUX_TARGET_DIR)" \
231 BUILD_DIR
="$(LINUX_BUILD_DIR)" \
232 KERNEL_DIR
="$(LINUX_SOURCE_DIR)" \
233 LINUX_VERSION
="$(LINUX_VERSION)" \
234 KERNEL_RELEASE
="$(PKG_RELEASE)"
236 install: compile
$(TARGET_MODULES_DIR
) $(KERNEL_IPKG
)
237 rm -rf
$(LINUX_BUILD_DIR
)/root
*
238 cp
-a
$(BUILD_DIR
)/root
$(LINUX_BUILD_DIR
)/
239 echo
-e
'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR
)/ipkg.conf
240 [ "$(INSTALL_TARGETS)" != "" ] && $(IPKG_KERNEL
) install $(INSTALL_TARGETS
) || true
243 rm -f
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.
{drivers-unpacked
,modules_done
}
244 $(MAKE
) -C
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean
245 rm -f
$(LINUX_KERNEL
) $(LINUX_IMAGE
)
249 if
[ -f
$(LINUX_KERNEL
) ]; then \
255 rm -rf
$(LINUX_BUILD_DIR
)