Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # $Id: Makefile 400 2009-05-01 20:13:27Z wbx $
  2. #-
  3. # This file is part of the OpenADK project. OpenADK is copyrighted
  4. # material, please see the LICENCE file in the top-level directory.
  5. include $(TOPDIR)/rules.mk
  6. include $(TOPDIR)/mk/rootfs.mk
  7. all: install
  8. ### Kernel .config Creation
  9. # The following target combines all kernel-related variables and
  10. # config files into a single one to be used as the final kernel
  11. # configuration when building. This is how it's done:
  12. # 1) fetch all ADK_KPACKAGE_KMOD_* 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) repeat 2) for the disabled ones and save them into
  17. # .kernelconfig.nokernel (to overwrite defaults)
  18. # 4) get the device-specific static kernel config and place it into
  19. # .kernelconfig.board
  20. # 5) prepare for merging:
  21. # * if a variable is disabled in .kernelconfig.board and
  22. # enabled in either of .kernelconfig.{modules,kernel},
  23. # remove it from .kernelconfig.board
  24. # * append ${FS_CMDLINE} to the kernel commandline inside
  25. # .kernelconfig.board
  26. # 6) merge (cat) it all together into .kernelconfig.tmp
  27. # 7) check if .kernelconfig.tmp differs from the current one
  28. # (.kernelconfig) at all, overwriting the current one
  29. # only if it does (so the timestamp stays intact)
  30. # 8) remove the temporary .kernelconfig.tmp
  31. ###
  32. config-prepare: $(TOPDIR)/.config
  33. sed -n '/^ADK_KPACKAGE_KMOD/s//CONFIG/p' ${TOPDIR}/.config | \
  34. sed 's/=y/=m/' >${BUILD_DIR}/.kernelconfig.modules
  35. sed -n '/^ADK_KERNEL/s//CONFIG/p' ${TOPDIR}/.config \
  36. >${BUILD_DIR}/.kernelconfig.kernel
  37. sed -n '/^ADK_MOD_KERNEL/s//CONFIG/p' ${TOPDIR}/.config | \
  38. sed 's/=y/=m/' >${BUILD_DIR}/.kernelconfig.modkernel
  39. sed -n '/^# ADK_KERNEL/s//# CONFIG/p' ${TOPDIR}/.config \
  40. >${BUILD_DIR}/.kernelconfig.nokernel
  41. # if native build, first try /proc/config.gz
  42. ifeq ($(ADK_NATIVE),y)
  43. if [ -f /proc/config.gz ];then zcat /proc/config.gz > ${BUILD_DIR}/.kernelconfig.board; else cp ${DEVICE}/kernel.config ${BUILD_DIR}/.kernelconfig.board; fi
  44. else
  45. cp ${DEVICE}/kernel.config ${BUILD_DIR}/.kernelconfig.board
  46. endif
  47. (cat ${BUILD_DIR}/.kernelconfig.{modules,kernel} | \
  48. while IFS='=' read symbol value; do \
  49. sed -i -e "/^# $$symbol/d" ${BUILD_DIR}/.kernelconfig.board; \
  50. done;)
  51. sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 ${FS_CMDLINE}"#' \
  52. ${BUILD_DIR}/.kernelconfig.board
  53. ifeq ($(ADK_KERNEL_DEBUG_WITH_KGDB),y)
  54. sed -i -e 's#^\(CONFIG_.*CMDLINE="\)\(.*\)"#\1\2 kgdbwait kgdboc=ttyS0,115200"#' \
  55. ${BUILD_DIR}/.kernelconfig.board
  56. endif
  57. cd ${BUILD_DIR} && cat .kernelconfig.board .kernelconfig.nokernel \
  58. .kernelconfig.kernel .kernelconfig.modkernel .kernelconfig.modules \
  59. >.kernelconfig.tmp
  60. cd ${BUILD_DIR} && cmp -s .kernelconfig.tmp .kernelconfig || \
  61. cp .kernelconfig.tmp .kernelconfig
  62. -rm -f ${BUILD_DIR}/.kernelconfig.tmp
  63. prepare: $(DEVICE)-prepare
  64. compile: $(DEVICE)-compile
  65. image: $(DEVICE)-imageclean $(DEVICE)-imageinstall
  66. install: $(DEVICE)-imageclean $(DEVICE)-install $(DEVICE)-imageinstall
  67. clean: $(DEVICE)-clean $(DEVICE)-imageclean
  68. %-clean:
  69. $(TRACE) target/$(patsubst %-clean,%,$@)-clean
  70. $(MAKE) -C $(patsubst %-clean,%,$@) clean
  71. %-imageclean:
  72. $(TRACE) target/$(patsubst %-imageclean,%,$@)-imageclean
  73. $(MAKE) -C $(patsubst %-imageclean,%,$@) imageclean
  74. %-prepare:
  75. $(TRACE) target/$(patsubst %-prepare,%,$@)-prepare
  76. $(MAKE) -C $(patsubst %-prepare,%,$@) prepare
  77. %-imageprepare:
  78. $(TRACE) target/$(patsubst %-imageprepare,%,$@)-imageprepare
  79. $(MAKE) -C $(patsubst %-imageprepare,%,$@) imageprepare
  80. %-compile: %-prepare
  81. $(TRACE) target/$(patsubst %-compile,%,$@)-compile
  82. $(MAKE) -C $(patsubst %-compile,%,$@) compile
  83. %-install: %-compile
  84. $(TRACE) target/$(patsubst %-install,%,$@)-install
  85. $(MAKE) -C $(patsubst %-install,%,$@) install
  86. %-imageinstall: %-imageprepare
  87. $(TRACE) target/$(patsubst %-imageinstall,%,$@)-imageinstall
  88. $(MAKE) -C $(patsubst %-imageinstall,%,$@) imageinstall