Advertisement
Guest User

Untitled

a guest
Jan 9th, 2015
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. ###############################################################################
  2. # Makefile for the project AVR
  3. ###############################################################################
  4.  
  5. ## General Flags
  6. PROJECT = demo
  7. MCU = atmega128
  8. TARGET = demo
  9. OPT = 3
  10.  
  11. CC=avr-gcc
  12. OBJCOPY=avr-objcopy
  13. AVRDUDE=avrdude
  14.  
  15. ## Options common to compile, link and assembly rules
  16. COMMON = -mmcu=$(MCU)
  17.  
  18. ## Compile options common for all C compilation units.
  19. CFLAGS = $(COMMON) \
  20. -Iport -I. \
  21. -I../../modbus/rtu -I../../modbus/ascii -I../../modbus/include -I24c
  22. CFLAGS += -Wall -gstabs -DF_CPU=16000000UL -Os -Wall -Wstrict-prototypes
  23.  
  24. CFLAGS += -Wp,-M,-MP,-MT,$(*F).o,-MF,dep/$(@F).d
  25.  
  26. CDEFS += -DRTS_ENABLE
  27.  
  28. ## Assembly specific flags
  29. ASMFLAGS = $(COMMON)
  30. ASMFLAGS += -x assembler-with-cpp -Wa,-gstabs
  31.  
  32. ## Linker flags
  33. LDFLAGS = $(COMMON)
  34. LDFLAGS += -Wl,-Map=$(TARGET).map,--cref
  35.  
  36. ## Intel Hex file production flags
  37. HEX_FLASH_FLAGS = -R .eeprom
  38.  
  39. HEX_EEPROM_FLAGS = -j .eeprom
  40. HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
  41. HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0
  42.  
  43.  
  44. ## Objects that must be built in order to link
  45. ## OBJECTS = excoils.o
  46. OBJECTS = demo.o
  47. MBPORTOBJECTS = port/portserial.o \
  48. port/portevent.o \
  49. port/porttimer.o \
  50. port/mbcrc.o
  51. MBOBJECTS = ../../modbus/mb.o \
  52. ../../modbus/rtu/mbrtu.o \
  53. ../../modbus/ascii/mbascii.o \
  54. ../../modbus/functions/mbfunccoils.o \
  55. ../../modbus/functions/mbfuncdiag.o \
  56. ../../modbus/functions/mbfuncholding.o \
  57. ../../modbus/functions/mbfuncinput.o \
  58. ../../modbus/functions/mbfuncother.o \
  59. ../../modbus/functions/mbfuncdisc.o \
  60. ../../modbus/functions/mbutils.o
  61.  
  62.  
  63. ## Build
  64. all: $(TARGET).elf $(TARGET).hex $(TARGET).eep
  65.  
  66. ## Compile
  67. demo.o: demo.c
  68. $(CC) $(INCLUDES) $(CFLAGS) -c $<
  69. 24c64.o: 24c64.c
  70. $(CC) $(INCLUDES) $(CFLAGS) -c $<
  71.  
  72. ##Link
  73. $(TARGET).elf: $(OBJECTS) $(MBOBJECTS) $(MBPORTOBJECTS)
  74. $(CC) $(LDFLAGS) $(OBJECTS) $(MBPORTOBJECTS) $(MBOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET).elf
  75.  
  76. %.hex: $(TARGET).elf
  77. $(OBJCOPY) -O ihex $(HEX_FLASH_FLAGS) $< $@
  78.  
  79. %.cof: $(TARGET).elf
  80. $(OBJCOPY) --debugging \
  81. --change-section-address .data-0x800000 \
  82. --change-section-address .bss-0x800000 \
  83. --change-section-address .noinit-0x800000 \
  84. --change-section-address .eeprom-0x810000 -O coff-avr $< $@
  85.  
  86. %.eep: $(TARGET).elf
  87. $(OBJCOPY) $(HEX_EEPROM_FLAGS) -O ihex $< $@
  88.  
  89. %.lss: $(TARGET)
  90. $(OBJCOPY) -h -S $< > $@
  91.  
  92. flash:
  93. $(AVRDUDE) -p m8 -c stk200 -U flash:w:$(TARGET).hex
  94.  
  95. size: avr-size ${TARGET} ${MCU}
  96.  
  97. ## Clean target
  98. .PHONY: clean
  99. clean:
  100. -rm -rf $(OBJECTS) $(MBOBJECTS) $(MBPORTOBJECTS)
  101. -rm -rf $(TARGET).elf $(TARGET).hex $(TARGET).eep $(TARGET).cof $(TARGET).map
  102. -rm -rf dep
  103.  
  104. ## Other dependencies
  105. -include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement