Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
567 kaklik 1
###############################################################################
2
# Makefile for the project blik
3
###############################################################################
4
 
5
## General Flags
6
PROJECT = blik
7
MCU = atmega168
8
TARGET = blik.elf
9
CC = avr-gcc.exe
10
 
11
## Options common to compile, link and assembly rules
12
COMMON = -mmcu=$(MCU)
13
 
14
## Compile options common for all C compilation units.
15
CFLAGS = $(COMMON)
16
CFLAGS += -Wall -gdwarf-2 -std=gnu99 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
17
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d 
18
 
19
## Assembly specific flags
20
ASMFLAGS = $(COMMON)
21
ASMFLAGS += $(CFLAGS)
22
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
23
 
24
## Linker flags
25
LDFLAGS = $(COMMON)
26
LDFLAGS +=  -Wl,-Map=blik.map
27
 
28
 
29
## Intel Hex file production flags
30
HEX_FLASH_FLAGS = -R .eeprom
31
 
32
HEX_EEPROM_FLAGS = -j .eeprom
33
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
34
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
35
 
36
 
37
## Objects that must be built in order to link
38
OBJECTS = blik.o 
39
 
40
## Objects explicitly added by the user
41
LINKONLYOBJECTS = 
42
 
43
## Build
44
all: $(TARGET) blik.hex blik.eep blik.lss size
45
 
46
## Compile
47
blik.o: ../blik.c
48
	$(CC) $(INCLUDES) $(CFLAGS) -c  $<
49
 
50
##Link
51
$(TARGET): $(OBJECTS)
52
	 $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
53
 
54
%.hex: $(TARGET)
55
	avr-objcopy -O ihex $(HEX_FLASH_FLAGS)  $< $@
56
 
57
%.eep: $(TARGET)
58
	-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
59
 
60
%.lss: $(TARGET)
61
	avr-objdump -h -S $< > $@
62
 
63
size: ${TARGET}
64
	@echo
65
	@avr-size -C --mcu=${MCU} ${TARGET}
66
 
67
## Clean target
68
.PHONY: clean
69
clean:
70
	-rm -rf $(OBJECTS) blik.elf dep/* blik.hex blik.eep blik.lss blik.map
71
 
72
 
73
## Other dependencies
74
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
75