# -*- make -*- # (C) 2016 by Eugeniy Mikhailov, TOPDIR=. 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) version.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) version $(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 GIT_VERSION:="$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1), branch $(shell [ -f $(TOPDIR)/.git/HEAD ] && sed 's/ref: refs\/heads\/\(.*\)/\\\\\\"\1\\\\\\"/g' $(TOPDIR)/.git/HEAD || echo 'unknown'))" VERSION:=$(shell git describe --tags --abbrev=0) version: version.lua version.lua: version.template $(lua_files%version.lua%) sed s/__VERSION__/{$(GIT_VERSION)}/ < $< > $@ term: $(term_cmd) clean: rm -rf $(UPLOAD_STAMPS) .PHONY: upload clean term