]> jfr.im git - uguu.git/blame - Makefile
Update .env
[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)
0a6585a2 10DOCKER_IMAGE = "$(shell basename $(CURDIR) | tr [:upper:] [:lower:])"
11DOCKER_TAG="$(DOCKER_TAG)"
12CONTAINER_NAME="$(CONTAINER_NAME)"
d8c46ff7
GJ
13# default modules
14MODULES="php"
15
16all: builddirs npm_dependencies swig htmlmin min-css min-js copy-img submodules
17
18swig:
19 $(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/faq.swig > $(CURDIR)/build/faq.html
20 $(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/index.swig > $(CURDIR)/build/index.html
21 $(NODE) node_modules/swig/bin/swig.js render -j dist.json templates/tools.swig > $(CURDIR)/build/tools.html
22
23htmlmin:
24 $(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/index.html -o $(CURDIR)/build/index.html
25 $(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/faq.html -o $(CURDIR)/build/faq.html
26 $(NODE) node_modules/htmlmin/bin/htmlmin $(CURDIR)/build/tools.html -o $(CURDIR)/build/tools.html
27
28installdirs:
29 mkdir -p $(DESTDIR)/ $(DESTDIR)/img
b43ff07c 30 mkdir -p $(DESTDIR)/ $(DESTDIR)/img/grills
d8c46ff7 31ifneq (,$(findstring php,$(MODULES)))
044a28cd 32 mkdir -p $(DESTDIR)/includes
d8c46ff7
GJ
33endif
34ifneq (,$(findstring moe,$(MODULES)))
35 mkdir -p $(DESTDIR)/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates}
36endif
37
38min-css:
1cbe6100 39 $(NODE) $(CURDIR)/node_modules/.bin/cleancss $(CURDIR)/static/css/uguu.css --output $(CURDIR)/build/uguu.min.css
d8c46ff7
GJ
40
41min-js:
42 echo "// @source https://github.com/nokonoko/uguu/tree/master/static/js" > $(CURDIR)/build/uguu.min.js
43 echo "// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat" >> $(CURDIR)/build/uguu.min.js
cef49852 44 $(NODE) $(CURDIR)/node_modules/.bin/uglifyjs ./static/js/app.js >> $(CURDIR)/build/uguu.min.js
d8c46ff7
GJ
45 echo "// @license-end" >> $(CURDIR)/build/uguu.min.js
46
47copy-img:
48 cp -v $(CURDIR)/static/img/*.png $(CURDIR)/build/img/
b43ff07c 49 cp -R $(CURDIR)/static/img/grills $(CURDIR)/build/img/
d8c46ff7
GJ
50
51copy-php:
52ifneq ($(wildcard $(CURDIR)/static/php/.),)
53 cp -rv $(CURDIR)/static/php/* $(CURDIR)/build/
54else
55 $(error The php submodule was not found)
56endif
57
58copy-moe:
59ifneq ($(wildcard $(CURDIR)/moe/.),)
60 cp -rv $(CURDIR)/moe $(CURDIR)/build/
61else
62 $(error The moe submodule was not found)
63endif
64
65install: installdirs
66 cp -rv $(CURDIR)/build/* $(DESTDIR)/
67
68dist:
69 DESTDIR=$(TMPDIR)/uguu-$(PKGVERSION)
70 export DESTDIR
71 install
72 $(TAR) cJf uguu-$(PKG_VERSION).tar.xz $(DESTDIR)
73 rm -rf $(TMPDIR)
74
75clean:
76 rm -rvf $(CURDIR)/node_modules
77 rm -rvf $(CURDIR)/build
78
79uninstall:
80 rm -rvf $(DESTDIR)/
81
82npm_dependencies:
83 $(NPM) install
84
0a6585a2 85
86build-image:
87 docker build -f docker/Dockerfile --build-arg VERSION=$(UGUU_RELEASE_VER) --no-cache -t $(DOCKER_IMAGE):$(DOCKER_TAG) .
88
89run-container:
90 docker run --name $(CONTAINER_NAME) -d -p 8080:80 --env-file docker/.env $(DOCKER_IMAGE):$(DOCKER_TAG)
91
92purge-container:
93 if docker images | grep $(DOCKER_IMAGE); then \
94 docker rm -f $(CONTAINER_NAME) && docker rmi $(DOCKER_IMAGE):$(DOCKER_TAG) || true;\
95 fi;
96
d8c46ff7
GJ
97builddirs:
98 mkdir -p $(CURDIR)/build $(CURDIR)/build/img
99ifneq (,$(findstring php,$(MODULES)))
100 mkdir -p $(CURDIR)/build/classes $(CURDIR)/build/includes
101endif
102ifneq (,$(findstring moe,$(MODULES)))
103 mkdir -p $(CURDIR)/build/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates}
104endif
105
106submodules:
107 $(info The following modules will be enabled: $(MODULES))
108ifneq (,$(findstring php,$(MODULES)))
109 $(MAKE) copy-php
110endif
111ifneq (,$(findstring moe,$(MODULES)))
112 $(MAKE) copy-moe
113endif