examples/AVR/DS401_Slave/GCC/default/Makefile
changeset 375 03fb0bfccc1f
equal deleted inserted replaced
374:b74f7ec412fc 375:03fb0bfccc1f
       
     1 ###############################################################################
       
     2 # Makefile for the project SlaveAVR
       
     3 ###############################################################################
       
     4 
       
     5 ## General Flags
       
     6 PROJECT = SlaveAVR
       
     7 MCU = at90can128
       
     8 TARGET = SlaveAVR.elf
       
     9 CC = avr-gcc.exe
       
    10 
       
    11 ## Options common to compile, link and assembly rules
       
    12 COMMON = -mmcu=$(MCU)
       
    13 
       
    14 ## Compile options common for all C compilation units.
       
    15 CFLAGS = $(COMMON)
       
    16 CFLAGS += -Wall -gdwarf-2                              -Os -fsigned-char -fpack-struct
       
    17 CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d 
       
    18 
       
    19 ## Assembly specific flags
       
    20 ASMFLAGS = $(COMMON)
       
    21 ASMFLAGS += $(CFLAGS)
       
    22 ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
       
    23 
       
    24 ## Linker flags
       
    25 LDFLAGS = $(COMMON)
       
    26 LDFLAGS +=  -Wl,-Map=SlaveAVR.map
       
    27 
       
    28 
       
    29 ## Intel Hex file production flags
       
    30 HEX_FLASH_FLAGS = -R .eeprom
       
    31 
       
    32 HEX_EEPROM_FLAGS = -j .eeprom
       
    33 HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
       
    34 HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
       
    35 
       
    36 
       
    37 ## Include Directories
       
    38 INCLUDES = -I"I:\Entwicklung\Firmware\CAN\CanFestival-3\examples\AVR\DS401_Slave\GCC\..\..\..\..\include\AVR" -I"I:\Entwicklung\Firmware\CAN\CanFestival-3\examples\AVR\DS401_Slave\GCC\." -I"I:\Entwicklung\Firmware\CAN\CanFestival-3\examples\AVR\DS401_Slave\GCC\..\..\..\..\include" 
       
    39 
       
    40 ## Objects that must be built in order to link
       
    41 OBJECTS = can_AVR.o dcf.o timer.o emcy.o lifegrd.o nmtSlave.o objacces.o pdo.o sdo.o states.o sync.o ObjDict.o main.o nmtMaster.o timer_AVR.o 
       
    42 
       
    43 ## Objects explicitly added by the user
       
    44 LINKONLYOBJECTS = 
       
    45 
       
    46 ## Build
       
    47 all: $(TARGET) SlaveAVR.hex SlaveAVR.eep SlaveAVR.lss size
       
    48 
       
    49 ## Compile
       
    50 can_AVR.o: ../../../../../drivers/AVR/can_AVR.c
       
    51 	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
       
    52 
       
    53 dcf.o: ../../../../../src/dcf.c
       
    54 	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
       
    55 
       
    56 timer.o: ../../../../../src/timer.c
       
    57 	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
       
    58 
       
    59 emcy.o: ../../../../../src/emcy.c
       
    60 	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
       
    61 
       
    62 lifegrd.o: ../../../../../src/lifegrd.c
       
    63 	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
       
    64 
       
    65 nmtSlave.o: ../../../../../src/nmtSlave.c
       
    66 	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
       
    67 
       
    68 objacces.o: ../../../../../src/objacces.c
       
    69 	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
       
    70 
       
    71 pdo.o: ../../../../../src/pdo.c
       
    72 	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
       
    73 
       
    74 sdo.o: ../../../../../src/sdo.c
       
    75 	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
       
    76 
       
    77 states.o: ../../../../../src/states.c
       
    78 	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
       
    79 
       
    80 sync.o: ../../../../../src/sync.c
       
    81 	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
       
    82 
       
    83 ObjDict.o: ../../ObjDict.c
       
    84 	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
       
    85 
       
    86 main.o: ../../main.c
       
    87 	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
       
    88 
       
    89 nmtMaster.o: ../../../../../src/nmtMaster.c
       
    90 	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
       
    91 
       
    92 timer_AVR.o: ../../../../../drivers/AVR/timer_AVR.c
       
    93 	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
       
    94 
       
    95 ##Link
       
    96 $(TARGET): $(OBJECTS)
       
    97 	 $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
       
    98 
       
    99 %.hex: $(TARGET)
       
   100 	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@
       
   101 
       
   102 %.eep: $(TARGET)
       
   103 	-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
       
   104 
       
   105 %.lss: $(TARGET)
       
   106 	avr-objdump -h -S $< > $@
       
   107 
       
   108 size: ${TARGET}
       
   109 	@echo
       
   110 	@avr-size -C --mcu=${MCU} ${TARGET}
       
   111 
       
   112 ## Clean target
       
   113 .PHONY: clean
       
   114 clean:
       
   115 	-rm -rf $(OBJECTS) SlaveAVR.elf dep/* SlaveAVR.hex SlaveAVR.eep SlaveAVR.lss SlaveAVR.map
       
   116 
       
   117 
       
   118 ## Other dependencies
       
   119 -include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
       
   120