fix kmod build after target/linux reorg
[openwrt.git] / openwrt / target / linux / kernel.mk
1 LINUX_SOURCE:=linux-$(LINUX_VERSION).tar.bz2
2 LINUX_SITE=http://www.fi.kernel.org/pub/linux/kernel/v$(KERNEL) \
3 http://www.fr.kernel.org/pub/linux/kernel/v$(KERNEL) \
4 http://www.kernel.org/pub/linux/kernel/v$(KERNEL) \
5 http://www.de.kernel.org/pub/linux/kernel/v$(KERNEL)
6
7 KERNEL_IPKG:=$(LINUX_BUILD_DIR)/kernel_$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)_$(ARCH).ipk
8 KERNEL_IDIR:=$(LINUX_BUILD_DIR)/kernel-ipkg
9
10 $(TARGETS): $(PACKAGE_DIR)
11
12 $(PACKAGE_DIR):
13 mkdir -p $(PACKAGE_DIR)
14
15 $(DL_DIR)/$(LINUX_SOURCE):
16 -mkdir -p $(DL_DIR)
17 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(LINUX_SOURCE) $(LINUX_KERNEL_MD5SUM) $(LINUX_SITE) $(MAKE_TRACE)
18
19 $(LINUX_DIR)/.unpacked: $(DL_DIR)/$(LINUX_SOURCE)
20 -mkdir -p $(LINUX_BUILD_DIR)
21 bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(LINUX_BUILD_DIR) $(TAR_OPTIONS) -
22 rm -f $(BUILD_DIR)/linux
23 ln -s $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(BUILD_DIR)/linux
24 touch $@
25
26 ifeq ($(KERNEL),2.4)
27 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
28 $(SED) "s,^CROSS_COMPILE.*,CROSS_COMPILE=$(KERNEL_CROSS),g;" \
29 $(LINUX_DIR)/Makefile \
30 $(LINUX_DIR)/arch/*/Makefile
31 $(SED) "s,\-mcpu=,\-mtune=,g;" $(LINUX_DIR)/arch/mips/Makefile
32 $(MAKE) -C $(LINUX_DIR) ARCH=$(LINUX_KARCH) oldconfig include/linux/version.h $(MAKE_TRACE)
33 touch $@
34
35 $(LINUX_DIR)/.depend_done: $(LINUX_DIR)/.configured
36 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(LINUX_KARCH) dep $(MAKE_TRACE)
37 touch $@
38
39 $(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.depend_done
40 else
41 $(LINUX_DIR)/.configured: $(LINUX_DIR)/.patched
42 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(LINUX_KARCH) oldconfig $(MAKE_TRACE)
43 touch $@
44 endif
45
46 $(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.configured
47 $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(LINUX_KARCH) PATH=$(TARGET_PATH) $(MAKE_TRACE)
48
49 $(LINUX_KERNEL): $(LINUX_DIR)/vmlinux
50 $(TARGET_CROSS)objcopy -O binary -R .reginfo -R .note -R .comment -R .mdebug -S $< $@ $(MAKE_TRACE)
51 touch -c $(LINUX_KERNEL)
52
53 $(LINUX_DIR)/.modules_done: $(LINUX_KERNEL) $(LINUX_IMAGE)
54 rm -rf $(LINUX_BUILD_DIR)/modules
55 $(MAKE) -C "$(LINUX_DIR)" CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(LINUX_KARCH) PATH="$(TARGET_PATH)" modules $(MAKE_TRACE)
56 $(MAKE) -C "$(LINUX_DIR)" CROSS_COMPILE="$(KERNEL_CROSS)" DEPMOD=true INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules modules_install $(MAKE_TRACE)
57 touch $(LINUX_DIR)/.modules_done
58
59 $(STAGING_DIR)/include/linux/version.h: $(LINUX_DIR)/.configured
60 mkdir -p $(STAGING_DIR)/include
61 tar -ch -C $(LINUX_DIR)/include -f - linux | tar -xf - -C $(STAGING_DIR)/include/
62 tar -ch -C $(LINUX_DIR)/include -f - asm | tar -xf - -C $(STAGING_DIR)/include/
63
64 $(STAMP_DIR)/.linux-compile: $(LINUX_DIR)/.modules_done
65 @mkdir -p $(STAMP_DIR)
66 @$(MAKE) $(TARGETS)
67 ln -sf $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) $(BUILD_DIR)/linux
68 @$(TRACE) target/linux/package
69 $(MAKE) -C $(TOPDIR)/target/linux/package \
70 $(KPKG_MAKEOPTS) \
71 compile
72 touch $@
73
74 $(TARGET_MODULES_DIR):
75 -mkdir -p $(TARGET_MODULES_DIR)
76
77 $(KERNEL_IPKG):
78 rm -rf $(KERNEL_IDIR)
79 mkdir -p $(KERNEL_IDIR)/etc
80 $(SCRIPT_DIR)/make-ipkg-dir.sh $(KERNEL_IDIR) ../control/kernel.control $(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE) $(ARCH)
81 if [ -f ./config/$(BOARD).modules ]; then \
82 cp ./config/$(BOARD).modules $(KERNEL_IDIR)/etc/modules; \
83 fi
84 $(IPKG_BUILD) $(KERNEL_IDIR) $(LINUX_BUILD_DIR) $(MAKE_TRACE)
85
86 source: $(DL_DIR)/$(LINUX_SOURCE)
87 prepare: $(PACKAGE_DIR) $(LINUX_DIR)/.configured
88 compile:
89 $(MAKE) $(STAMP_DIR)/.linux-compile $(MAKE_TRACE)
90
91 install: compile $(TARGET_MODULES_DIR) $(KERNEL_IPKG)
92 rm -rf $(LINUX_BUILD_DIR)/root*
93 cp -fpR $(BUILD_DIR)/root $(LINUX_BUILD_DIR)/
94 echo -e 'dest root /\noption offline_root $(LINUX_BUILD_DIR)/root' > $(LINUX_BUILD_DIR)/ipkg.conf
95 $(MAKE) -C $(TOPDIR)/target/linux/package \
96 $(KPKG_MAKEOPTS) \
97 install
98 @{ [ "$(INSTALL_TARGETS)" != "" ] && $(IPKG_KERNEL) install $(INSTALL_TARGETS) || true; } $(MAKE_TRACE)
99
100 mostlyclean:
101 rm -f $(STAMP_DIR)/.linux-compile
102 rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.modules_done
103 rm -f $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION)/.drivers-unpacked
104 $(MAKE) -C $(LINUX_BUILD_DIR)/linux-$(LINUX_VERSION) clean $(MAKE_TRACE)
105 rm -f $(LINUX_KERNEL) $(LINUX_IMAGE)
106
107 rebuild:
108 -$(MAKE) mostlyclean
109 if [ -f $(LINUX_KERNEL) ]; then \
110 $(MAKE) clean $(MAKE_TRACE); \
111 fi
112 $(MAKE) compile $(MAKE_TRACE)
113
114 clean:
115 rm -f $(STAMP_DIR)/.linux-compile
116 rm -rf $(LINUX_BUILD_DIR)
117 rm -f $(TARGETS)
This page took 0.063844 seconds and 5 git commands to generate.