]> jfr.im git - uguu.git/blame - Makefile
new uguu code
[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)
10# default modules
11MODULES="php"
12
13all: builddirs npm_dependencies swig htmlmin min-css min-js copy-img submodules
14
15swig:
16 $(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/faq.swig > $(CURDIR)/build/faq.html
17 $(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/index.swig > $(CURDIR)/build/index.html
18 $(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/tools.swig > $(CURDIR)/build/tools.html
19
20htmlmin:
21 $(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/index.html -o $(CURDIR)/build/index.html
22 $(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/faq.html -o $(CURDIR)/build/faq.html
23 $(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/tools.html -o $(CURDIR)/build/tools.html
24
25installdirs:
26 mkdir -p $(DESTDIR)/ $(DESTDIR)/img
27ifneq (,$(findstring php,$(MODULES)))
28 mkdir -p $(DESTDIR)/classes $(DESTDIR)/includes
29endif
30ifneq (,$(findstring moe,$(MODULES)))
31 mkdir -p $(DESTDIR)/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates}
32endif
33
34min-css:
35 $(NODE) $(CURDIR)/node_modules/.bin/cleancss --skip-rebase --O1 specialComments:0 $(CURDIR)/static/css/uguu.css --output $(CURDIR)/build/uguu.min.css
36
37min-js:
38 echo "// @source https://github.com/nokonoko/uguu/tree/master/static/js" > $(CURDIR)/build/uguu.min.js
39 echo "// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat" >> $(CURDIR)/build/uguu.min.js
40 $(NODE) $(CURDIR)/node_modules/.bin/uglifyjs --screw-ie8 ./static/js/app.js >> $(CURDIR)/build/uguu.min.js
41 echo "// @license-end" >> $(CURDIR)/build/uguu.min.js
42
43copy-img:
44 cp -v $(CURDIR)/static/img/*.png $(CURDIR)/build/img/
45 cp -v $(CURDIR)/static/img/favicon.ico $(CURDIR)/build/favicon.ico
46
47copy-php:
48ifneq ($(wildcard $(CURDIR)/static/php/.),)
49 cp -rv $(CURDIR)/static/php/* $(CURDIR)/build/
50else
51 $(error The php submodule was not found)
52endif
53
54copy-moe:
55ifneq ($(wildcard $(CURDIR)/moe/.),)
56 cp -rv $(CURDIR)/moe $(CURDIR)/build/
57else
58 $(error The moe submodule was not found)
59endif
60
61install: installdirs
62 cp -rv $(CURDIR)/build/* $(DESTDIR)/
63
64dist:
65 DESTDIR=$(TMPDIR)/uguu-$(PKGVERSION)
66 export DESTDIR
67 install
68 $(TAR) cJf uguu-$(PKG_VERSION).tar.xz $(DESTDIR)
69 rm -rf $(TMPDIR)
70
71clean:
72 rm -rvf $(CURDIR)/node_modules
73 rm -rvf $(CURDIR)/build
74
75uninstall:
76 rm -rvf $(DESTDIR)/
77
78npm_dependencies:
79 $(NPM) install
80
81builddirs:
82 mkdir -p $(CURDIR)/build $(CURDIR)/build/img
83ifneq (,$(findstring php,$(MODULES)))
84 mkdir -p $(CURDIR)/build/classes $(CURDIR)/build/includes
85endif
86ifneq (,$(findstring moe,$(MODULES)))
87 mkdir -p $(CURDIR)/build/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates}
88endif
89
90submodules:
91 $(info The following modules will be enabled: $(MODULES))
92ifneq (,$(findstring php,$(MODULES)))
93 $(MAKE) copy-php
94endif
95ifneq (,$(findstring moe,$(MODULES)))
96 $(MAKE) copy-moe
97endif