Makefile 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. OUTPUT = $(OUTPUT-y)
  32. # Source files located in the api_examples directory
  33. SOBJ_FILES-$(CONFIG_API) += crt0.o
  34. COBJ_FILES-$(CONFIG_API) += demo.o
  35. COBJ_FILES-$(CONFIG_API) += glue.o
  36. COBJ_FILES-$(CONFIG_API) += libgenwrap.o
  37. # Source files which exist outside the api_examples directory
  38. EXT_COBJ_FILES-$(CONFIG_API) += lib_generic/crc32.o
  39. EXT_COBJ_FILES-$(CONFIG_API) += lib_generic/ctype.o
  40. EXT_COBJ_FILES-$(CONFIG_API) += lib_generic/string.o
  41. EXT_COBJ_FILES-$(CONFIG_API) += lib_generic/vsprintf.o
  42. ifeq ($(ARCH),ppc)
  43. EXT_SOBJ_FILES-$(CONFIG_API) += lib_ppc/ppcstring.o
  44. endif
  45. # Create a list of source files so their dependencies can be auto-generated
  46. SRCS += $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c))
  47. SRCS += $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S))
  48. SRCS += $(addprefix $(SRCTREE)/api_examples/,$(COBJ_FILES-y:.o=.c))
  49. SRCS += $(addprefix $(SRCTREE)/api_examples/,$(SOBJ_FILES-y:.o=.S))
  50. # Create a list of object files to be compiled
  51. OBJS += $(addprefix $(obj),$(SOBJ_FILES-y))
  52. OBJS += $(addprefix $(obj),$(COBJ_FILES-y))
  53. OBJS += $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y)))
  54. OBJS += $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y)))
  55. gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
  56. CPPFLAGS += -I..
  57. all: $(obj).depend $(OUTPUT)
  58. #########################################################################
  59. $(OUTPUT): $(OBJS)
  60. $(LD) -Ttext $(LOAD_ADDR) -o $@ $^ -L$(gcclibdir) -lgcc
  61. $(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null
  62. # Rule to build generic library C files
  63. $(obj)%.o: $(SRCTREE)/lib_generic/%.c
  64. $(CC) -g $(CFLAGS) -c -o $@ $<
  65. # Rule to build architecture-specific library assembly files
  66. $(obj)%.o: $(SRCTREE)/lib_$(ARCH)/%.S
  67. $(CC) -g $(CFLAGS) -c -o $@ $<
  68. #########################################################################
  69. # defines $(obj).depend target
  70. include $(SRCTREE)/rules.mk
  71. sinclude $(obj).depend
  72. #########################################################################