]> jfr.im git - uguu.git/blame - Makefile
Add make target to exec ansible role
[uguu.git] / Makefile
CommitLineData
d8c46ff7
GJ
1MAKE="make"
2INSTALL="install"
3TAR="tar"
4GREP="grep"
5NODE="node"
6NPM="npm"
7DESTDIR="./dist"
8PKG_VERSION := $( $(GREP) -Po '(?<="version": ")[^"]*' )
9TMPDIR := $(shell mktemp -d)
fa3a6fd7 10HOSTS_FILE = $(HOSTS_FILE)
d8c46ff7
GJ
11# default modules
12MODULES="php"
13
14all: builddirs npm_dependencies swig htmlmin min-css min-js copy-img submodules
15
16swig:
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
21htmlmin:
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
26installdirs:
27 mkdir -p $(DESTDIR)/ $(DESTDIR)/img
b43ff07c 28 mkdir -p $(DESTDIR)/ $(DESTDIR)/img/grills
d8c46ff7 29ifneq (,$(findstring php,$(MODULES)))
044a28cd 30 mkdir -p $(DESTDIR)/includes
d8c46ff7
GJ
31endif
32ifneq (,$(findstring moe,$(MODULES)))
33 mkdir -p $(DESTDIR)/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates}
34endif
35
36min-css:
1cbe6100 37 $(NODE) $(CURDIR)/node_modules/.bin/cleancss $(CURDIR)/static/css/uguu.css --output $(CURDIR)/build/uguu.min.css
d8c46ff7
GJ
38
39min-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
45copy-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
49copy-php:
50ifneq ($(wildcard $(CURDIR)/static/php/.),)
51 cp -rv $(CURDIR)/static/php/* $(CURDIR)/build/
52else
53 $(error The php submodule was not found)
54endif
55
56copy-moe:
57ifneq ($(wildcard $(CURDIR)/moe/.),)
58 cp -rv $(CURDIR)/moe $(CURDIR)/build/
59else
60 $(error The moe submodule was not found)
61endif
62
63install: installdirs
64 cp -rv $(CURDIR)/build/* $(DESTDIR)/
65
fa3a6fd7 66submodule-update:
67 git submodule update
68
69deploy:
70 ansible-playbook -i $(HOSTS_FILE) ansible/site.yml
71
d8c46ff7
GJ
72dist:
73 DESTDIR=$(TMPDIR)/uguu-$(PKGVERSION)
74 export DESTDIR
75 install
76 $(TAR) cJf uguu-$(PKG_VERSION).tar.xz $(DESTDIR)
77 rm -rf $(TMPDIR)
78
79clean:
80 rm -rvf $(CURDIR)/node_modules
81 rm -rvf $(CURDIR)/build
82
83uninstall:
84 rm -rvf $(DESTDIR)/
85
86npm_dependencies:
87 $(NPM) install
88
89builddirs:
90 mkdir -p $(CURDIR)/build $(CURDIR)/build/img
91ifneq (,$(findstring php,$(MODULES)))
92 mkdir -p $(CURDIR)/build/classes $(CURDIR)/build/includes
93endif
94ifneq (,$(findstring moe,$(MODULES)))
95 mkdir -p $(CURDIR)/build/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates}
96endif
97
98submodules:
99 $(info The following modules will be enabled: $(MODULES))
100ifneq (,$(findstring php,$(MODULES)))
101 $(MAKE) copy-php
102endif
103ifneq (,$(findstring moe,$(MODULES)))
104 $(MAKE) copy-moe
105endif