kernel-build.mk 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # This file is part of the OpenADK project. OpenADK is copyrighted
  2. # material, please see the LICENCE file in the top-level directory.
  3. include $(TOPDIR)/rules.mk
  4. include $(TOPDIR)/mk/linux.mk
  5. include ${TOPDIR}/mk/buildhlp.mk
  6. KERNEL_IDIR:=$(LINUX_BUILD_DIR)/kernel-ipkg
  7. $(TOOLCHAIN_BUILD_DIR)/linux-$(KERNEL_VERSION)/.patched:
  8. $(TRACE) target/$(DEVICE)-kernel-patch
  9. $(PATCH) $(TOOLCHAIN_BUILD_DIR)/linux-$(KERNEL_VERSION) ../linux/patches/$(KERNEL_VERSION) *.patch $(MAKE_TRACE)
  10. $(PATCH) $(TOOLCHAIN_BUILD_DIR)/linux-$(KERNEL_VERSION) ../$(DEVICE)/patches *.patch $(MAKE_TRACE)
  11. touch $@
  12. $(LINUX_DIR)/.prepared: $(TOOLCHAIN_BUILD_DIR)/linux-$(KERNEL_VERSION)/.patched
  13. $(TRACE) target/$(DEVICE)-kernel-prepare
  14. ln -sf $(TOOLCHAIN_BUILD_DIR)/linux-$(KERNEL_VERSION) $(LINUX_DIR)
  15. mkdir -p $(LINUX_BUILD_DIR)/kmod-control
  16. touch $@
  17. $(LINUX_DIR)/.config: $(LINUX_DIR)/.prepared $(BUILD_DIR)/.kernelconfig
  18. $(TRACE) target/$(DEVICE)-kernel-configure
  19. for f in $(TARGETS);do if [ -f $$f ];then rm $$f;fi;done $(MAKE_TRACE)
  20. $(CP) $(BUILD_DIR)/.kernelconfig $(LINUX_DIR)/.config
  21. ifeq ($(ADK_NATIVE),y)
  22. echo N | $(MAKE) -C $(LINUX_DIR) oldconfig $(MAKE_TRACE)
  23. $(MAKE) -C $(LINUX_DIR) V=1 prepare scripts $(MAKE_TRACE)
  24. else
  25. echo N | $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(ARCH) CC="$(TARGET_CC)" oldconfig $(MAKE_TRACE)
  26. $(MAKE) -C $(LINUX_DIR) V=1 CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(ARCH) CC="$(TARGET_CC)" prepare scripts $(MAKE_TRACE)
  27. endif
  28. touch -c $(LINUX_DIR)/.config
  29. $(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.config
  30. $(TRACE) target/$(DEVICE)-kernel-compile
  31. ifeq ($(ADK_NATIVE),y)
  32. $(MAKE) -C $(LINUX_DIR) V=1 $(MAKE_TRACE)
  33. $(TRACE) target/$(DEVICE)-kernel-modules-install
  34. rm -rf $(LINUX_BUILD_DIR)/modules
  35. $(MAKE) -C "$(LINUX_DIR)" V=1 DEPMOD=true INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules modules_install $(MAKE_TRACE)
  36. else
  37. $(MAKE) -C $(LINUX_DIR) V=1 CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(ARCH) CC="$(TARGET_CC)" $(MAKE_TRACE)
  38. $(TRACE) target/$(DEVICE)-kernel-modules-install
  39. rm -rf $(LINUX_BUILD_DIR)/modules
  40. $(MAKE) -C "$(LINUX_DIR)" V=1 CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(ARCH) DEPMOD=true INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules modules_install $(MAKE_TRACE)
  41. endif
  42. $(TRACE) target/$(DEVICE)-create-packages
  43. $(MAKE) $(KERNEL_IPKG) $(TARGETS)
  44. touch -c $(LINUX_DIR)/vmlinux
  45. $(KERNEL_IPKG):
  46. $(TRACE) target/$(DEVICE)-create-kernel-package
  47. rm -rf $(KERNEL_IDIR)
  48. @mkdir -p $(KERNEL_IDIR)/etc
  49. ${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh ${KERNEL_IDIR} \
  50. ../linux/kernel.control ${DEVICE}-${KERNEL_VERSION} ${CPU_ARCH}
  51. $(IPKG_BUILD) $(KERNEL_IDIR) $(PACKAGE_DIR) $(MAKE_TRACE)
  52. prepare:
  53. compile: $(LINUX_DIR)/vmlinux
  54. install: compile
  55. ifneq ($(strip $(INSTALL_TARGETS)),)
  56. $(TRACE) target/${DEVICE}-modules-install
  57. $(IPKG) install $(INSTALL_TARGETS) $(MAKE_TRACE)
  58. endif
  59. clean:
  60. rm -rf $(LINUX_BUILD_DIR)
  61. rm -f $(TARGETS)