summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-10-23 05:20:06 -0300
committerEuAndreh <eu@euandre.org>2024-10-27 08:01:49 -0300
commit5826fb5037983bdbe04b8d3b364167e8516ab7db (patch)
treedab7a5eeadbc7ffc755dd8b3f5c603ebff3e643a /Makefile
parentWIP service worker strategies (diff)
downloadchat.papo.im-5826fb5037983bdbe04b8d3b364167e8516ab7db.tar.gz
chat.papo.im-5826fb5037983bdbe04b8d3b364167e8516ab7db.tar.xz
WIP: Init work on HTML
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile83
1 files changed, 68 insertions, 15 deletions
diff --git a/Makefile b/Makefile
index 669e9cc..f1e01eb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,24 @@
.POSIX:
-NAME = webapp
+DATE = 1970-01-01
+VERSION = 0.1.0
+NAME = chat.papo.im
+NAME_UC = $(NAME)
+LANGUAGES = en
+## Installation prefix. Defaults to "/usr".
PREFIX = /usr
+BINDIR = $(PREFIX)/bin
+LIBDIR = $(PREFIX)/lib
+INCLUDEDIR = $(PREFIX)/include
SRCDIR = $(PREFIX)/src/$(NAME)
SHAREDIR = $(PREFIX)/share
-# DOCDIR? JavaScript goes to DOCDIR? Really?
+LOCALEDIR = $(SHAREDIR)/locale
+MANDIR = $(SHAREDIR)/man
DOCDIR = $(SHAREDIR)/doc/$(NAME)
+HTMLDIR = $(SHAREDIR)/html/$(NAME)
+EXEC = ./
+## Where to store the installation. Empty by default.
+DESTDIR =
+LDLIBS =
@@ -12,37 +26,51 @@ DOCDIR = $(SHAREDIR)/doc/$(NAME)
.SUFFIXES: .js
+
all:
include deps.mk
-
-static-contents = \
+sources = \
src/content/papo.js \
src/content/style.css \
src/content/index.html \
+ src/content/sw.js \
+ $(img.svg) \
contents = \
+ src/content/papo.js \
+ src/content/style.css \
+ src/content/index.html \
src/content/service-worker.js \
$(img.svg) \
derived-assets = \
+ src/sw-pre.js \
src/content/papo.exported.js \
src/content/sw.exported.js \
src/content/service-worker.js \
+side-assets = \
+
+## Default target. Builds all artifacts required for testing
+## and installation.
all: $(derived-assets)
+src/sw-pre.js: Makefile deps.mk
+ printf 'const IMG_PATHS = [\n' > $@
+ printf '\t"%s",\n' $(img.svg) >> $@
+ printf '];\n\n' >> $@
## 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/service-worker.js: src/sw-pre.js src/content/sw.js src/sw-main.js
+ tail -n+2 src/content/sw.js | cat src/sw-pre.js - src/sw-main.js > $@
src/content/papo.exported.js src/content/sw.exported.js: \
Makefile src/exported.sh
@@ -60,38 +88,63 @@ tests/sw.js-check: src/content/sw.exported.js
tests/papo.js-check tests/sw.js-check:
node tests/node-driver.js $*.js
+src/content/service-worker.js-check: src/content/service-worker.js
+ test "`grep -c '^const IMG_PATHS ' $*.js`" = 1
check-unit: tests/papo.js-check tests/sw.js-check
+check-unit: src/content/service-worker.js-check
+
+
+integration-tests = \
-check-integration:
+.PRECIOUS: $(integration-tests)
+$(integration-tests): ALWAYS
+ sh $@
+check-integration: $(integration-tests)
+
+
+## Run all tests. Each test suite is isolated, so that a parallel
+## build can run tests at the same time. The required artifacts
+## are created if missing.
check: check-unit check-integration
+
+## Remove *all* derived artifacts produced during the build.
+## A dedicated test asserts that this is always true.
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/}"`"; \
+## Installs into $(DESTDIR)$(PREFIX). Its dependency target
+## ensures that all installable artifacts are crafted beforehand.
+install: all
+ for f in $(contents); do \
+ dir='$(DESTDIR)$(HTMLDIR)'/"`dirname "$${f#src/content/}"`"; \
+ mkdir -p "$$dir"; \
+ cp -P "$$f" "$$dir"; \
+ done
+ for f in $(sources); do \
+ dir='$(DESTDIR)$(SRCDIR)'/"`dirname "$${f#src/content/}"`"; \
mkdir -p "$$dir"; \
cp -P "$$f" "$$dir"; \
done
+## Uninstalls from $(DESTDIR)$(PREFIX). This is a perfect mirror
+## of the "install" target, and removes *all* that was installed.
+## A dedicated test asserts that this is always true.
uninstall:
rm -rf \
'$(DESTDIR)$(SRCDIR)' \
- '$(DESTDIR)$(DOCDIR)' \
+ '$(DESTDIR)$(HTMLDIR)' \
PORT = 3334
-## Run file server for local static files
+## Run file server for local static files.
run:
- serve -n -p $(PORT) -d '$(DESTDIR)$(DOCDIR)'
+ serve -n -p $(PORT) -d '$(DESTDIR)$(HTMLDIR)'
ALWAYS: