Subversion Repositories svnkaklik

Rev

Rev 484 | Details | Compare with Previous | Last modification | View Log

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