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. ifdef FTRACE
  8. ccflags-y += -finstrument-functions -DFTRACE
  9. endif
  10. extra-y := hello_world
  11. extra-$(CONFIG_SMC91111) += smc91111_eeprom
  12. extra-$(CONFIG_SMC911X) += smc911x_eeprom
  13. extra-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2
  14. extra-$(CONFIG_MPC5xxx) += interrupt
  15. extra-$(CONFIG_8xx) += test_burst timer
  16. extra-$(CONFIG_8260) += mem_to_mem_idma2intr
  17. extra-$(CONFIG_PPC) += sched
  18. #
  19. # Some versions of make do not handle trailing white spaces properly;
  20. # leading to build failures. The problem was found with GNU Make 3.80.
  21. # Using 'strip' as a workaround for the problem.
  22. #
  23. ELF := $(strip $(extra-y))
  24. extra-y += $(addsuffix .srec,$(extra-y)) $(addsuffix .bin,$(extra-y))
  25. clean-files := $(extra-) $(addsuffix .srec,$(extra-)) $(addsuffix .bin,$(extra-))
  26. COBJS := $(ELF:=.o)
  27. LIB = $(obj)/libstubs.o
  28. LIBAOBJS-$(CONFIG_PPC) += ppc_longjmp.o ppc_setjmp.o
  29. LIBAOBJS-$(CONFIG_8xx) += test_burst_lib.o
  30. LIBAOBJS := $(LIBAOBJS-y)
  31. LIBCOBJS = stubs.o
  32. .SECONDARY: $(call objectify,$(COBJS))
  33. targets += $(patsubst $(obj)/%,%,$(LIB)) $(COBJS) $(LIBAOBJS) $(LIBCOBJS)
  34. LIBOBJS = $(addprefix $(obj)/,$(LIBAOBJS) $(LIBCOBJS))
  35. ELF := $(addprefix $(obj)/,$(ELF))
  36. gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
  37. # For PowerPC there's no need to compile standalone applications as a
  38. # relocatable executable. The relocation data is not needed, and
  39. # also causes the entry point of the standalone application to be
  40. # inconsistent.
  41. ifeq ($(ARCH),powerpc)
  42. # FIX ME
  43. CPPFLAGS := $(filter-out $(RELFLAGS), $(CPPFLAGS))
  44. endif
  45. # We don't want gcc reordering functions if possible. This ensures that an
  46. # application's entry point will be the first function in the application's
  47. # source file.
  48. ccflags-y += $(call cc-option,-fno-toplevel-reorder)
  49. #########################################################################
  50. quiet_cmd_link_lib = LD $@
  51. cmd_link_lib = $(LD) $(ld_flags) -r -o $@ $(filter $(LIBOBJS), $^)
  52. $(LIB): $(LIBOBJS) FORCE
  53. $(call if_changed,link_lib)
  54. $(ELF):
  55. $(obj)/%: $(obj)/%.o $(LIB)
  56. $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
  57. -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
  58. -L$(gcclibdir) -lgcc
  59. $(obj)/%.srec: $(obj)/%
  60. $(OBJCOPY) -O srec $< $@ 2>/dev/null
  61. $(obj)/%.bin: $(obj)/%
  62. $(OBJCOPY) -O binary $< $@ 2>/dev/null