on f9faafa help sign in
searx/Makefile
275 lines 8.0 kB history raw
1# -*- coding: utf-8; mode: makefile-gmake -*-
2.DEFAULT_GOAL=help
4# START Makefile setup
5export GIT_URL=https://github.com/asciimoo/searx
6export GIT_BRANCH=master
7export SEARX_URL=https://searx.me
8export DOCS_URL=https://asciimoo.github.io/searx
9# END Makefile setup
11include utils/makefile.include
13PYOBJECTS = searx
14DOC = docs
15PY_SETUP_EXTRAS ?= \[test\]
17include utils/makefile.python
18include utils/makefile.sphinx
20all: clean install
22PHONY += help-min help-all help
24help: help-min
25 @echo ''
26 @echo 'to get more help: make help-all'
28help-min:
29 @echo ' test - run developer tests'
30 @echo ' docs - build documentation'
31 @echo ' docs-live - autobuild HTML documentation while editing'
32 @echo ' run - run developer instance'
33 @echo ' install - developer install (./local)'
34 @echo ' uninstall - uninstall (./local)'
35 @echo ' gh-pages - build docs & deploy on gh-pages branch'
36 @echo ' clean - drop builds and environments'
37 @echo ' project - re-build generic files of the searx project'
38 @echo ' buildenv - re-build environment files (aka brand)'
39 @echo ' themes - re-build build the source of the themes'
40 @echo ' docker - build Docker image'
41 @echo ' node.env - download & install npm dependencies locally'
42 @echo ''
43 @echo 'environment'
44 @echo ' SEARX_URL = $(SEARX_URL)'
45 @echo ' GIT_URL = $(GIT_URL)'
46 @echo ' DOCS_URL = $(DOCS_URL)'
47 @echo ''
48 @$(MAKE) -e -s make-help
50help-all: help-min
51 @echo ''
52 @$(MAKE) -e -s python-help
53 @echo ''
54 @$(MAKE) -e -s docs-help
56PHONY += install
57install: buildenv pyenvinstall
59PHONY += uninstall
60uninstall: pyenvuninstall
62PHONY += clean
63clean: pyclean docs-clean node.clean test.clean
64 $(call cmd,common_clean)
66PHONY += run
67run: buildenv pyenvinstall
68 $(Q) ( \
69 sed -i -e "s/debug : False/debug : True/g" ./searx/settings.yml ; \
70 sleep 2 ; \
71 xdg-open http://127.0.0.1:8888/ ; \
72 sleep 3 ; \
73 sed -i -e "s/debug : True/debug : False/g" ./searx/settings.yml ; \
74 ) &
75 $(PY_ENV)/bin/python ./searx/webapp.py
77# docs
78# ----
80sphinx-doc-prebuilds:: buildenv pyenvinstall prebuild-includes
82PHONY += docs
83docs: sphinx-doc-prebuilds sphinx-doc
84 $(call cmd,sphinx,html,docs,docs)
86PHONY += docs-live
87docs-live: sphinx-doc-prebuilds sphinx-live
88 $(call cmd,sphinx_autobuild,html,docs,docs)
90PHONY += prebuild-includes
91prebuild-includes:
92 $(Q)mkdir -p $(DOCS_BUILD)/includes
93 $(Q)./utils/searx.sh doc | cat > $(DOCS_BUILD)/includes/searx.rst
94 $(Q)./utils/filtron.sh doc | cat > $(DOCS_BUILD)/includes/filtron.rst
95 $(Q)./utils/morty.sh doc | cat > $(DOCS_BUILD)/includes/morty.rst
98$(GH_PAGES)::
99 @echo "doc available at --> $(DOCS_URL)"
101# update project files
102# --------------------
104PHONY += project engines.languages useragents.update buildenv
106project: buildenv useragents.update engines.languages
108engines.languages: pyenvinstall
109 $(Q)echo "fetch languages .."
110 $(Q)$(PY_ENV_ACT); python utils/fetch_languages.py
111 $(Q)echo "update searx/data/engines_languages.json"
112 $(Q)mv engines_languages.json searx/data/engines_languages.json
113 $(Q)echo "update searx/languages.py"
114 $(Q)mv languages.py searx/languages.py
116useragents.update: pyenvinstall
117 $(Q)echo "Update searx/data/useragents.json with the most recent versions of Firefox."
118 $(Q)$(PY_ENV_ACT); python utils/fetch_firefox_version.py
120buildenv:
121 $(Q)echo "build searx/brand.py"
122 $(Q)echo "GIT_URL = '$(GIT_URL)'" > searx/brand.py
123 $(Q)echo "GIT_BRANCH = '$(GIT_BRANCH)'" >> searx/brand.py
124 $(Q)echo "ISSUE_URL = 'https://github.com/asciimoo/searx/issues'" >> searx/brand.py
125 $(Q)echo "SEARX_URL = '$(SEARX_URL)'" >> searx/brand.py
126 $(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py
127 $(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py
128 $(Q)echo "build utils/brand.env"
129 $(Q)echo "export GIT_URL='$(GIT_URL)'" > utils/brand.env
130 $(Q)echo "export GIT_BRANCH='$(GIT_BRANCH)'" >> utils/brand.env
131 $(Q)echo "export ISSUE_URL='https://github.com/asciimoo/searx/issues'" >> utils/brand.env
132 $(Q)echo "export SEARX_URL='$(SEARX_URL)'" >> utils/brand.env
133 $(Q)echo "export DOCS_URL='$(DOCS_URL)'" >> utils/brand.env
134 $(Q)echo "export PUBLIC_INSTANCES='https://searx.space'" >> utils/brand.env
137# node / npm
138# ----------
140node.env: buildenv
141 $(Q)./manage.sh npm_packages
143node.clean:
144 $(Q)echo "CLEAN locally installed npm dependencies"
145 $(Q)rm -rf \
146 ./node_modules \
147 ./package-lock.json \
148 ./searx/static/themes/oscar/package-lock.json \
149 ./searx/static/themes/oscar/node_modules \
150 ./searx/static/themes/simple/package-lock.json \
151 ./searx/static/themes/simple/node_modules
153# build themes
154# ------------
156PHONY += themes.bootstrap themes themes.oscar themes.simple themes.legacy themes.courgette themes.pixart
157themes: buildenv themes.bootstrap themes.oscar themes.simple themes.legacy themes.courgette themes.pixart
159quiet_cmd_lessc = LESSC $3
160 cmd_lessc = PATH="$$(npm bin):$$PATH" \
161 lessc --clean-css="--s1 --advanced --compatibility=ie9" "searx/static/$2" "searx/static/$3"
163quiet_cmd_grunt = GRUNT $2
164 cmd_grunt = PATH="$$(npm bin):$$PATH" \
165 grunt --gruntfile "$2"
167themes.oscar: node.env
168 $(Q)echo '[!] build oscar theme'
169 $(call cmd,grunt,searx/static/themes/oscar/gruntfile.js)
171themes.simple: node.env
172 $(Q)echo '[!] build simple theme'
173 $(call cmd,grunt,searx/static/themes/simple/gruntfile.js)
175themes.legacy: node.env
176 $(Q)echo '[!] build legacy theme'
177 $(call cmd,lessc,themes/legacy/less/style-rtl.less,themes/legacy/css/style-rtl.css)
178 $(call cmd,lessc,themes/legacy/less/style.less,themes/legacy/css/style.css)
180themes.courgette: node.env
181 $(Q)echo '[!] build courgette theme'
182 $(call cmd,lessc,themes/courgette/less/style.less,themes/courgette/css/style.css)
183 $(call cmd,lessc,themes/courgette/less/style-rtl.less,themes/courgette/css/style-rtl.css)
185themes.pixart: node.env
186 $(Q)echo '[!] build pixart theme'
187 $(call cmd,lessc,themes/pix-art/less/style.less,themes/pix-art/css/style.css)
189themes.bootstrap: node.env
190 $(call cmd,lessc,less/bootstrap/bootstrap.less,css/bootstrap.min.css)
193# docker
194# ------
196PHONY += docker
197docker: buildenv
198 $(Q)./manage.sh docker_build
200docker.push: buildenv
201 $(Q)./manage.sh docker_build push
203# gecko
204# -----
206PHONY += gecko.driver
207gecko.driver:
208 $(PY_ENV_ACT); ./manage.sh install_geckodriver
210# test
211# ----
213PHONY += test test.sh test.pylint test.pep8 test.unit test.coverage test.robot
214test: buildenv test.pylint test.pep8 test.unit gecko.driver test.robot
216ifeq ($(PY),2)
217test.pylint:
218 @echo "LINT skip liniting py2"
219else
220# TODO: balance linting with pylint
222test.pylint: pyenvinstall
223 $(call cmd,pylint,\
224 searx/preferences.py \
225 searx/testing.py \
226 searx/engines/gigablast.py \
227 )
228endif
230# ignored rules:
231# E402 module level import not at top of file
232# W503 line break before binary operator
234# ubu1604: uses shellcheck v0.3.7 (from 04/2015), no longer supported!
235test.sh:
236 shellcheck -x -s bash utils/brand.env
237 shellcheck -x utils/lib.sh
238 shellcheck -x utils/filtron.sh
239 shellcheck -x utils/searx.sh
240 shellcheck -x utils/morty.sh
241 shellcheck -x utils/lxc.sh
242 shellcheck -x utils/lxc-searx.env
243 shellcheck -x .config.sh
245test.pep8: pyenvinstall
246 @echo "TEST pep8"
247 $(Q)$(PY_ENV_ACT); pep8 --exclude='searx/static, searx/engines/gigablast.py' --max-line-length=120 --ignore "E402,W503" searx tests
249test.unit: pyenvinstall
250 @echo "TEST tests/unit"
251 $(Q)$(PY_ENV_ACT); python -m nose2 -s tests/unit
253test.coverage: pyenvinstall
254 @echo "TEST unit test coverage"
255 $(Q)$(PY_ENV_ACT); \
256 python -m nose2 -C --log-capture --with-coverage --coverage searx -s tests/unit \
257 && coverage report \
258 && coverage html \
260test.robot: pyenvinstall gecko.driver
261 @echo "TEST robot"
262 $(Q)$(PY_ENV_ACT); PYTHONPATH=. python searx/testing.py robot
264test.clean:
265 @echo "CLEAN intermediate test stuff"
266 $(Q)rm -rf geckodriver.log .coverage coverage/
269# travis
270# ------
272travis.codecov:
273 $(Q)$(PY_ENV_BIN)/python -m pip install codecov
275.PHONY: $(PHONY)