]> 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 mkdir -p $(DESTDIR)/ $(DESTDIR)/img/grills
28 ifneq (,$(findstring php,$(MODULES)))
29 mkdir -p $(DESTDIR)/includes
30 endif
31 ifneq (,$(findstring moe,$(MODULES)))
32 mkdir -p $(DESTDIR)/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates}
33 endif
34
35 min-css:
36 $(NODE) $(CURDIR)/node_modules/.bin/cleancss $(CURDIR)/static/css/uguu.css --output $(CURDIR)/build/uguu.min.css
37
38 min-js:
39 echo "// @source https://github.com/nokonoko/uguu/tree/master/static/js" > $(CURDIR)/build/uguu.min.js
40 echo "// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat" >> $(CURDIR)/build/uguu.min.js
41 $(NODE) $(CURDIR)/node_modules/.bin/uglifyjs ./static/js/app.js >> $(CURDIR)/build/uguu.min.js
42 echo "// @license-end" >> $(CURDIR)/build/uguu.min.js
43
44 copy-img:
45 cp -v $(CURDIR)/static/img/*.png $(CURDIR)/build/img/
46 cp -R $(CURDIR)/static/img/grills $(CURDIR)/build/img/
47
48 copy-php:
49 ifneq ($(wildcard $(CURDIR)/static/php/.),)
50 cp -rv $(CURDIR)/static/php/* $(CURDIR)/build/
51 else
52 $(error The php submodule was not found)
53 endif
54
55 copy-moe:
56 ifneq ($(wildcard $(CURDIR)/moe/.),)
57 cp -rv $(CURDIR)/moe $(CURDIR)/build/
58 else
59 $(error The moe submodule was not found)
60 endif
61
62 install: installdirs
63 cp -rv $(CURDIR)/build/* $(DESTDIR)/
64
65 dist:
66 DESTDIR=$(TMPDIR)/uguu-$(PKGVERSION)
67 export DESTDIR
68 install
69 $(TAR) cJf uguu-$(PKG_VERSION).tar.xz $(DESTDIR)
70 rm -rf $(TMPDIR)
71
72 clean:
73 rm -rvf $(CURDIR)/node_modules
74 rm -rvf $(CURDIR)/build
75
76 uninstall:
77 rm -rvf $(DESTDIR)/
78
79 npm_dependencies:
80 $(NPM) install
81
82 builddirs:
83 mkdir -p $(CURDIR)/build $(CURDIR)/build/img
84 ifneq (,$(findstring php,$(MODULES)))
85 mkdir -p $(CURDIR)/build/classes $(CURDIR)/build/includes
86 endif
87 ifneq (,$(findstring moe,$(MODULES)))
88 mkdir -p $(CURDIR)/build/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates}
89 endif
90
91 submodules:
92 $(info The following modules will be enabled: $(MODULES))
93 ifneq (,$(findstring php,$(MODULES)))
94 $(MAKE) copy-php
95 endif
96 ifneq (,$(findstring moe,$(MODULES)))
97 $(MAKE) copy-moe
98 endif