tetris/Makefile

66 lines
2.4 KiB
Makefile

ARDUINO_DIR = /home/dan/projects/arduino-1.8.9
ARDUINO_PLATFORM_LIB_PATH = /home/dan/.arduino15/packages/esp32/hardware/esp32/1.0.2/libraries
USER_LIB_PATH = /home/dan/Arduino/libraries
ARDUINO = $(ARDUINO_DIR)/arduino
CTAGS_PATH = $(ARDUINO_DIR)/tools-builder/ctags/5.8-arduino11/ctags
# ctags command: append, flags unsort (as will be sorted after) and specify filename
# use ETAGS format
CTAGS_CMD = $(CTAGS_PATH) -auef
TAGS_FILE = TAGS
all:
$(ARDUINO) --verify tetris.ino
upload:
$(ARDUINO) --upload tetris.ino
# Local sources
LOCAL_C_SRCS ?= $(wildcard *.c)
LOCAL_CPP_SRCS ?= $(wildcard *.cpp)
LOCAL_CC_SRCS ?= $(wildcard *.cc)
LOCAL_PDE_SRCS ?= $(wildcard *.pde)
LOCAL_INO_SRCS ?= $(wildcard *.ino)
LOCAL_AS_SRCS ?= $(wildcard *.S)
LOCAL_SRCS = $(LOCAL_C_SRCS) $(LOCAL_CPP_SRCS) \
$(LOCAL_CC_SRCS) $(LOCAL_PDE_SRCS) \
$(LOCAL_INO_SRCS) $(LOCAL_AS_SRCS)
# Determine Arduino libs that are used
# first do platform-specific libraries
# then "core" libraries
# then sketchbook libraries and user-installed libraries
ifndef ARDUINO_LIBS
ARDUINO_LIBS_NAMES1 = $(filter $(notdir $(wildcard $(ARDUINO_PLATFORM_LIB_PATH)/*)), \
$(shell sed -ne 's/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p' $(LOCAL_SRCS)))
ARDUINO_LIBS += $(foreach lib,$(ARDUINO_LIBS_NAMES1),$(ARDUINO_PLATFORM_LIB_PATH)/$(lib))
ARDUINO_LIBS_NAMES2 = $(filter $(notdir $(wildcard $(ARDUINO_DIR)/libraries/*)), \
$(shell sed -ne 's/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p' $(LOCAL_SRCS)))
ARDUINO_LIBS += $(foreach lib,$(ARDUINO_LIBS_NAMES2),$(ARDUINO_DIR)/libraries/$(lib))
# ARDUINO_LIBS_NAMES = $(filter $(notdir $(wildcard $(ARDUINO_SKETCHBOOK)/libraries/*)), \
# $(shell sed -ne 's/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p' $(LOCAL_SRCS)))
# ARDUINO_LIBS += $(foreach lib,$(ARDUINO_LIBS_NAMES),$(ARDUINO_SKETCHBOOK)/libraries/$(lib))
ARDUINO_LIBS_NAMES3 = $(filter $(notdir $(wildcard $(USER_LIB_PATH)/*)), \
$(shell sed -ne 's/^ *\# *include *[<\"]\(.*\)\.h[>\"]/\1/p' $(LOCAL_SRCS)))
ARDUINO_LIBS += $(foreach lib,$(ARDUINO_LIBS_NAMES3),$(USER_LIB_PATH)/$(lib))
endif
.PHONY: tags
tags:
rm -f $(TAGS_FILE)
@echo "Generating tags for local sources: "
$(CTAGS_CMD) $(TAGS_FILE) --langmap=c++:+.ino.pde $(LOCAL_SRCS)
ifneq ($(words $(ARDUINO_LIBS)), 0)
@echo "Generating tags for project libraries: "
$(CTAGS_CMD) $(TAGS_FILE) -R $(ARDUINO_LIBS)
endif
#sort $(TAGS_FILE) -o $(TAGS_FILE)