summaryrefslogtreecommitdiff
path: root/Makefile
blob: 5dcd4f6b95484bd6ec914096888597d644136d57 (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
# -*- make -*-
# (C) 2016 by Eugeniy Mikhailov, <evgmik@gmail.com>

include ./local.mk

# this file is a bit complex since it tries to be general enough to use
# either luatool or nodemcu-uploader
# you have a choice
 
ifeq ($(UPLOAD_TOOL), nodemcu-uploader)
offline_upload_cmd = python $(NODEMCU-UPLOADER) --baud $(BAUD_RATE) --port $(PORT) --start_baud $(START_BAUD_RATE)
online_upload_cmd = $(offline_upload_cmd)
else
offline_upload_cmd = $(LUATOOL) -b $(BAUD_RATE) --port $(PORT)
online_upload_cmd = $(LUATOOL) --ip $(IP)
endif


# luatool support work via telnet
ifeq ($(UPLOAD_TYPE),online)
upload_cmd = $(online_upload_cmd)
term_cmd = echo not sure how to do online terminal
else
upload_cmd = $(offline_upload_cmd)
term_cmd = miniterm.py -b $(BAUD_RATE) --port $(PORT)
endif


UPLOAD_STAMPS = .upload_stamps

lua_files = $(wildcard *.lua)
httpserver_lua_files = $(wildcard nodemcu-httpserver/httpserver*.lua)
html_files = $(wildcard http/*)

lua_files_upload_stamps = $(lua_files:%=$(UPLOAD_STAMPS)/%.uploaded)
httpserver_files_upload_stamps = $(httpserver_lua_files:%=$(UPLOAD_STAMPS)/%.uploaded)
html_files_upload_stamps = $(html_files:%=$(UPLOAD_STAMPS)/%.uploaded)

upload: $(UPLOAD_STAMPS) $(html_files_upload_stamps) $(lua_files_upload_stamps) $(httpserver_files_upload_stamps)

$(UPLOAD_STAMPS):
	mkdir -p $(UPLOAD_STAMPS)
	mkdir -p $(UPLOAD_STAMPS)/http
	mkdir -p $(UPLOAD_STAMPS)/nodemcu-httpserver

$(lua_files_upload_stamps): $(UPLOAD_STAMPS)/%.uploaded : %
ifeq ($(UPLOAD_TOOL), nodemcu-uploader)
	($(upload_cmd) upload $(<)) && touch $@
else
	($(upload_cmd) --src $<) && touch $@
endif

$(httpserver_files_upload_stamps): $(UPLOAD_STAMPS)/%.uploaded : %
ifeq ($(UPLOAD_TOOL), nodemcu-uploader)
	($(upload_cmd) upload $(<):$(<:nodemcu-httpserver/%=%)) && touch $@
else
	($(upload_cmd) --src $< --dest $(<:nodemcu-httpserver/%=%)) && touch $@
endif


$(html_files_upload_stamps): $(UPLOAD_STAMPS)/%.uploaded : %
ifeq ($(UPLOAD_TOOL), nodemcu-uploader)
	($(upload_cmd) upload $(<)) && touch $@
else
	($(upload_cmd) --src $< --dest $<) && touch $@
endif


term:
	$(term_cmd)

clean:
	rm -rf $(UPLOAD_STAMPS)

.PHONY: upload clean term