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