add initial video4linux support (for usb webcams) to head
[openwrt.git] / openwrt / target / linux / linux-2.4 / Makefile
1 #############################################################
2 # $Id$
3 #
4 # Linux 2.4 kernel target for the OpenWRT project
5 #
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
10 #
11 #############################################################
12
13 include $(TOPDIR)/rules.mk
14 include ../rules.mk
15
16 LINUX_VERSION:=2.4.30
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/' \
23 -e 's/mipsel/mips/' \
24 -e 's/powerpc/ppc/' \
25 -e 's/sh[234]/sh/' \
26 )
27
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
34
35 PKG_BUILD_DIR := $(LINUX_BUILD_DIR)/linux-modules
36 PKG_RELEASE := 2
37
38 KERNEL_IPKG:=$(LINUX_BUILD_DIR)/kernel-$(LINUX_VERSION)-$(BOARD)_$(PKG_RELEASE)_$(ARCH).ipk
39 KERNEL_IDIR:=$(LINUX_BUILD_DIR)/kernel-ipkg
40
41 KPKG_MAKEOPTS:= IPKG="$(IPKG_KERNEL)" \
42 BOARD="$(BOARD)" \
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)"
48
49 include $(LINUX_KCONFIG)
50
51 INSTALL_TARGETS := $(KERNEL_IPKG)
52 TARGETS :=
53
54 ifeq ($(BOARD),brcm)
55 include ./broadcom.mk
56 endif
57
58 ifeq ($(BOARD),soekris)
59 include ./soekris.mk
60 endif
61
62 ifeq ($(BOARD),ar7)
63 include ./ar7.mk
64 endif
65
66 $(eval $(call KMOD_template,ATM,atm,\
67 $(MODULES_DIR)/kernel/net/atm/atm.o \
68 $(MODULES_DIR)/kernel/net/atm/br2684.o \
69 ,CONFIG_ATM,,50,atm))
70 $(eval $(call KMOD_template,PPPOATM,pppoatm,\
71 $(MODULES_DIR)/kernel/net/atm/pppoatm.o \
72 ,CONFIG_PPPOATM))
73 $(eval $(call KMOD_template,USB_ACM,usb-acm,\
74 $(MODULES_DIR)/kernel/drivers/usb/acm.o \
75 ,CONFIG_USB_ACM))
76 $(eval $(call KMOD_template,B44,b44,\
77 $(MODULES_DIR)/kernel/drivers/net/b44.o \
78 ,CONFIG_B44))
79 $(eval $(call KMOD_template,BLUETOOTH,bluetooth,\
80 $(MODULES_DIR)/kernel/net/bluetooth/*.o \
81 $(MODULES_DIR)/kernel/net/bluetooth/rfcomm/*.o \
82 $(MODULES_DIR)/kernel/drivers/bluetooth/*.o \
83 ,CONFIG_BLUEZ))
84 $(eval $(call KMOD_template,ARPT,arptables,\
85 $(MODULES_DIR)/kernel/net/ipv4/netfilter/arp*.o \
86 ,CONFIG_IP_NF_ARPTABLES))
87 $(eval $(call KMOD_template,EBT,ebtables,\
88 $(MODULES_DIR)/kernel/net/bridge/netfilter/*.o \
89 ,CONFIG_BRIDGE_NF_EBTABLES))
90 $(eval $(call KMOD_template,IPTABLES_V4_EXTRA,iptables-extra,\
91 $(MODULES_DIR)/kernel/net/ipv4/netfilter/ip*.o \
92 ))
93 $(eval $(call KMOD_template,IPTABLES_V6,ip6tables,\
94 $(MODULES_DIR)/kernel/net/ipv6/netfilter/ip*.o \
95 ,CONFIG_IP6_NF_IPTABLES,kmod-ipv6))
96 $(eval $(call KMOD_template,IPV6,ipv6,\
97 $(MODULES_DIR)/kernel/net/ipv6/ipv6.o \
98 ,CONFIG_IPV6,,20,ipv6))
99 $(eval $(call KMOD_template,CIFS,cifs,\
100 $(MODULES_DIR)/kernel/fs/cifs/cifs.o \
101 ,CONFIG_CIFS,,30,cifs))
102 $(eval $(call KMOD_template,NFS,nfs,\
103 $(MODULES_DIR)/kernel/fs/lockd/*.o \
104 $(MODULES_DIR)/kernel/fs/nfs/*.o \
105 $(MODULES_DIR)/kernel/net/sunrpc/*.o \
106 ,CONFIG_NFS_FS,,30,sunrpc lockd nfs))
107 $(eval $(call KMOD_template,USB,usb-core,\
108 $(MODULES_DIR)/kernel/drivers/usb/usbcore.o \
109 ,CONFIG_USB,,50,usbcore))
110 $(eval $(call KMOD_template,USB_UHCI,usb-uhci,\
111 $(MODULES_DIR)/kernel/drivers/usb/host/uhci.o \
112 ,CONFIG_USB_UHCI_ALT,kmod-usb-core,60,uhci))
113 $(eval $(call KMOD_template,USB_OHCI,usb-ohci,\
114 $(MODULES_DIR)/kernel/drivers/usb/host/usb-ohci.o \
115 ,CONFIG_USB_OHCI,kmod-usb-core,60,usb-ohci))
116 $(eval $(call KMOD_template,USB2,usb2,\
117 $(MODULES_DIR)/kernel/drivers/usb/host/ehci-hcd.o \
118 ,CONFIG_USB_EHCI_HCD,kmod-usb-core,60,ehci-hcd))
119 $(eval $(call KMOD_template,USB_STORAGE,usb-storage,\
120 $(MODULES_DIR)/kernel/drivers/scsi/*.o \
121 $(MODULES_DIR)/kernel/drivers/usb/storage/*.o \
122 ,CONFIG_USB_STORAGE,kmod-usb-core,60,scsi_mod sd_mod usb-storage))
123 $(eval $(call KMOD_template,USB_PRINTER,usb-printer,\
124 $(MODULES_DIR)/kernel/drivers/usb/printer.o \
125 ,CONFIG_USB_PRINTER,kmod-usb-core,60,printer))
126 $(eval $(call KMOD_template,IDE,ide,\
127 $(MODULES_DIR)/kernel/drivers/ide/*.o \
128 $(MODULES_DIR)/kernel/drivers/ide/*/*.o \
129 ,CONFIG_IDE))
130 $(eval $(call KMOD_template,LOOP,loop,\
131 $(MODULES_DIR)/kernel/drivers/block/loop.o \
132 ,CONFIG_BLK_DEV_LOOP,,20,loop))
133 $(eval $(call KMOD_template,EXT2,ext2,\
134 $(MODULES_DIR)/kernel/fs/ext2/*.o \
135 ,CONFIG_EXT2_FS,,30,ext2))
136 $(eval $(call KMOD_template,EXT3,ext3,\
137 $(MODULES_DIR)/kernel/fs/ext3/*.o \
138 $(MODULES_DIR)/kernel/fs/jbd/*.o \
139 ,CONFIG_EXT3_FS,,30,jbd ext3))
140 $(eval $(call KMOD_template,XFS,xfs,\
141 $(MODULES_DIR)/kernel/fs/xfs/*.o \
142 ,CONFIG_XFS_FS,,30,xfs))
143 $(eval $(call KMOD_template,HFSPLUS,hfsplus,\
144 $(MODULES_DIR)/kernel/fs/hfsplus/*.o \
145 ,CONFIG_HFSPLUS_FS,,30,hfsplus))
146 $(eval $(call KMOD_template,VFAT,vfat,\
147 $(MODULES_DIR)/kernel/fs/vfat/vfat.o \
148 $(MODULES_DIR)/kernel/fs/fat/fat.o \
149 ,CONFIG_VFAT_FS,,30,fat vfat))
150 $(eval $(call KMOD_template,CRYPTO,crypto,\
151 $(MODULES_DIR)/kernel/crypto/*.o \
152 ))
153 $(eval $(call KMOD_template,PPP,ppp,\
154 $(MODULES_DIR)/kernel/drivers/net/ppp_async.o \
155 $(MODULES_DIR)/kernel/drivers/net/ppp_generic.o \
156 $(MODULES_DIR)/kernel/drivers/net/slhc.o \
157 ,CONFIG_PPP))
158 $(eval $(call KMOD_template,MPPE,mppe,\
159 $(MODULES_DIR)/kernel/drivers/net/ppp_mppe_mppc.o \
160 ,CONFIG_PPP_MPPE_MPPC))
161 $(eval $(call KMOD_template,PPPOE,pppoe,\
162 $(MODULES_DIR)/kernel/drivers/net/pppoe.o \
163 $(MODULES_DIR)/kernel/drivers/net/pppox.o \
164 ,CONFIG_PPPOE))
165 $(eval $(call KMOD_template,TUN,tun,\
166 $(MODULES_DIR)/kernel/drivers/net/tun.o \
167 ,CONFIG_TUN,,20,tun))
168 $(eval $(call KMOD_template,GRE,gre,\
169 $(MODULES_DIR)/kernel/net/ipv4/ip_gre.o \
170 ,CONFIG_NET_IPGRE))
171 $(eval $(call KMOD_template,SCHED,sched,\
172 $(MODULES_DIR)/kernel/net/sched/*.o \
173 ))
174 $(eval $(call KMOD_template,VIDEODEV,videodev,\
175 $(MODULES_DIR)/kernel/drivers/media/video/videodev.o \
176 ))
177 $(eval $(call KMOD_template,PWC,pwc,\
178 $(MODULES_DIR)/kernel/drivers/usb/pwc.o \
179 ))
180
181 $(TARGETS): $(PACKAGE_DIR)
182
183 $(PACKAGE_DIR):
184 mkdir -p $(PACKAGE_DIR)
185
186 $(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE)
187 -mkdir -p $(LINUX_BUILD_DIR)
188 bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(LINUX_BUILD_DIR) $(TAR_OPTIONS) -
189 rm -f $(LINUX_DIR)
190 ln -s $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(LINUX_DIR)
191 touch $(LINUX_DIR)/.unpacked
192
193 $(LINUX_DIR)/.patched: $(LINUX_DIR)/.unpacked
194 $(PATCH) $(LINUX_DIR) ./patches/generic
195 [ -d ./patches/$(BOARD) ] && $(PATCH) $(LINUX_DIR) ./patches/$(BOARD)
196 touch $(LINUX_DIR)/.patched
197
198 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
199 -cp $(LINUX_KCONFIG) $(LINUX_DIR)/.config
200 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" \
201 $(LINUX_DIR)/Makefile \
202 $(LINUX_DIR)/arch/*/Makefile
203 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
204 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) oldconfig include/linux/version.h
205 touch $(LINUX_DIR)/.configured
206
207 $(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
208 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) dep
209 touch $(LINUX_DIR)/.depend_done
210
211 $(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.depend_done
212 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH)
213
214 $(LINUX_KERNEL): $(LINUX_DIR)/vmlinux
215 $(TARGET_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $< $@
216 touch -c $(LINUX_KERNEL)
217
218 $(LINUX_DIR)/.modules_done: $(LINUX_KERNEL) $(LINUX_IMAGE)
219 rm -rf $(LINUX_BUILD_DIR)/modules
220 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) modules
221 $(MAKE) -C $(LINUX_DIR) DEPMOD=true INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules modules_install
222 touch $(LINUX_DIR)/.modules_done
223
224 $(STAGING_DIR)/include/linux/version.h: $(LINUX_DIR)/.configured
225 mkdir -p $(STAGING_DIR)/include
226 tar -ch -C $(LINUX_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
227 tar -ch -C $(LINUX_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/
228
229 $(TARGET_MODULES_DIR):
230 -mkdir -p $(TARGET_MODULES_DIR)
231
232 $(KERNEL_IPKG):
233 rm -rf $(KERNEL_IDIR)
234 mkdir -p $(KERNEL_IDIR)/etc
235 $(SCRIPT_DIR)/make-ipkg-dir.sh $(KERNEL_IDIR) ../control/kernel.control $(PKG_RELEASE) $(ARCH)
236 echo 'Package: kernel-$(LINUX_VERSION)-$(BOARD)' >> $(KERNEL_IDIR)/CONTROL/control
237 if [ -f ./config/$(BOARD).modules ]; then \
238 cp ./config/$(BOARD).modules $(KERNEL_IDIR)/etc/modules; \
239 fi
240 $(IPKG_BUILD) $(KERNEL_IDIR) $(LINUX_BUILD_DIR)
241
242 source: $(DL_DIR)/$(LINUX_SOURCE)
243 prepare: $(LINUX_DIR)/.configured
244 compile: $(LINUX_DIR)/.modules_done $(TARGETS)
245 ln -sf $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(LINUX_DIR)
246 $(MAKE) -C $(TOPDIR)/target/linux/package \
247 $(KPKG_MAKEOPTS) \
248 compile
249
250 install: compile $(TARGET_MODULES_DIR) $(KERNEL_IPKG)
251 rm -rf $(LINUX_BUILD_DIR)/root*
252 echo -e 'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR)/ipkg.conf
253 $(MAKE) -C $(TOPDIR)/package \
254 TARGET_DIR="$(LINUX_TARGET_DIR)" \
255 IPKG_CONF="$(LINUX_BUILD_DIR)" \
256 BOARD="$(BOARD)" \
257 install
258 $(MAKE) -C $(TOPDIR)/target/linux/package \
259 $(KPKG_MAKEOPTS) \
260 install
261 [ "$(INSTALL_TARGETS)" != "" ] && $(IPKG_KERNEL) install $(INSTALL_TARGETS) || true
262
263 mostlyclean:
264 rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.modules_done
265 rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.drivers-unpacked
266 $(MAKE) -C $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) clean
267 rm -f $(LINUX_KERNEL) $(LINUX_IMAGE)
268
269 rebuild:
270 -$(MAKE) mostlyclean
271 if [ -f $(LINUX_KERNEL) ]; then \
272 $(MAKE) clean; \
273 fi
274 $(MAKE) compile
275
276 clean:
277 rm -rf $(LINUX_BUILD_DIR)
278 rm -f $(TARGETS)
This page took 0.056465 seconds and 5 git commands to generate.