Makefile 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. ifeq ($(ADK_NATIVE),y)
  40. @if [ -f /etc/adktarget ];then \
  41. target=$$(cat /etc/adktarget); \
  42. cp $(TOPDIR)/target/$$target/kernel.config ${BUILD_DIR}/.kernelconfig.board; \
  43. else \
  44. 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; \
  45. fi
  46. else
  47. @cp ${ADK_TARGET}/kernel.config ${BUILD_DIR}/.kernelconfig.board
  48. endif
  49. @(cat ${BUILD_DIR}/.kernelconfig.{modules,kernel} | \
  50. while IFS='=' read symbol value; do \
  51. sed -i -e "/^# $$symbol/d" ${BUILD_DIR}/.kernelconfig.board; \
  52. done;)
  53. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ${FS_CMDLINE}"#' \
  54. ${BUILD_DIR}/.kernelconfig.board
  55. ifeq ($(ADK_KERNEL_DEBUG_WITH_KGDB),y)
  56. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 kgdbwait kgdboc=ttyS0,115200"#' \
  57. ${BUILD_DIR}/.kernelconfig.board
  58. endif
  59. @cd ${BUILD_DIR} && cat .kernelconfig.board .kernelconfig.nokernel \
  60. .kernelconfig.kernel .kernelconfig.modkernel .kernelconfig.modules \
  61. >.kernelconfig.tmp
  62. @cd ${BUILD_DIR} && cmp -s .kernelconfig.tmp .kernelconfig || \
  63. cp .kernelconfig.tmp .kernelconfig
  64. @-rm -f ${BUILD_DIR}/.kernelconfig.tmp
  65. prepare: $(ADK_TARGET)-prepare
  66. compile: $(ADK_TARGET)-compile
  67. image: $(ADK_TARGET)-imageclean $(ADK_TARGET)-imageinstall
  68. install: $(ADK_TARGET)-imageclean $(ADK_TARGET)-install $(ADK_TARGET)-imageinstall
  69. clean: $(ADK_TARGET)-clean $(ADK_TARGET)-imageclean
  70. %-clean:
  71. $(TRACE) target/$(patsubst %-clean,%,$@)-clean
  72. $(MAKE) -C $(patsubst %-clean,%,$@) clean
  73. %-imageclean:
  74. $(TRACE) target/$(patsubst %-imageclean,%,$@)-imageclean
  75. $(MAKE) -C $(patsubst %-imageclean,%,$@) imageclean
  76. %-prepare:
  77. $(TRACE) target/$(patsubst %-prepare,%,$@)-prepare
  78. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
  79. %-imageprepare:
  80. $(TRACE) target/$(patsubst %-imageprepare,%,$@)-imageprepare
  81. $(MAKE) -C $(patsubst %-imageprepare,%,$@) imageprepare
  82. %-compile: %-prepare
  83. $(TRACE) target/$(patsubst %-compile,%,$@)-compile
  84. $(MAKE) -C $(patsubst %-compile,%,$@) compile
  85. %-install: %-compile
  86. $(TRACE) target/$(patsubst %-install,%,$@)-install
  87. $(MAKE) -C $(patsubst %-install,%,$@) install
  88. %-imageinstall: %-imageprepare
  89. $(TRACE) target/$(patsubst %-imageinstall,%,$@)-imageinstall
  90. $(MAKE) -C $(patsubst %-imageinstall,%,$@) imageinstall
  91. @echo 'Login as user root with password ${ADK_RUNTIME_PASSWORD} via ssh or console'