aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorTeddy Wing2021-03-21 16:48:32 +0100
committerTeddy Wing2021-03-21 17:45:12 +0100
commit34bcab5f0aacee38d55d11821073c878ca51e923 (patch)
treecd0530a6958abc94f31474c0a69a8f11cd6bb0a9 /Makefile
parentdb45d89fc0acf1999c2b996397d2872159c0b74c (diff)
downloadPeniquitous-34bcab5f0aacee38d55d11821073c878ca51e923.tar.bz2
Makefile: Add build rules to build dependencies into main.js
Instead of copy-pasting the code from the files directly into main.js, do it in the build recipes.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile57
1 files changed, 48 insertions, 9 deletions
diff --git a/Makefile b/Makefile
index 4bc90c8..c557f76 100644
--- a/Makefile
+++ b/Makefile
@@ -16,17 +16,56 @@
BROWSERIFY := ./node_modules/.bin/browserify
+IMPORTS := peniquitous.js lib/mousetrap/tests/libs/key-event.js
+IMPORTS_BASENAME := $(notdir $(IMPORTS))
+
all: peniquitous.user.js
-peniquitous.user.js: peniquitous.js lib/mousetrap/tests/libs/key-event.js userscript-header.txt
- sed -e '1d' -e '$$d' \
- lib/mousetrap/tests/libs/key-event.js \
- > key-event.js
+# peniquitous.user.js: peniquitous.js lib/mousetrap/tests/libs/key-event.js userscript-header.txt
+# sed -e '1d' -e '$$d' \
+# lib/mousetrap/tests/libs/key-event.js \
+# > key-event.js
+#
+# cat \
+# userscript-header.txt \
+# key-event.js \
+# peniquitous.js \
+# > $@
+#
+# rm key-event.js
+
+# build/?: $(IMPORTS)
+# sed -e '/^(function/d' -e '$$d' file
+#
+# build/main.js: build/*.js
+
+build:
+ mkdir -p $@
+
+build/key-event.js: lib/mousetrap/tests/libs/key-event.js | build
+ sed -e '/^(function/d' -e '$$d' $< > $@
+
+build/peniquitous.js: peniquitous.js | build
+ sed -e '/^(function/d' -e '$$d' $< > $@
- cat \
- userscript-header.txt \
- key-event.js \
- peniquitous.js \
+# TODO: Swap main file names
+main.js.in: $(addprefix build/,$(IMPORTS_BASENAME))
+ sed \
+ -e '/\$$KEY_EVENT/r build/key-event.js' \
+ -e '/\$$KEY_EVENT/d' \
+ -e '/\$$PENIQUITOUS/r build/peniquitous.js' \
+ -e '/\$$PENIQUITOUS/d' \
+ main.js \
> $@
- rm key-event.js
+peniquitous.user.js: main.js peniquitous.js userscript-header.txt
+ $(BROWSERIFY) \
+ --outfile $@ \
+ $<
+
+ cat userscript-header.txt $@ > "$@.tmp"
+ mv "$@.tmp" $@
+
+.PHONY: clean
+clean:
+ rm -rf build