Subversion Repositories Projects

Rev

Rev 902 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 902 Rev 1437
1
#/****************************************************************************
1
#/****************************************************************************
2
# *   Copyright (C) 2009-2011 by Claas Anders "CaScAdE" Rathje               *
2
# *   Copyright (C) 2009-2012 by Claas Anders "CaScAdE" Rathje               *
3
# *   admiralcascade@gmail.com                                               *
3
# *   admiralcascade@gmail.com                                               *
4
# *   Project-URL: http://www.mylifesucks.de/oss/c-strom/                      *
4
# *   Project-URL: http://www.mylifesucks.de/oss/c-strom/                      *
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
## General Flags
21
## General Flags
22
PROJECT = C-Strom
22
PROJECT = C-Strom
23
MCU = atmega8
23
MCU = atmega8
24
TARGET = C-Strom.elf
24
TARGET = C-Strom.elf
25
CC = avr-gcc
25
CC = avr-gcc
26
 
26
 
27
## Options common to compile, link and assembly rules
27
## Options common to compile, link and assembly rules
28
COMMON = -mmcu=$(MCU)
28
COMMON = -mmcu=$(MCU)
29
 
29
 
30
## Compile options common for all C compilation units.
30
## Compile options common for all C compilation units.
31
CFLAGS = $(COMMON)
31
CFLAGS = $(COMMON)
32
CFLAGS += -Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
32
CFLAGS += -Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
33
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d 
33
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d 
34
 
34
 
35
## Assembly specific flags
35
## Assembly specific flags
36
ASMFLAGS = $(COMMON)
36
ASMFLAGS = $(COMMON)
37
ASMFLAGS += $(CFLAGS)
37
ASMFLAGS += $(CFLAGS)
38
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
38
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
39
 
39
 
40
## Linker flags
40
## Linker flags
41
LDFLAGS = $(COMMON)
41
LDFLAGS = $(COMMON)
42
LDFLAGS +=  -Wl,-Map=C-Strom.map
42
LDFLAGS +=  -Wl,-Map=C-Strom.map
43
 
43
 
44
 
44
 
45
## Intel Hex file production flags
45
## Intel Hex file production flags
46
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature
46
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature
47
 
47
 
48
HEX_EEPROM_FLAGS = -j .eeprom
48
HEX_EEPROM_FLAGS = -j .eeprom
49
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
49
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
50
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
50
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
51
 
51
 
52
 
52
 
53
## Objects that must be built in order to link
53
## Objects that must be built in order to link
54
OBJECTS = C-Strom.o i2c_slave.o 
54
OBJECTS = C-Strom.o i2c_slave.o 
55
 
55
 
56
## Objects explicitly added by the user
56
## Objects explicitly added by the user
57
LINKONLYOBJECTS = 
57
LINKONLYOBJECTS = 
58
 
58
 
59
## Build
59
## Build
60
all: $(TARGET) C-Strom.hex C-Strom.eep C-Strom.lss size
60
all: $(TARGET) C-Strom.hex C-Strom.eep C-Strom.lss size
61
 
61
 
62
## Compile
62
## Compile
63
C-Strom.o: ../C-Strom.c
63
C-Strom.o: ../C-Strom.c
64
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
64
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
65
 
65
 
66
i2c_slave.o: ../i2c_slave.c
66
i2c_slave.o: ../i2c_slave.c
67
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
67
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
68
 
68
 
69
##Link
69
##Link
70
$(TARGET): $(OBJECTS)
70
$(TARGET): $(OBJECTS)
71
	 $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
71
	 $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
72
 
72
 
73
%.hex: $(TARGET)
73
%.hex: $(TARGET)
74
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@
74
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@
75
 
75
 
76
%.eep: $(TARGET)
76
%.eep: $(TARGET)
77
	-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
77
	-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
78
 
78
 
79
%.lss: $(TARGET)
79
%.lss: $(TARGET)
80
	avr-objdump -h -S $< > $@
80
	avr-objdump -h -S $< > $@
81
 
81
 
82
size: ${TARGET}
82
size: ${TARGET}
83
	@echo
83
	@echo
84
	@avr-size -C --mcu=${MCU} ${TARGET}
84
	@avr-size -C --mcu=${MCU} ${TARGET}
85
 
85
 
86
## Clean target
86
## Clean target
87
.PHONY: clean
87
.PHONY: clean
88
clean:
88
clean:
89
	-rm -rf $(OBJECTS) C-Strom.elf dep/* C-Strom.hex C-Strom.eep C-Strom.lss C-Strom.map
89
	-rm -rf $(OBJECTS) C-Strom.elf dep/* C-Strom.hex C-Strom.eep C-Strom.lss C-Strom.map
90
 
90
 
91
 
91
 
92
## Other dependencies
92
## Other dependencies
93
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
93
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
94
 
94