Makefile 2.5 KB

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