Makefile.autoconf 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 ! grep -q "$${line%=*}=" include/config/auto.conf; then \
  51. echo "$$line"; \
  52. fi \
  53. done > $@; \
  54. rm $@.tmp; \
  55. } || { \
  56. rm $@.tmp; false; \
  57. }
  58. include/autoconf.mk: FORCE
  59. $(call cmd,autoconf)
  60. spl/include/autoconf.mk: FORCE
  61. $(Q)mkdir -p $(dir $@)
  62. $(call cmd,autoconf,-DCONFIG_SPL_BUILD)
  63. tpl/include/autoconf.mk: FORCE
  64. $(Q)mkdir -p $(dir $@)
  65. $(call cmd,autoconf,-DCONFIG_SPL_BUILD -DCONFIG_TPL_BUILD)
  66. include/autoconf.mk include/autoconf.mk.dep \
  67. spl/include/autoconf.mk tpl/include/autoconf.mk: include/config.h
  68. # include/config.h
  69. # Prior to Kconfig, it was generated by mkconfig. Now it is created here.
  70. define filechk_config_h
  71. (echo "/* Automatically generated - do not edit */"; \
  72. for i in $$(echo $(CONFIG_SYS_EXTRA_OPTIONS) | sed 's/,/ /g'); do \
  73. echo \#define CONFIG_$$i \
  74. | sed '/=/ {s/=/ /;q; } ; { s/$$/ 1/; }'; \
  75. done; \
  76. echo \#define CONFIG_BOARDDIR board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);\
  77. echo \#include \<config_defaults.h\>; \
  78. echo \#include \<config_uncmd_spl.h\>; \
  79. echo \#include \<configs/$(CONFIG_SYS_CONFIG_NAME).h\>; \
  80. echo \#include \<asm/config.h\>; \
  81. echo \#include \<config_fallbacks.h\>;)
  82. endef
  83. include/config.h: scripts/Makefile.autoconf create_symlink FORCE
  84. $(call filechk,config_h)
  85. # symbolic links
  86. # If arch/$(ARCH)/mach-$(SOC)/include/mach exists,
  87. # make a symbolic link to that directory.
  88. # Otherwise, create a symbolic link to arch/$(ARCH)/include/asm/arch-$(SOC).
  89. PHONY += create_symlink
  90. create_symlink:
  91. ifneq ($(KBUILD_SRC),)
  92. $(Q)mkdir -p include/asm
  93. $(Q)if [ -d $(KBUILD_SRC)/arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \
  94. dest=arch/$(ARCH)/mach-$(SOC)/include/mach; \
  95. else \
  96. dest=arch/$(ARCH)/include/asm/arch-$(if $(SOC),$(SOC),$(CPU)); \
  97. fi; \
  98. ln -fsn $(KBUILD_SRC)/$$dest include/asm/arch
  99. else
  100. $(Q)if [ -d arch/$(ARCH)/mach-$(SOC)/include/mach ]; then \
  101. dest=../../mach-$(SOC)/include/mach; \
  102. else \
  103. dest=arch-$(if $(SOC),$(SOC),$(CPU)); \
  104. fi; \
  105. ln -fsn $$dest arch/$(ARCH)/include/asm/arch
  106. endif
  107. PHONY += FORCE
  108. FORCE:
  109. .PHONY: $(PHONY)