summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile97
1 files changed, 97 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..669e9cc
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,97 @@
+.POSIX:
+NAME = webapp
+PREFIX = /usr
+SRCDIR = $(PREFIX)/src/$(NAME)
+SHAREDIR = $(PREFIX)/share
+# DOCDIR? JavaScript goes to DOCDIR? Really?
+DOCDIR = $(SHAREDIR)/doc/$(NAME)
+
+
+
+.SUFFIXES:
+.SUFFIXES: .js
+
+
+all:
+include deps.mk
+
+
+
+static-contents = \
+ src/content/papo.js \
+ src/content/style.css \
+ src/content/index.html \
+
+contents = \
+ src/content/service-worker.js \
+ $(img.svg) \
+
+
+derived-assets = \
+ src/content/papo.exported.js \
+ src/content/sw.exported.js \
+ src/content/service-worker.js \
+
+
+
+all: $(derived-assets)
+
+
+## The use of static `import` statements inside service workers
+## isn't supported. So in order to have tests for the code in
+## it, a "main()" function is included in the generated file
+## so that is can be ran as a standalone file.
+src/content/service-worker.js: src/content/sw.js src/sw-main.js Makefile
+ cat src/content/sw.js src/sw-main.js > $@
+
+src/content/papo.exported.js src/content/sw.exported.js: \
+ Makefile src/exported.sh
+src/content/papo.exported.js: src/content/papo.js
+src/content/sw.exported.js: src/content/sw.js
+
+src/content/papo.exported.js src/content/sw.exported.js:
+ sh src/exported.sh $(@D)/`basename $@ .exported.js`.js > $@
+
+
+
+.SUFFIXES: .js-check
+tests/papo.js-check: src/content/papo.exported.js
+tests/sw.js-check: src/content/sw.exported.js
+tests/papo.js-check tests/sw.js-check:
+ node tests/node-driver.js $*.js
+
+
+check-unit: tests/papo.js-check tests/sw.js-check
+
+check-integration:
+
+check: check-unit check-integration
+
+
+clean:
+ rm -rf $(derived-assets) $(side-assets)
+
+install: all
+ mkdir -p \
+ '$(DESTDIR)$(SRCDIR)' \
+
+ for f in $(contents) $(static-contents); do \
+ dir='$(DESTDIR)$(DOCDIR)'/"`dirname "$${f#src/content/}"`"; \
+ mkdir -p "$$dir"; \
+ cp -P "$$f" "$$dir"; \
+ done
+
+uninstall:
+ rm -rf \
+ '$(DESTDIR)$(SRCDIR)' \
+ '$(DESTDIR)$(DOCDIR)' \
+
+
+
+PORT = 3334
+## Run file server for local static files
+run:
+ serve -n -p $(PORT) -d '$(DESTDIR)$(DOCDIR)'
+
+
+ALWAYS: