Makefile 4.2 KB

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