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