Makefile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. ifeq ($(SOC),omap3)
  43. LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
  44. endif
  45. ifeq ($(SOC),omap4)
  46. LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
  47. endif
  48. START := $(addprefix $(SPLTREE)/,$(START))
  49. LIBS := $(addprefix $(SPLTREE)/,$(sort $(LIBS-y)))
  50. __START := $(subst $(obj),,$(START))
  51. __LIBS := $(subst $(obj),,$(LIBS))
  52. # Linker Script
  53. ifdef CONFIG_SPL_LDSCRIPT
  54. # need to strip off double quotes
  55. LDSCRIPT := $(addprefix $(SRCTREE)/,$(subst ",,$(CONFIG_SPL_LDSCRIPT)))
  56. endif
  57. ifeq ($(wildcard $(LDSCRIPT)),)
  58. LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-spl.lds
  59. endif
  60. ifeq ($(wildcard $(LDSCRIPT)),)
  61. LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-spl.lds
  62. endif
  63. ifeq ($(wildcard $(LDSCRIPT)),)
  64. $(error could not find linker script)
  65. endif
  66. # Special flags for CPP when processing the linker script.
  67. # Pass the version down so we can handle backwards compatibility
  68. # on the fly.
  69. LDPPFLAGS += \
  70. -include $(TOPDIR)/include/u-boot/u-boot.lds.h \
  71. -include $(OBJTREE)/include/config.h \
  72. $(shell $(LD) --version | \
  73. sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
  74. ALL-y += $(obj)u-boot-spl.bin
  75. all: $(ALL-y)
  76. $(obj)u-boot-spl.bin: $(obj)u-boot-spl
  77. $(OBJCOPY) $(OBJCFLAGS) -O binary $< $@
  78. GEN_UBOOT = \
  79. UNDEF_SYM=`$(OBJDUMP) -x $(LIBS) | \
  80. sed -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
  81. cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__START) \
  82. --start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
  83. -Map u-boot-spl.map -o u-boot-spl
  84. $(obj)u-boot-spl: depend $(START) $(LIBS) $(obj)u-boot-spl.lds
  85. $(GEN_UBOOT)
  86. $(START): depend
  87. $(MAKE) -C $(SRCTREE)/$(CPUDIR) $@
  88. $(LIBS): depend
  89. $(MAKE) -C $(SRCTREE)$(dir $(subst $(SPLTREE),,$@))
  90. $(obj)u-boot-spl.lds: $(LDSCRIPT) depend
  91. $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - < $< > $@
  92. depend: $(obj).depend
  93. .PHONY: depend
  94. # defines $(obj).depend target
  95. include $(SRCTREE)/rules.mk