Makefile 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #
  2. # (C) Copyright 2007 Semihalf
  3. #
  4. # See file CREDITS for list of people who contributed to this
  5. # project.
  6. #
  7. # This program is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU General Public License as
  9. # published by the Free Software Foundatio; either version 2 of
  10. # the License, or (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. # MA 02111-1307 USA
  21. #
  22. ifeq ($(ARCH),ppc)
  23. LOAD_ADDR = 0x40000
  24. endif
  25. ifeq ($(ARCH),arm)
  26. LOAD_ADDR = 0x1000000
  27. endif
  28. include $(TOPDIR)/config.mk
  29. ELF-$(CONFIG_API) += demo
  30. BIN-$(CONFIG_API) += demo.bin
  31. ELF := $(ELF-y)
  32. BIN := $(BIN-y)
  33. #CFLAGS += -v
  34. COBJS-$(CONFIG_API) += $(ELF:=.o)
  35. SOBJS-$(CONFIG_API) += crt0.o
  36. ifeq ($(ARCH),ppc)
  37. SOBJS-$(CONFIG_API) += ppcstring.o
  38. endif
  39. COBJS := $(COBJS-y)
  40. SOBJS := $(SOBJS-y)
  41. LIB = $(obj)libglue.a
  42. LIBCOBJS-$(CONFIG_API) += glue.o
  43. LIBCOBJS-$(CONFIG_API) += crc32.o
  44. LIBCOBJS-$(CONFIG_API) += ctype.o
  45. LIBCOBJS-$(CONFIG_API) += string.o
  46. LIBCOBJS-$(CONFIG_API) += vsprintf.o
  47. LIBCOBJS-$(CONFIG_API) += libgenwrap.o
  48. LIBCOBJS := $(LIBCOBJS-y)
  49. LIBOBJS += $(addprefix $(obj),$(SOBJS))
  50. LIBOBJS += $(addprefix $(obj),$(LIBCOBJS))
  51. SRCS += $(COBJS:.o=.c)
  52. SRCS += $(LIBCOBJS:.o=.c)
  53. SRCS += $(SOBJS:.o=.S)
  54. OBJS := $(addprefix $(obj),$(COBJS))
  55. ELF := $(addprefix $(obj),$(ELF))
  56. BIN := $(addprefix $(obj),$(BIN))
  57. gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
  58. CPPFLAGS += -I..
  59. all: $(obj).depend $(OBJS) $(LIB) $(ELF) $(BIN)
  60. #########################################################################
  61. $(LIB): $(obj).depend $(LIBOBJS)
  62. $(AR) $(ARFLAGS) $@ $(LIBOBJS)
  63. $(ELF):
  64. $(obj)%: $(obj)%.o $(LIB)
  65. $(LD) $(obj)crt0.o -Ttext $(LOAD_ADDR) \
  66. -o $@ $< $(LIB) \
  67. -L$(gcclibdir) -lgcc
  68. $(BIN):
  69. $(obj)%.bin: $(obj)%
  70. $(OBJCOPY) -O binary $< $@ 2>/dev/null
  71. $(obj)crc32.c:
  72. @rm -f $(obj)crc32.c
  73. ln -s $(src)../lib_generic/crc32.c $(obj)crc32.c
  74. $(obj)ctype.c:
  75. @rm -f $(obj)ctype.c
  76. ln -s $(src)../lib_generic/ctype.c $(obj)ctype.c
  77. $(obj)string.c:
  78. @rm -f $(obj)string.c
  79. ln -s $(src)../lib_generic/string.c $(obj)string.c
  80. $(obj)vsprintf.c:
  81. @rm -f $(obj)vsprintf.c
  82. ln -s $(src)../lib_generic/vsprintf.c $(obj)vsprintf.c
  83. ifeq ($(ARCH),ppc)
  84. $(obj)ppcstring.S:
  85. @rm -f $(obj)ppcstring.S
  86. ln -s $(src)../lib_ppc/ppcstring.S $(obj)ppcstring.S
  87. endif
  88. #########################################################################
  89. # defines $(obj).depend target
  90. include $(SRCTREE)/rules.mk
  91. sinclude $(obj).depend
  92. #########################################################################