Makefile 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #
  2. # (C) Copyright 2000-2006
  3. # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. #
  5. # SPDX-License-Identifier: GPL-2.0+
  6. #
  7. extra-y := hello_world
  8. extra-$(CONFIG_SMC91111) += smc91111_eeprom
  9. extra-$(CONFIG_SMC911X) += smc911x_eeprom
  10. extra-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2
  11. extra-$(CONFIG_MPC5xxx) += interrupt
  12. extra-$(CONFIG_8xx) += test_burst timer
  13. extra-$(CONFIG_MPC8260) += mem_to_mem_idma2intr
  14. extra-$(CONFIG_PPC) += sched
  15. #
  16. # Some versions of make do not handle trailing white spaces properly;
  17. # leading to build failures. The problem was found with GNU Make 3.80.
  18. # Using 'strip' as a workaround for the problem.
  19. #
  20. ELF := $(strip $(extra-y))
  21. extra-y += $(addsuffix .srec,$(extra-y)) $(addsuffix .bin,$(extra-y))
  22. clean-files := *.srec *.bin
  23. COBJS := $(ELF:=.o)
  24. LIB = $(obj)/libstubs.o
  25. LIBOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o
  26. LIBOBJS-$(CONFIG_8xx) += test_burst_lib.o
  27. LIBOBJS-y += stubs.o
  28. .SECONDARY: $(call objectify,$(COBJS))
  29. targets += $(patsubst $(obj)/%,%,$(LIB)) $(COBJS) $(LIBOBJS-y)
  30. LIBOBJS := $(addprefix $(obj)/,$(LIBOBJS-y))
  31. ELF := $(addprefix $(obj)/,$(ELF))
  32. # For PowerPC there's no need to compile standalone applications as a
  33. # relocatable executable. The relocation data is not needed, and
  34. # also causes the entry point of the standalone application to be
  35. # inconsistent.
  36. ifeq ($(CONFIG_PPC),y)
  37. PLATFORM_CPPFLAGS := $(filter-out $(RELFLAGS),$(PLATFORM_CPPFLAGS))
  38. endif
  39. # We don't want gcc reordering functions if possible. This ensures that an
  40. # application's entry point will be the first function in the application's
  41. # source file.
  42. ccflags-y += $(call cc-option,-fno-toplevel-reorder)
  43. #########################################################################
  44. quiet_cmd_link_lib = LD $@
  45. cmd_link_lib = $(LD) $(ld_flags) -r -o $@ $(filter $(LIBOBJS), $^)
  46. $(LIB): $(LIBOBJS) FORCE
  47. $(call if_changed,link_lib)
  48. quiet_cmd_link_elf = LD $@
  49. cmd_link_elf = $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
  50. -o $@ -e $(SYM_PREFIX)$(@F) $< $(LIB) $(PLATFORM_LIBGCC)
  51. $(ELF): $(obj)/%: $(obj)/%.o $(LIB) FORCE
  52. $(call if_changed,link_elf)
  53. $(obj)/%.srec: OBJCOPYFLAGS := -O srec
  54. $(obj)/%.srec: $(obj)/% FORCE
  55. $(call if_changed,objcopy)
  56. $(obj)/%.bin: OBJCOPYFLAGS := -O binary
  57. $(obj)/%.bin: $(obj)/% FORCE
  58. $(call if_changed,objcopy)
  59. # some files can only build in ARM or THUMB2, not THUMB1
  60. ifdef CONFIG_SYS_THUMB_BUILD
  61. ifndef CONFIG_HAS_THUMB2
  62. CFLAGS_stubs.o := -marm
  63. endif
  64. endif