1
0

Makefile 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. # fetch all ADK_KERNELMOD_* vars into
  13. # .kernelconfig.modules and set them to "m"
  14. # 2) fetch all enabled ADK_KERNEL_* vars into
  15. # .kernelconfig.kernel (no conversion, as they are booleans)
  16. # 3) repeat 2) for the disabled ones and save them into
  17. # .kernelconfig.nokernel (to overwrite defaults)
  18. # 4) get the device-specific static kernel config and place it into
  19. # .kernelconfig.board
  20. # 5) prepare for merging:
  21. # * if a variable is disabled in .kernelconfig.board and
  22. # enabled in either of .kernelconfig.{modules,kernel},
  23. # remove it from .kernelconfig.board
  24. # * append ${FS_CMDLINE} to the kernel commandline inside
  25. # .kernelconfig.board
  26. # 6) merge (cat) it all together into .kernelconfig.tmp
  27. # 7) check if .kernelconfig.tmp differs from the current one
  28. # (.kernelconfig) at all, overwriting the current one
  29. # only if it does (so the timestamp stays intact)
  30. # 8) remove the temporary .kernelconfig.tmp
  31. ###
  32. ifeq (${ADK_TARGET_KERNEL_CUSTOMISING},y)
  33. config-prepare: $(TOPDIR)/.config
  34. @sed -n '/^ADK_KPACKAGE_KMOD/s//CONFIG/p' ${TOPDIR}/.config | \
  35. sed 's/=y/=m/' >${BUILD_DIR}/.kernelconfig.modules
  36. @sed -n '/^ADK_KERNEL_MOD/s//CONFIG/p' ${TOPDIR}/.config | \
  37. sed 's/=y/=m/' >>${BUILD_DIR}/.kernelconfig.modules
  38. @sed -n '/^ADK_KERNEL/s//CONFIG/p' ${TOPDIR}/.config \
  39. >${BUILD_DIR}/.kernelconfig.kernel
  40. @sed -n '/^# ADK_KERNEL/s//# CONFIG/p' ${TOPDIR}/.config \
  41. >${BUILD_DIR}/.kernelconfig.nokernel
  42. ifeq ($(ADK_NATIVE),y)
  43. @if [ -f /etc/adktarget ];then \
  44. cp $(TOPDIR)/target/$(ARCH)/kernel.config ${BUILD_DIR}/.kernelconfig.board; \
  45. else \
  46. 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; \
  47. fi
  48. else
  49. @cp ${ADK_TARGET_ARCH}/kernel.config ${BUILD_DIR}/.kernelconfig.board
  50. endif
  51. @(cat ${BUILD_DIR}/.kernelconfig.{modules,kernel} | \
  52. while IFS='=' read symbol value; do \
  53. sed -i -e "/^# $$symbol/d" ${BUILD_DIR}/.kernelconfig.board; \
  54. done;)
  55. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ${FS_CMDLINE}"#' \
  56. ${BUILD_DIR}/.kernelconfig.board
  57. ifneq ($(ADK_TARGET_CMDLINE),)
  58. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ${ADK_TARGET_CMDLINE}"#' \
  59. ${BUILD_DIR}/.kernelconfig.board
  60. endif
  61. ifeq ($(ADK_QUIET_KERNEL),y)
  62. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 quiet"#' \
  63. ${BUILD_DIR}/.kernelconfig.board
  64. endif
  65. ifeq ($(ADK_KERNEL_DEBUG_WITH_KGDB),y)
  66. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 kgdbwait kgdboc=ttyS0,115200"#' \
  67. ${BUILD_DIR}/.kernelconfig.board
  68. endif
  69. @cd ${BUILD_DIR} && cat .kernelconfig.board .kernelconfig.nokernel \
  70. .kernelconfig.kernel .kernelconfig.modules \
  71. >.kernelconfig.tmp
  72. @cd ${BUILD_DIR} && cmp -s .kernelconfig.tmp .kernelconfig || \
  73. cp .kernelconfig.tmp .kernelconfig
  74. @-rm -f ${BUILD_DIR}/.kernelconfig.tmp
  75. else
  76. config-prepare: $(TOPDIR)/.config
  77. @cp ${ADK_TARGET_ARCH}/kernel.config ${BUILD_DIR}/.kernelconfig
  78. endif
  79. prepare: $(ADK_TARGET_ARCH)-prepare
  80. compile: $(ADK_TARGET_ARCH)-compile
  81. image: $(ADK_TARGET_ARCH)-imageclean $(ADK_TARGET_ARCH)-imageinstall
  82. install: $(ADK_TARGET_ARCH)-imageclean $(ADK_TARGET_ARCH)-install $(ADK_TARGET_ARCH)-imageinstall
  83. clean: $(ADK_TARGET_ARCH)-clean $(ADK_TARGET_ARCH)-imageclean
  84. %-clean:
  85. $(TRACE) target/$(patsubst %-clean,%,$@)-clean
  86. $(MAKE) -C $(patsubst %-clean,%,$@) clean
  87. %-imageclean:
  88. $(TRACE) target/$(patsubst %-imageclean,%,$@)-imageclean
  89. $(MAKE) -C $(patsubst %-imageclean,%,$@) imageclean
  90. %-prepare:
  91. $(TRACE) target/$(patsubst %-prepare,%,$@)-prepare
  92. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
  93. %-imageprepare:
  94. $(TRACE) target/$(patsubst %-imageprepare,%,$@)-imageprepare
  95. $(MAKE) -C $(patsubst %-imageprepare,%,$@) imageprepare
  96. %-compile: %-prepare
  97. $(TRACE) target/$(patsubst %-compile,%,$@)-compile
  98. $(MAKE) -C $(patsubst %-compile,%,$@) compile
  99. %-install: %-compile
  100. $(TRACE) target/$(patsubst %-install,%,$@)-install
  101. $(MAKE) -C $(patsubst %-install,%,$@) install
  102. %-imageinstall: %-imageprepare
  103. $(TRACE) target/$(patsubst %-imageinstall,%,$@)-imageinstall
  104. $(MAKE) -C $(patsubst %-imageinstall,%,$@) imageinstall
  105. @echo 'Login as user root with password ${ADK_RUNTIME_PASSWORD} via ssh or console.'