Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1199 - 1
###############################################################################
2
# Makefile for the project C-Epilepsy
3
###############################################################################
4
 
5
## General Flags
6
PROJECT = C-Epilepsy
7
ifndef MCU
8
MCU = atmega644p
9
endif
10
 
11
TARGET = C-Epilepsy.elf
12
CC = avr-gcc
13
 
14
CPP = avr-g++
15
 
16
## Options common to compile, link and assembly rules
17
COMMON = -mmcu=$(MCU) -DMCU=$(MCU)
18
#COMMON =
19
 
20
## Compile options common for all C compilation units.
21
CFLAGS += $(COMMON)
22
CFLAGS += -Wall -gdwarf-2 -std=gnu99 -DF_CPU=20000000UL -O2 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
23
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
24
 
25
## Assembly specific flags
26
ASMFLAGS = $(COMMON)
27
ASMFLAGS += $(CFLAGS)
28
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
29
 
30
## Linker flags
31
LDFLAGS = $(COMMON)
32
LDFLAGS +=  -Wl,-Map=C-Epilepsy.map
33
 
34
 
35
## Intel Hex file production flags
36
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature
37
 
38
HEX_EEPROM_FLAGS = -j .eeprom
39
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
40
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
41
 
42
 
43
## Objects that must be built in order to link
44
OBJECTS = main.o usart0.o usart1.o timer0.o timer1.o led_out.o player.o epi_helpers.o nc_handler.o buttons.o eeprom.o integer_math.o
45
 
46
## Objects explicitly added by the user
47
LINKONLYOBJECTS =
48
 
49
## Build
50
all: $(TARGET) C-Epilepsy.hex C-Epilepsy.eep C-Epilepsy.lss size
51
 
52
## Compile
53
main.o: ../main.c
54
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
55
 
56
usart0.o: ../usart0.c
57
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
58
 
59
usart1.o: ../usart1.c
60
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
61
 
62
timer0.o: ../timer0.c
63
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
64
 
65
timer1.o: ../timer1.c
66
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
67
 
68
led_out.o: ../led_out.c
69
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
70
 
71
player.o: ../player.c
72
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
73
 
74
epi_helpers.o: ../epi_helpers.c
75
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
76
 
77
nc_handler.o: ../nc_handler.c
78
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
79
 
80
buttons.o: ../buttons.c
81
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
82
 
83
eeprom.o: ../eeprom.c
84
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
85
 
86
integer_math.o: ../integer_math.c
87
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
88
 
89
##Link
90
$(TARGET): $(OBJECTS)
91
	 $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
92
 
93
%.hex: $(TARGET)
94
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@
95
 
96
%.eep: $(TARGET)
97
	-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
98
 
99
%.lss: $(TARGET)
100
	avr-objdump -h -S $< > $@
101
 
102
size: ${TARGET}
103
	@echo
104
	@avr-size -C --mcu=${MCU} ${TARGET}
105
 
106
## Clean target
107
.PHONY: clean
108
clean:
109
	-rm -rf $(OBJECTS) C-Epilepsy.elf dep/* C-Epilepsy.hex C-Epilepsy.eep C-Epilepsy.lss C-Epilepsy.map
110
 
111
 
112
## Other dependencies
113
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
114