kernel-build.mk 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. ifeq ($(ADK_TARGET_PACKAGE_IPKG),y)
  49. $(PKG_INSTALL) $(INSTALL_TARGETS) $(MAKE_TRACE)
  50. else
  51. $(foreach pkg,$(INSTALL_TARGETS),$(shell $(PKG_INSTALL) $(pkg)))
  52. endif
  53. endif
  54. clean:
  55. rm -rf $(LINUX_BUILD_DIR)
  56. rm -f $(TARGETS)