Advertisement
bueddl

Untitled

Apr 28th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 3.11 KB | None | 0 0
  1. # Projekt-Name
  2. PROJECT = ledblink
  3.  
  4.  
  5. # Projekt-Dateien
  6. # Liste alle Quellcode Dateien deines Projektes hier auf
  7. SRC = ./Source/main.c
  8. SRC += ./Source/interrupt.c
  9. SRC += ./Source/startup.c
  10.  
  11.  
  12. # Bibliothek
  13. # Alle benötigten Quellcode-Dateien der Library hier aktivieren/deaktivieren
  14. #SRC += ./Library/src/stm32f10x_adc.c
  15. #SRC += ./Library/src/stm32f10x_bkp.c
  16. #SRC += ./Library/src/stm32f10x_can.c
  17. #SRC += ./Library/src/stm32f10x_crc.c
  18. #SRC += ./Library/src/stm32f10x_dac.c
  19. #SRC += ./Library/src/stm32f10x_dbgmcu.c
  20. #SRC += ./Library/src/stm32f10x_dma.c
  21. #SRC += ./Library/src/stm32f10x_exti.c
  22. SRC += ./Library/src/stm32f10x_flash.c
  23. #SRC += ./Library/src/stm32f10x_fsmc.c
  24. SRC += ./Library/src/stm32f10x_gpio.c
  25. #SRC += ./Library/src/stm32f10x_i2c.c
  26. #SRC += ./Library/src/stm32f10x_iwdg.c
  27. SRC += ./Library/src/stm32f10x_lib.c
  28. SRC += ./Library/src/stm32f10x_nvic.c
  29. #SRC += ./Library/src/stm32f10x_pwr.c
  30. SRC += ./Library/src/stm32f10x_rcc.c
  31. #SRC += ./Library/src/stm32f10x_rtc.c
  32. #SRC += ./Library/src/stm32f10x_sdio.c
  33. #SRC += ./Library/src/stm32f10x_spi.c
  34. #SRC += ./Library/src/stm32f10x_systick.c
  35. SRC += ./Library/src/stm32f10x_tim.c
  36. #SRC += ./Library/src/stm32f10x_usart.c
  37. #SRC += ./Library/src/stm32f10x_wwdg.c
  38.  
  39. # User Include-Verzeichnisse
  40. UINCDIR =
  41.  
  42. # Compiler Stuff
  43. # (Binaries der Toolchain)
  44. TRGT = arm-none-eabi-
  45. CC   = $(TRGT)gcc
  46. CP   = $(TRGT)objcopy
  47. AS   = $(TRGT)gcc -x assembler-with-cpp
  48. SIZE = $(TRGT)size
  49. BIN  = $(CP) -O binary
  50.  
  51. # Andere Tools (OpenOCD zum Flashen und Debuggen)
  52. OPENOCD = /usr/bin/openocd
  53.  
  54. # Optimierung
  55. OPT = -O0
  56. #OPT = -O2 -falgin-functions=16 -fno-inline -fomit-frame-pointer
  57.  
  58. # Debug Symbole
  59. DEBUG = -gdwarf-2
  60.  
  61. # # # # # # # # # # # # # # # # # # # # #
  62. # DONT CHANGE ANYTHING BELOW HERE
  63. # # # # # # # # # # # # # # # # # # # # #
  64.  
  65. # STM32 Macro File
  66. # (wird immer benötigt)
  67. ASRC = ./Source/cortexm3_macro.s
  68.  
  69. # Default Include-Verzeichnisse
  70. DINCDIR = ./
  71. DINCDIR += ./Source/
  72. DINCDIR += ./Library/inc
  73.  
  74. # Liste aller .o-Dateien erstellen
  75. OBJS    = $(ASRC:.s=.o) $(SRC:.c=.o)
  76.  
  77. # Include-Pfad Liste erstellen
  78. INCDIR  = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
  79.  
  80. # Build Flags
  81. # Eigenhändig aus den Build-Logs der HiTOP IDE kopiert
  82. ASFLAGS = -mcpu=cortex-m3 -mthumb -mfpu=vfp
  83. CPFLAGS = -mcpu=cortex-m3 -mthumb -mfpu=vfp $(DEBUG) $(OPT) -Wall -fsigned-char -mlittle-endian
  84. LDFLAGS = -T./Settings/main.ld -t -static -nostartfiles -lc -lgcc -lm
  85.  
  86. # # # # # # # # # # # # # # # # # # # # #
  87. # Make-Rules
  88. # # # # # # # # # # # # # # # # # # # # #
  89.  
  90.  
  91. all: $(OBJS) $(PROJECT).elf $(PROJECT).bin
  92.  
  93. # .c zu .o
  94. %.o : %.c
  95.     $(CC) -c $(CPFLAGS) -I . $(INCDIR) -o $@ $<
  96.  
  97. # .s zu .o
  98. %.o : %.s
  99.     $(AS) -c $(ASFLAGS) $< -o $@
  100.  
  101. # .elf aus .o linken
  102. %elf: $(OBJS)
  103.     $(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
  104.  
  105. # flash.bin aus .elf erstellen
  106. %bin: %elf
  107.     $(BIN) $< $@
  108.  
  109.  
  110. size:
  111.     $(SIZE) $(PROJECT).elf
  112.  
  113. flash:
  114.     cp \$(PROJECT).bin flash.bin
  115.     $(OPENOCD) -f ./Settings/flash.cfg
  116.  
  117. # Cleanup
  118. clean:
  119.     -rm -f $(OBJS)
  120.     -rm -f $(SRC:.c=.c.bak)
  121.     -rm -f $(SRC:.c=.lst)
  122.     -rm -f $(ASRC:.s=.s.bak)
  123.     -rm -f $(ASRC:.s=.lst)
  124.     -rm -f $(PROJECT).elf
  125.     -rm -f $(PROJECT).bin
  126.     -rm -f flash.bin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement