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