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