-
Notifications
You must be signed in to change notification settings - Fork 166
/
Makefile
70 lines (54 loc) · 2.12 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
######################################################################
# Makefile user configuration
######################################################################
# Path to nodemcu-uploader (https://github.com/kmpm/nodemcu-uploader)
NODEMCU-UPLOADER?=python ../nodemcu-uploader/nodemcu-uploader.py
# Path to LUA cross compiler (part of the nodemcu firmware; only needed to compile the LFS image yourself)
LUACC?=../nodemcu-firmware/luac.cross
# Serial port
PORT?=$(shell ls /dev/cu.SLAB_USBtoUART /dev/ttyUSB* 2>/dev/null|head -n1)
SPEED?=115200
define _upload
@$(NODEMCU-UPLOADER) -b $(SPEED) --start_baud $(SPEED) -p $(PORT) upload $^
endef
######################################################################
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"
@echo "make upload_lfs to upload lfs based server code"
@echo "make upload_all_lfs to upload all (LFS based)"
# Upload one file 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)
$(LFS_IMAGE):
$(LUACC) -f -o $(LFS_IMAGE) srv/*.lua
# 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
.PHONY: usage upload_http upload_server upload_wifi_config \
upload_lfs upload_all upload_all_lfs