Subversion Repositories Projects

Rev

Rev 2099 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
902 - 1
#/****************************************************************************
2225 - 2
# *   Copyright (C) 2009-2016 by Claas Anders "CaScAdE" Rathje               *
902 - 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
1281 - 28
#ISPTYPE = usbasp
29
ISPTYPE = avrispmkII
1197 - 30
ISPPORT = usb
321 cascade 31
 
1197 - 32
 
321 cascade 33
## Options common to compile, link and assembly rules
34
COMMON = -mmcu=$(MCU)
35
 
36
## Compile options common for all C compilation units.
456 cascade 37
CFLAGS += $(COMMON)
738 cascade 38
##CFLAGS += -fno-common
757 cascade 39
CFLAGS += -Wall -gdwarf-2 -std=gnu99 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
346 cascade 40
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
321 cascade 41
 
42
## Assembly specific flags
43
ASMFLAGS = $(COMMON)
44
ASMFLAGS += $(CFLAGS)
45
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
46
 
47
## Linker flags
48
LDFLAGS = $(COMMON)
49
LDFLAGS +=  -Wl,-Map=C-OSD.map
50
 
51
 
52
## Intel Hex file production flags
53
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature
54
 
55
HEX_EEPROM_FLAGS = -j .eeprom
56
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
57
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
58
 
59
 
60
## Objects that must be built in order to link
772 - 61
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 62
 
63
## Objects explicitly added by the user
346 cascade 64
LINKONLYOBJECTS =
321 cascade 65
 
66
## Build
1197 - 67
all: $(TARGET) C-OSD.hex C-OSD.eep C-OSD.lss size #flash
321 cascade 68
 
69
## Compile
70
main.o: ../main.c
71
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
72
 
346 cascade 73
usart1.o: ../usart1.c
74
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
349 cascade 75
 
772 - 76
usart0.o: ../usart0.c
77
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
78
 
346 cascade 79
max7456_software_spi.o: ../max7456_software_spi.c
80
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
349 cascade 81
 
389 cascade 82
osd_helpers.o: ../osd_helpers.c
83
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
477 cascade 84
 
471 cascade 85
config.o: ../config.c
86
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
389 cascade 87
 
471 cascade 88
spi.o: ../spi.c
89
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
477 cascade 90
 
471 cascade 91
buttons.o: ../buttons.c
92
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
93
 
477 cascade 94
ppm.o: ../ppm.c
95
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
514 cascade 96
 
497 cascade 97
osd_ncmode_default.o: ../osd_ncmode_default.c
98
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
514 cascade 99
 
497 cascade 100
osd_ncmode_minimal.o: ../osd_ncmode_minimal.c
101
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
477 cascade 102
 
497 cascade 103
osd_fcmode_default.o: ../osd_fcmode_default.c
104
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
685 cascade 105
 
106
osd_fcmode_jopl.o: ../osd_fcmode_jopl.c
107
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
514 cascade 108
 
109
characters.o: ../characters.c
110
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
497 cascade 111
 
321 cascade 112
##Link
113
$(TARGET): $(OBJECTS)
114
	 $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
115
 
116
%.hex: $(TARGET)
117
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@
118
 
119
%.eep: $(TARGET)
120
	-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
121
 
122
%.lss: $(TARGET)
123
	avr-objdump -h -S $< > $@
124
 
125
size: ${TARGET}
126
	@echo
127
	@avr-size -C --mcu=${MCU} ${TARGET}
128
 
1197 - 129
flash: ${TARGET}
130
	@echo
131
	avrdude -c ${ISPTYPE} -P ${ISPPORT} -p ${MCU} -u -U flash:w:C-OSD.hex
132
 
133
 
321 cascade 134
## Clean target
135
.PHONY: clean
136
clean:
137
	-rm -rf $(OBJECTS) C-OSD.elf dep/* C-OSD.hex C-OSD.eep C-OSD.lss C-OSD.map
138
 
139
 
140
## Other dependencies
685 cascade 141
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)