kernel-build.mk 2.9 KB

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