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