Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 crc32.o ctype.o string.o vsprintf.o \
  43. libgenwrap.o
  44. LIBCOBJS := $(LIBCOBJS-y)
  45. LIBOBJS = $(addprefix $(obj),$(SOBJS) $(LIBCOBJS))
  46. SRCS := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(SOBJS:.o=.S)
  47. OBJS := $(addprefix $(obj),$(COBJS))
  48. ELF := $(addprefix $(obj),$(ELF))
  49. BIN := $(addprefix $(obj),$(BIN))
  50. gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
  51. CPPFLAGS += -I..
  52. all: $(obj).depend $(OBJS) $(LIB) $(ELF) $(BIN)
  53. #########################################################################
  54. $(LIB): $(obj).depend $(LIBOBJS)
  55. $(AR) $(ARFLAGS) $@ $(LIBOBJS)
  56. $(ELF):
  57. $(obj)%: $(obj)%.o $(LIB)
  58. $(LD) $(obj)crt0.o -Ttext $(LOAD_ADDR) \
  59. -o $@ $< $(LIB) \
  60. -L$(gcclibdir) -lgcc
  61. $(BIN):
  62. $(obj)%.bin: $(obj)%
  63. $(OBJCOPY) -O binary $< $@ 2>/dev/null
  64. $(obj)crc32.c:
  65. @rm -f $(obj)crc32.c
  66. ln -s $(src)../lib_generic/crc32.c $(obj)crc32.c
  67. $(obj)ctype.c:
  68. @rm -f $(obj)ctype.c
  69. ln -s $(src)../lib_generic/ctype.c $(obj)ctype.c
  70. $(obj)string.c:
  71. @rm -f $(obj)string.c
  72. ln -s $(src)../lib_generic/string.c $(obj)string.c
  73. $(obj)vsprintf.c:
  74. @rm -f $(obj)vsprintf.c
  75. ln -s $(src)../lib_generic/vsprintf.c $(obj)vsprintf.c
  76. ifeq ($(ARCH),ppc)
  77. $(obj)ppcstring.S:
  78. @rm -f $(obj)ppcstring.S
  79. ln -s $(src)../lib_ppc/ppcstring.S $(obj)ppcstring.S
  80. endif
  81. #########################################################################
  82. # defines $(obj).depend target
  83. include $(SRCTREE)/rules.mk
  84. sinclude $(obj).depend
  85. #########################################################################