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