]> jfr.im git - uguu.git/blame - Makefile
changes
[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)))
044a28cd 28 mkdir -p $(DESTDIR)/includes
d8c46ff7
GJ
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:
1cbe6100 35 $(NODE) $(CURDIR)/node_modules/.bin/cleancss $(CURDIR)/static/css/uguu.css --output $(CURDIR)/build/uguu.min.css
d8c46ff7
GJ
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
cef49852 40 $(NODE) $(CURDIR)/node_modules/.bin/uglifyjs ./static/js/app.js >> $(CURDIR)/build/uguu.min.js
d8c46ff7
GJ
41 echo "// @license-end" >> $(CURDIR)/build/uguu.min.js
42
43copy-img:
44 cp -v $(CURDIR)/static/img/*.png $(CURDIR)/build/img/
d8c46ff7
GJ
45
46copy-php:
47ifneq ($(wildcard $(CURDIR)/static/php/.),)
48 cp -rv $(CURDIR)/static/php/* $(CURDIR)/build/
49else
50 $(error The php submodule was not found)
51endif
52
53copy-moe:
54ifneq ($(wildcard $(CURDIR)/moe/.),)
55 cp -rv $(CURDIR)/moe $(CURDIR)/build/
56else
57 $(error The moe submodule was not found)
58endif
59
60install: installdirs
61 cp -rv $(CURDIR)/build/* $(DESTDIR)/
62
63dist:
64 DESTDIR=$(TMPDIR)/uguu-$(PKGVERSION)
65 export DESTDIR
66 install
67 $(TAR) cJf uguu-$(PKG_VERSION).tar.xz $(DESTDIR)
68 rm -rf $(TMPDIR)
69
70clean:
71 rm -rvf $(CURDIR)/node_modules
72 rm -rvf $(CURDIR)/build
73
74uninstall:
75 rm -rvf $(DESTDIR)/
76
77npm_dependencies:
78 $(NPM) install
79
80builddirs:
81 mkdir -p $(CURDIR)/build $(CURDIR)/build/img
82ifneq (,$(findstring php,$(MODULES)))
83 mkdir -p $(CURDIR)/build/classes $(CURDIR)/build/includes
84endif
85ifneq (,$(findstring moe,$(MODULES)))
86 mkdir -p $(CURDIR)/build/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates}
87endif
88
89submodules:
90 $(info The following modules will be enabled: $(MODULES))
91ifneq (,$(findstring php,$(MODULES)))
92 $(MAKE) copy-php
93endif
94ifneq (,$(findstring moe,$(MODULES)))
95 $(MAKE) copy-moe
96endif