Subversion Repositories Projects

Rev

Rev 321 | Rev 349 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
321 cascade 1
###############################################################################
2
# Makefile for the project C-OSD
3
###############################################################################
4
 
5
## General Flags
6
PROJECT = C-OSD
7
MCU = atmega162
8
TARGET = C-OSD.elf
9
CC = avr-gcc
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 -std=gnu99        -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
346 cascade 17
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
321 cascade 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=C-OSD.map
27
 
28
 
29
## Intel Hex file production flags
30
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature
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
## Objects that must be built in order to link
346 cascade 38
OBJECTS = main.o usart1.o max7456_software_spi.o
321 cascade 39
 
40
## Objects explicitly added by the user
346 cascade 41
LINKONLYOBJECTS =
321 cascade 42
 
43
## Build
44
all: $(TARGET) C-OSD.hex C-OSD.eep C-OSD.lss size
45
 
46
## Compile
47
main.o: ../main.c
48
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
49
 
346 cascade 50
usart1.o: ../usart1.c
51
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
52
 
53
max7456_software_spi.o: ../max7456_software_spi.c
54
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
55
 
321 cascade 56
##Link
57
$(TARGET): $(OBJECTS)
58
	 $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
59
 
60
%.hex: $(TARGET)
61
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@
62
 
63
%.eep: $(TARGET)
64
	-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
65
 
66
%.lss: $(TARGET)
67
	avr-objdump -h -S $< > $@
68
 
69
size: ${TARGET}
70
	@echo
71
	@avr-size -C --mcu=${MCU} ${TARGET}
72
 
73
## Clean target
74
.PHONY: clean
75
clean:
76
	-rm -rf $(OBJECTS) C-OSD.elf dep/* C-OSD.hex C-OSD.eep C-OSD.lss C-OSD.map
77
 
78
 
79
## Other dependencies
80
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)