Makefile 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #
  2. # (C) Copyright 2007 Semihalf
  3. #
  4. # SPDX-License-Identifier: GPL-2.0+
  5. #
  6. ifeq ($(ARCH),powerpc)
  7. LOAD_ADDR = 0x40000
  8. endif
  9. ifeq ($(ARCH),arm)
  10. LOAD_ADDR = 0x1000000
  11. endif
  12. ifeq ($(ARCH),mips)
  13. ifdef CONFIG_64BIT
  14. LOAD_ADDR = 0xffffffff80200000
  15. else
  16. LOAD_ADDR = 0x80200000
  17. endif
  18. endif
  19. # Resulting ELF and binary exectuables will be named demo and demo.bin
  20. extra-y = demo
  21. # Source files located in the examples/api directory
  22. OBJ-y += crt0.o
  23. OBJ-y += demo.o
  24. OBJ-y += glue.o
  25. OBJ-y += libgenwrap.o
  26. # Source files which exist outside the examples/api directory
  27. EXT_COBJ-y += lib/crc32.o
  28. EXT_COBJ-y += lib/ctype.o
  29. EXT_COBJ-y += lib/div64.o
  30. EXT_COBJ-y += lib/string.o
  31. EXT_COBJ-y += lib/time.o
  32. EXT_COBJ-y += lib/vsprintf.o
  33. EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
  34. # Create a list of object files to be compiled
  35. OBJS := $(OBJ-y) $(notdir $(EXT_COBJ-y) $(EXT_SOBJ-y))
  36. targets += $(OBJS)
  37. OBJS := $(addprefix $(obj)/,$(OBJS))
  38. #########################################################################
  39. quiet_cmd_link_demo = LD $@
  40. cmd_link_demo = $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS)
  41. $(obj)/demo: $(OBJS) FORCE
  42. $(call if_changed,link_demo)
  43. # demo.bin is never genrated. Is this necessary?
  44. OBJCOPYFLAGS_demo.bin := -O binary
  45. $(obj)/demo.bin: $(obj)/demo FORCE
  46. $(call if_changed,objcopy)
  47. # Rule to build generic library C files
  48. $(addprefix $(obj)/,$(notdir $(EXT_COBJ-y))): $(obj)/%.o: lib/%.c FORCE
  49. $(call cmd,force_checksrc)
  50. $(call if_changed_rule,cc_o_c)
  51. # Rule to build architecture-specific library assembly files
  52. $(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/powerpc/lib/%.S FORCE
  53. $(call if_changed_dep,as_o_S)