kernel-build.mk 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. echo N | $(MAKE) -C $(LINUX_DIR) CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(ARCH) CC="$(TARGET_CC)" oldconfig $(MAKE_TRACE)
  25. $(MAKE) -C $(LINUX_DIR) V=1 CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(ARCH) CC="$(TARGET_CC)" prepare scripts $(MAKE_TRACE)
  26. touch -c $(LINUX_DIR)/.config
  27. $(LINUX_DIR)/vmlinux: $(LINUX_DIR)/.config
  28. $(TRACE) target/$(DEVICE)-kernel-compile
  29. $(MAKE) -C $(LINUX_DIR) V=1 CROSS_COMPILE="$(KERNEL_CROSS)" ARCH=$(ARCH) CC="$(TARGET_CC)" $(MAKE_TRACE)
  30. $(TRACE) target/$(DEVICE)-kernel-modules-install
  31. rm -rf $(LINUX_BUILD_DIR)/modules
  32. $(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)
  33. $(TRACE) target/$(DEVICE)-create-packages
  34. $(MAKE) $(KERNEL_IPKG) $(TARGETS)
  35. touch -c $(LINUX_DIR)/vmlinux
  36. $(KERNEL_IPKG):
  37. $(TRACE) target/$(DEVICE)-create-kernel-package
  38. rm -rf $(KERNEL_IDIR)
  39. @mkdir -p $(KERNEL_IDIR)/etc
  40. ${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh ${KERNEL_IDIR} \
  41. ../linux/kernel.control ${DEVICE}-${KERNEL_VERSION} ${ARCH}
  42. $(IPKG_BUILD) $(KERNEL_IDIR) $(PACKAGE_DIR) $(MAKE_TRACE)
  43. prepare:
  44. compile: $(LINUX_DIR)/vmlinux
  45. install: compile
  46. ifneq ($(strip $(INSTALL_TARGETS)),)
  47. $(TRACE) target/${DEVICE}-modules-install
  48. $(IPKG) install $(INSTALL_TARGETS) $(MAKE_TRACE)
  49. endif
  50. clean:
  51. rm -rf $(LINUX_BUILD_DIR)
  52. rm -f $(TARGETS)