forked from marcoskirsch/nodemcu-httpserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (61 loc) · 2.17 KB
/
Copy pathMakefile
File metadata and controls
78 lines (61 loc) · 2.17 KB
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
######################################################################
# Makefile user configuration
######################################################################
# Path to nodemcu-uploader (https://github.com/kmpm/nodemcu-uploader)
NODEMCU_UPLOADER?=python ../nodemcu-uploader/nodemcu-uploader.py
# Path to nodemcu-tool (https://github.com/AndiDittrich/NodeMCU-Tool)
NODEMCU_TOOL?=../nodemcu-tool/node_modules/nodemcu-tool/bin/nodemcu-tool.js
USE_NODEMCU_TOOL?=
# Serial port
PORT?=/dev/cu.SLAB_USBtoUART
SPEED?=115200
ifdef USE_NODEMCU_TOOL
define _upload
@$(NODEMCU_TOOL) -b $(SPEED) --baud $(SPEED) -p $(PORT) upload --keeppath $^
endef
else
define _upload
@$(NODEMCU_UPLOADER) -b $(SPEED) --start_baud $(SPEED) -p $(PORT) upload $^
endef
endif
######################################################################
LFS_IMAGE ?= lfs.img
HTTP_FILES := $(wildcard http/*)
WIFI_CONFIG := $(wildcard *conf*.lua)
SERVER_FILES := $(filter-out $(WIFI_CONFIG), $(wildcard srv/*.lua) $(wildcard *.lua))
LFS_FILES := $(LFS_IMAGE) $(filter-out $(WIFI_CONFIG), $(wildcard *.lua))
FILE ?=
# Print usage
usage:
@echo "make upload FILE:=<file> to upload a specific file (i.e make upload FILE:=init.lua)"
@echo "make upload_http to upload files to be served"
@echo "make upload_server to upload the server code and init.lua"
@echo "make upload_all to upload all"
# Upload one files only
upload: $(FILE)
$(_upload)
# Upload HTTP files only
upload_http: $(HTTP_FILES)
$(_upload)
# Upload httpserver lua files
upload_server: $(SERVER_FILES)
$(_upload)
# Upload wifi configuration
upload_wifi_config: $(WIFI_CONFIG)
$(_upload)
# Upload lfs image
upload_lfs: $(LFS_FILES)
$(_upload)
# Throw error if lfs file not found
$(LFS_IMAGE):
$(error File $(LFS_IMAGE) not found)
# Upload all non-lfs files
upload_all: $(HTTP_FILES) $(SERVER_FILES) $(WIFI_CONFIG)
$(_upload)
# Upload all lfs files
upload_all_lfs: $(HTTP_FILES) $(LFS_FILES) $(WIFI_CONFIG)
$(_upload)
.ENTRY: usage
MAKEFLAGS: --always-make
.PHONY: usage upload_http upload_server upload_wifi_config \
upload_lfs upload_all upload_all_lfs