1389 |
miho |
1 |
############################################################################### |
|
|
2 |
# Makefile for the project Tykadlo |
|
|
3 |
############################################################################### |
|
|
4 |
# (c)miho www.mlab.cz |
|
|
5 |
|
|
|
6 |
|
|
|
7 |
## User Settings |
|
|
8 |
FREQUENCIES = 30000 32000 34000 36000 38000 40000 56000 |
|
|
9 |
CALIBRATION = 0 |
|
|
10 |
|
|
|
11 |
## Project |
|
|
12 |
PROJECT = Tykadlo |
|
|
13 |
MCU = attiny13 |
|
|
14 |
TARGETDIR = BIN |
|
|
15 |
|
|
|
16 |
## Variants - all supported frequences |
|
|
17 |
VARIANTS = $(foreach FREQ, $(FREQUENCIES), $(PROJECT)_$(FREQ)) |
|
|
18 |
|
|
|
19 |
## General Flags |
|
|
20 |
CC = avr-gcc |
|
|
21 |
|
|
|
22 |
## Options common to compile, link and assembly rules |
|
|
23 |
COMMON = -mmcu=$(MCU) |
|
|
24 |
|
|
|
25 |
## Compile options common for all C compilation units. |
|
|
26 |
CFLAGS = $(COMMON) |
|
|
27 |
CFLAGS += -Wall -gdwarf-2 -std=gnu99 -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums |
|
|
28 |
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d |
|
|
29 |
|
|
|
30 |
## Linker flags |
|
|
31 |
LDFLAGS = $(COMMON) |
|
|
32 |
LDFLAGS += -Wl |
|
|
33 |
|
|
|
34 |
## Intel Hex file production flags |
|
|
35 |
HEX_FLASH_FLAGS = -R .fuse -R .lock -R .signature |
|
|
36 |
|
|
|
37 |
## Build |
|
|
38 |
.PHONY: all |
|
|
39 |
all: allhex |
|
|
40 |
|
|
|
41 |
.PHONY: allhex |
|
|
42 |
allhex: $(foreach VAR, $(VARIANTS), $(VAR).hex) |
|
|
43 |
|
|
|
44 |
.PHONY: alllss |
|
|
45 |
alllss: $(foreach VAR, $(VARIANTS), $(VAR).lss) |
|
|
46 |
|
|
|
47 |
%.o: $(PROJECT).c |
|
|
48 |
$(CC) $(INCLUDES) $(CFLAGS) -c $< -D CALIBRATION=$(CALIBRATION) -D IR_FREQUENCY=$(subst $(PROJECT)_,,$(@:.o=))UL -o $@ |
|
|
49 |
|
|
|
50 |
%.elf: %.o |
|
|
51 |
$(CC) $(LDFLAGS) $< $(LIBDIRS) $(LIBS) -o $@ |
|
|
52 |
rm $< |
|
|
53 |
|
|
|
54 |
%.hex: %.elf |
|
|
55 |
avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $(TARGETDIR)/$@ |
|
|
56 |
|
|
|
57 |
%.lss: %.elf |
|
|
58 |
avr-objdump -h -S $< > $(TARGETDIR)/$@ |
|
|
59 |
|
|
|
60 |
## Clean target |
|
|
61 |
.PHONY: clean |
|
|
62 |
clean: |
|
|
63 |
-rm -rf $(PROJECT)*.o $(PROJECT)*.elf dep/* $(TARGETDIR)/$(PROJECT)*.hex $(TARGETDIR)/$(PROJECT)*.lss |
|
|
64 |
-rmdir dep |
|
|
65 |
-rmdir $(TARGETDIR) |
|
|
66 |
|
|
|
67 |
## Other dependencies |
|
|
68 |
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*) |
|
|
69 |
-include $(shell mkdir $(TARGETDIR) 2>/dev/null) |