Makefile 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #
  2. # (C) Copyright 2007 Semihalf
  3. #
  4. # SPDX-License-Identifier: GPL-2.0+
  5. #
  6. ifdef FTRACE
  7. CFLAGS += -finstrument-functions -DFTRACE
  8. endif
  9. ifeq ($(ARCH),powerpc)
  10. LOAD_ADDR = 0x40000
  11. endif
  12. ifeq ($(ARCH),arm)
  13. LOAD_ADDR = 0x1000000
  14. endif
  15. # Resulting ELF and binary exectuables will be named demo and demo.bin
  16. extra-y = demo
  17. # Source files located in the examples/api directory
  18. SOBJ_FILES-y += crt0.o
  19. COBJ_FILES-y += demo.o
  20. COBJ_FILES-y += glue.o
  21. COBJ_FILES-y += libgenwrap.o
  22. # Source files which exist outside the examples/api directory
  23. EXT_COBJ_FILES-y += lib/crc32.o
  24. EXT_COBJ_FILES-y += lib/ctype.o
  25. EXT_COBJ_FILES-y += lib/div64.o
  26. EXT_COBJ_FILES-y += lib/string.o
  27. EXT_COBJ_FILES-y += lib/time.o
  28. EXT_COBJ_FILES-y += lib/vsprintf.o
  29. EXT_SOBJ_FILES-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
  30. # Create a list of source files so their dependencies can be auto-generated
  31. SRCS += $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c))
  32. SRCS += $(addprefix $(SRCTREE)/,$(EXT_SOBJ_FILES-y:.o=.S))
  33. SRCS += $(addprefix $(SRCTREE)/examples/api/,$(COBJ_FILES-y:.o=.c))
  34. SRCS += $(addprefix $(SRCTREE)/examples/api/,$(SOBJ_FILES-y:.o=.S))
  35. # Create a list of object files to be compiled
  36. OBJS += $(addprefix $(obj)/,$(SOBJ_FILES-y))
  37. OBJS += $(addprefix $(obj)/,$(COBJ_FILES-y))
  38. OBJS += $(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y)))
  39. OBJS += $(addprefix $(obj)/,$(notdir $(EXT_SOBJ_FILES-y)))
  40. #########################################################################
  41. $(obj)/demo: $(OBJS)
  42. $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS)
  43. $(obj)/demo.bin: $(obj)/demo
  44. $(OBJCOPY) -O binary $< $@ 2>/dev/null
  45. # Rule to build generic library C files
  46. $(addprefix $(obj)/,$(notdir $(EXT_COBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/lib/%.c
  47. $(CC) -g $(CFLAGS) -c -o $@ $<
  48. # Rule to build architecture-specific library assembly files
  49. $(addprefix $(obj)/,$(notdir $(EXT_SOBJ_FILES-y))): $(obj)/%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
  50. $(CC) -g $(CFLAGS) -c -o $@ $<