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