forked from marcoskirsch/nodemcu-httpserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
66 lines (51 loc) · 1.84 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
######################################################################
# Makefile user configuration
######################################################################
# Path to nodemcu-uploader (https://github.com/kmpm/nodemcu-uploader)
NODEMCU-UPLOADER?=python ../nodemcu-uploader/nodemcu-uploader.py
# Serial port
PORT?=/dev/cu.SLAB_USBtoUART
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"
# 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
.PHONY: usage upload_http upload_server upload_wifi_config \
upload_lfs upload_all upload_all_lfs