-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
75 lines (49 loc) · 1.69 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
BIN_DIR = /tmp/arduino_build
ELF = $(BIN_DIR)/*elf
GDB_SRV = JLinkGDBServer
ARM_GDB = arm-none-eabi-gdb
ARG = -if swd -speed 1000 -device NRF52832_xxAA
TERM = gnome-terminal --
BOARD = sandeepmistry:nRF5:Generic_nRF52832:softdevice=s132
.PHONY: all upload compile pref_list debug startgdbserver local_startgdbserver \
stopgdbserver clean clean_cache c l d
all: upload
# TODO: make install (upload could depend on it too) examples:
#
# Install AVR board support, 1.6.2
# arduino --install-boards "arduino:avr:1.6.2"
#
# Install Bridge and Servo libraries
# arduino --install-library "Bridge:1.0.0,Servo:1.2.0"
# Documentation:
# https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc
upload: *.ino *.cpp *.h stopgdbserver clean_cache
arduino --pref build.path=$(BIN_DIR) --preserve-temp-files --board $(BOARD) \
--upload --verbose-upload --useprogrammer --verbose *.ino
# optional
compile: *.ino *.cpp *.h clean_cache
arduino --pref build.path=$(BIN_DIR) --preserve-temp-files --board $(BOARD) \
--verify --verbose *ino
# optional
pref_list:
arduino --get-pref
# TODO: use precise ELF name
debug: $(ELF) startgdbserver
$(ARM_GDB) $(ELF)
startgdbserver:
@pidof $(GDB_SRV) > /dev/null || { $(TERM) $(GDB_SRV) $(ARG) & sleep 1 ; }
#optional
local_startgdbserver:
@pidof $(GDB_SRV) > /dev/null || $(GDB_SRV) $(ARG)
stopgdbserver:
@pidof $(ARM_GDB) > /dev/null && killall $(ARM_GDB) || true
@pidof $(GDB_SRV) > /dev/null && killall $(GDB_SRV) || true
clean_cache:
rm -rf /tmp/arduino_cache*
clean: clean_cache
rm -rf $(BIN_DIR)
###############################################################################
# Lazy aliases:
c: compile
l: local_startgdbserver
d: debug