fix dependency problem
[openwrt.git] / target / linux / rules.mk
1 KERNEL:=unknown
2 ifneq (,$(findstring 2.4.,$(LINUX_VERSION)))
3 KERNEL:=2.4
4 endif
5 ifneq (,$(findstring 2.6.,$(LINUX_VERSION)))
6 KERNEL:=2.6
7 endif
8
9 MODULES_SUBDIR:=lib/modules/$(LINUX_VERSION)
10
11 LINUX_BUILD_DIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
12 LINUX_DIR := $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)
13 LINUX_KERNEL:=$(LINUX_BUILD_DIR)/vmlinux
14
15 LINUX_TARGET_DIR:=$(LINUX_BUILD_DIR)/root
16
17 LINUX_KARCH:=$(shell echo $(ARCH) | sed -e 's/i[3-9]86/i386/' \
18 -e 's/mipsel/mips/' \
19 -e 's/mipseb/mips/' \
20 -e 's/powerpc/ppc/' \
21 -e 's/sh[234]/sh/' \
22 -e 's/armeb/arm/' \
23 )
24
25 KMOD_BUILD_DIR := $(LINUX_BUILD_DIR)/linux-modules
26 MODULES_DIR := $(LINUX_BUILD_DIR)/modules/$(MODULES_SUBDIR)
27 TARGET_MODULES_DIR := $(LINUX_TARGET_DIR)/$(MODULES_SUBDIR)
28
29 ifeq ($(KERNEL),2.6)
30 LINUX_KMOD_SUFFIX=ko
31 else
32 LINUX_KMOD_SUFFIX=o
33 endif
34
35 define KMOD_template
36 ifeq ($$(strip $(4)),)
37 KDEPEND_$(1):=m
38 else
39 KDEPEND_$(1):=$($(4))
40 endif
41
42 IDEPEND_$(1):=kernel ($(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)) $(foreach pkg,$(5),", $(pkg)")
43
44 PKG_$(1) := $(PACKAGE_DIR)/kmod-$(2)_$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)_$(ARCH).ipk
45 I_$(1) := $(KMOD_BUILD_DIR)/ipkg/$(2)
46
47 ifeq ($$(KDEPEND_$(1)),m)
48 ifneq ($(CONFIG_PACKAGE_KMOD_$(1)),)
49 TARGETS += $$(PKG_$(1))
50 endif
51 ifeq ($(CONFIG_PACKAGE_KMOD_$(1)),y)
52 INSTALL_TARGETS += $$(PKG_$(1))
53 endif
54 endif
55
56 $$(PKG_$(1)): $(LINUX_DIR)/.modules_done
57 rm -rf $$(I_$(1))
58 $(SCRIPT_DIR)/make-ipkg-dir.sh $$(I_$(1)) ../control/kmod-$(2).control $(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE) $(ARCH)
59 echo "Depends: $$(IDEPEND_$(1))" >> $$(I_$(1))/CONTROL/control
60 ifneq ($(strip $(3)),)
61 mkdir -p $$(I_$(1))/lib/modules/$(LINUX_VERSION)
62 $(CP) $(3) $$(I_$(1))/lib/modules/$(LINUX_VERSION)
63 endif
64 ifneq ($(6),)
65 mkdir -p $$(I_$(1))/etc/modules.d
66 for module in $(7); do \
67 echo $$$$module >> $$(I_$(1))/etc/modules.d/$(6)-$(2); \
68 done
69 echo "#!/bin/sh" >> $$(I_$(1))/CONTROL/postinst
70 echo "[ -z \"\$$$$IPKG_INSTROOT\" ] || exit" >> $$(I_$(1))/CONTROL/postinst
71 echo ". /etc/functions.sh" >> $$(I_$(1))/CONTROL/postinst
72 echo "load_modules /etc/modules.d/$(6)-$(2)" >> $$(I_$(1))/CONTROL/postinst
73 chmod 0755 $$(I_$(1))/CONTROL/postinst
74 endif
75 $(8)
76 $(IPKG_BUILD) $$(I_$(1)) $(PACKAGE_DIR)
77 endef
78
79 KERNEL_IPKG:=$(LINUX_BUILD_DIR)/kernel_$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)_$(ARCH).ipk
80 INSTALL_TARGETS := $(KERNEL_IPKG)
81 TARGETS :=
82
This page took 0.046438 seconds and 5 git commands to generate.