kernel-build.mk 2.9 KB

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