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