Makefile.autoconf 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. # This helper makefile is used for creating
  2. # - symbolic links (arch/$ARCH/include/asm/arch
  3. # - include/autoconf.mk, {spl,tpl}/include/autoconf.mk
  4. # - include/config.h
  5. #
  6. # When our migration to Kconfig is done
  7. # (= When we move all CONFIGs from header files to Kconfig)
  8. # this makefile can be deleted.
  9. __all: include/autoconf.mk include/autoconf.mk.dep
  10. ifeq ($(shell grep -q '^CONFIG_SPL=y' include/config/auto.conf 2>/dev/null && echo y),y)
  11. __all: spl/include/autoconf.mk
  12. endif
  13. ifeq ($(shell grep -q '^CONFIG_TPL=y' include/config/auto.conf 2>/dev/null && echo y),y)
  14. __all: tpl/include/autoconf.mk
  15. endif
  16. include include/config/auto.conf
  17. include scripts/Kbuild.include
  18. # Need to define CC and CPP again here in case the top Makefile did not
  19. # include config.mk. Some architectures expect CROSS_COMPILE to be defined
  20. # in arch/$(ARCH)/config.mk
  21. CC = $(CROSS_COMPILE)gcc
  22. CPP = $(CC) -E
  23. include config.mk
  24. UBOOTINCLUDE := \
  25. -Iinclude \
  26. $(if $(KBUILD_SRC), -I$(srctree)/include) \
  27. -I$(srctree)/arch/$(ARCH)/include \
  28. -include $(srctree)/include/linux/kconfig.h
  29. c_flags := $(KBUILD_CFLAGS) $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) \
  30. $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
  31. quiet_cmd_autoconf_dep = GEN $@
  32. cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M -MP $(c_flags) \
  33. -MQ include/config/auto.conf $(srctree)/include/common.h > $@ || { \
  34. rm $@; false; \
  35. }
  36. include/autoconf.mk.dep: FORCE
  37. $(call cmd,autoconf_dep)
  38. # We are migrating from board headers to Kconfig little by little.
  39. # In the interim, we use both of
  40. # - include/config/auto.conf (generated by Kconfig)
  41. # - include/autoconf.mk (used in the U-Boot conventional configuration)
  42. # The following rule creates autoconf.mk
  43. # include/config/auto.conf is grepped in order to avoid duplication of the
  44. # same CONFIG macros
  45. quiet_cmd_autoconf = GEN $@
  46. cmd_autoconf = \
  47. $(CPP) $(c_flags) $2 -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && { \
  48. sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp | \
  49. while read line; do \
  50. if [ -n "${KCONFIG_IGNORE_DUPLICATES}" ] || \
  51. ! grep -q "$${line%=*}=" include/config/auto.conf; then \
  52. echo "$$line"; \
  53. fi \
  54. done > $@; \
  55. rm $@.tmp; \
  56. } || { \
  57. rm $@.tmp; false; \
  58. }
  59. include/autoconf.mk: FORCE
  60. $(call cmd,autoconf)
  61. spl/include/autoconf.mk: FORCE
  62. $(Q)mkdir -p $(dir $@)
  63. $(call cmd,autoconf,-DCONFIG_SPL_BUILD)
  64. tpl/include/autoconf.mk: FORCE
  65. $(Q)mkdir -p $(dir $@)
  66. $(call cmd,autoconf,-DCONFIG_SPL_BUILD -DCONFIG_TPL_BUILD)
  67. include/autoconf.mk include/autoconf.mk.dep \
  68. spl/include/autoconf.mk tpl/include/autoconf.mk: include/config.h
  69. # include/config.h
  70. # Prior to Kconfig, it was generated by mkconfig. Now it is created here.
  71. define filechk_config_h
  72. (echo "/* Automatically generated - do not edit */"; \
  73. for i in $$(echo $(CONFIG_SYS_EXTRA_OPTIONS) | sed 's/,/ /g'); do \
  74. echo \#define CONFIG_$$i \
  75. | sed '/=/ {s/=/ /;q; } ; { s/$$/ 1/; }'; \
  76. done; \
  77. echo \#define CONFIG_BOARDDIR board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);\
  78. echo \#include \<config_defaults.h\>; \
  79. echo \#include \<config_uncmd_spl.h\>; \
  80. echo \#include \<configs/$(CONFIG_SYS_CONFIG_NAME).h\>; \
  81. echo \#include \<asm/config.h\>; \
  82. echo \#include \<config_fallbacks.h\>;)
  83. endef
  84. include/config.h: scripts/Makefile.autoconf create_symlink FORCE
  85. $(call filechk,config_h)
  86. # symbolic links
  87. # If arch/$(ARCH)/mach-$(SOC)/include/mach exists,
  88. # make a symbolic link to that directory.
  89. # Otherwise, create a symbolic link to arch/$(ARCH)/include/asm/arch-$(SOC).
  90. PHONY += create_symlink
  91. create_symlink:
  92. ifdef CONFIG_CREATE_ARCH_SYMLINK
  93. ifneq ($(KBUILD_SRC),)
  94. $(Q)mkdir -p include/asm
  95. $(Q)if [ -d $(KBUILD_SRC)/arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \
  96. dest=arch/$(ARCH)/mach-$(SOC)/include/mach; \
  97. else \
  98. dest=arch/$(ARCH)/include/asm/arch-$(if $(SOC),$(SOC),$(CPU)); \
  99. fi; \
  100. ln -fsn $(KBUILD_SRC)/$$dest include/asm/arch
  101. else
  102. $(Q)if [ -d arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \
  103. dest=../../mach-$(SOC)/include/mach; \
  104. else \
  105. dest=arch-$(if $(SOC),$(SOC),$(CPU)); \
  106. fi; \
  107. ln -fsn $$dest arch/$(ARCH)/include/asm/arch
  108. endif
  109. endif
  110. PHONY += FORCE
  111. FORCE:
  112. .PHONY: $(PHONY)