Makefile 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # SPDX-License-Identifier: GPL-2.0+
  2. #
  3. # (C) Copyright 2007 Semihalf
  4. # Provide symbol API_BUILD to signal that the API example is being built.
  5. KBUILD_CPPFLAGS += -DAPI_BUILD
  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/hexdump.o
  31. EXT_COBJ-y += lib/string.o
  32. EXT_COBJ-y += lib/time.o
  33. EXT_COBJ-y += lib/vsprintf.o
  34. EXT_COBJ-y += lib/charset.o
  35. EXT_COBJ-$(CONFIG_LIB_UUID) += lib/uuid.o
  36. EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
  37. ifeq ($(ARCH),arm)
  38. EXT_SOBJ-$(CONFIG_USE_ARCH_MEMSET) += arch/arm/lib/memset.o
  39. endif
  40. # Create a list of object files to be compiled
  41. OBJS := $(OBJ-y) $(notdir $(EXT_COBJ-y) $(EXT_SOBJ-y))
  42. targets += $(OBJS)
  43. OBJS := $(addprefix $(obj)/,$(OBJS))
  44. #########################################################################
  45. quiet_cmd_link_demo = LD $@
  46. cmd_link_demo = $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS)
  47. $(obj)/demo: $(OBJS) FORCE
  48. $(call if_changed,link_demo)
  49. # demo.bin is never genrated. Is this necessary?
  50. OBJCOPYFLAGS_demo.bin := -O binary
  51. $(obj)/demo.bin: $(obj)/demo FORCE
  52. $(call if_changed,objcopy)
  53. # Rule to build generic library C files
  54. $(addprefix $(obj)/,$(notdir $(EXT_COBJ-y))): $(obj)/%.o: lib/%.c FORCE
  55. $(call cmd,force_checksrc)
  56. $(call if_changed_rule,cc_o_c)
  57. # Rule to build architecture-specific library assembly files
  58. $(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/$(ARCH)/lib/%.S FORCE
  59. $(call if_changed_dep,as_o_S)