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