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