You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

146 lines
3.4 KiB

  1. #
  2. # !!!! Do NOT edit this makefile with an editor which replace tabs by spaces !!!!
  3. #
  4. ##############################################################################################
  5. #
  6. # On command line:
  7. #
  8. # make all = Create project
  9. #
  10. # make clean = Clean project files.
  11. #
  12. # To rebuild project do "make clean" and "make all".
  13. #
  14. ##############################################################################################
  15. # Start of default section
  16. #
  17. TRGT = arm-elf-
  18. CC = $(TRGT)gcc
  19. CP = $(TRGT)objcopy
  20. AS = $(TRGT)gcc -x assembler-with-cpp
  21. BIN = $(CP) -O ihex
  22. MCU = arm7tdmi
  23. # List all default C defines here, like -D_DEBUG=1
  24. DDEFS =
  25. # List all default ASM defines here, like -D_DEBUG=1
  26. DADEFS =
  27. # List all default directories to look for include files here
  28. DINCDIR =
  29. # List the default directory to look for the libraries here
  30. DLIBDIR =
  31. # List all default libraries here
  32. DLIBS =
  33. #
  34. # End of default section
  35. ##############################################################################################
  36. ##############################################################################################
  37. # Start of user section
  38. #
  39. # Define project name here
  40. PROJECT = test
  41. # Define linker script file here
  42. LDSCRIPT_RAM = ./prj/hitex_str7_ram.ld
  43. LDSCRIPT_ROM = ./prj/hitex_str7_rom.ld
  44. # List all user C define here, like -D_DEBUG=1
  45. UDEFS =
  46. # Define ASM defines here
  47. UADEFS =
  48. # List C source files here
  49. SRC = ./src/main.c
  50. # List ASM source files here
  51. ASRC = ./src/crt.s
  52. # List all user directories here
  53. UINCDIR = ./inc
  54. # List the user directory to look for the libraries here
  55. ULIBDIR =
  56. # List all user libraries here
  57. ULIBS =
  58. # Define optimisation level here
  59. OPT = -O0
  60. #
  61. # End of user defines
  62. ##############################################################################################
  63. INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
  64. LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
  65. DEFS = $(DDEFS) $(UDEFS)
  66. ADEFS = $(DADEFS) $(UADEFS)
  67. OBJS = $(ASRC:.s=.o) $(SRC:.c=.o)
  68. LIBS = $(DLIBS) $(ULIBS)
  69. MCFLAGS = -mcpu=$(MCU)
  70. ASFLAGS = $(MCFLAGS) -g -gdwarf-2 -Wa,-amhls=$(<:.s=.lst) $(ADEFS)
  71. CPFLAGS = $(MCFLAGS) $(OPT) -gdwarf-2 -mthumb-interwork -fomit-frame-pointer -Wall -Wstrict-prototypes -fverbose-asm -Wa,-ahlms=$(<:.c=.lst) $(DEFS)
  72. LDFLAGS_RAM = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT_RAM) -Wl,-Map=$(PROJECT)_ram.map,--cref,--no-warn-mismatch $(LIBDIR)
  73. LDFLAGS_ROM = $(MCFLAGS) -nostartfiles -T$(LDSCRIPT_ROM) -Wl,-Map=$(PROJECT)_rom.map,--cref,--no-warn-mismatch $(LIBDIR)
  74. # Generate dependency information
  75. CPFLAGS += -MD -MP -MF .dep/$(@F).d
  76. #
  77. # makefile rules
  78. #
  79. all: RAM ROM
  80. RAM: $(OBJS) $(PROJECT)_ram.elf $(PROJECT)_ram.hex
  81. ROM: $(OBJS) $(PROJECT)_rom.elf $(PROJECT)_rom.hex
  82. %o : %c
  83. $(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@
  84. %o : %s
  85. $(AS) -c $(ASFLAGS) $< -o $@
  86. %ram.elf: $(OBJS)
  87. $(CC) $(OBJS) $(LDFLAGS_RAM) $(LIBS) -o $@
  88. %rom.elf: $(OBJS)
  89. $(CC) $(OBJS) $(LDFLAGS_ROM) $(LIBS) -o $@
  90. %hex: %elf
  91. $(BIN) $< $@
  92. clean:
  93. -rm -f $(OBJS)
  94. -rm -f $(PROJECT)_ram.elf
  95. -rm -f $(PROJECT)_ram.map
  96. -rm -f $(PROJECT)_ram.hex
  97. -rm -f $(PROJECT)_rom.elf
  98. -rm -f $(PROJECT)_rom.map
  99. -rm -f $(PROJECT)_rom.hex
  100. -rm -f $(SRC:.c=.c.bak)
  101. -rm -f $(SRC:.c=.lst)
  102. -rm -f $(ASRC:.s=.s.bak)
  103. -rm -f $(ASRC:.s=.lst)
  104. -rm -fR .dep
  105. #
  106. # Include the dependency files, should be the last of the makefile
  107. #
  108. -include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
  109. # *** EOF ***