Makefile 2.8 KB

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