summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-12-21 16:13:01 +0100
committerHampusM <hampus@hampusmat.com>2021-12-21 16:13:01 +0100
commite3d42145644ead8706c66acfd5b05cab492b544e (patch)
tree098711abc3807ff15aec3388bf9d501144737949 /Makefile
parent72ab3d315269950d59e2f7307ae42db577423d10 (diff)
build: refactor build scripts
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile63
1 files changed, 63 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 65fcacf..5b20494 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,73 @@
+# 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
+
+
+# Paths
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 GY521
+# 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