Line 1... |
Line 1... |
1 |
############################################################################### |
1 |
############################################################################### |
2 |
# Makefile for the project Tykadlo |
2 |
# Makefile for the project Tykadlo |
3 |
############################################################################### |
3 |
############################################################################### |
4 |
# (c)miho www.mlab.cz |
4 |
# (c)miho www.mlab.cz |
5 |
|
- |
|
- |
|
5 |
# 1.00 - new makefile |
- |
|
6 |
# 1.01 - solved problem with default rules (invalid target "Makefile") |
6 |
|
7 |
|
7 |
## User Settings |
8 |
## User Settings |
- |
|
9 |
# Frequencies are in Hz, Callibration is usualy not needed |
8 |
FREQUENCIES = 30000 32000 34000 36000 38000 40000 56000 |
10 |
FREQUENCIES = 30000 32000 34000 36000 38000 40000 56000 |
9 |
CALIBRATION = 0 |
11 |
CALIBRATION = 0 |
10 |
|
12 |
|
11 |
## Project |
13 |
## Project |
- |
|
14 |
# Main source file name, target platform, destination directory |
12 |
PROJECT = Tykadlo |
15 |
PROJECT = Tykadlo |
13 |
MCU = attiny13 |
16 |
MCU = attiny13 |
14 |
TARGETDIR = BIN |
17 |
TARGETDIR = BIN |
15 |
|
18 |
|
16 |
## Variants - all supported frequences |
19 |
## Variants - all supported frequences |
- |
|
20 |
# Combine project name with all required frequencies |
17 |
VARIANTS = $(foreach FREQ, $(FREQUENCIES), $(PROJECT)_$(FREQ)) |
21 |
VARIANTS = $(foreach FREQ, $(FREQUENCIES), $(PROJECT)_$(FREQ)) |
18 |
|
22 |
|
19 |
## General Flags |
23 |
## General Flags |
20 |
CC = avr-gcc |
24 |
CC = avr-gcc |
21 |
|
25 |
|
Line 33... |
Line 37... |
33 |
|
37 |
|
34 |
## Intel Hex file production flags |
38 |
## Intel Hex file production flags |
35 |
HEX_FLASH_FLAGS = -R .fuse -R .lock -R .signature |
39 |
HEX_FLASH_FLAGS = -R .fuse -R .lock -R .signature |
36 |
|
40 |
|
37 |
## Build |
41 |
## Build |
- |
|
42 |
|
- |
|
43 |
# Tag targets that are not / do not require files |
- |
|
44 |
.PHONY: all allhex alllss clean Makefile |
- |
|
45 |
|
38 |
.PHONY: all |
46 |
# Main target |
39 |
all: allhex |
47 |
all: allhex |
40 |
|
48 |
|
41 |
.PHONY: allhex |
49 |
# Subtarget - all variants hex files |
42 |
allhex: $(foreach VAR, $(VARIANTS), $(VAR).hex) |
50 |
allhex: $(foreach VAR, $(VARIANTS), $(VAR).hex) |
43 |
|
51 |
|
44 |
.PHONY: alllss |
52 |
# Subtarget - all variants lss files |
45 |
alllss: $(foreach VAR, $(VARIANTS), $(VAR).lss) |
53 |
alllss: $(foreach VAR, $(VARIANTS), $(VAR).lss) |
46 |
|
54 |
|
- |
|
55 |
# How to translate .o file - from .c with all possible frequencies |
47 |
%.o: $(PROJECT).c |
56 |
%.o: $(PROJECT).c |
48 |
$(CC) $(INCLUDES) $(CFLAGS) -c $< -D CALIBRATION=$(CALIBRATION) -D IR_FREQUENCY=$(subst $(PROJECT)_,,$(@:.o=))UL -o $@ |
57 |
$(CC) $(INCLUDES) $(CFLAGS) -c $< -D CALIBRATION=$(CALIBRATION) -D IR_FREQUENCY=$(subst $(PROJECT)_,,$(@:.o=))UL -o $@ |
49 |
|
58 |
|
- |
|
59 |
# How to link .elf - from .o |
50 |
%.elf: %.o |
60 |
%.elf: %.o |
51 |
$(CC) $(LDFLAGS) $< $(LIBDIRS) $(LIBS) -o $@ |
61 |
$(CC) $(LDFLAGS) $< $(LIBDIRS) $(LIBS) -o $@ |
52 |
rm $< |
62 |
rm $< |
53 |
|
63 |
|
- |
|
64 |
# How to generate .hex file - from .elf |
54 |
%.hex: %.elf |
65 |
%.hex: %.elf |
55 |
avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $(TARGETDIR)/$@ |
66 |
avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $(TARGETDIR)/$@ |
56 |
|
67 |
|
- |
|
68 |
# How to generate .lss file - from .elf |
57 |
%.lss: %.elf |
69 |
%.lss: %.elf |
58 |
avr-objdump -h -S $< > $(TARGETDIR)/$@ |
70 |
avr-objdump -h -S $< > $(TARGETDIR)/$@ |
59 |
|
71 |
|
60 |
## Clean target |
72 |
## Clean target |
61 |
.PHONY: clean |
- |
|
62 |
clean: |
73 |
clean: |
63 |
-rm -rf $(PROJECT)*.o $(PROJECT)*.elf dep/* $(TARGETDIR)/$(PROJECT)*.hex $(TARGETDIR)/$(PROJECT)*.lss |
74 |
-rm -rf $(PROJECT)*.o $(PROJECT)*.elf dep/* $(TARGETDIR)/$(PROJECT)*.hex $(TARGETDIR)/$(PROJECT)*.lss |
64 |
-rmdir dep |
75 |
-rmdir dep |
65 |
-rmdir $(TARGETDIR) |
76 |
-rmdir $(TARGETDIR) |
66 |
|
77 |
|