config.mk 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #
  2. # (C) Copyright 2000-2013
  3. # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. #
  5. # SPDX-License-Identifier: GPL-2.0+
  6. #
  7. #########################################################################
  8. ifeq ($(CURDIR),$(SRCTREE))
  9. dir :=
  10. else
  11. dir := $(subst $(SRCTREE)/,,$(CURDIR))
  12. endif
  13. ifneq ($(OBJTREE),$(SRCTREE))
  14. # Create object files for SPL in a separate directory
  15. ifeq ($(CONFIG_SPL_BUILD),y)
  16. ifeq ($(CONFIG_TPL_BUILD),y)
  17. obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/)
  18. else
  19. obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
  20. endif
  21. else
  22. obj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)
  23. endif
  24. src := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)
  25. $(shell mkdir -p $(obj))
  26. else
  27. # Create object files for SPL in a separate directory
  28. ifeq ($(CONFIG_SPL_BUILD),y)
  29. ifeq ($(CONFIG_TPL_BUILD),y)
  30. obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/)
  31. else
  32. obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
  33. endif
  34. $(shell mkdir -p $(obj))
  35. else
  36. obj :=
  37. endif
  38. src :=
  39. endif
  40. # clean the slate ...
  41. PLATFORM_RELFLAGS =
  42. PLATFORM_CPPFLAGS =
  43. PLATFORM_LDFLAGS =
  44. #########################################################################
  45. # Load generated board configuration
  46. ifeq ($(CONFIG_TPL_BUILD),y)
  47. # Include TPL autoconf
  48. sinclude $(OBJTREE)/include/tpl-autoconf.mk
  49. else
  50. ifeq ($(CONFIG_SPL_BUILD),y)
  51. # Include SPL autoconf
  52. sinclude $(OBJTREE)/include/spl-autoconf.mk
  53. else
  54. # Include normal autoconf
  55. sinclude $(OBJTREE)/include/autoconf.mk
  56. endif
  57. endif
  58. sinclude $(OBJTREE)/include/config.mk
  59. # Some architecture config.mk files need to know what CPUDIR is set to,
  60. # so calculate CPUDIR before including ARCH/SOC/CPU config.mk files.
  61. # Check if arch/$ARCH/cpu/$CPU exists, otherwise assume arch/$ARCH/cpu contains
  62. # CPU-specific code.
  63. CPUDIR=arch/$(ARCH)/cpu/$(CPU)
  64. ifneq ($(SRCTREE)/$(CPUDIR),$(wildcard $(SRCTREE)/$(CPUDIR)))
  65. CPUDIR=arch/$(ARCH)/cpu
  66. endif
  67. sinclude $(TOPDIR)/arch/$(ARCH)/config.mk # include architecture dependend rules
  68. sinclude $(TOPDIR)/$(CPUDIR)/config.mk # include CPU specific rules
  69. ifdef SOC
  70. sinclude $(TOPDIR)/$(CPUDIR)/$(SOC)/config.mk # include SoC specific rules
  71. endif
  72. ifdef VENDOR
  73. BOARDDIR = $(VENDOR)/$(BOARD)
  74. else
  75. BOARDDIR = $(BOARD)
  76. endif
  77. ifdef BOARD
  78. sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk # include board specific rules
  79. endif
  80. #########################################################################
  81. RELFLAGS= $(PLATFORM_RELFLAGS)
  82. OBJCFLAGS += --gap-fill=0xff
  83. CPPFLAGS = $(KBUILD_CPPFLAGS) $(RELFLAGS)
  84. CPPFLAGS += $(UBOOTINCLUDE)
  85. CPPFLAGS += $(NOSTDINC_FLAGS) -pipe $(PLATFORM_CPPFLAGS)
  86. CFLAGS := $(KBUILD_CFLAGS) $(CPPFLAGS)
  87. BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
  88. AFLAGS := $(KBUILD_AFLAGS) $(CPPFLAGS)
  89. LDFLAGS += $(PLATFORM_LDFLAGS)
  90. LDFLAGS_FINAL += -Bstatic
  91. #########################################################################
  92. export PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS