Makefile 2.3 KB

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