This repository has been archived by the owner on Jan 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
96 lines (73 loc) · 2.72 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
VERSION ?= $(shell cat .version)
CLEAN_FILES := chromium firefox dist dist-webstore
CHROME := $(shell which chromium 2>/dev/null || which chromium-browser 2>/dev/null || which chrome 2>/dev/null || which google-chrome 2>/dev/null || which google-chrome-stable 2>/dev/null)
#######################
# For local development
.PHONY: all
all: extension chromium firefox
.PHONY: extension
extension:
$(MAKE) -C src
EXTENSION_FILES := \
src/*.css \
src/*.png \
src/*.svg \
src/fonts/* \
src/popup/*.html \
src/popup/*.svg
EXTENSION_FILES := \
$(wildcard $(EXTENSION_FILES)) \
src/css/popup.dist.css \
src/js/background.dist.js \
src/js/popup.dist.js \
src/js/inject.dist.js
CHROMIUM_FILES := $(patsubst src/%,chromium/%, $(EXTENSION_FILES))
FIREFOX_FILES := $(patsubst src/%,firefox/%, $(EXTENSION_FILES))
.PHONY: chromium
chromium: extension $(CHROMIUM_FILES) chromium/manifest.json
$(CHROMIUM_FILES) : chromium/% : src/%
[ -d $(dir $@) ] || mkdir -p $(dir $@)
cp $< $@
chromium/manifest.json : src/manifest-chromium.json
[ -d $(dir $@) ] || mkdir -p $(dir $@)
cp $< $@
.PHONY: firefox
firefox: extension $(FIREFOX_FILES) firefox/manifest.json
$(FIREFOX_FILES) : firefox/% : src/%
[ -d $(dir $@) ] || mkdir -p $(dir $@)
cp $< $@
firefox/manifest.json : src/manifest-firefox.json
[ -d $(dir $@) ] || mkdir -p $(dir $@)
cp $< $@
#######################
# For official releases
.PHONY: clean
clean:
rm -rf $(CLEAN_FILES)
$(MAKE) -C src clean
.PHONY: crx-webstore
crx-webstore:
"$(CHROME)" --disable-gpu --pack-extension=./chromium --pack-extension-key=webstore.pem
mv chromium.crx browserpass-otp-webstore.crx
.PHONY: crx-github
crx-github:
"$(CHROME)" --disable-gpu --pack-extension=./chromium --pack-extension-key=github.pem
mv chromium.crx browserpass-otp-github.crx
.PHONY: dist
dist: clean extension chromium firefox crx-webstore crx-github
mkdir -p dist
git archive -o dist/browserpass-otp-$(VERSION).tar.gz --format tar.gz --prefix=browserpass-otp-$(VERSION)/ $(VERSION)
(cd chromium && zip -r ../dist/browserpass-otp-chromium-$(VERSION).zip *)
(cd firefox && zip -r ../dist/browserpass-otp-firefox-$(VERSION).zip *)
mv browserpass-otp-webstore.crx dist/browserpass-otp-webstore-$(VERSION).crx
mv browserpass-otp-github.crx dist/browserpass-otp-github-$(VERSION).crx
for file in dist/*; do \
gpg --detach-sign --armor "$$file"; \
done
mkdir -p dist-webstore
cp dist/browserpass-otp-firefox-$(VERSION).zip dist-webstore/firefox-$(VERSION).zip
mv dist/browserpass-otp-$(VERSION).tar.gz dist-webstore/firefox-$(VERSION)-src.tar.gz
cp -a chromium dist-webstore/
sed -i '/"key"/d' dist-webstore/chromium/manifest.json
(cd dist-webstore/chromium && zip -r ../chrome-$(VERSION).zip *)
rm -rf dist-webstore/chromium