Makefile.autoconf 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. # obj is "include" or "spl/include" or "tpl/include"
  10. # for non-SPL, SPL, TPL, respectively
  11. include $(obj)/config/auto.conf
  12. include scripts/Kbuild.include
  13. # Need to define CC and CPP again here in case the top Makefile did not
  14. # include config.mk. Some architectures expect CROSS_COMPILE to be defined
  15. # in arch/$(ARCH)/config.mk
  16. CC = $(CROSS_COMPILE)gcc
  17. CPP = $(CC) -E
  18. include config.mk
  19. UBOOTINCLUDE := \
  20. -I$(obj) \
  21. -Iinclude \
  22. $(if $(KBUILD_SRC), -I$(srctree)/include) \
  23. -I$(srctree)/arch/$(ARCH)/include \
  24. -include $(srctree)/include/linux/kconfig.h
  25. c_flags := $(KBUILD_CFLAGS) $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) \
  26. $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
  27. quiet_cmd_autoconf_dep = GEN $@
  28. cmd_autoconf_dep = $(CC) -x c -DDO_DEPS_ONLY -M -MP $(c_flags) \
  29. -MQ include/config/auto.conf $(srctree)/include/common.h > $@ || { \
  30. rm $@; false; \
  31. }
  32. include/autoconf.mk.dep: FORCE
  33. $(call cmd,autoconf_dep)
  34. # We are migrating from board headers to Kconfig little by little.
  35. # In the interim, we use both of
  36. # - include/config/auto.conf (generated by Kconfig)
  37. # - include/autoconf.mk (used in the U-Boot conventional configuration)
  38. # The following rule creates autoconf.mk
  39. # include/config/auto.conf is grepped in order to avoid duplication of the
  40. # same CONFIG macros
  41. quiet_cmd_autoconf = GEN $@
  42. cmd_autoconf = \
  43. $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && { \
  44. sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp | \
  45. while read line; do \
  46. if ! grep -q "$${line%=*}=" $(obj)/config/auto.conf; then \
  47. echo "$$line"; \
  48. fi \
  49. done > $@; \
  50. rm $@.tmp; \
  51. } || { \
  52. rm $@.tmp; false; \
  53. }
  54. $(obj)/autoconf.mk: FORCE
  55. $(call cmd,autoconf)
  56. include/autoconf.mk include/autoconf.mk.dep: include/config.h
  57. # include/config.h
  58. # Prior to Kconfig, it was generated by mkconfig. Now it is created here.
  59. define filechk_config_h
  60. (echo "/* Automatically generated - do not edit */"; \
  61. for i in $$(echo $(CONFIG_SYS_EXTRA_OPTIONS) | sed 's/,/ /g'); do \
  62. echo \#define CONFIG_$$i \
  63. | sed '/=/ {s/=/ /;q; } ; { s/$$/ 1/; }'; \
  64. done; \
  65. echo \#define CONFIG_BOARDDIR board/$(if $(VENDOR),$(VENDOR)/)$(BOARD);\
  66. echo \#include \<config_cmd_defaults.h\>; \
  67. echo \#include \<config_defaults.h\>; \
  68. echo \#include \<configs/$(CONFIG_SYS_CONFIG_NAME).h\>; \
  69. echo \#include \<asm/config.h\>; \
  70. echo \#include \<config_fallbacks.h\>; \
  71. echo \#include \<config_uncmd_spl.h\>; )
  72. endef
  73. include/config.h: scripts/Makefile.autoconf create_symlink FORCE
  74. $(call filechk,config_h)
  75. # symbolic links
  76. PHONY += create_symlink
  77. create_symlink:
  78. ifneq ($(KBUILD_SRC),)
  79. $(Q)mkdir -p include/asm
  80. endif
  81. $(Q)ln -fsn $(srctree)/arch/$(ARCH)/include/asm/arch-$(if $(SOC),$(SOC),$(CPU)) \
  82. $(if $(KBUILD_SRC),,arch/$(ARCH)/)include/asm/arch
  83. PHONY += FORCE
  84. FORCE:
  85. .PHONY: $(PHONY)