kernel-build.mk 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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/kernel-vars.mk
  6. KERNEL_FILE:=$(ADK_TARGET_KERNEL)
  7. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  8. ifeq ($(ADK_TARGET_KERNEL_ZIMAGE),y)
  9. KERNEL_FILE:=vmlinux
  10. KERNEL_TARGET:=$(ADK_TARGET_KERNEL)
  11. endif
  12. ifeq ($(ADK_TARGET_KERNEL_BZIMAGE),y)
  13. KERNEL_FILE:=vmlinux
  14. KERNEL_TARGET:=all
  15. endif
  16. $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_VERSION)/.patched:
  17. $(TRACE) target/kernel-patch
  18. $(PATCH) $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_VERSION) \
  19. ../linux/patches/$(KERNEL_VERSION) *.patch $(MAKE_TRACE)
  20. touch $@
  21. $(LINUX_DIR)/.prepared: $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_VERSION)/.patched
  22. $(TRACE) target/kernel-prepare
  23. ln -sf $(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/linux-$(KERNEL_VERSION) $(LINUX_DIR)
  24. mkdir -p $(LINUX_BUILD_DIR)/kmod-control
  25. touch $@
  26. $(LINUX_DIR)/.config: $(LINUX_DIR)/.prepared $(BUILD_DIR)/.kernelconfig $(TOPDIR)/mk/modules.mk
  27. $(TRACE) target/$(ADK_TARGET_ARCH)-kernel-configure
  28. -for f in $(TARGETS);do if [ -f $$f ];then rm $$f;fi;done
  29. $(CP) $(BUILD_DIR)/.kernelconfig $(LINUX_DIR)/.config
  30. echo N | ${KERNEL_MAKE_ENV} $(MAKE) ${KERNEL_MAKE_OPTS} oldconfig $(MAKE_TRACE)
  31. ${KERNEL_MAKE_ENV} $(MAKE) ${KERNEL_MAKE_OPTS} prepare scripts $(MAKE_TRACE)
  32. touch -c $(LINUX_DIR)/.config
  33. $(LINUX_DIR)/$(KERNEL_FILE): $(LINUX_DIR)/.config
  34. -rm $(LINUX_DIR)/$(KERNEL_TARGET) 2>/dev/null
  35. $(TRACE) target/$(ADK_TARGET_ARCH)-kernel-compile
  36. ${KERNEL_MAKE_ENV} $(MAKE) V=1 ${KERNEL_MAKE_OPTS} -j${ADK_MAKE_JOBS} LOCALVERSION="" $(KERNEL_TARGET) $(MAKE_TRACE)
  37. $(TRACE) target/$(ADK_TARGET_ARCH)-kernel-modules-install
  38. rm -rf $(LINUX_BUILD_DIR)/modules
  39. ${KERNEL_MAKE_ENV} $(MAKE) ${KERNEL_MAKE_OPTS} DEPMOD=true \
  40. INSTALL_MOD_PATH=$(LINUX_BUILD_DIR)/modules \
  41. LOCALVERSION="" \
  42. modules modules_install $(MAKE_TRACE)
  43. $(TRACE) target/$(ADK_TARGET_ARCH)-create-packages
  44. ifneq ($(strip $(TARGETS)),)
  45. $(MAKE) $(TARGETS)
  46. endif
  47. touch -c $(LINUX_DIR)/$(KERNEL_FILE)
  48. prepare:
  49. compile: $(LINUX_DIR)/$(KERNEL_FILE)
  50. install: compile
  51. ifneq ($(strip $(INSTALL_TARGETS)),)
  52. $(TRACE) target/${ADK_TARGET_ARCH}-modules-install
  53. ifeq ($(ADK_TARGET_PACKAGE_IPKG),y)
  54. $(PKG_INSTALL) $(INSTALL_TARGETS) $(MAKE_TRACE)
  55. else
  56. $(foreach pkg,$(INSTALL_TARGETS),$(shell $(PKG_INSTALL) $(pkg)))
  57. endif
  58. endif
  59. clean:
  60. rm -rf $(LINUX_BUILD_DIR)
  61. rm -f $(TARGETS)