Makefile 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. #
  2. # (C) Copyright 2000-2011
  3. # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. #
  5. # (C) Copyright 2011
  6. # Daniel Schwierzeck, daniel.schwierzeck@googlemail.com.
  7. #
  8. # (C) Copyright 2011
  9. # Texas Instruments Incorporated - http://www.ti.com/
  10. # Aneesh V <aneesh@ti.com>
  11. #
  12. # SPDX-License-Identifier: GPL-2.0+
  13. #
  14. # Based on top-level Makefile.
  15. #
  16. src := $(obj)
  17. # Create output directory if not already present
  18. _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
  19. include $(srctree)/scripts/Kbuild.include
  20. CONFIG_SPL_BUILD := y
  21. export CONFIG_SPL_BUILD
  22. KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD
  23. ifeq ($(CONFIG_TPL_BUILD),y)
  24. KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD
  25. endif
  26. # Enable garbage collection of un-used sections for SPL
  27. KBUILD_CFLAGS += -ffunction-sections -fdata-sections
  28. LDFLAGS_FINAL += --gc-sections
  29. ifeq ($(CONFIG_TPL_BUILD),y)
  30. export CONFIG_TPL_BUILD
  31. SPL_BIN := u-boot-tpl
  32. else
  33. SPL_BIN := u-boot-spl
  34. endif
  35. include include/config.mk
  36. ifeq ($(CONFIG_TPL_BUILD),y)
  37. -include include/tpl-autoconf.mk
  38. else
  39. -include include/spl-autoconf.mk
  40. endif
  41. include $(TOPDIR)/config.mk
  42. # FIX ME
  43. c_flags := $(KBUILD_CFLAGS) $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
  44. # Auto-generate the spl-autoconf.mk file (which is included by all makefiles for SPL)
  45. quiet_cmd_autoconf = GEN $@
  46. cmd_autoconf = \
  47. $(CPP) $(c_flags) -DDO_DEPS_ONLY -dM $(srctree)/include/common.h > $@.tmp && \
  48. sed -n -f $(srctree)/tools/scripts/define2mk.sed $@.tmp > $@; \
  49. rm $@.tmp
  50. include/tpl-autoconf.mk: include/config.h
  51. $(call cmd,autoconf)
  52. include/spl-autoconf.mk: include/config.h
  53. $(call cmd,autoconf)
  54. HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(SRCTREE)/board/$(VENDOR)/common/Makefile),y,n)
  55. ifdef CONFIG_SPL_START_S_PATH
  56. START_PATH := $(CONFIG_SPL_START_S_PATH:"%"=%)
  57. else
  58. START_PATH := $(CPUDIR)
  59. endif
  60. head-y := $(START_PATH)/start.o
  61. head-$(CONFIG_X86) += $(START_PATH)/start16.o $(START_PATH)/resetvec.o
  62. head-$(CONFIG_4xx) += $(START_PATH)/resetvec.o
  63. head-$(CONFIG_MPC85xx) += $(START_PATH)/resetvec.o
  64. libs-y += arch/$(ARCH)/lib/
  65. libs-y += $(CPUDIR)/
  66. ifdef SOC
  67. libs-y += $(CPUDIR)/$(SOC)/
  68. endif
  69. libs-y += board/$(BOARDDIR)/
  70. libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
  71. libs-$(CONFIG_SPL_FRAMEWORK) += common/spl/
  72. libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/
  73. libs-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/
  74. libs-$(CONFIG_SPL_I2C_SUPPORT) += drivers/i2c/
  75. libs-$(CONFIG_SPL_GPIO_SUPPORT) += drivers/gpio/
  76. libs-$(CONFIG_SPL_MMC_SUPPORT) += drivers/mmc/
  77. libs-$(CONFIG_SPL_MPC8XXX_INIT_DDR_SUPPORT) += drivers/ddr/fsl/
  78. libs-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/
  79. libs-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/
  80. libs-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/
  81. libs-y += fs/
  82. libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
  83. libs-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/ drivers/power/pmic/
  84. libs-$(if $(CONFIG_CMD_NAND),$(CONFIG_SPL_NAND_SUPPORT)) += drivers/mtd/nand/
  85. libs-$(CONFIG_SPL_DRIVERS_MISC_SUPPORT) += drivers/misc/
  86. libs-$(CONFIG_SPL_ONENAND_SUPPORT) += drivers/mtd/onenand/
  87. libs-$(CONFIG_SPL_DMA_SUPPORT) += drivers/dma/
  88. libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/
  89. libs-$(CONFIG_SPL_NET_SUPPORT) += net/
  90. libs-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/
  91. libs-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/
  92. libs-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/net/phy/
  93. libs-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/
  94. libs-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/
  95. libs-$(CONFIG_SPL_WATCHDOG_SUPPORT) += drivers/watchdog/
  96. libs-$(CONFIG_SPL_USB_HOST_SUPPORT) += drivers/usb/host/
  97. libs-$(CONFIG_OMAP_USB_PHY) += drivers/usb/phy/
  98. libs-$(CONFIG_SPL_SATA_SUPPORT) += drivers/block/
  99. ifneq (,$(CONFIG_MX23)$(CONFIG_MX35)$(filter $(SOC), mx25 mx27 mx5 mx6 mx31 mx35))
  100. libs-y += arch/$(ARCH)/imx-common/
  101. endif
  102. libs-$(CONFIG_ARM) += arch/arm/cpu/
  103. libs-$(CONFIG_PPC) += arch/powerpc/cpu/
  104. head-y := $(addprefix $(obj)/,$(head-y))
  105. libs-y := $(addprefix $(obj)/,$(libs-y))
  106. u-boot-spl-dirs := $(patsubst %/,%,$(filter %/, $(libs-y)))
  107. libs-y := $(patsubst %/, %/built-in.o, $(libs-y))
  108. # Add GCC lib
  109. ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
  110. PLATFORM_LIBGCC = $(SPLTREE)/arch/$(ARCH)/lib/lib.a
  111. PLATFORM_LIBS := $(filter-out %/lib.a, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC)
  112. endif
  113. u-boot-spl-init := $(head-y)
  114. u-boot-spl-main := $(libs-y)
  115. # Linker Script
  116. ifdef CONFIG_SPL_LDSCRIPT
  117. # need to strip off double quotes
  118. LDSCRIPT := $(addprefix $(SRCTREE)/,$(CONFIG_SPL_LDSCRIPT:"%"=%))
  119. endif
  120. ifeq ($(wildcard $(LDSCRIPT)),)
  121. LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-spl.lds
  122. endif
  123. ifeq ($(wildcard $(LDSCRIPT)),)
  124. LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-spl.lds
  125. endif
  126. ifeq ($(wildcard $(LDSCRIPT)),)
  127. LDSCRIPT := $(TOPDIR)/arch/$(ARCH)/cpu/u-boot-spl.lds
  128. endif
  129. ifeq ($(wildcard $(LDSCRIPT)),)
  130. $(error could not find linker script)
  131. endif
  132. # Special flags for CPP when processing the linker script.
  133. # Pass the version down so we can handle backwards compatibility
  134. # on the fly.
  135. LDPPFLAGS += \
  136. -include $(TOPDIR)/include/u-boot/u-boot.lds.h \
  137. -include $(OBJTREE)/include/config.h \
  138. -DCPUDIR=$(CPUDIR) \
  139. $(shell $(LD) --version | \
  140. sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
  141. $(OBJTREE)/MLO: $(obj)/u-boot-spl.bin
  142. $(OBJTREE)/tools/mkimage -T omapimage \
  143. -a $(CONFIG_SPL_TEXT_BASE) -d $< $@
  144. $(OBJTREE)/MLO.byteswap: $(obj)/u-boot-spl.bin
  145. $(OBJTREE)/tools/mkimage -T omapimage -n byteswap \
  146. -a $(CONFIG_SPL_TEXT_BASE) -d $< $@
  147. $(objtree)/SPL : $(obj)/u-boot-spl.bin
  148. $(MAKE) $(build)=spl/arch/arm/imx-common $@
  149. ALL-y += $(obj)/$(SPL_BIN).bin
  150. ifdef CONFIG_SAMSUNG
  151. ALL-y += $(obj)/$(BOARD)-spl.bin
  152. endif
  153. all: $(ALL-y)
  154. ifdef CONFIG_SAMSUNG
  155. ifdef CONFIG_VAR_SIZE_SPL
  156. VAR_SIZE_PARAM = --vs
  157. else
  158. VAR_SIZE_PARAM =
  159. endif
  160. $(obj)/$(BOARD)-spl.bin: $(obj)/u-boot-spl.bin
  161. $(if $(wildcard $(OBJTREE)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl),\
  162. $(OBJTREE)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl,\
  163. $(OBJTREE)/tools/mkexynosspl) $(VAR_SIZE_PARAM) $< $@
  164. endif
  165. $(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN)
  166. $(OBJCOPY) $(OBJCOPYFLAGS) $(SPL_OBJCFLAGS) -O binary $< $@
  167. LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL)
  168. ifneq ($(CONFIG_SPL_TEXT_BASE),)
  169. LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
  170. endif
  171. quiet_cmd_u-boot-spl = LD $@
  172. cmd_u-boot-spl = cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
  173. $(patsubst $(obj)/%,%,$(u-boot-spl-init)) --start-group \
  174. $(patsubst $(obj)/%,%,$(u-boot-spl-main)) --end-group \
  175. $(PLATFORM_LIBS) -Map $(SPL_BIN).map -o $(SPL_BIN)
  176. $(obj)/$(SPL_BIN): $(u-boot-spl-init) $(u-boot-spl-main) $(obj)/u-boot-spl.lds
  177. $(call cmd,u-boot-spl)
  178. $(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ;
  179. PHONY += $(u-boot-spl-dirs)
  180. $(u-boot-spl-dirs):
  181. $(Q)$(MAKE) $(build)=$@
  182. # FIX ME
  183. cpp_flags := $(KBUILD_CPPFLAGS) $(CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)
  184. $(obj)/u-boot-spl.lds: $(LDSCRIPT) FORCE
  185. $(CPP) $(cpp_flags) $(LDPPFLAGS) -I$(obj). -ansi -D__ASSEMBLY__ -P - < $< > $@
  186. PHONY += FORCE
  187. FORCE:
  188. # Declare the contents of the .PHONY variable as phony. We keep that
  189. # information in a variable so we can use it in if_changed and friends.
  190. .PHONY: $(PHONY)