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