]>
Commit | Line | Data |
---|---|---|
d8c46ff7 GJ |
1 | MAKE="make" |
2 | INSTALL="install" | |
3 | TAR="tar" | |
4 | GREP="grep" | |
5 | NODE="node" | |
6 | NPM="npm" | |
7 | DESTDIR="./dist" | |
8 | PKG_VERSION := $( $(GREP) -Po '(?<="version": ")[^"]*' ) | |
9 | TMPDIR := $(shell mktemp -d) | |
fa3a6fd7 | 10 | HOSTS_FILE = $(HOSTS_FILE) |
d8c46ff7 GJ |
11 | # default modules |
12 | MODULES="php" | |
13 | ||
14 | all: builddirs npm_dependencies swig htmlmin min-css min-js copy-img submodules | |
15 | ||
16 | swig: | |
17 | $(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/faq.swig > $(CURDIR)/build/faq.html | |
18 | $(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/index.swig > $(CURDIR)/build/index.html | |
19 | $(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/tools.swig > $(CURDIR)/build/tools.html | |
20 | ||
21 | htmlmin: | |
22 | $(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/index.html -o $(CURDIR)/build/index.html | |
23 | $(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/faq.html -o $(CURDIR)/build/faq.html | |
24 | $(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/tools.html -o $(CURDIR)/build/tools.html | |
25 | ||
26 | installdirs: | |
27 | mkdir -p $(DESTDIR)/ $(DESTDIR)/img | |
b43ff07c | 28 | mkdir -p $(DESTDIR)/ $(DESTDIR)/img/grills |
d8c46ff7 | 29 | ifneq (,$(findstring php,$(MODULES))) |
044a28cd | 30 | mkdir -p $(DESTDIR)/includes |
d8c46ff7 GJ |
31 | endif |
32 | ifneq (,$(findstring moe,$(MODULES))) | |
33 | mkdir -p $(DESTDIR)/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates} | |
34 | endif | |
35 | ||
36 | min-css: | |
1cbe6100 | 37 | $(NODE) $(CURDIR)/node_modules/.bin/cleancss $(CURDIR)/static/css/uguu.css --output $(CURDIR)/build/uguu.min.css |
d8c46ff7 GJ |
38 | |
39 | min-js: | |
40 | echo "// @source https://github.com/nokonoko/uguu/tree/master/static/js" > $(CURDIR)/build/uguu.min.js | |
41 | echo "// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat" >> $(CURDIR)/build/uguu.min.js | |
cef49852 | 42 | $(NODE) $(CURDIR)/node_modules/.bin/uglifyjs ./static/js/app.js >> $(CURDIR)/build/uguu.min.js |
d8c46ff7 GJ |
43 | echo "// @license-end" >> $(CURDIR)/build/uguu.min.js |
44 | ||
45 | copy-img: | |
46 | cp -v $(CURDIR)/static/img/*.png $(CURDIR)/build/img/ | |
b43ff07c | 47 | cp -R $(CURDIR)/static/img/grills $(CURDIR)/build/img/ |
d8c46ff7 GJ |
48 | |
49 | copy-php: | |
50 | ifneq ($(wildcard $(CURDIR)/static/php/.),) | |
51 | cp -rv $(CURDIR)/static/php/* $(CURDIR)/build/ | |
52 | else | |
53 | $(error The php submodule was not found) | |
54 | endif | |
55 | ||
56 | copy-moe: | |
57 | ifneq ($(wildcard $(CURDIR)/moe/.),) | |
58 | cp -rv $(CURDIR)/moe $(CURDIR)/build/ | |
59 | else | |
60 | $(error The moe submodule was not found) | |
61 | endif | |
62 | ||
63 | install: installdirs | |
64 | cp -rv $(CURDIR)/build/* $(DESTDIR)/ | |
65 | ||
fa3a6fd7 | 66 | submodule-update: |
67 | git submodule update | |
68 | ||
69 | deploy: | |
70 | ansible-playbook -i $(HOSTS_FILE) ansible/site.yml | |
71 | ||
d8c46ff7 GJ |
72 | dist: |
73 | DESTDIR=$(TMPDIR)/uguu-$(PKGVERSION) | |
74 | export DESTDIR | |
75 | install | |
76 | $(TAR) cJf uguu-$(PKG_VERSION).tar.xz $(DESTDIR) | |
77 | rm -rf $(TMPDIR) | |
78 | ||
79 | clean: | |
80 | rm -rvf $(CURDIR)/node_modules | |
81 | rm -rvf $(CURDIR)/build | |
82 | ||
83 | uninstall: | |
84 | rm -rvf $(DESTDIR)/ | |
85 | ||
86 | npm_dependencies: | |
87 | $(NPM) install | |
88 | ||
89 | builddirs: | |
90 | mkdir -p $(CURDIR)/build $(CURDIR)/build/img | |
91 | ifneq (,$(findstring php,$(MODULES))) | |
92 | mkdir -p $(CURDIR)/build/classes $(CURDIR)/build/includes | |
93 | endif | |
94 | ifneq (,$(findstring moe,$(MODULES))) | |
95 | mkdir -p $(CURDIR)/build/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates} | |
96 | endif | |
97 | ||
98 | submodules: | |
99 | $(info The following modules will be enabled: $(MODULES)) | |
100 | ifneq (,$(findstring php,$(MODULES))) | |
101 | $(MAKE) copy-php | |
102 | endif | |
103 | ifneq (,$(findstring moe,$(MODULES))) | |
104 | $(MAKE) copy-moe | |
105 | endif |