Subversion Repositories Projects

Rev

Rev 902 | Rev 1281 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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