author | Christian Taedcke <hacking@taedcke.com> |
Mon, 21 May 2012 16:13:47 +0200 | |
changeset 720 | 09dd61317f0f |
parent 675 | e5c5101c4f0b |
permissions | -rw-r--r-- |
413 | 1 |
############################################################################### |
2 |
# Makefile for the project SlaveAVR |
|
3 |
############################################################################### |
|
4 |
||
5 |
## General Flags |
|
6 |
PROJECT = SlaveAVR |
|
7 |
MCU = at90can128 |
|
8 |
TARGET = AVR |
|
675
e5c5101c4f0b
FIXED: - The AVR example now compiles in linux.
Christian Taedcke <hacking@taedcke.com>
parents:
413
diff
changeset
|
9 |
CC = avr-gcc |
413 | 10 |
SRC = ../../../src |
11 |
DRV = ../../../drivers/AVR |
|
12 |
||
13 |
## Options common to compile, link and assembly rules |
|
14 |
COMMON = -mmcu=$(MCU) |
|
15 |
||
16 |
## Compile options common for all C compilation units. |
|
17 |
CFLAGS = $(COMMON) |
|
18 |
CFLAGS += -Wall -gdwarf-2 -Os -fsigned-char -fpack-struct |
|
19 |
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d |
|
20 |
||
21 |
## Assembly specific flags |
|
22 |
ASMFLAGS = $(COMMON) |
|
23 |
ASMFLAGS += $(CFLAGS) |
|
24 |
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2 |
|
25 |
||
26 |
## Linker flags |
|
27 |
LDFLAGS = $(COMMON) |
|
28 |
LDFLAGS += -Wl,-Map=$(PROJECT).map |
|
29 |
||
30 |
## Intel Hex file production flags |
|
31 |
HEX_FLASH_FLAGS = -R .eeprom |
|
32 |
||
33 |
HEX_EEPROM_FLAGS = -j .eeprom |
|
34 |
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load" |
|
35 |
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings |
|
36 |
||
37 |
## Include Directories |
|
675
e5c5101c4f0b
FIXED: - The AVR example now compiles in linux.
Christian Taedcke <hacking@taedcke.com>
parents:
413
diff
changeset
|
38 |
INCLUDES = -I../../../include/AVR -I../../../include |
413 | 39 |
|
40 |
## Objects that must be built in order to link |
|
41 |
OBJECTS = $(DRV)/can_AVR.o\ |
|
42 |
$(DRV)/timer_AVR.o\ |
|
43 |
$(SRC)/dcf.o\ |
|
44 |
$(SRC)/timer.o\ |
|
45 |
$(SRC)/emcy.o\ |
|
46 |
$(SRC)/lifegrd.o\ |
|
47 |
$(SRC)/lss.o\ |
|
48 |
$(SRC)/nmtMaster.o\ |
|
49 |
$(SRC)/nmtSlave.o\ |
|
50 |
$(SRC)/objacces.o\ |
|
51 |
$(SRC)/pdo.o\ |
|
52 |
$(SRC)/sdo.o\ |
|
53 |
$(SRC)/states.o\ |
|
54 |
$(SRC)/sync.o\ |
|
55 |
ObjDict.o\ |
|
56 |
ds401.o\ |
|
57 |
main.o |
|
58 |
||
59 |
## Build |
|
60 |
all: $(PROJECT).elf $(PROJECT).hex $(PROJECT).eep $(PROJECT).lss size |
|
61 |
||
62 |
## Compile |
|
63 |
%.o: %.c |
|
64 |
# @echo " " |
|
65 |
@echo "---------------------------------------------------------------------------" |
|
66 |
@echo "**Compiling $< -> $@" |
|
67 |
# @echo "*********************************************" |
|
68 |
$(CC) $(INCLUDES) $(CFLAGS) -c $< |
|
69 |
# $(CC) $(INCLUDES) $(CFLAGS) -c -o $@ $< |
|
70 |
||
71 |
||
72 |
##Link |
|
73 |
$(PROJECT).elf: $(OBJECTS) |
|
74 |
# @echo " " |
|
75 |
@echo "---------------------------------------------------------------------------" |
|
76 |
@echo "**Linking : $@" |
|
77 |
# @echo "*********************************************" |
|
78 |
$(CC) $(LDFLAGS) $(LIBDIRS) $(LIBS) $(^F) -o $@ |
|
79 |
||
80 |
%.hex: $(PROJECT).elf |
|
81 |
avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@ |
|
82 |
||
83 |
%.eep: $(PROJECT).elf |
|
84 |
-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0 |
|
85 |
||
86 |
%.lss: $(PROJECT).elf |
|
87 |
avr-objdump -h -S $< > $@ |
|
88 |
||
89 |
size: $(PROJECT).elf |
|
90 |
@echo |
|
91 |
@avr-size -C --mcu=${MCU} $(PROJECT).elf |
|
92 |
||
93 |
## Clean target |
|
94 |
.PHONY: clean |
|
95 |
clean: |
|
96 |
-rm -rf *.o $(PROJECT).elf dep/* $(PROJECT).hex $(PROJECT).eep $(PROJECT).lss $(PROJECT).map |
|
97 |
||
98 |
||
99 |
## Other dependencies |
|
100 |
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*) |
|
101 |