Makefile 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. CFLAGS += -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. LIBOBJS = $(addprefix $(obj),$(LIBAOBJS) $(LIBCOBJS))
  33. SRCS := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
  34. OBJS := $(addprefix $(obj),$(COBJS))
  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. AFLAGS := $(filter-out $(RELFLAGS),$(AFLAGS))
  43. CFLAGS := $(filter-out $(RELFLAGS),$(CFLAGS))
  44. CPPFLAGS := $(filter-out $(RELFLAGS),$(CPPFLAGS))
  45. endif
  46. # We don't want gcc reordering functions if possible. This ensures that an
  47. # application's entry point will be the first function in the application's
  48. # source file.
  49. CFLAGS += $(call cc-option,-fno-toplevel-reorder)
  50. #########################################################################
  51. $(LIB): $(LIBOBJS)
  52. $(call cmd_link_o_target, $(LIBOBJS))
  53. $(ELF):
  54. $(obj)%: $(obj)%.o $(LIB)
  55. $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
  56. -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
  57. -L$(gcclibdir) -lgcc
  58. $(obj)%.srec: $(obj)%
  59. $(OBJCOPY) -O srec $< $@ 2>/dev/null
  60. $(obj)%.bin: $(obj)%
  61. $(OBJCOPY) -O binary $< $@ 2>/dev/null