kernel-build.mk 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. include ${TOPDIR}/mk/kernel-vars.mk
  7. KERNEL_PKGDIR:=$(LINUX_BUILD_DIR)/kernel-pkg
  8. $(TOOLCHAIN_BUILD_DIR)/linux-$(KERNEL_VERSION)/.patched:
  9. $(TRACE) target/$(ADK_TARGET)-kernel-patch
  10. $(PATCH) $(TOOLCHAIN_BUILD_DIR)/linux-$(KERNEL_VERSION) ../linux/patches/$(KERNEL_VERSION) *.patch $(MAKE_TRACE)
  11. $(PATCH) $(TOOLCHAIN_BUILD_DIR)/linux-$(KERNEL_VERSION) ../$(ADK_TARGET)/patches *.patch $(MAKE_TRACE)
  12. touch $@
  13. $(LINUX_DIR)/.prepared: $(TOOLCHAIN_BUILD_DIR)/linux-$(KERNEL_VERSION)/.patched
  14. $(TRACE) target/$(ADK_TARGET)-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/$(ADK_TARGET)-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. echo N | $(MAKE) ${KERNEL_MAKE_OPTS} oldconfig $(MAKE_TRACE)
  23. $(MAKE) ${KERNEL_MAKE_OPTS} prepare scripts $(MAKE_TRACE)
  24. touch -c $(LINUX_DIR)/.config
  25. $(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.config
  26. $(TRACE) target/$(ADK_TARGET)-kernel-compile
  27. $(MAKE) ${KERNEL_MAKE_OPTS} -j${ADK_MAKE_JOBS} $(MAKE_TRACE)
  28. $(TRACE) target/$(ADK_TARGET)-kernel-modules-install
  29. rm -rf $(LINUX_BUILD_DIR)/modules
  30. $(MAKE) ${KERNEL_MAKE_OPTS} DEPMOD=true \
  31. INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules \
  32. modules_install $(MAKE_TRACE)
  33. $(TRACE) target/$(ADK_TARGET)-create-packages
  34. $(MAKE) $(KERNEL_PKG) $(TARGETS)
  35. touch -c $(LINUX_DIR)/vmlinux
  36. $(KERNEL_PKG):
  37. $(TRACE) target/$(ADK_TARGET)-create-kernel-package
  38. rm -rf $(KERNEL_PKGDIR)
  39. @mkdir -p $(KERNEL_PKGDIR)/etc
  40. ${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh ${KERNEL_PKGDIR} \
  41. ../linux/kernel.control ${ADK_TARGET}-${KERNEL_VERSION} ${CPU_ARCH}
  42. $(PKG_BUILD) $(KERNEL_PKGDIR) $(PACKAGE_DIR) $(MAKE_TRACE)
  43. prepare:
  44. compile: $(LINUX_DIR)/vmlinux
  45. install: compile
  46. ifneq ($(strip $(INSTALL_TARGETS)),)
  47. $(TRACE) target/${ADK_TARGET}-modules-install
  48. $(PKG_INSTALL) $(INSTALL_TARGETS) $(MAKE_TRACE)
  49. endif
  50. clean:
  51. rm -rf $(LINUX_BUILD_DIR)
  52. rm -f $(TARGETS)