-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
79 lines (63 loc) · 2.61 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
77
78
79
# Board serial port for upload
SERIAL_PORT ?= /dev/cu.usbserial-0001
BAUDRATE ?= 115200
# Hardware to target
#HARDWARE ?= HARDWARE_PROTO_ESP8266
#HARDWARE ?= HARDWARE_PROTO_ESP32
HARDWARE ?= HARDWARE_REV0
ifeq ($(HARDWARE), HARDWARE_PROTO_ESP8266)
MCU_TYPE ?= esp8266
else ifeq ($(HARDWARE), HARDWARE_PROTO_ESP32)
MCU_TYPE ?= esp32
else ifeq ($(HARDWARE), HARDWARE_REV0)
MCU_TYPE ?= esp32
endif
ifeq ($(MCU_TYPE), esp8266)
BOARD_TYPE ?= $(MCU_TYPE):$(MCU_TYPE):nodemcuv2
PACKAGE_URLS ?= "https://arduino.esp8266.com/stable/package_esp8266com_index.json"
BOARD_OPTIONS ?= :xtal=160
GIT_LIBRARIES ?= https://github.com/me-no-dev/ESPAsyncWebServer.git https://github.com/me-no-dev/ESPAsyncTCP
else ifeq ($(MCU_TYPE), esp32)
BOARD_TYPE ?= $(MCU_TYPE):$(MCU_TYPE):node32s
PACKAGE_URLS ?= https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
GIT_LIBRARIES ?= https://github.com/me-no-dev/ESPAsyncWebServer.git https://github.com/me-no-dev/AsyncTCP.git
BOARD_OPTIONS ?=
endif
LIBRARIES ?= ESP8266Audio # Add extra libraries in a space-separated list
PROJECT_BASE = fm-streamer
PROJECT ?= fm-streamer
# Tool paths / names
ARDUINO_CLI = arduino-cli
# Optional verbose compile/upload trigger
V ?= 0
VERBOSE=
# Build path -- used to store built binary and object files
BUILD_DIR=_build
SOURCE_PATH=$(PWD)/$(PROJECT_BASE)/
BUILD_PATH=$(SOURCE_PATH)$(BUILD_DIR)
ifneq ($(V), 0)
VERBOSE=-v
endif
.PHONY: all fm-streamer program clean
all: fm-streamer
config-tools:
$(ARDUINO_CLI) cache clean
$(ARDUINO_CLI) config init --additional-urls $(PACKAGE_URLS) --overwrite
$(ARDUINO_CLI) config set library.enable_unsafe_install true
$(ARDUINO_CLI) core update-index
$(ARDUINO_CLI) core install $(MCU_TYPE):$(MCU_TYPE)
$(ARDUINO_CLI) lib install $(LIBRARIES)
$(foreach lib, $(GIT_LIBRARIES), $(ARDUINO_CLI) lib install --git-url $(lib);)
fm-streamer:
$(ARDUINO_CLI) compile $(VERBOSE) --build-path=$(BUILD_PATH) --build-cache-path=$(BUILD_PATH) -b $(BOARD_TYPE)$(BOARD_OPTIONS) --build-property "compiler.cpp.extra_flags=-D$(HARDWARE)" $(PROJECT_BASE)/$(PROJECT)
program: all stop-serial
$(ARDUINO_CLI) upload $(VERBOSE) -p $(SERIAL_PORT) --fqbn $(BOARD_TYPE)$(BOARD_OPTIONS) --input-dir=$(BUILD_PATH)
stop-serial:
screen -ls | grep Detached | cut -d. -f1 | awk '{print $1}' | xargs kill
serial: stop-serial
screen $(SERIAL_PORT) $(BAUDRATE)
check:
clang-format $(SOURCE_PATH)*.ino $(SOURCE_PATH)*.cpp $(SOURCE_PATH)*.h -style=file -i
cppcheck --suppress=missingIncludeSystem --enable=all --std=c++11 --inline-suppr --language=c++ $(SOURCE_PATH)*.ino $(SOURCE_PATH)*.cpp $(SOURCE_PATH)*.h
clean:
@rm -rf $(BUILD_PATH)