Subversion Repositories Projects

Rev

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

Rev Author Line No. Line
902 - 1
#/****************************************************************************
2
# *   Copyright (C) 2009-2011 by Claas Anders "CaScAdE" Rathje               *
3
# *   admiralcascade@gmail.com                                               *
4
# *   Project-URL: http://www.mylifesucks.de/oss/c-osd/                      *
5
# *                                                                          *
6
# *   This program is free software; you can redistribute it and/or modify   *
7
# *   it under the terms of the GNU General Public License as published by   *
8
# *   the Free Software Foundation; either version 2 of the License.         *
9
# *                                                                          *
10
# *   This program is distributed in the hope that it will be useful,        *
11
# *   but WITHOUT ANY WARRANTY; without even the implied warranty of         *
12
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
13
# *   GNU General Public License for more details.                           *
14
# *                                                                          *
15
# *   You should have received a copy of the GNU General Public License      *
16
# *   along with this program; if not, write to the                          *
17
# *   Free Software Foundation, Inc.,                                        *
18
# *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.              *
19
# ****************************************************************************/
321 cascade 20
 
902 - 21
 
321 cascade 22
## General Flags
23
PROJECT = C-OSD
24
MCU = atmega162
25
TARGET = C-OSD.elf
26
CC = avr-gcc
1197 - 27
AVRDUDE = avrdude
28
ISPTYPE = usbasp
29
ISPPORT = usb
321 cascade 30
 
1197 - 31
 
321 cascade 32
## Options common to compile, link and assembly rules
33
COMMON = -mmcu=$(MCU)
34
 
35
## Compile options common for all C compilation units.
456 cascade 36
CFLAGS += $(COMMON)
738 cascade 37
##CFLAGS += -fno-common
757 cascade 38
CFLAGS += -Wall -gdwarf-2 -std=gnu99 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
346 cascade 39
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
321 cascade 40
 
41
## Assembly specific flags
42
ASMFLAGS = $(COMMON)
43
ASMFLAGS += $(CFLAGS)
44
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
45
 
46
## Linker flags
47
LDFLAGS = $(COMMON)
48
LDFLAGS +=  -Wl,-Map=C-OSD.map
49
 
50
 
51
## Intel Hex file production flags
52
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature
53
 
54
HEX_EEPROM_FLAGS = -j .eeprom
55
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
56
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
57
 
58
 
59
## Objects that must be built in order to link
772 - 60
OBJECTS = main.o usart0.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 61
 
62
## Objects explicitly added by the user
346 cascade 63
LINKONLYOBJECTS =
321 cascade 64
 
65
## Build
1197 - 66
all: $(TARGET) C-OSD.hex C-OSD.eep C-OSD.lss size #flash
321 cascade 67
 
68
## Compile
69
main.o: ../main.c
70
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
71
 
346 cascade 72
usart1.o: ../usart1.c
73
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
349 cascade 74
 
772 - 75
usart0.o: ../usart0.c
76
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
77
 
346 cascade 78
max7456_software_spi.o: ../max7456_software_spi.c
79
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
349 cascade 80
 
389 cascade 81
osd_helpers.o: ../osd_helpers.c
82
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
477 cascade 83
 
471 cascade 84
config.o: ../config.c
85
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
389 cascade 86
 
471 cascade 87
spi.o: ../spi.c
88
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
477 cascade 89
 
471 cascade 90
buttons.o: ../buttons.c
91
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
92
 
477 cascade 93
ppm.o: ../ppm.c
94
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
514 cascade 95
 
497 cascade 96
osd_ncmode_default.o: ../osd_ncmode_default.c
97
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
514 cascade 98
 
497 cascade 99
osd_ncmode_minimal.o: ../osd_ncmode_minimal.c
100
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
477 cascade 101
 
497 cascade 102
osd_fcmode_default.o: ../osd_fcmode_default.c
103
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
685 cascade 104
 
105
osd_fcmode_jopl.o: ../osd_fcmode_jopl.c
106
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
514 cascade 107
 
108
characters.o: ../characters.c
109
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
497 cascade 110
 
321 cascade 111
##Link
112
$(TARGET): $(OBJECTS)
113
	 $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
114
 
115
%.hex: $(TARGET)
116
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@
117
 
118
%.eep: $(TARGET)
119
	-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
120
 
121
%.lss: $(TARGET)
122
	avr-objdump -h -S $< > $@
123
 
124
size: ${TARGET}
125
	@echo
126
	@avr-size -C --mcu=${MCU} ${TARGET}
127
 
1197 - 128
flash: ${TARGET}
129
	@echo
130
	avrdude -c ${ISPTYPE} -P ${ISPPORT} -p ${MCU} -u -U flash:w:C-OSD.hex
131
 
132
 
321 cascade 133
## Clean target
134
.PHONY: clean
135
clean:
136
	-rm -rf $(OBJECTS) C-OSD.elf dep/* C-OSD.hex C-OSD.eep C-OSD.lss C-OSD.map
137
 
138
 
139
## Other dependencies
685 cascade 140
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)