Makefile 2.7 KB

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