-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (64 loc) · 2.87 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
########################################################################################
#
# Copyright by Stefan Koch <StefanKoch@gmx.org>, 2016
#
# ATTiny85 Makefile
# This file is part of TinyAvrMakefileProject
#
# omxAutomation is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# TinyAvrMakefileProject is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with TinyAvrMakefileProject. If not, see <http://www.gnu.org/licenses/>.
#
########################################################################################
#adapt the name to your needs
NAME = hello_cw_main
#-------------------DEVICE-----------------------------------------------------------
DEVICE = attiny85
COREFREQ = 8000000
#-------------------BINUTILS---------------------------------------------------------
CROSS_COMPILE = avr-
CROSS_CC = $(CROSS_COMPILE)gcc
CROSS_LD = $(CROSS_COMPILE)gcc
CROSS_OBJCOPY = $(CROSS_COMPILE)objcopy
CROSS_SIZE = $(CROSS_COMPILE)size
# HEXIFY requires the .o and .hex filename to be appended
HEXIFY = $(CROSS_OBJCOPY) -j .text -j .data -O ihex
#-------------------TOOLCHAIN_CONFIG-------------------------------------------------
CROSS_CFLAGS = -Wall -gdwarf-2 -Os -std=gnu99 -mmcu=$(DEVICE) -DF_CPU=$(COREFREQ)
CROSS_CFLAGS += -fno-inline-small-functions -ffunction-sections -fdata-sections
CROSS_CFLAGS += -Wl,--relax,--gc-sections -I.
CROSS_CFLAGS += -Wl,--undefined=_mmcu,--section-start=.mmcu=0x910000
CROSS_LDFLAGS = -g -mmcu=$(DEVICE)
#-------------------GENERIC_DEFS-----------------------------------------------------
SOURCES = $(wildcard *.c)
HEADERS = $(wildcard *.h)
OBJECTS = $(SOURCES:.c=.o)
#-------------------INTRO_RULES------------------------------------------------------
all: $(NAME).hex
$(NAME).hex: $(OBJECTS)
@echo [LD] link
@$(CROSS_CC) $(CROSS_CFLAGS) $(OBJECTS) -o $(NAME).elf
@$(CROSS_SIZE) $(NAME).elf | grep $(NAME).elf | awk '{print "[Si] Program_Size = "$$1" bytes"}'
@echo [HX] generate hex file
@$(HEXIFY) $(NAME).elf $(NAME).hex
#-------------------GENERIC_RULES----------------------------------------------------
%.o: %.c
@echo [CC] $@
@$(CROSS_CC) -c $(CROSS_CFLAGS) ${^} -o ${@}
#-------------------SPECIFIC_RULES---------------------------------------------------
prog: $(NAME).hex
@echo [PR] program flash
@avrdude -c usbasp -p t85 -e -U flash:w:$(NAME).hex
clean:
@echo [CL] clean
@rm -f *.o *.o *.hex *.elf
distclean: clean