1
0

Makefile 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. ifeq (${ADK_TARGET_KERNEL64},y)
  7. KERNEL_CFG:=kernel64.config
  8. else
  9. KERNEL_CFG:=kernel.config
  10. endif
  11. ### Kernel .config Creation
  12. # The following target combines all kernel-related variables and
  13. # config files into a single one to be used as the final kernel
  14. # configuration when building. This is how it's done:
  15. # 1) fetch all ADK_KPACKAGE_KMOD_* vars into
  16. # .kernelconfig.modules and set them to "m",
  17. # fetch all ADK_KERNEL_MOD_* vars into
  18. # .kernelconfig.modules and set them to "m"
  19. # 2) fetch all enabled ADK_KERNEL_* vars into
  20. # .kernelconfig.kernel (no conversion, as they are booleans)
  21. # 3) repeat 2) for the disabled ones and save them into
  22. # .kernelconfig.nokernel (to overwrite defaults)
  23. # 4) get the device-specific static kernel config and place it into
  24. # .kernelconfig.board
  25. # 5) prepare for merging:
  26. # * if a variable is disabled in .kernelconfig.board and
  27. # enabled in either of .kernelconfig.{modules,kernel},
  28. # remove it from .kernelconfig.board
  29. # * append ${FS_CMDLINE} to the kernel commandline inside
  30. # .kernelconfig.board
  31. # 6) merge (cat) it all together into .kernelconfig.tmp
  32. # 7) check if .kernelconfig.tmp differs from the current one
  33. # (.kernelconfig) at all, overwriting the current one
  34. # only if it does (so the timestamp stays intact)
  35. # 8) remove the temporary .kernelconfig.tmp
  36. ###
  37. ADK_PACKAGE_CRYPTINIT_ROOT:=$(strip $(subst ",, $(ADK_PACKAGE_CRYPTINIT_ROOT)))
  38. ADK_PACKAGE_CRYPTINIT_SWAP:=$(strip $(subst ",, $(ADK_PACKAGE_CRYPTINIT_SWAP)))
  39. ADK_PACKAGE_CMDLINE:=root=$(ADK_PACKAGE_CRYPTINIT_ROOT) swap=$(ADK_PACKAGE_CRYPTINIT_SWAP) resume=/dev/mapper/swapcrypt
  40. ifeq (${ADK_TARGET_KERNEL_CUSTOMISING},y)
  41. config-prepare: $(TOPDIR)/.config
  42. @sed -n '/^ADK_KPACKAGE_KMOD/s//CONFIG/p' ${TOPDIR}/.config | \
  43. sed 's/=y/=m/' >${BUILD_DIR}/.kernelconfig.modules
  44. @sed -n '/^ADK_KERNEL_MOD/s//CONFIG/p' ${TOPDIR}/.config | \
  45. sed 's/=y/=m/' >>${BUILD_DIR}/.kernelconfig.modules
  46. @sed -n '/^ADK_KERNEL/s//CONFIG/p' ${TOPDIR}/.config \
  47. >${BUILD_DIR}/.kernelconfig.kernel
  48. @sed -n '/^# ADK_KERNEL/s//# CONFIG/p' ${TOPDIR}/.config \
  49. >${BUILD_DIR}/.kernelconfig.nokernel
  50. ifeq ($(ADK_NATIVE),y)
  51. @if [ -f /etc/adktarget ];then \
  52. cp $(TOPDIR)/target/$(ARCH)/${KERNEL_CFG} ${BUILD_DIR}/.kernelconfig.board; \
  53. else \
  54. 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; \
  55. fi
  56. else
  57. ifeq ($(ADK_USE_KERNEL_MINICONFIG),y)
  58. @if [ -f ${ADK_TARGET_ARCH}/kernel/${ADK_TARGET_KERNEL_MINICONFIG} ];then \
  59. cat ${TOPDIR}/target/linux/kernel.config \
  60. ${ADK_TARGET_ARCH}/kernel/${ADK_TARGET_KERNEL_MINICONFIG} > ${BUILD_DIR}/.kernelconfig.board; \
  61. else \
  62. echo "no miniconfig found for target system"; \
  63. exit 1; \
  64. fi
  65. else
  66. @if [ -f ${ADK_TARGET_ARCH}/${KERNEL_CFG}.$(ADK_TARGET_SYSTEM) ];then \
  67. cp ${ADK_TARGET_ARCH}/${KERNEL_CFG}.$(ADK_TARGET_SYSTEM) ${BUILD_DIR}/.kernelconfig.board; \
  68. else \
  69. cp ${ADK_TARGET_ARCH}/${KERNEL_CFG} ${BUILD_DIR}/.kernelconfig.board; \
  70. fi
  71. endif
  72. endif
  73. @(cat ${BUILD_DIR}/.kernelconfig.{modules,kernel} | \
  74. while IFS='=' read symbol value; do \
  75. sed -i -e "/^# $$symbol/d" ${BUILD_DIR}/.kernelconfig.board; \
  76. done;)
  77. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ${FS_CMDLINE}"#' \
  78. ${BUILD_DIR}/.kernelconfig.board
  79. ifneq ($(ADK_TARGET_CMDLINE),)
  80. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ${ADK_TARGET_CMDLINE}"#' \
  81. ${BUILD_DIR}/.kernelconfig.board
  82. endif
  83. ifneq ($(ADK_PACKAGE_CRYPTINIT_ROOT),)
  84. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ${ADK_PACKAGE_CMDLINE}"#' \
  85. ${BUILD_DIR}/.kernelconfig.board
  86. endif
  87. ifeq ($(ADK_QUIET_KERNEL),y)
  88. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 quiet"#' \
  89. ${BUILD_DIR}/.kernelconfig.board
  90. endif
  91. ifeq ($(ADK_KERNEL_DEBUG_WITH_KGDB),y)
  92. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 kgdbwait kgdboc=ttyS0,115200"#' \
  93. ${BUILD_DIR}/.kernelconfig.board
  94. endif
  95. ifeq ($(ADK_KERNEL_NETCONSOLE),y)
  96. @sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 netconsole=@$(ADK_PARAMETER_NETCONSOLE_SRC_IP)/,@$(ADK_PARAMETER_NETCONSOLE_DST_IP)/"#' \
  97. ${BUILD_DIR}/.kernelconfig.board
  98. endif
  99. @cd ${BUILD_DIR} && cat .kernelconfig.board .kernelconfig.nokernel \
  100. .kernelconfig.kernel .kernelconfig.modules \
  101. >.kernelconfig.tmp
  102. @cd ${BUILD_DIR} && cmp -s .kernelconfig.tmp .kernelconfig || \
  103. cp .kernelconfig.tmp .kernelconfig
  104. @-rm -f ${BUILD_DIR}/.kernelconfig.tmp
  105. else
  106. config-prepare: $(TOPDIR)/.config
  107. if [ -f ${ADK_TARGET_ARCH}/${KERNEL_CFG}.$(ADK_TARGET_SYSTEM) ];then \
  108. cp ${ADK_TARGET_ARCH}/${KERNEL_CFG}.$(ADK_TARGET_SYSTEM) ${BUILD_DIR}/.kernelconfig.board; \
  109. else \
  110. cp ${ADK_TARGET_ARCH}/${KERNEL_CFG} ${BUILD_DIR}/.kernelconfig.board; \
  111. fi
  112. endif
  113. prepare: $(ADK_TARGET_ARCH)-prepare
  114. compile: $(ADK_TARGET_ARCH)-compile
  115. image: $(ADK_TARGET_ARCH)-imageclean $(ADK_TARGET_ARCH)-imageinstall
  116. install: $(ADK_TARGET_ARCH)-imageclean $(ADK_TARGET_ARCH)-install $(ADK_TARGET_ARCH)-imageinstall
  117. clean: $(ADK_TARGET_ARCH)-clean $(ADK_TARGET_ARCH)-imageclean
  118. %-clean:
  119. $(TRACE) target/$(patsubst %-clean,%,$@)-clean
  120. $(MAKE) -C $(patsubst %-clean,%,$@) clean
  121. %-imageclean:
  122. $(TRACE) target/$(patsubst %-imageclean,%,$@)-imageclean
  123. $(MAKE) -C $(patsubst %-imageclean,%,$@) imageclean
  124. %-prepare:
  125. $(TRACE) target/$(patsubst %-prepare,%,$@)-prepare
  126. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
  127. %-imageprepare:
  128. $(TRACE) target/$(patsubst %-imageprepare,%,$@)-imageprepare
  129. $(MAKE) -C $(patsubst %-imageprepare,%,$@) imageprepare
  130. %-compile: %-prepare
  131. $(TRACE) target/$(patsubst %-compile,%,$@)-compile
  132. $(MAKE) -C $(patsubst %-compile,%,$@) compile
  133. %-install: %-compile
  134. $(TRACE) target/$(patsubst %-install,%,$@)-install
  135. $(MAKE) -C $(patsubst %-install,%,$@) install
  136. %-imageinstall: %-imageprepare
  137. $(TRACE) target/$(patsubst %-imageinstall,%,$@)-imageinstall
  138. $(MAKE) -C $(patsubst %-imageinstall,%,$@) imageinstall
  139. @echo 'Login as user root with password ${ADK_RUNTIME_PASSWORD} via ssh or console.'