1
0

Makefile 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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/rootfs.mk
  5. all: install
  6. ### Kernel .config Creation
  7. # The following target combines all kernel-related variables and
  8. # config files into a single one to be used as the final kernel
  9. # configuration when building. This is how it's done:
  10. # 1) fetch all ADK_KPACKAGE_KMOD_* vars into
  11. # .kernelconfig.modules and set them to "m"
  12. # 2) fetch all enabled ADK_KERNEL_* vars into
  13. # .kernelconfig.kernel (no conversion, as they are booleans)
  14. # 3) repeat 2) for the disabled ones and save them into
  15. # .kernelconfig.nokernel (to overwrite defaults)
  16. # 4) get the device-specific static kernel config and place it into
  17. # .kernelconfig.board
  18. # 5) prepare for merging:
  19. # * if a variable is disabled in .kernelconfig.board and
  20. # enabled in either of .kernelconfig.{modules,kernel},
  21. # remove it from .kernelconfig.board
  22. # * append ${FS_CMDLINE} to the kernel commandline inside
  23. # .kernelconfig.board
  24. # 6) merge (cat) it all together into .kernelconfig.tmp
  25. # 7) check if .kernelconfig.tmp differs from the current one
  26. # (.kernelconfig) at all, overwriting the current one
  27. # only if it does (so the timestamp stays intact)
  28. # 8) remove the temporary .kernelconfig.tmp
  29. ###
  30. config-prepare: $(TOPDIR)/.config
  31. @sed -n '/^ADK_KPACKAGE_KMOD/s//CONFIG/p' ${TOPDIR}/.config | \
  32. sed 's/=y/=m/' >${BUILD_DIR}/.kernelconfig.modules
  33. @sed -n '/^ADK_KERNEL/s//CONFIG/p' ${TOPDIR}/.config \
  34. >${BUILD_DIR}/.kernelconfig.kernel
  35. @sed -n '/^ADK_MOD_KERNEL/s//CONFIG/p' ${TOPDIR}/.config | \
  36. sed 's/=y/=m/' >${BUILD_DIR}/.kernelconfig.modkernel
  37. @sed -n '/^# ADK_KERNEL/s//# CONFIG/p' ${TOPDIR}/.config \
  38. >${BUILD_DIR}/.kernelconfig.nokernel
  39. # if native build, first try /proc/config.gz
  40. ifeq ($(ADK_NATIVE),y)
  41. @if [ -f /proc/config.gz ];then zcat /proc/config.gz > ${BUILD_DIR}/.kernelconfig.board; else cp ${ADK_TARGET}/kernel.config.$(ARCH) ${BUILD_DIR}/.kernelconfig.board; fi
  42. else
  43. @cp ${ADK_TARGET}/kernel.config ${BUILD_DIR}/.kernelconfig.board
  44. endif
  45. @(cat ${BUILD_DIR}/.kernelconfig.{modules,kernel} | \
  46. while IFS='=' read symbol value; do \
  47. sed -i -e "/^# $$symbol/d" ${BUILD_DIR}/.kernelconfig.board; \
  48. done;)
  49. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ${FS_CMDLINE}"#' \
  50. ${BUILD_DIR}/.kernelconfig.board
  51. ifeq ($(ADK_KERNEL_DEBUG_WITH_KGDB),y)
  52. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 kgdbwait kgdboc=ttyS0,115200"#' \
  53. ${BUILD_DIR}/.kernelconfig.board
  54. endif
  55. @cd ${BUILD_DIR} && cat .kernelconfig.board .kernelconfig.nokernel \
  56. .kernelconfig.kernel .kernelconfig.modkernel .kernelconfig.modules \
  57. >.kernelconfig.tmp
  58. @cd ${BUILD_DIR} && cmp -s .kernelconfig.tmp .kernelconfig || \
  59. cp .kernelconfig.tmp .kernelconfig
  60. @-rm -f ${BUILD_DIR}/.kernelconfig.tmp
  61. prepare: $(ADK_TARGET)-prepare
  62. compile: $(ADK_TARGET)-compile
  63. image: $(ADK_TARGET)-imageclean $(ADK_TARGET)-imageinstall
  64. install: $(ADK_TARGET)-imageclean $(ADK_TARGET)-install $(ADK_TARGET)-imageinstall
  65. clean: $(ADK_TARGET)-clean $(ADK_TARGET)-imageclean
  66. %-clean:
  67. $(TRACE) target/$(patsubst %-clean,%,$@)-clean
  68. $(MAKE) -C $(patsubst %-clean,%,$@) clean
  69. %-imageclean:
  70. $(TRACE) target/$(patsubst %-imageclean,%,$@)-imageclean
  71. $(MAKE) -C $(patsubst %-imageclean,%,$@) imageclean
  72. %-prepare:
  73. $(TRACE) target/$(patsubst %-prepare,%,$@)-prepare
  74. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
  75. %-imageprepare:
  76. $(TRACE) target/$(patsubst %-imageprepare,%,$@)-imageprepare
  77. $(MAKE) -C $(patsubst %-imageprepare,%,$@) imageprepare
  78. %-compile: %-prepare
  79. $(TRACE) target/$(patsubst %-compile,%,$@)-compile
  80. $(MAKE) -C $(patsubst %-compile,%,$@) compile
  81. %-install: %-compile
  82. $(TRACE) target/$(patsubst %-install,%,$@)-install
  83. $(MAKE) -C $(patsubst %-install,%,$@) install
  84. %-imageinstall: %-imageprepare
  85. $(TRACE) target/$(patsubst %-imageinstall,%,$@)-imageinstall
  86. $(MAKE) -C $(patsubst %-imageinstall,%,$@) imageinstall