Makefile 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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_QUIET_KERNEL),y)
  56. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 quiet"#' \
  57. ${BUILD_DIR}/.kernelconfig.board
  58. endif
  59. ifeq ($(ADK_KERNEL_DEBUG_WITH_KGDB),y)
  60. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 kgdbwait kgdboc=ttyS0,115200"#' \
  61. ${BUILD_DIR}/.kernelconfig.board
  62. endif
  63. @cd ${BUILD_DIR} && cat .kernelconfig.board .kernelconfig.nokernel \
  64. .kernelconfig.kernel .kernelconfig.modkernel .kernelconfig.modules \
  65. >.kernelconfig.tmp
  66. @cd ${BUILD_DIR} && cmp -s .kernelconfig.tmp .kernelconfig || \
  67. cp .kernelconfig.tmp .kernelconfig
  68. @-rm -f ${BUILD_DIR}/.kernelconfig.tmp
  69. prepare: $(ADK_TARGET)-prepare
  70. compile: $(ADK_TARGET)-compile
  71. image: $(ADK_TARGET)-imageclean $(ADK_TARGET)-imageinstall
  72. install: $(ADK_TARGET)-imageclean $(ADK_TARGET)-install $(ADK_TARGET)-imageinstall
  73. clean: $(ADK_TARGET)-clean $(ADK_TARGET)-imageclean
  74. %-clean:
  75. $(TRACE) target/$(patsubst %-clean,%,$@)-clean
  76. $(MAKE) -C $(patsubst %-clean,%,$@) clean
  77. %-imageclean:
  78. $(TRACE) target/$(patsubst %-imageclean,%,$@)-imageclean
  79. $(MAKE) -C $(patsubst %-imageclean,%,$@) imageclean
  80. %-prepare:
  81. $(TRACE) target/$(patsubst %-prepare,%,$@)-prepare
  82. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
  83. %-imageprepare:
  84. $(TRACE) target/$(patsubst %-imageprepare,%,$@)-imageprepare
  85. $(MAKE) -C $(patsubst %-imageprepare,%,$@) imageprepare
  86. %-compile: %-prepare
  87. $(TRACE) target/$(patsubst %-compile,%,$@)-compile
  88. $(MAKE) -C $(patsubst %-compile,%,$@) compile
  89. %-install: %-compile
  90. $(TRACE) target/$(patsubst %-install,%,$@)-install
  91. $(MAKE) -C $(patsubst %-install,%,$@) install
  92. %-imageinstall: %-imageprepare
  93. $(TRACE) target/$(patsubst %-imageinstall,%,$@)-imageinstall
  94. $(MAKE) -C $(patsubst %-imageinstall,%,$@) imageinstall
  95. @echo 'Login as user root with password ${ADK_RUNTIME_PASSWORD} via ssh or console.'