Subversion Repositories Projects

Rev

Rev 685 | Rev 738 | 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.
456 cascade 15
CFLAGS += $(COMMON)
734 cascade 16
CFLAGS += -Wall -gdwarf-2 -std=gnu99 -DF_CPU=16000000UL -O2 -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
685 cascade 38
OBJECTS = main.o usart1.o max7456_software_spi.o osd_helpers.o config.o spi.o buttons.o ppm.o osd_ncmode_default.o osd_ncmode_minimal.o osd_fcmode_default.o osd_fcmode_jopl.o characters.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  $<
349 cascade 52
 
346 cascade 53
max7456_software_spi.o: ../max7456_software_spi.c
54
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
349 cascade 55
 
389 cascade 56
osd_helpers.o: ../osd_helpers.c
57
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
477 cascade 58
 
471 cascade 59
config.o: ../config.c
60
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
389 cascade 61
 
471 cascade 62
spi.o: ../spi.c
63
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
477 cascade 64
 
471 cascade 65
buttons.o: ../buttons.c
66
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
67
 
477 cascade 68
ppm.o: ../ppm.c
69
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
514 cascade 70
 
497 cascade 71
osd_ncmode_default.o: ../osd_ncmode_default.c
72
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
514 cascade 73
 
497 cascade 74
osd_ncmode_minimal.o: ../osd_ncmode_minimal.c
75
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
477 cascade 76
 
497 cascade 77
osd_fcmode_default.o: ../osd_fcmode_default.c
78
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
685 cascade 79
 
80
osd_fcmode_jopl.o: ../osd_fcmode_jopl.c
81
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
514 cascade 82
 
83
characters.o: ../characters.c
84
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
497 cascade 85
 
321 cascade 86
##Link
87
$(TARGET): $(OBJECTS)
88
	 $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
89
 
90
%.hex: $(TARGET)
91
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@
92
 
93
%.eep: $(TARGET)
94
	-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
95
 
96
%.lss: $(TARGET)
97
	avr-objdump -h -S $< > $@
98
 
99
size: ${TARGET}
100
	@echo
101
	@avr-size -C --mcu=${MCU} ${TARGET}
102
 
103
## Clean target
104
.PHONY: clean
105
clean:
106
	-rm -rf $(OBJECTS) C-OSD.elf dep/* C-OSD.hex C-OSD.eep C-OSD.lss C-OSD.map
107
 
108
 
109
## Other dependencies
685 cascade 110
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)