]>
Commit | Line | Data |
---|---|---|
d8c46ff7 GJ |
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) | |
0a6585a2 | 10 | DOCKER_IMAGE = "$(shell basename $(CURDIR) | tr [:upper:] [:lower:])" |
11 | DOCKER_TAG="$(DOCKER_TAG)" | |
12 | CONTAINER_NAME="$(CONTAINER_NAME)" | |
d8c46ff7 GJ |
13 | # default modules |
14 | MODULES="php" | |
15 | ||
16 | all: builddirs npm_dependencies swig htmlmin min-css min-js copy-img submodules | |
17 | ||
18 | swig: | |
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 | ||
23 | htmlmin: | |
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 | ||
28 | installdirs: | |
29 | mkdir -p $(DESTDIR)/ $(DESTDIR)/img | |
b43ff07c | 30 | mkdir -p $(DESTDIR)/ $(DESTDIR)/img/grills |
d8c46ff7 | 31 | ifneq (,$(findstring php,$(MODULES))) |
044a28cd | 32 | mkdir -p $(DESTDIR)/includes |
d8c46ff7 GJ |
33 | endif |
34 | ifneq (,$(findstring moe,$(MODULES))) | |
35 | mkdir -p $(DESTDIR)/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates} | |
36 | endif | |
37 | ||
38 | min-css: | |
1cbe6100 | 39 | $(NODE) $(CURDIR)/node_modules/.bin/cleancss $(CURDIR)/static/css/uguu.css --output $(CURDIR)/build/uguu.min.css |
d8c46ff7 GJ |
40 | |
41 | min-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 | ||
47 | copy-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 | |
51 | copy-php: | |
52 | ifneq ($(wildcard $(CURDIR)/static/php/.),) | |
53 | cp -rv $(CURDIR)/static/php/* $(CURDIR)/build/ | |
54 | else | |
55 | $(error The php submodule was not found) | |
56 | endif | |
57 | ||
58 | copy-moe: | |
59 | ifneq ($(wildcard $(CURDIR)/moe/.),) | |
60 | cp -rv $(CURDIR)/moe $(CURDIR)/build/ | |
61 | else | |
62 | $(error The moe submodule was not found) | |
63 | endif | |
64 | ||
65 | install: installdirs | |
66 | cp -rv $(CURDIR)/build/* $(DESTDIR)/ | |
67 | ||
68 | dist: | |
69 | DESTDIR=$(TMPDIR)/uguu-$(PKGVERSION) | |
70 | export DESTDIR | |
71 | install | |
72 | $(TAR) cJf uguu-$(PKG_VERSION).tar.xz $(DESTDIR) | |
73 | rm -rf $(TMPDIR) | |
74 | ||
75 | clean: | |
76 | rm -rvf $(CURDIR)/node_modules | |
77 | rm -rvf $(CURDIR)/build | |
78 | ||
79 | uninstall: | |
80 | rm -rvf $(DESTDIR)/ | |
81 | ||
82 | npm_dependencies: | |
83 | $(NPM) install | |
84 | ||
0a6585a2 | 85 | |
86 | build-image: | |
87 | docker build -f docker/Dockerfile --build-arg VERSION=$(UGUU_RELEASE_VER) --no-cache -t $(DOCKER_IMAGE):$(DOCKER_TAG) . | |
88 | ||
89 | run-container: | |
90 | docker run --name $(CONTAINER_NAME) -d -p 8080:80 --env-file docker/.env $(DOCKER_IMAGE):$(DOCKER_TAG) | |
91 | ||
92 | purge-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 |
97 | builddirs: |
98 | mkdir -p $(CURDIR)/build $(CURDIR)/build/img | |
99 | ifneq (,$(findstring php,$(MODULES))) | |
100 | mkdir -p $(CURDIR)/build/classes $(CURDIR)/build/includes | |
101 | endif | |
102 | ifneq (,$(findstring moe,$(MODULES))) | |
103 | mkdir -p $(CURDIR)/build/moe/{css,fonts,includes,js,login,panel/css/font,panel/css/images,register,templates} | |
104 | endif | |
105 | ||
106 | submodules: | |
107 | $(info The following modules will be enabled: $(MODULES)) | |
108 | ifneq (,$(findstring php,$(MODULES))) | |
109 | $(MAKE) copy-php | |
110 | endif | |
111 | ifneq (,$(findstring moe,$(MODULES))) | |
112 | $(MAKE) copy-moe | |
113 | endif |