Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. # This file is released under the terms of GPL v2 and any later version.
  13. # See the file COPYING in the root directory of the source tree for details.
  14. #
  15. # Based on top-level Makefile.
  16. #
  17. CONFIG_SPL_BUILD := y
  18. export CONFIG_SPL_BUILD
  19. include $(TOPDIR)/config.mk
  20. # We want the final binaries in this directory
  21. obj := $(OBJTREE)/spl/
  22. HAVE_VENDOR_COMMON_LIB := $(shell [ -f $(SRCTREE)/board/$(VENDOR)/common/Makefile ] \
  23. && echo y || echo n)
  24. START := $(CPUDIR)/start.o
  25. LIBS-y += arch/$(ARCH)/lib/lib$(ARCH).o
  26. LIBS-y += $(CPUDIR)/lib$(CPU).o
  27. ifdef SOC
  28. LIBS-y += $(CPUDIR)/$(SOC)/lib$(SOC).o
  29. endif
  30. LIBS-y += board/$(BOARDDIR)/lib$(BOARD).o
  31. LIBS-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/lib$(VENDOR).o
  32. LIBS-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/libcommon.o
  33. LIBS-$(CONFIG_SPL_LIBDISK_SUPPORT) += disk/libdisk.o
  34. LIBS-$(CONFIG_SPL_I2C_SUPPORT) += drivers/i2c/libi2c.o
  35. LIBS-$(CONFIG_SPL_GPIO_SUPPORT) += drivers/gpio/libgpio.o
  36. LIBS-$(CONFIG_SPL_MMC_SUPPORT) += drivers/mmc/libmmc.o
  37. LIBS-$(CONFIG_SPL_SERIAL_SUPPORT) += drivers/serial/libserial.o
  38. LIBS-$(CONFIG_SPL_SPI_FLASH_SUPPORT) += drivers/mtd/spi/libspi_flash.o
  39. LIBS-$(CONFIG_SPL_SPI_SUPPORT) += drivers/spi/libspi.o
  40. LIBS-$(CONFIG_SPL_FAT_SUPPORT) += fs/fat/libfat.o
  41. LIBS-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/libgeneric.o
  42. LIBS-$(CONFIG_SPL_POWER_SUPPORT) += drivers/power/libpower.o
  43. LIBS-$(CONFIG_SPL_NAND_SUPPORT) += drivers/mtd/nand/libnand.o
  44. ifeq ($(SOC),omap3)
  45. LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
  46. endif
  47. ifeq ($(SOC),omap4)
  48. LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
  49. endif
  50. START := $(addprefix $(SPLTREE)/,$(START))
  51. LIBS := $(addprefix $(SPLTREE)/,$(sort $(LIBS-y)))
  52. __START := $(subst $(obj),,$(START))
  53. __LIBS := $(subst $(obj),,$(LIBS))
  54. # Linker Script
  55. ifdef CONFIG_SPL_LDSCRIPT
  56. # need to strip off double quotes
  57. LDSCRIPT := $(addprefix $(SRCTREE)/,$(subst ",,$(CONFIG_SPL_LDSCRIPT)))
  58. endif
  59. ifeq ($(wildcard $(LDSCRIPT)),)
  60. LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-spl.lds
  61. endif
  62. ifeq ($(wildcard $(LDSCRIPT)),)
  63. LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-spl.lds
  64. endif
  65. ifeq ($(wildcard $(LDSCRIPT)),)
  66. $(error could not find linker script)
  67. endif
  68. # Special flags for CPP when processing the linker script.
  69. # Pass the version down so we can handle backwards compatibility
  70. # on the fly.
  71. LDPPFLAGS += \
  72. -include $(TOPDIR)/include/u-boot/u-boot.lds.h \
  73. -include $(OBJTREE)/include/config.h \
  74. $(shell $(LD) --version | \
  75. sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
  76. ifdef CONFIG_OMAP
  77. $(OBJTREE)/MLO: $(obj)u-boot-spl.bin
  78. $(OBJTREE)/tools/mkimage -T omapimage \
  79. -a $(CONFIG_SPL_TEXT_BASE) -d $< $@
  80. endif
  81. ALL-y += $(obj)u-boot-spl.bin
  82. ifdef CONFIG_SAMSUNG
  83. ALL-y += $(obj)$(BOARD)-spl.bin
  84. endif
  85. all: $(ALL-y)
  86. ifdef CONFIG_SAMSUNG
  87. $(obj)$(BOARD)-spl.bin: $(obj)u-boot-spl.bin
  88. $(TOPDIR)/board/$(BOARDDIR)/tools/mk$(BOARD)spl.exe \
  89. $(obj)u-boot-spl.bin $(obj)$(BOARD)-spl.bin
  90. endif
  91. $(obj)u-boot-spl.bin: $(obj)u-boot-spl
  92. $(OBJCOPY) $(OBJCFLAGS) -O binary $< $@
  93. GEN_UBOOT = \
  94. UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) | \
  95. sed -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
  96. cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__START) \
  97. --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
  98. -Map u-boot-spl.map -o u-boot-spl
  99. $(obj)u-boot-spl: depend $(START) $(LIBS) $(obj)u-boot-spl.lds
  100. $(GEN_UBOOT)
  101. $(START): depend
  102. $(MAKE) -C $(SRCTREE)/$(CPUDIR) $@
  103. $(LIBS): depend
  104. $(MAKE) -C $(SRCTREE)$(dir $(subst $(SPLTREE),,$@))
  105. $(obj)u-boot-spl.lds: $(LDSCRIPT) depend
  106. $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - < $< > $@
  107. depend: $(obj).depend
  108. .PHONY: depend
  109. # defines $(obj).depend target
  110. include $(SRCTREE)/rules.mk