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