Subversion Repositories svnkaklik

Rev

Rev 484 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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