use subpackages to ave some space
[openadk.git] / mk / kernel-build.mk
blobb66f711320244c5bba94de18a7445c5f3117742f
1 # This file is part of the OpenADK project. OpenADK is copyrighted
2 # material, please see the LICENCE file in the top-level directory.
4 include $(ADK_TOPDIR)/rules.mk
5 include ${ADK_TOPDIR}/mk/kernel-ver.mk
6 include $(ADK_TOPDIR)/mk/linux.mk
7 include ${ADK_TOPDIR}/mk/kernel-vars.mk
9 KERNEL_FILE:=$(ADK_TARGET_KERNEL)
10 KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
11 ifeq ($(ADK_TARGET_KERNEL_LINUXBIN),y)
12 KERNEL_FILE:=vmlinux
13 KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
14 endif
15 ifeq ($(ADK_TARGET_KERNEL_ZIMAGE),y)
16 KERNEL_FILE:=vmlinux
17 KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
18 endif
19 ifeq ($(ADK_TARGET_KERNEL_BZIMAGE),y)
20 KERNEL_FILE:=vmlinux
21 KERNEL_TARGET:=all
22 endif
23 ifeq ($(ADK_TARGET_KERNEL_IMAGE),y)
24 KERNEL_FILE:=vmlinux
25 KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
26 endif
28 $(LINUX_DIR)/.prepared: $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_VERSION)/.patched
29 $(TRACE) target/kernel-prepare
30 ln -sf $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_VERSION) $(LINUX_DIR)
31 mkdir -p $(LINUX_BUILD_DIR)/kmod-control
32 touch $@
34 $(LINUX_DIR)/.config: $(LINUX_DIR)/.prepared $(BUILD_DIR)/.kernelconfig $(ADK_TOPDIR)/mk/modules.mk
35 $(TRACE) target/$(ADK_TARGET_ARCH)-kernel-configure
36 -for f in $(TARGETS);do if [ -f $$f ];then rm $$f;fi;done
37 $(CP) $(BUILD_DIR)/.kernelconfig $(LINUX_DIR)/mini.config
38 ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} KCONFIG_ALLCONFIG=mini.config allnoconfig $(MAKE_TRACE)
39 touch -c $(LINUX_DIR)/.config
41 $(LINUX_DIR)/$(KERNEL_FILE): $(LINUX_DIR)/.config
42 $(TRACE) target/$(ADK_TARGET_ARCH)-kernel-compile
43 ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} -j${ADK_MAKE_JOBS} LOCALVERSION="" $(KERNEL_TARGET) modules $(MAKE_TRACE)
44 touch -c $(LINUX_DIR)/$(KERNEL_FILE)
46 $(LINUX_BUILD_DIR)/modules: $(LINUX_DIR)/$(KERNEL_FILE)
47 $(TRACE) target/$(ADK_TARGET_ARCH)-kernel-modules-install
48 rm -rf $(LINUX_BUILD_DIR)/modules
49 ${KERNEL_MAKE_ENV} $(MAKE) -C "${LINUX_DIR}" ${KERNEL_MAKE_OPTS} DEPMOD=true \
50 INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules \
51 LOCALVERSION="" \
52 modules_install $(MAKE_TRACE)
53 $(TRACE) target/$(ADK_TARGET_ARCH)-create-packages
54 @mkdir -p ${PACKAGE_DIR}
55 ifneq ($(strip $(TARGETS)),)
56 $(MAKE) $(TARGETS)
57 endif
59 $(INSTALL_TARGETS): $(LINUX_BUILD_DIR)/modules
61 prepare:
62 compile: $(LINUX_BUILD_DIR)/modules
63 install: compile $(INSTALL_TARGETS)
64 ifneq ($(strip $(INSTALL_TARGETS)),)
65 $(TRACE) target/${ADK_TARGET_ARCH}-modules-install
66 ifeq ($(ADK_TARGET_PACKAGE_IPKG),y)
67 $(PKG_INSTALL) $(INSTALL_TARGETS) $(MAKE_TRACE)
68 else
69 $(foreach pkg,$(INSTALL_TARGETS),$(shell $(PKG_INSTALL) $(pkg)))
70 endif
71 endif
73 clean:
74 rm -rf $(LINUX_BUILD_DIR)
75 rm -f $(TARGETS)