Subversion Repositories Projects

Rev

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

Rev 772 Rev 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   *
1
###############################################################################
7
# *   it under the terms of the GNU General Public License as published by   *
2
# Makefile for the project C-OSD
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.              *
3
###############################################################################
19
# ****************************************************************************/
-
 
20
 
4
 
21
 
5
## General Flags
22
## General Flags
6
PROJECT = C-OSD
23
PROJECT = C-OSD
7
MCU = atmega162
24
MCU = atmega162
8
TARGET = C-OSD.elf
25
TARGET = C-OSD.elf
9
CC = avr-gcc
26
CC = avr-gcc
10
 
27
 
11
## Options common to compile, link and assembly rules
28
## Options common to compile, link and assembly rules
12
COMMON = -mmcu=$(MCU)
29
COMMON = -mmcu=$(MCU)
13
 
30
 
14
## Compile options common for all C compilation units.
31
## Compile options common for all C compilation units.
15
CFLAGS += $(COMMON)
32
CFLAGS += $(COMMON)
16
##CFLAGS += -fno-common
33
##CFLAGS += -fno-common
17
CFLAGS += -Wall -gdwarf-2 -std=gnu99 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
34
CFLAGS += -Wall -gdwarf-2 -std=gnu99 -DF_CPU=16000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
18
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
35
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
19
 
36
 
20
## Assembly specific flags
37
## Assembly specific flags
21
ASMFLAGS = $(COMMON)
38
ASMFLAGS = $(COMMON)
22
ASMFLAGS += $(CFLAGS)
39
ASMFLAGS += $(CFLAGS)
23
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
40
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
24
 
41
 
25
## Linker flags
42
## Linker flags
26
LDFLAGS = $(COMMON)
43
LDFLAGS = $(COMMON)
27
LDFLAGS +=  -Wl,-Map=C-OSD.map
44
LDFLAGS +=  -Wl,-Map=C-OSD.map
28
 
45
 
29
 
46
 
30
## Intel Hex file production flags
47
## Intel Hex file production flags
31
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature
48
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature
32
 
49
 
33
HEX_EEPROM_FLAGS = -j .eeprom
50
HEX_EEPROM_FLAGS = -j .eeprom
34
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
51
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
35
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
52
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
36
 
53
 
37
 
54
 
38
## Objects that must be built in order to link
55
## Objects that must be built in order to link
39
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
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
40
 
57
 
41
## Objects explicitly added by the user
58
## Objects explicitly added by the user
42
LINKONLYOBJECTS =
59
LINKONLYOBJECTS =
43
 
60
 
44
## Build
61
## Build
45
all: $(TARGET) C-OSD.hex C-OSD.eep C-OSD.lss size
62
all: $(TARGET) C-OSD.hex C-OSD.eep C-OSD.lss size
46
 
63
 
47
## Compile
64
## Compile
48
main.o: ../main.c
65
main.o: ../main.c
49
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
66
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
50
 
67
 
51
usart1.o: ../usart1.c
68
usart1.o: ../usart1.c
52
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
69
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
53
 
70
 
54
usart0.o: ../usart0.c
71
usart0.o: ../usart0.c
55
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
72
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
56
 
73
 
57
max7456_software_spi.o: ../max7456_software_spi.c
74
max7456_software_spi.o: ../max7456_software_spi.c
58
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
75
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
59
 
76
 
60
osd_helpers.o: ../osd_helpers.c
77
osd_helpers.o: ../osd_helpers.c
61
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
78
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
62
 
79
 
63
config.o: ../config.c
80
config.o: ../config.c
64
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
81
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
65
 
82
 
66
spi.o: ../spi.c
83
spi.o: ../spi.c
67
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
84
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
68
 
85
 
69
buttons.o: ../buttons.c
86
buttons.o: ../buttons.c
70
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
87
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
71
 
88
 
72
ppm.o: ../ppm.c
89
ppm.o: ../ppm.c
73
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
90
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
74
 
91
 
75
osd_ncmode_default.o: ../osd_ncmode_default.c
92
osd_ncmode_default.o: ../osd_ncmode_default.c
76
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
93
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
77
 
94
 
78
osd_ncmode_minimal.o: ../osd_ncmode_minimal.c
95
osd_ncmode_minimal.o: ../osd_ncmode_minimal.c
79
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
96
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
80
 
97
 
81
osd_fcmode_default.o: ../osd_fcmode_default.c
98
osd_fcmode_default.o: ../osd_fcmode_default.c
82
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
99
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
83
 
100
 
84
osd_fcmode_jopl.o: ../osd_fcmode_jopl.c
101
osd_fcmode_jopl.o: ../osd_fcmode_jopl.c
85
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
102
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
86
	
103
	
87
characters.o: ../characters.c
104
characters.o: ../characters.c
88
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
105
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
89
 
106
 
90
##Link
107
##Link
91
$(TARGET): $(OBJECTS)
108
$(TARGET): $(OBJECTS)
92
	 $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
109
	 $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
93
 
110
 
94
%.hex: $(TARGET)
111
%.hex: $(TARGET)
95
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@
112
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@
96
 
113
 
97
%.eep: $(TARGET)
114
%.eep: $(TARGET)
98
	-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
115
	-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
99
 
116
 
100
%.lss: $(TARGET)
117
%.lss: $(TARGET)
101
	avr-objdump -h -S $< > $@
118
	avr-objdump -h -S $< > $@
102
 
119
 
103
size: ${TARGET}
120
size: ${TARGET}
104
	@echo
121
	@echo
105
	@avr-size -C --mcu=${MCU} ${TARGET}
122
	@avr-size -C --mcu=${MCU} ${TARGET}
106
 
123
 
107
## Clean target
124
## Clean target
108
.PHONY: clean
125
.PHONY: clean
109
clean:
126
clean:
110
	-rm -rf $(OBJECTS) C-OSD.elf dep/* C-OSD.hex C-OSD.eep C-OSD.lss C-OSD.map
127
	-rm -rf $(OBJECTS) C-OSD.elf dep/* C-OSD.hex C-OSD.eep C-OSD.lss C-OSD.map
111
 
128
 
112
 
129
 
113
## Other dependencies
130
## Other dependencies
114
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
131
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)