Makefile 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. # Resulting ELF and binary exectuables will be named demo and demo.bin
  13. extra-y = demo
  14. # Source files located in the examples/api directory
  15. OBJ-y += crt0.o
  16. OBJ-y += demo.o
  17. OBJ-y += glue.o
  18. OBJ-y += libgenwrap.o
  19. # Source files which exist outside the examples/api directory
  20. EXT_COBJ-y += lib/crc32.o
  21. EXT_COBJ-y += lib/ctype.o
  22. EXT_COBJ-y += lib/div64.o
  23. EXT_COBJ-y += lib/string.o
  24. EXT_COBJ-y += lib/time.o
  25. EXT_COBJ-y += lib/vsprintf.o
  26. EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
  27. # Create a list of object files to be compiled
  28. OBJS := $(OBJ-y) $(notdir $(EXT_COBJ-y) $(EXT_SOBJ-y))
  29. targets += $(OBJS)
  30. OBJS := $(addprefix $(obj)/,$(OBJS))
  31. #########################################################################
  32. quiet_cmd_link_demo = LD $@
  33. cmd_link_demo = $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS)
  34. $(obj)/demo: $(OBJS) FORCE
  35. $(call if_changed,link_demo)
  36. # demo.bin is never genrated. Is this necessary?
  37. OBJCOPYFLAGS_demo.bin := -O binary
  38. $(obj)/demo.bin: $(obj)/demo FORCE
  39. $(call if_changed,objcopy)
  40. # Rule to build generic library C files
  41. $(addprefix $(obj)/,$(notdir $(EXT_COBJ-y))): $(obj)/%.o: lib/%.c FORCE
  42. $(call cmd,force_checksrc)
  43. $(call if_changed_rule,cc_o_c)
  44. # Rule to build architecture-specific library assembly files
  45. $(addprefix $(obj)/,$(notdir $(EXT_SOBJ-y))): $(obj)/%.o: arch/powerpc/lib/%.S FORCE
  46. $(call if_changed_dep,as_o_S)