Makefile 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #
  2. # (C) Copyright 2000-2006
  3. # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. #
  5. # See file CREDITS for list of people who contributed to this
  6. # project.
  7. #
  8. # This program is free software; you can redistribute it and/or
  9. # modify it under the terms of the GNU General Public License as
  10. # published by the Free Software Foundation; either version 2 of
  11. # the License, or (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. # MA 02111-1307 USA
  22. #
  23. include $(TOPDIR)/config.mk
  24. ELF-$(ARCH) :=
  25. ELF-$(BOARD) :=
  26. ELF-$(CPU) :=
  27. ELF-y := hello_world
  28. ELF-$(CONFIG_SMC91111) += smc91111_eeprom
  29. ELF-$(CONFIG_SMC911X) += smc911x_eeprom
  30. ELF-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2
  31. ELF-i386 += 82559_eeprom
  32. ELF-mpc5xxx += interrupt
  33. ELF-mpc8xx += test_burst timer
  34. ELF-mpc8260 += mem_to_mem_idma2intr
  35. ELF-ppc += sched
  36. ELF-oxc += eepro100_eeprom
  37. #
  38. # Some versions of make do not handle trailing white spaces properly;
  39. # leading to build failures. The problem was found with GNU Make 3.80.
  40. # Using 'strip' as a workaround for the problem.
  41. #
  42. ELF := $(strip $(ELF-y) $(ELF-$(ARCH)) $(ELF-$(BOARD)) $(ELF-$(CPU)))
  43. SREC = $(addsuffix .srec,$(ELF))
  44. BIN = $(addsuffix .bin,$(ELF))
  45. COBJS := $(ELF:=.o)
  46. LIB = $(obj)libstubs.a
  47. LIBAOBJS-$(ARCH) :=
  48. LIBAOBJS-$(CPU) :=
  49. LIBAOBJS-ppc += $(ARCH)_longjmp.o $(ARCH)_setjmp.o
  50. LIBAOBJS-mpc8xx += test_burst_lib.o
  51. LIBAOBJS := $(LIBAOBJS-$(ARCH)) $(LIBAOBJS-$(CPU))
  52. LIBCOBJS = stubs.o
  53. LIBOBJS = $(addprefix $(obj),$(LIBAOBJS) $(LIBCOBJS))
  54. SRCS := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
  55. OBJS := $(addprefix $(obj),$(COBJS))
  56. ELF := $(addprefix $(obj),$(ELF))
  57. BIN := $(addprefix $(obj),$(BIN))
  58. SREC := $(addprefix $(obj),$(SREC))
  59. gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
  60. CPPFLAGS += -I..
  61. # For PowerPC there's no need to compile standalone applications as a
  62. # relocatable executable. The relocation data is not needed, and
  63. # also causes the entry point of the standalone application to be
  64. # inconsistent.
  65. ifeq ($(ARCH),powerpc)
  66. AFLAGS := $(filter-out $(RELFLAGS),$(AFLAGS))
  67. CFLAGS := $(filter-out $(RELFLAGS),$(CFLAGS))
  68. CPPFLAGS := $(filter-out $(RELFLAGS),$(CPPFLAGS))
  69. endif
  70. # We don't want gcc reordering functions if possible. This ensures that an
  71. # application's entry point will be the first function in the application's
  72. # source file.
  73. CFLAGS += $(call cc-option,-fno-toplevel-reorder)
  74. all: $(obj).depend $(OBJS) $(LIB) $(SREC) $(BIN) $(ELF)
  75. #########################################################################
  76. $(LIB): $(obj).depend $(LIBOBJS)
  77. $(AR) $(ARFLAGS) $@ $(LIBOBJS)
  78. $(ELF):
  79. $(obj)%: $(obj)%.o $(LIB)
  80. $(LD) -g -Ttext $(STANDALONE_LOAD_ADDR) \
  81. -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
  82. -L$(gcclibdir) -lgcc
  83. $(SREC):
  84. $(obj)%.srec: $(obj)%
  85. $(OBJCOPY) -O srec $< $@ 2>/dev/null
  86. $(BIN):
  87. $(obj)%.bin: $(obj)%
  88. $(OBJCOPY) -O binary $< $@ 2>/dev/null
  89. #########################################################################
  90. # defines $(obj).depend target
  91. include $(SRCTREE)/rules.mk
  92. sinclude $(obj).depend
  93. #########################################################################