summaryrefslogtreecommitdiff
path: root/Makefile
blob: 0b0359497eff52a05cf67385d24cf34660e30e72 (plain)
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
# Arduino specs
ARDUINO_VERSION = 1.8.4
ARDUINO_VERSION_SHORT = $(shell sed "s/\.//g" <<< $(ARDUINO_VERSION))
BOARD_TAG = leonardo
ARCHITECTURE  = avr
ARDUINO_ARCH_FLAG = -DARDUINO_ARCH_AVR
ARDMK_VENDOR = arduino
MONITOR_BAUDRATE = 9600
OPTIMIZATION_LEVEL=s
DEBUG_FLAGS = -O0 -g
MCU_FLAG_NAME = mmcu

# Flags
LOG_MONITOR = 0

# Paths
MONITOR_LOG_FILE = monitor.log
ARDUINO_DIR = $(HOME).arduino15/packages/arduino
ARDMK_DIR = make-scripts
AVRDUDE_CONF = /etc/avrdude.conf
ARDUINO_VAR_PATH = $(ARDUINO_DIR)/hardware/$(ARCHITECTURE)/$(ARDUINO_VERSION)/variants
BOARDS_TXT  = $(ARDUINO_DIR)/hardware/$(ARCHITECTURE)/$(ARDUINO_VERSION)/boards.txt
ARDUINO_LIB_PATH = $(ARDUINO_DIR)/libraries
TOOLS_PATH = $(ARDUINO_DIR)/tools/avr-gcc/$(shell /bin/ls --color=never -1 $(ARDUINO_DIR)/tools/avr-gcc/ | sort -r | xargs | awk '{print $$1}')/bin
PROJ_LIBS_PATH = libraries
BOOTLOADER_PARENT = $(ARDUINO_DIR)/hardware/$(ARCHITECTURE)/$(ARDUINO_VERSION)/bootloaders
BUNDLED_AVR_TOOLS_DIR := $(call dir_if_exists,$(ARDUINO_DIR)/hardware/tools/avr)
ARDUINO_PLATFORM_LIB_PATH = $(ARDUINO_DIR)/hardware/$(ARCHITECTURE)/$(ARDUINO_VERSION)/libraries
PRE_BUILD_HOOK = pre-build-hook.sh
OBJDIR = build
LOCAL_SRCS  ?= $(wildcard src/*.cpp)
LOCAL_OBJ_FILES = $(LOCAL_SRCS:.cpp=.cpp.o)
LOCAL_OBJS      = $(patsubst %,$(OBJDIR)/%,$(LOCAL_OBJ_FILES))
ARDUINO_HEADER=Arduino.h
TAGS_FILE = tags
ARD_RESET_ARDUINO_PATH = tools/reset_leonardo.py

# Libraries
ARDUINO_LIBS = Wire

# Tools
TOOL_PREFIX = avr
CC_NAME := $(TOOL_PREFIX)-gcc
CXX_NAME := $(TOOL_PREFIX)-g++
AS_NAME := $(TOOL_PREFIX)-as
OBJCOPY_NAME := $(TOOL_PREFIX)-objcopy
OBJDUMP_NAME := $(TOOL_PREFIX)-objdump
AR_NAME := $(TOOL_PREFIX)-ar
SIZE_NAME := $(TOOL_PREFIX)-size
NM_NAME := $(TOOL_PREFIX)-nm

CC      = $(TOOLS_PATH)/$(CC_NAME)
CXX     = $(TOOLS_PATH)/$(CXX_NAME)
AS      = $(TOOLS_PATH)/$(AS_NAME)
OBJCOPY = $(TOOLS_PATH)/$(OBJCOPY_NAME)
OBJDUMP = $(TOOLS_PATH)/$(OBJDUMP_NAME)
AR      = $(TOOLS_PATH)/$(AR_NAME)
SIZE    = $(TOOLS_PATH)/$(SIZE_NAME)
NM      = $(TOOLS_PATH)/$(NM_NAME)

REMOVE  = rm -rf
MV      = mv -f
CAT     = cat
ECHO    = printf
MKDIR   = mkdir -p

MONITOR_CMD = screen

CTAGS_EXEC = ctags

# Target
space :=
space +=
TARGET = $(notdir $(subst $(space),_,$(CURDIR)))

include $(ARDMK_DIR)/Arduino.mk