Makefile 2.4 KB

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