-
Notifications
You must be signed in to change notification settings - Fork 26
/
Makefile
106 lines (79 loc) · 2.95 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))
NODE_MODS := $(DIR)/node_modules
PUG := $(NODE_MODS)/.bin/pug
STYLUS := $(NODE_MODS)/.bin/stylus
TARGET_DIR := build/http
HTML := index
HTML := $(patsubst %,$(TARGET_DIR)/%.html,$(HTML))
RESOURCES := $(shell find src/resources -type f)
RESOURCES := $(patsubst src/resources/%,$(TARGET_DIR)/%,$(RESOURCES))
TEMPLS := $(wildcard src/pug/templates/*.pug)
AVR_FIRMWARE := src/avr/bbctrl-avr-firmware.hex
GPLAN_MOD := rpi-share/camotics/gplan.so
GPLAN_TARGET := src/py/camotics/gplan.so
GPLAN_IMG := gplan-dev.img
RSYNC_EXCLUDE := \*.pyc __pycache__ \*.egg-info \\\#* \*~ .\\\#\*
RSYNC_EXCLUDE := $(patsubst %,--exclude %,$(RSYNC_EXCLUDE))
RSYNC_OPTS := $(RSYNC_EXCLUDE) -rv --no-g --delete --force
VERSION := $(shell sed -n 's/^.*"version": "\([^"]*\)",.*$$/\1/p' package.json)
PKG_NAME := bbctrl-$(VERSION)
SUBPROJECTS := avr boot pwr jig
ifndef HOST
HOST=onefinity.local
endif
ifndef PASSWORD
PASSWORD=onefinity
endif
all: $(HTML) $(RESOURCES)
@for SUB in $(SUBPROJECTS); do $(MAKE) -C src/$$SUB; done
pkg: all $(AVR_FIRMWARE) bbserial
./setup.py sdist
bbserial:
$(MAKE) -C src/bbserial
gplan: $(GPLAN_TARGET)
$(GPLAN_TARGET): $(GPLAN_MOD)
cp $< $@
$(GPLAN_MOD): $(GPLAN_IMG)
./scripts/gplan-init-build.sh
cp ./scripts/gplan-build.sh rpi-share/
chmod +x rpi-share/gplan-build.sh
sudo ./scripts/rpi-chroot.sh $(GPLAN_IMG) /mnt/host/gplan-build.sh
$(GPLAN_IMG):
./scripts/gplan-init-build.sh
.PHONY: $(AVR_FIRMWARE)
$(AVR_FIRMWARE):
$(MAKE) -C src/avr
update: pkg
http_proxy= curl -i -X PUT -H "Content-Type: multipart/form-data" \
-F "firmware=@dist/$(PKG_NAME).tar.bz2" -F "password=$(PASSWORD)" \
http://$(HOST)/api/firmware/update
@-tput sgr0 && echo # Fix terminal output
build/templates.pug: $(TEMPLS)
mkdir -p build
cat $(TEMPLS) >$@
node_modules: package.json
npm install && touch node_modules
$(TARGET_DIR)/%: src/resources/%
install -D $< $@
src/svelte-components/dist/%:
cd src/svelte-components && rm -rf dist && npm run build
$(TARGET_DIR)/index.html: build/templates.pug
$(TARGET_DIR)/index.html: $(wildcard src/static/js/*)
$(TARGET_DIR)/index.html: $(wildcard src/static/css/*)
$(TARGET_DIR)/index.html: $(wildcard src/pug/templates/*)
$(TARGET_DIR)/index.html: $(wildcard src/js/*)
$(TARGET_DIR)/index.html: $(wildcard src/stylus/*)
$(TARGET_DIR)/index.html: src/resources/config-template.json
$(TARGET_DIR)/index.html: $(wildcard src/resources/onefinity*defaults.json)
$(TARGET_DIR)/index.html: $(wildcard src/svelte-components/dist/*)
FORCE:
$(TARGET_DIR)/%.html: src/pug/%.pug node_modules FORCE
cd src/svelte-components && rm -rf dist && npm run build
@mkdir -p $(TARGET_DIR)/svelte-components
cp src/svelte-components/dist/* $(TARGET_DIR)/svelte-components/
@mkdir -p $(TARGET_DIR)
$(PUG) -O pug-opts.js -P $< -o $(TARGET_DIR) || (rm -f $@; exit 1)
clean:
rm -rf rpi-share
git clean -fxd
.PHONY: all install clean tidy pkg gplan lint pylint jshint bbserial