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
)
55 $(eval
$(call KMOD_template
,B44
,b44
,\
56 $(MODULES_DIR
)/kernel
/drivers
/net
/b44.o \
58 $(eval
$(call KMOD_template
,ARPT
,arptables
,\
59 $(MODULES_DIR
)/kernel
/net
/ipv4
/netfilter
/arp
*.o \
60 ,CONFIG_IP_NF_ARPTABLES
))
61 $(eval
$(call KMOD_template
,EBT
,ebtables
,\
62 $(MODULES_DIR
)/kernel
/net
/bridge
/netfilter
/*.o \
63 ,CONFIG_BRIDGE_NF_EBTABLES
))
64 $(eval
$(call KMOD_template
,IPTABLES_V4_EXTRA
,iptables-extra
,\
65 $(MODULES_DIR
)/kernel
/net
/ipv4
/netfilter
/ip
*.o \
67 $(eval
$(call KMOD_template
,IPTABLES_V6
,ip6tables
,\
68 $(MODULES_DIR
)/kernel
/net
/ipv6
/netfilter
/ip
*.o \
69 ,CONFIG_IP6_NF_IPTABLES
,kmod-ipv6
))
70 $(eval
$(call KMOD_template
,IPV6
,ipv6
,\
71 $(MODULES_DIR
)/kernel
/net
/ipv6
/ipv6.o \
73 $(eval
$(call KMOD_template
,CIFS
,cifs
,\
74 $(MODULES_DIR
)/kernel
/fs
/cifs
/cifs.o \
76 $(eval
$(call KMOD_template
,NFS
,nfs
,\
77 $(MODULES_DIR
)/kernel
/fs
/lockd
/*.o \
78 $(MODULES_DIR
)/kernel
/fs
/nfs
/*.o \
79 $(MODULES_DIR
)/kernel
/net
/sunrpc
/*.o \
81 $(eval
$(call KMOD_template
,USB
,usb-core
,\
82 $(MODULES_DIR
)/kernel
/drivers
/usb
/usbcore.o \
84 $(eval
$(call KMOD_template
,USB_UHCI
,usb-uhci
,\
85 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/uhci.o \
86 ,CONFIG_USB_UHCI_ALT
,kmod-usb-core
))
87 $(eval
$(call KMOD_template
,USB_OHCI
,usb-ohci
,\
88 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/usb-ohci.o \
89 ,CONFIG_USB_OHCI
,kmod-usb-core
))
90 $(eval
$(call KMOD_template
,USB2
,usb2
,\
91 $(MODULES_DIR
)/kernel
/drivers
/usb
/host
/ehci-hcd.o \
92 ,CONFIG_USB_EHCI_HCD
,kmod-usb-core
))
93 $(eval
$(call KMOD_template
,USB_STORAGE
,usb-storage
,\
94 $(MODULES_DIR
)/kernel
/drivers
/scsi
/*.o \
95 $(MODULES_DIR
)/kernel
/drivers
/usb
/storage
/*.o \
97 $(eval
$(call KMOD_template
,USB_PRINTER
,usb-printer
,\
98 $(MODULES_DIR
)/kernel
/drivers
/usb
/printer.o \
100 $(eval
$(call KMOD_template
,IDE
,ide
,\
101 $(MODULES_DIR
)/kernel
/drivers
/ide
/*.o \
102 $(MODULES_DIR
)/kernel
/drivers
/ide
/*/*.o \
104 $(eval
$(call KMOD_template
,EXT2
,ext2
,\
105 $(MODULES_DIR
)/kernel
/fs
/ext2
/*.o \
107 $(eval
$(call KMOD_template
,EXT3
,ext3
,\
108 $(MODULES_DIR
)/kernel
/fs
/ext3
/*.o \
109 $(MODULES_DIR
)/kernel
/fs
/jbd
/*.o \
111 $(eval
$(call KMOD_template
,XFS
,xfs
,\
112 $(MODULES_DIR
)/kernel
/fs
/xfs
/*.o \
114 $(eval
$(call KMOD_template
,HFSPLUS
,hfsplus
,\
115 $(MODULES_DIR
)/kernel
/fs
/hfsplus
/*.o \
117 $(eval
$(call KMOD_template
,VFAT
,vfat
,\
118 $(MODULES_DIR
)/kernel
/fs
/vfat
/vfat.o \
119 $(MODULES_DIR
)/kernel
/fs
/fat
/fat.o \
121 $(eval
$(call KMOD_template
,CRYPTO
,crypto
,\
122 $(MODULES_DIR
)/kernel
/crypto
/*.o \
124 $(eval
$(call KMOD_template
,PPP
,ppp
,\
125 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_async.o \
126 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_generic.o \
127 $(MODULES_DIR
)/kernel
/drivers
/net
/slhc.o \
129 $(eval
$(call KMOD_template
,MPPE
,mppe
,\
130 $(MODULES_DIR
)/kernel
/drivers
/net
/ppp_mppe_mppc.o \
131 ,CONFIG_PPP_MPPE_MPPC
))
132 $(eval
$(call KMOD_template
,PPPOE
,pppoe
,\
133 $(MODULES_DIR
)/kernel
/drivers
/net
/pppoe.o \
134 $(MODULES_DIR
)/kernel
/drivers
/net
/pppox.o \
136 $(eval
$(call KMOD_template
,TUN
,tun
,\
137 $(MODULES_DIR
)/kernel
/drivers
/net
/tun.o \
139 $(eval
$(call KMOD_template
,GRE
,gre
,\
140 $(MODULES_DIR
)/kernel
/net
/ipv4
/ip_gre.o \
142 $(eval
$(call KMOD_template
,SCHED
,sched
,\
143 $(MODULES_DIR
)/kernel
/net
/sched
/*.o \
146 $(TARGETS
): $(PACKAGE_DIR
)
149 mkdir
-p
$(PACKAGE_DIR
)
151 $(LINUX_DIR
)/.unpacked
: $(DL_DIR
)/$(LINUX_SOURCE
) $(DL_DIR
)/$(LINUX_BINARY_WL_DRIVER
) $(DL_DIR
)/$(LINUX_ET_DRIVER
)
152 -mkdir
-p
$(LINUX_BUILD_DIR
)
153 bzcat
$(DL_DIR
)/$(LINUX_SOURCE
) |
tar -C
$(LINUX_BUILD_DIR
) $(TAR_OPTIONS
) -
155 ln
-s
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(LINUX_DIR
)
156 touch
$(LINUX_DIR
)/.unpacked
158 $(LINUX_DIR
)/.patched
: $(LINUX_DIR
)/.unpacked
159 $(PATCH
) $(LINUX_DIR
) .
/patches
/generic
160 [ -d .
/patches
/$(BOARD
) ] && $(PATCH
) $(LINUX_DIR
) .
/patches
/$(BOARD
)
161 touch
$(LINUX_DIR
)/.patched
163 $(LINUX_DIR
)/.configured
: $(LINUX_DIR
)/.patched
164 -cp
$(LINUX_KCONFIG
) $(LINUX_DIR
)/.config
165 $(SED
) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" \
166 $(LINUX_DIR
)/Makefile \
167 $(LINUX_DIR
)/arch
/mips
/Makefile
168 $(SED
) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR
)/arch
/mips
/Makefile
169 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) oldconfig
include/linux
/version.h
170 touch
$(LINUX_DIR
)/.configured
172 $(LINUX_DIR
)/.depend_done
: $(LINUX_DIR
)/.configured
173 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) dep
174 touch
$(LINUX_DIR
)/.depend_done
176 $(LINUX_DIR
)/vmlinux
: $(LINUX_DIR
)/.depend_done
177 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) PATH
=$(TARGET_PATH
)
179 $(LINUX_KERNEL
): $(LINUX_DIR
)/vmlinux
180 $(TARGET_CROSS
)objcopy
-O binary
-R .reginfo
-R .note
-R .comment
-R .mdebug
-S
$< $@
181 touch
-c
$(LINUX_KERNEL
)
183 $(LINUX_DIR
)/.modules_done
: $(LINUX_KERNEL
) $(LINUX_IMAGE
)
184 rm -rf
$(LINUX_BUILD_DIR
)/modules
185 $(MAKE
) -C
$(LINUX_DIR
) ARCH
=$(LINUX_KARCH
) PATH
=$(TARGET_PATH
) modules
186 $(MAKE
) -C
$(LINUX_DIR
) DEPMOD
=true INSTALL_MOD_PATH
=$(LINUX_BUILD_DIR
)/modules modules_install
187 touch
$(LINUX_DIR
)/.modules_done
189 $(STAGING_DIR
)/include/linux
/version.h
: $(LINUX_DIR
)/.configured
190 mkdir
-p
$(STAGING_DIR
)/include
191 tar -ch
-C
$(LINUX_DIR
)/include -f
- linux |
tar -xf
- -C
$(STAGING_DIR
)/include/
192 tar -ch
-C
$(LINUX_DIR
)/include -f
- asm |
tar -xf
- -C
$(STAGING_DIR
)/include/
194 $(TARGET_MODULES_DIR
):
195 -mkdir
-p
$(TARGET_MODULES_DIR
)
198 rm -rf
$(KERNEL_IDIR
)
199 mkdir
-p
$(KERNEL_IDIR
)/etc
200 $(SCRIPT_DIR
)/make-ipkg-dir.sh
$(KERNEL_IDIR
) ..
/control
/kernel.control
$(LINUX_VERSION
)-$(BOARD
)-$(PKG_RELEASE
) $(ARCH
)
201 if
[ -f .
/config
/$(BOARD
).modules
]; then \
202 cp .
/config
/$(BOARD
).modules
$(KERNEL_IDIR
)/etc
/modules
; \
204 $(IPKG_BUILD
) $(KERNEL_IDIR
) $(LINUX_BUILD_DIR
)
206 source
: $(DL_DIR
)/$(LINUX_SOURCE
)
207 prepare
: $(LINUX_DIR
)/.configured
208 compile
: $(LINUX_DIR
)/.modules_done
$(TARGETS
)
209 ln
-sf
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) $(LINUX_DIR
)
210 $(MAKE
) -C
$(TOPDIR
)/target
/linux
/package \
212 TARGET_DIR
="$(LINUX_TARGET_DIR)" \
213 BUILD_DIR
="$(LINUX_BUILD_DIR)" \
214 KERNEL_DIR
="$(LINUX_SOURCE_DIR)" \
215 LINUX_VERSION
="$(LINUX_VERSION)" \
216 KERNEL_RELEASE
="$(PKG_RELEASE)"
218 install: compile
$(TARGET_MODULES_DIR
) $(KERNEL_IPKG
)
219 rm -rf
$(LINUX_BUILD_DIR
)/root
*
220 cp
-a
$(BUILD_DIR
)/root
$(LINUX_BUILD_DIR
)/
221 echo
-e
'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR
)/ipkg.conf
222 [ "$(INSTALL_TARGETS)" != "" ] && $(IPKG_KERNEL
) install $(INSTALL_TARGETS
) || true
225 rm -f
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
)/.
{drivers-unpacked
,modules_done
}
226 $(MAKE
) -C
$(LINUX_BUILD_DIR
)/linux-
$(LINUX_VERSION
) clean
227 rm -f
$(LINUX_KERNEL
) $(LINUX_IMAGE
)
231 if
[ -f
$(LINUX_KERNEL
) ]; then \
237 rm -rf
$(LINUX_BUILD_DIR
)