makefile 2.8 KB

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