Makefile 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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_8260) += 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 := $(extra-) $(addsuffix .srec,$(extra-)) $(addsuffix .bin,$(extra-))
  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. gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
  33. # For PowerPC there's no need to compile standalone applications as a
  34. # relocatable executable. The relocation data is not needed, and
  35. # also causes the entry point of the standalone application to be
  36. # inconsistent.
  37. ifeq ($(CONFIG_PPC),y)
  38. PLATFORM_CPPFLAGS := $(filter-out $(RELFLAGS),$(PLATFORM_CPPFLAGS))
  39. endif
  40. # We don't want gcc reordering functions if possible. This ensures that an
  41. # application's entry point will be the first function in the application's
  42. # source file.
  43. ccflags-y += $(call cc-option,-fno-toplevel-reorder)
  44. #########################################################################
  45. quiet_cmd_link_lib = LD $@
  46. cmd_link_lib = $(LD) $(ld_flags) -r -o $@ $(filter $(LIBOBJS), $^)
  47. $(LIB): $(LIBOBJS) FORCE
  48. $(call if_changed,link_lib)
  49. quiet_cmd_link_elf = LD $@
  50. cmd_link_elf = $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
  51. -o $@ -e $(SYM_PREFIX)$(@F) $< $(LIB) -L$(gcclibdir) -lgcc
  52. $(ELF): $(obj)/%: $(obj)/%.o $(LIB) FORCE
  53. $(call if_changed,link_elf)
  54. $(obj)/%.srec: OBJCOPYFLAGS := -O srec
  55. $(obj)/%.srec: $(obj)/% FORCE
  56. $(call if_changed,objcopy)
  57. $(obj)/%.bin: OBJCOPYFLAGS := -O binary
  58. $(obj)/%.bin: $(obj)/% FORCE
  59. $(call if_changed,objcopy)