makefile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #
  2. # Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
  3. # Copyright (c) 2015-2018, Renesas Electronics Corporation. All rights reserved.
  4. #
  5. # SPDX-License-Identifier: BSD-3-Clause
  6. #
  7. toolchains := aarch64
  8. include ../../../make_helpers/build-rules.mk
  9. include ../../../make_helpers/common.mk
  10. include ../../../make_helpers/toolchain.mk
  11. ###################################################
  12. # makefile
  13. ###################################################
  14. #output file name
  15. FILE_NAME_SA0 = bootparam_sa0
  16. FILE_NAME_SA6 = cert_header_sa6
  17. OUTPUT_FILE_SA0 = $(FILE_NAME_SA0).elf
  18. OUTPUT_FILE_SA6 = $(FILE_NAME_SA6).elf
  19. #object file name
  20. OBJ_FILE_SA0 = sa0.o
  21. OBJ_FILE_SA6 = sa6.o
  22. #linker script name
  23. MEMORY_DEF_SA0 = sa0.ld.S
  24. MEMORY_DEF_SA6 = sa6.ld.S
  25. ###################################################
  26. # Convenience function for adding build definitions
  27. # $(eval $(call add_define,FOO)) will have:
  28. # -DFOO if $(FOO) is empty; -DFOO=$(FOO) otherwise
  29. define add_define
  30. DEFINES += -D$(1)$(if $(value $(1)),=$(value $(1)),)
  31. endef
  32. # Process RCAR_SA0_SIZE flag
  33. ifndef RCAR_SA0_SIZE
  34. RCAR_SA0_SIZE := 1
  35. else
  36. ifeq (${RCAR_SA0_SIZE},0)
  37. RCAR_SA0_SIZE := 0
  38. else
  39. RCAR_SA0_SIZE := 1
  40. endif
  41. endif
  42. $(eval $(call add_define,RCAR_SA0_SIZE))
  43. # Process RCAR_SA6_TYPE flag
  44. ifndef RCAR_SA6_TYPE
  45. RCAR_SA6_TYPE := 0
  46. else
  47. ifeq (${RCAR_SA6_TYPE},0)
  48. RCAR_SA6_TYPE := 0
  49. else
  50. RCAR_SA6_TYPE := 1
  51. endif
  52. endif
  53. $(eval $(call add_define,RCAR_SA6_TYPE))
  54. # Handle different VMA adjustment on D3
  55. ifeq (${RCAR_LSI},${RCAR_D3})
  56. RCAR_VMA_ADJUST_ADDR := 0xE6320000
  57. else
  58. RCAR_VMA_ADJUST_ADDR := 0xE6312000
  59. endif
  60. $(eval $(call add_define,RCAR_VMA_ADJUST_ADDR))
  61. ###################################################
  62. #c compiler
  63. CFLAGS += ${DEFINES}
  64. CFLAGS += -I../../include/lib/stdlib
  65. #clean
  66. CL = rm -f
  67. ###################################################
  68. .SUFFIXES : .s .c .o
  69. ###################################################
  70. # command
  71. .PHONY: all
  72. all: $(FILE_NAME_SA0).srec $(FILE_NAME_SA0).bin
  73. all: $(FILE_NAME_SA6).srec $(FILE_NAME_SA6).bin
  74. ###################################################
  75. # Linker
  76. ###################################################
  77. $(FILE_NAME_SA0).srec: $(OUTPUT_FILE_SA0) | $$(@D)/
  78. $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).srec
  79. $(FILE_NAME_SA0).bin: $(OUTPUT_FILE_SA0) | $$(@D)/
  80. $(aarch64-oc) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).bin
  81. $(OUTPUT_FILE_SA0): $(MEMORY_DEF_SA0) $(OBJ_FILE_SA0) | $$(@D)/
  82. $(aarch64-ld) $(OBJ_FILE_SA0) -nostdlib -static -Wl,--build-id=none -T $(MEMORY_DEF_SA0) -o $(OUTPUT_FILE_SA0) -Wl,-Map $(FILE_NAME_SA0).map
  83. $(FILE_NAME_SA6).srec: $(OUTPUT_FILE_SA6) | $$(@D)/
  84. $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).srec
  85. $(FILE_NAME_SA6).bin: $(OUTPUT_FILE_SA6) | $$(@D)/
  86. $(aarch64-oc) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).bin
  87. $(OUTPUT_FILE_SA6): $(MEMORY_DEF_SA6) $(OBJ_FILE_SA6) | $$(@D)/
  88. $(aarch64-ld) $(OBJ_FILE_SA6) -nostdlib -static -Wl,--build-id=none -T $(MEMORY_DEF_SA6) -o $(OUTPUT_FILE_SA6) -Wl,-Map $(FILE_NAME_SA6).map
  89. ###################################################
  90. # Compile
  91. ###################################################
  92. %.o: %.c | $$(@D)/
  93. $(aarch64-cc) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
  94. .PHONY: clean
  95. clean:
  96. $(CL) *.bin *.map *.srec *.elf *.o