1
0

Makefile 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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_KERNEL_MOD_* 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) get the global and device-specific static kernel config and place it into
  17. # .kernelconfig.board
  18. # 4) 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. # 5) merge (cat) it all together into .kernelconfig.tmp
  25. # 6) 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. # 7) remove the temporary .kernelconfig.tmp
  29. ###
  30. ADK_PACKAGE_CRYPTINIT_ROOT:=$(strip $(subst ",, $(ADK_PACKAGE_CRYPTINIT_ROOT)))
  31. ADK_PACKAGE_CRYPTINIT_SWAP:=$(strip $(subst ",, $(ADK_PACKAGE_CRYPTINIT_SWAP)))
  32. ADK_PACKAGE_CMDLINE:=root=$(ADK_PACKAGE_CRYPTINIT_ROOT) swap=$(ADK_PACKAGE_CRYPTINIT_SWAP) resume=/dev/mapper/swapcrypt
  33. ifeq (${ADK_TARGET_KERNEL_CUSTOMISING},y)
  34. config-prepare: $(TOPDIR)/.config
  35. @sed -n '/^ADK_KPACKAGE_KMOD/s//CONFIG/p' ${TOPDIR}/.config | \
  36. sed 's/=y/=m/' >${BUILD_DIR}/.kernelconfig.modules
  37. @sed -n '/^ADK_KERNEL_MOD/s//CONFIG/p' ${TOPDIR}/.config | \
  38. sed 's/=y/=m/' >>${BUILD_DIR}/.kernelconfig.modules
  39. @sed -n '/^ADK_KERNEL/s//CONFIG/p' ${TOPDIR}/.config \
  40. >${BUILD_DIR}/.kernelconfig.kernel
  41. @if [ -f ${ADK_TARGET_ARCH}/kernel/${ADK_TARGET_KERNEL_MINICONFIG} ];then \
  42. cat ${TOPDIR}/target/linux/kernel.config \
  43. ${ADK_TARGET_ARCH}/kernel/${ADK_TARGET_KERNEL_MINICONFIG} > ${BUILD_DIR}/.kernelconfig.board; \
  44. else \
  45. echo "no miniconfig found for target system"; \
  46. exit 1; \
  47. fi
  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 ro"#' \
  53. ${BUILD_DIR}/.kernelconfig.board
  54. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ${FS_CMDLINE}"#' \
  55. ${BUILD_DIR}/.kernelconfig.board
  56. ifneq ($(ADK_TARGET_CMDLINE),)
  57. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ${ADK_TARGET_CMDLINE}"#' \
  58. ${BUILD_DIR}/.kernelconfig.board
  59. endif
  60. ifeq ($(ADK_TARGET_QEMU_WITH_GRAPHIC),y)
  61. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 console=tty0"#' \
  62. ${BUILD_DIR}/.kernelconfig.board
  63. endif
  64. ifneq ($(ADK_PACKAGE_CRYPTINIT_ROOT),)
  65. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ${ADK_PACKAGE_CMDLINE}"#' \
  66. ${BUILD_DIR}/.kernelconfig.board
  67. endif
  68. ifeq ($(ADK_QUIET_KERNEL),y)
  69. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 quiet"#' \
  70. ${BUILD_DIR}/.kernelconfig.board
  71. endif
  72. ifeq ($(ADK_KERNEL_DEBUG_WITH_KGDB),y)
  73. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 kgdbwait kgdboc=ttyS0,115200"#' \
  74. ${BUILD_DIR}/.kernelconfig.board
  75. endif
  76. ifeq ($(ADK_KERNEL_NETCONSOLE),y)
  77. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 netconsole=@$(ADK_PARAMETER_NETCONSOLE_SRC_IP)/,@$(ADK_PARAMETER_NETCONSOLE_DST_IP)/"#' \
  78. ${BUILD_DIR}/.kernelconfig.board
  79. endif
  80. @cd ${BUILD_DIR} && cat .kernelconfig.board \
  81. .kernelconfig.kernel .kernelconfig.modules \
  82. >.kernelconfig.tmp
  83. @cd ${BUILD_DIR} && cmp -s .kernelconfig.tmp .kernelconfig || \
  84. cp .kernelconfig.tmp .kernelconfig
  85. @-rm -f ${BUILD_DIR}/.kernelconfig.tmp
  86. else
  87. config-prepare: $(TOPDIR)/.config
  88. @if [ -f ${ADK_TARGET_ARCH}/kernel/${ADK_TARGET_KERNEL_MINICONFIG} ];then \
  89. cat ${TOPDIR}/target/linux/kernel.config \
  90. ${ADK_TARGET_ARCH}/kernel/${ADK_TARGET_KERNEL_MINICONFIG} > ${BUILD_DIR}/.kernelconfig.board; \
  91. else \
  92. echo "no miniconfig found for target system"; \
  93. exit 1; \
  94. fi
  95. endif
  96. prepare: $(ADK_TARGET_ARCH)-prepare
  97. compile: $(ADK_TARGET_ARCH)-compile
  98. image: $(ADK_TARGET_ARCH)-imageclean $(ADK_TARGET_ARCH)-imageinstall
  99. install: $(ADK_TARGET_ARCH)-imageclean $(ADK_TARGET_ARCH)-install $(ADK_TARGET_ARCH)-imageinstall
  100. clean: $(ADK_TARGET_ARCH)-clean $(ADK_TARGET_ARCH)-imageclean
  101. %-clean:
  102. $(TRACE) target/$(patsubst %-clean,%,$@)-clean
  103. $(MAKE) -C $(patsubst %-clean,%,$@) clean
  104. %-imageclean:
  105. $(TRACE) target/$(patsubst %-imageclean,%,$@)-imageclean
  106. $(MAKE) -C $(patsubst %-imageclean,%,$@) imageclean
  107. %-prepare:
  108. $(TRACE) target/$(patsubst %-prepare,%,$@)-prepare
  109. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
  110. %-imageprepare:
  111. $(TRACE) target/$(patsubst %-imageprepare,%,$@)-imageprepare
  112. $(MAKE) -C $(patsubst %-imageprepare,%,$@) imageprepare
  113. %-compile: %-prepare
  114. $(TRACE) target/$(patsubst %-compile,%,$@)-compile
  115. $(MAKE) -C $(patsubst %-compile,%,$@) compile
  116. %-install: %-compile
  117. $(TRACE) target/$(patsubst %-install,%,$@)-install
  118. $(MAKE) -C $(patsubst %-install,%,$@) install
  119. %-imageinstall: %-imageprepare
  120. $(TRACE) target/$(patsubst %-imageinstall,%,$@)-imageinstall
  121. $(MAKE) -C $(patsubst %-imageinstall,%,$@) imageinstall
  122. @echo 'Login as user root with password ${ADK_RUNTIME_PASSWORD} via ssh or console.'