backport base-files fix from whiterussian [2308],
[openwrt.git] / target / linux / linux-2.6 / Makefile
1 # $Id$
2 # Linux 2.6 kernel target for the OpenWRT project
3
4 include $(TOPDIR)/rules.mk
5 include ../rules.mk
6
7 KERNEL:=2.6
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/' \
20 -e 's/mipsel/mips/' \
21 -e 's/powerpc/ppc/' \
22 -e 's/sh[234]/sh/' \
23 )
24
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
30
31 PKG_BUILD_DIR := $(LINUX_BUILD_DIR)/linux-modules
32 PKG_RELEASE := 1
33
34 KERNEL_IPKG:=$(LINUX_BUILD_DIR)/kernel-$(LINUX_VERSION)-$(BOARD)_$(PKG_RELEASE)_$(ARCH).ipk
35 KERNEL_IDIR:=$(LINUX_BUILD_DIR)/kernel-ipkg
36
37 KPKG_MAKEOPTS:= IPKG="$(IPKG_KERNEL)" \
38 BOARD="$(BOARD)" \
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)"
44
45 include $(LINUX_KCONFIG)
46
47 INSTALL_TARGETS := $(KERNEL_IPKG)
48 TARGETS :=
49
50 $(eval $(call KMOD_template,ATM,atm,\
51 $(MODULES_DIR)/kernel/net/atm/atm.ko \
52 $(MODULES_DIR)/kernel/net/atm/br2684.ko \
53 ,CONFIG_ATM,,50,atm))
54 $(eval $(call KMOD_template,PPPOATM,pppoatm,\
55 $(MODULES_DIR)/kernel/net/atm/pppoatm.ko \
56 ,CONFIG_PPPOATM))
57 $(eval $(call KMOD_template,ARPT,arptables,\
58 $(MODULES_DIR)/kernel/net/ipv4/netfilter/arp*.ko \
59 ,CONFIG_IP_NF_ARPTABLES))
60 $(eval $(call KMOD_template,EBT,ebtables,\
61 $(MODULES_DIR)/kernel/net/bridge/netfilter/*.ko \
62 ,CONFIG_BRIDGE_NF_EBTABLES))
63 $(eval $(call KMOD_template,IPTABLES_V4_EXTRA,iptables-extra,\
64 $(MODULES_DIR)/kernel/net/ipv4/netfilter/ip*.ko \
65 ))
66 $(eval $(call KMOD_template,IPTABLES_V6,ip6tables,\
67 $(MODULES_DIR)/kernel/net/ipv6/netfilter/ip*.ko \
68 ,CONFIG_IP6_NF_IPTABLES,kmod-ipv6))
69 $(eval $(call KMOD_template,IPV6,ipv6,\
70 $(MODULES_DIR)/kernel/net/ipv6/ipv6.ko \
71 ,CONFIG_IPV6,,20,ipv6))
72 $(eval $(call KMOD_template,IDE,ide,\
73 $(MODULES_DIR)/kernel/drivers/ide/*.ko \
74 $(MODULES_DIR)/kernel/drivers/ide/*/*.ko \
75 ,CONFIG_IDE))
76 $(eval $(call KMOD_template,LOOP,loop,\
77 $(MODULES_DIR)/kernel/drivers/block/loop.ko \
78 ,CONFIG_BLK_DEV_LOOP,,20,loop))
79 $(eval $(call KMOD_template,CRYPTO,crypto,\
80 $(MODULES_DIR)/kernel/crypto/*.ko \
81 ))
82 $(eval $(call KMOD_template,PPP,ppp,\
83 $(MODULES_DIR)/kernel/drivers/net/ppp_async.ko \
84 $(MODULES_DIR)/kernel/drivers/net/ppp_generic.ko \
85 $(MODULES_DIR)/kernel/drivers/net/slhc.ko \
86 ,CONFIG_PPP))
87 $(eval $(call KMOD_template,MPPE,mppe,\
88 $(MODULES_DIR)/kernel/drivers/net/ppp_mppe_mppc.ko \
89 ,CONFIG_PPP_MPPE_MPPC))
90 $(eval $(call KMOD_template,PPPOE,pppoe,\
91 $(MODULES_DIR)/kernel/drivers/net/pppoe.ko \
92 $(MODULES_DIR)/kernel/drivers/net/pppox.ko \
93 ,CONFIG_PPPOE))
94 $(eval $(call KMOD_template,TUN,tun,\
95 $(MODULES_DIR)/kernel/drivers/net/tun.ko \
96 ,CONFIG_TUN,,20,tun))
97 $(eval $(call KMOD_template,GRE,gre,\
98 $(MODULES_DIR)/kernel/net/ipv4/ip_gre.ko \
99 ,CONFIG_NET_IPGRE))
100 $(eval $(call KMOD_template,SCHED,sched,\
101 $(MODULES_DIR)/kernel/net/sched/*.ko \
102 ))
103
104
105 # Filesystems
106
107 $(eval $(call KMOD_template,FS_CIFS,fs-cifs,\
108 $(MODULES_DIR)/kernel/fs/cifs/cifs.ko \
109 ,CONFIG_CIFS,kmod-nls-base,30,cifs))
110
111 $(eval $(call KMOD_template,FS_EXT2,fs-ext2,\
112 $(MODULES_DIR)/kernel/fs/ext2/*.ko \
113 ,CONFIG_EXT2_FS,,30,ext2))
114
115 $(eval $(call KMOD_template,FS_EXT3,fs-ext3,\
116 $(MODULES_DIR)/kernel/fs/ext3/*.ko \
117 $(MODULES_DIR)/kernel/fs/jbd/*.ko \
118 ,CONFIG_EXT3_FS,,30,jbd ext3))
119
120 $(eval $(call KMOD_template,FS_HFSPLUS,fs-hfsplus,\
121 $(MODULES_DIR)/kernel/fs/hfsplus/*.ko \
122 ,CONFIG_HFSPLUS_FS,kmod-nls-base,30,hfsplus))
123
124 $(eval $(call KMOD_template,FS_NFS,fs-nfs,\
125 $(MODULES_DIR)/kernel/fs/lockd/*.ko \
126 $(MODULES_DIR)/kernel/fs/nfs/*.ko \
127 $(MODULES_DIR)/kernel/net/sunrpc/*.ko \
128 ,CONFIG_NFS_FS,,30,sunrpc lockd nfs))
129
130 $(eval $(call KMOD_template,FS_VFAT,fs-vfat,\
131 $(MODULES_DIR)/kernel/fs/fat/fat.ko \
132 $(MODULES_DIR)/kernel/fs/vfat/vfat.ko \
133 ,CONFIG_VFAT_FS,kmod-nls-base,30,fat vfat))
134
135 $(eval $(call KMOD_template,FS_XFS,fs-xfs,\
136 $(MODULES_DIR)/kernel/fs/xfs/*.ko \
137 ,CONFIG_XFS_FS,,30,xfs))
138
139
140 # NLS
141
142 $(eval $(call KMOD_template,NLS_BASE,nls-base,\
143 $(MODULES_DIR)/kernel/fs/nls/nls_base.ko \
144 ,CONFIG_NLS,,20,nls_base))
145
146 $(eval $(call KMOD_template,NLS_CP437,nls-cp437,\
147 $(MODULES_DIR)/kernel/fs/nls/nls_cp437.ko \
148 ,CONFIG_NLS_CODEPAGE_437,,20,nls_cp437))
149
150 $(eval $(call KMOD_template,NLS_CP850,nls-cp850,\
151 $(MODULES_DIR)/kernel/fs/nls/nls_cp850.ko \
152 ,CONFIG_NLS_CODEPAGE_850,,20,nls_cp850))
153
154 $(eval $(call KMOD_template,NLS_ISO8859_1,nls-iso8859-1,\
155 $(MODULES_DIR)/kernel/fs/nls/nls_iso8859-1.ko \
156 ,CONFIG_NLS_ISO8859_1,,20,nls_iso8859-1))
157
158 $(eval $(call KMOD_template,NLS_ISO8859_15,nls-iso8859-15,\
159 $(MODULES_DIR)/kernel/fs/nls/nls_iso8859-15.ko \
160 ,CONFIG_NLS_ISO8859_15,,20,nls_iso8859-15))
161
162 $(eval $(call KMOD_template,NLS_UTF8,nls-utf8,\
163 $(MODULES_DIR)/kernel/fs/nls/nls_utf8.ko \
164 ,CONFIG_NLS_UTF8,,20,nls_utf8))
165
166
167 # Network devices
168
169 $(eval $(call KMOD_template,NET_B44,net-b44,\
170 $(MODULES_DIR)/kernel/drivers/net/b44.ko \
171 ,CONFIG_B44))
172
173
174 # USB
175
176 $(eval $(call KMOD_template,USB,usb-core,\
177 $(MODULES_DIR)/kernel/drivers/usb/core/usbcore.ko \
178 ,CONFIG_USB,,50,usbcore))
179
180 $(eval $(call KMOD_template,USB_OHCI,usb-ohci,\
181 $(MODULES_DIR)/kernel/drivers/usb/host/ohci-hcd.ko \
182 ,CONFIG_USB_OHCI_HCD,kmod-usb-core,60,ohci-hcd))
183
184 $(eval $(call KMOD_template,USB_UHCI,usb-uhci,\
185 $(MODULES_DIR)/kernel/drivers/usb/host/uhci.ko \
186 ,CONFIG_USB_UHCI_ALT,kmod-usb-core,60,uhci))
187
188 $(eval $(call KMOD_template,USB2,usb2,\
189 $(MODULES_DIR)/kernel/drivers/usb/host/ehci-hcd.ko \
190 ,CONFIG_USB_EHCI_HCD,kmod-usb-core,60,ehci-hcd))
191
192 $(eval $(call KMOD_template,USB_ACM,usb-acm,\
193 $(MODULES_DIR)/kernel/drivers/usb/class/cdc-acm.ko \
194 ,CONFIG_USB_ACM))
195
196 $(eval $(call KMOD_template,USB_PRINTER,usb-printer,\
197 $(MODULES_DIR)/kernel/drivers/usb/class/usblp.ko \
198 ,CONFIG_USB_PRINTER,kmod-usb-core,60,usblp))
199
200 $(eval $(call KMOD_template,USB_STORAGE,usb-storage,\
201 $(MODULES_DIR)/kernel/drivers/scsi/*.ko \
202 $(MODULES_DIR)/kernel/drivers/usb/storage/*.ko \
203 ,CONFIG_USB_STORAGE,kmod-usb-core,60,scsi_mod sd_mod usb-storage))
204
205
206 # Misc.
207
208 $(eval $(call KMOD_template,BLUETOOTH,bluetooth,\
209 $(MODULES_DIR)/kernel/net/bluetooth/*.ko \
210 $(MODULES_DIR)/kernel/net/bluetooth/rfcomm/*.ko \
211 $(MODULES_DIR)/kernel/drivers/bluetooth/*.ko \
212 ,CONFIG_BLUEZ))
213
214
215 $(TARGETS): $(PACKAGE_DIR)
216
217 $(PACKAGE_DIR):
218 mkdir -p $(PACKAGE_DIR)
219
220 $(DL_DIR)/$(LINUX_SOURCE):
221 -mkdir -p $(DL_DIR)
222 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE) $(MAKE_TRACE)
223
224 $(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE)
225 -mkdir -p $(LINUX_BUILD_DIR)
226 bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(LINUX_BUILD_DIR) $(TAR_OPTIONS) -
227 rm -f $(LINUX_DIR)
228 ln -s $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(LINUX_DIR)
229 touch $(LINUX_DIR)/.unpacked
230
231 $(LINUX_DIR)/.patched: $(LINUX_DIR)/.unpacked
232 $(PATCH) $(LINUX_DIR) ./patches/generic $(MAKE_TRACE)
233 [ -d ./patches/$(BOARD) ] && $(PATCH) $(LINUX_DIR) ./patches/$(BOARD) $(MAKE_TRACE)
234 touch $(LINUX_DIR)/.patched
235
236 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
237 -cp $(LINUX_KCONFIG) $(LINUX_DIR)/.config
238 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) oldconfig $(MAKE_TRACE)
239 touch $(LINUX_DIR)/.configured
240
241 $(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.configured
242 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE=$(TARGET_CROSS) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) $(MAKE_TRACE)
243
244 $(LINUX_KERNEL): $(LINUX_DIR)/vmlinux
245 $(TARGET_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $< $@ $(MAKE_TRACE)
246 touch -c $(LINUX_KERNEL)
247
248 $(LINUX_DIR)/.modules_done: $(LINUX_KERNEL) $(LINUX_IMAGE)
249 rm -rf $(LINUX_BUILD_DIR)/modules
250 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE=$(TARGET_CROSS) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) modules $(MAKE_TRACE)
251 $(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)
252 touch $(LINUX_DIR)/.modules_done
253
254 $(STAGING_DIR)/include/linux/version.h: $(LINUX_DIR)/.configured
255 mkdir -p $(STAGING_DIR)/include
256 tar -ch -C $(LINUX_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
257 tar -ch -C $(LINUX_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/
258
259 $(TARGET_MODULES_DIR):
260 -mkdir -p $(TARGET_MODULES_DIR)
261
262 $(KERNEL_IPKG):
263 rm -rf $(KERNEL_IDIR)
264 mkdir -p $(KERNEL_IDIR)/etc
265 $(SCRIPT_DIR)/make-ipkg-dir.sh $(KERNEL_IDIR) ../control/kernel.control $(PKG_RELEASE) $(ARCH)
266 echo 'Package: kernel-$(LINUX_VERSION)-$(BOARD)' >> $(KERNEL_IDIR)/CONTROL/control
267 if [ -f ./config/$(BOARD).modules ]; then \
268 cp ./config/$(BOARD).modules $(KERNEL_IDIR)/etc/modules; \
269 fi
270 $(IPKG_BUILD) $(KERNEL_IDIR) $(LINUX_BUILD_DIR) $(MAKE_TRACE)
271
272 $(STAMP_DIR)/.linux-compile: $(LINUX_DIR)/.modules_done
273 @mkdir -p $(STAMP_DIR)
274 @$(MAKE) $(TARGETS)
275 ln -sf $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(LINUX_DIR)
276 @$(TRACE) target/linux/package
277 $(MAKE) -C $(TOPDIR)/target/linux/package \
278 $(KPKG_MAKEOPTS) \
279 compile
280 touch $@
281
282 source: $(DL_DIR)/$(LINUX_SOURCE)
283 prepare: $(LINUX_DIR)/.configured
284 compile:
285 $(MAKE) $(STAMP_DIR)/.linux-compile $(MAKE_TRACE)
286
287 install: compile $(TARGET_MODULES_DIR) $(KERNEL_IPKG)
288 rm -rf $(LINUX_BUILD_DIR)/root*
289 cp -fpR $(BUILD_DIR)/root $(LINUX_BUILD_DIR)/
290 echo -e 'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR)/ipkg.conf
291 $(MAKE) -C $(TOPDIR)/target/linux/package \
292 $(KPKG_MAKEOPTS) \
293 install
294 @{ [ "$(INSTALL_TARGETS)" != "" ] && $(IPKG_KERNEL) install $(INSTALL_TARGETS) || true; } $(MAKE_TRACE)
295
296 mostlyclean:
297 rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.modules_done
298 rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.drivers-unpacked
299 $(MAKE) -C $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) clean
300 rm -f $(LINUX_KERNEL) $(LINUX_IMAGE)
301
302 rebuild:
303 -$(MAKE) mostlyclean
304 if [ -f $(LINUX_KERNEL) ]; then \
305 $(MAKE) clean; \
306 fi
307 $(MAKE) compile
308
309 clean:
310 rm -f $(STAMP_DIR)/.linux-compile
311 rm -rf $(LINUX_BUILD_DIR)
312 rm -f $(TARGETS)
This page took 0.069875 seconds and 5 git commands to generate.