makefile 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #
  2. # Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
  3. # Copyright (c) 2020, 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. RCAR_VMA_ADJUST_ADDR := 0xE6320000
  55. $(eval $(call add_define,RCAR_VMA_ADJUST_ADDR))
  56. ###################################################
  57. #c compiler
  58. CFLAGS += ${DEFINES}
  59. CFLAGS += -nostdinc \
  60. -I../../../include/lib/libc \
  61. -I../../../include/lib/libc/aarch64
  62. #clean
  63. CL = rm -f
  64. ###################################################
  65. .SUFFIXES : .s .c .o
  66. ###################################################
  67. # command
  68. .PHONY: all
  69. all: $(FILE_NAME_SA0).srec $(FILE_NAME_SA0).bin
  70. all: $(FILE_NAME_SA6).srec $(FILE_NAME_SA6).bin
  71. ###################################################
  72. # Linker
  73. ###################################################
  74. $(FILE_NAME_SA0).srec: $(OUTPUT_FILE_SA0) | $$(@D)/
  75. $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).srec
  76. $(FILE_NAME_SA0).bin: $(OUTPUT_FILE_SA0) | $$(@D)/
  77. $(aarch64-oc) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA0) $(FILE_NAME_SA0).bin
  78. $(OUTPUT_FILE_SA0): $(MEMORY_DEF_SA0) $(OBJ_FILE_SA0) | $$(@D)/
  79. $(aarch64-ld) $(OBJ_FILE_SA0) -nostdlib -T $(MEMORY_DEF_SA0) -o $(OUTPUT_FILE_SA0) -Wl,-Map $(FILE_NAME_SA0).map
  80. $(FILE_NAME_SA6).srec: $(OUTPUT_FILE_SA6) | $$(@D)/
  81. $(aarch64-oc) -O srec --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).srec
  82. $(FILE_NAME_SA6).bin: $(OUTPUT_FILE_SA6) | $$(@D)/
  83. $(aarch64-oc) -O binary --adjust-vma=$(RCAR_VMA_ADJUST_ADDR) --srec-forceS3 $(OUTPUT_FILE_SA6) $(FILE_NAME_SA6).bin
  84. $(OUTPUT_FILE_SA6): $(MEMORY_DEF_SA6) $(OBJ_FILE_SA6) | $$(@D)/
  85. $(aarch64-ld) $(OBJ_FILE_SA6) -nostdlib -T $(MEMORY_DEF_SA6) -o $(OUTPUT_FILE_SA6) -Wl,-Map $(FILE_NAME_SA6).map
  86. ###################################################
  87. # Compile
  88. ###################################################
  89. %.o: %.c | $$(@D)/
  90. $(aarch64-cc) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
  91. .PHONY: clean
  92. clean:
  93. $(CL) *.bin *.map *.srec *.elf *.o