on 9f8ebec help sign in
searx/Makefile
281 lines 8.3 kB history raw
1# -*- coding: utf-8; mode: makefile-gmake -*-
2.DEFAULT_GOAL=help
4# START Makefile setup
5export GIT_URL=https://github.com/searx/searx
6export GIT_BRANCH=master
7export SEARX_URL=https://searx.me
8export DOCS_URL=https://searx.github.io/searx
9# END Makefile setup
11include utils/makefile.include
13PYOBJECTS = searx
14DOC = docs
15PY_SETUP_EXTRAS ?= \[test\]
16PYLINT_SEARX_DISABLE_OPTION := I,C,R,W0105,W0212,W0511,W0603,W0613,W0621,W0702,W0703,W1401
17PYLINT_ADDITIONAL_BUILTINS_FOR_ENGINES := supported_languages,language_aliases
19include utils/makefile.python
20include utils/makefile.sphinx
22all: clean install
24PHONY += help-min help-all help
26help: help-min
27 @echo ''
28 @echo 'to get more help: make help-all'
30help-min:
31 @echo ' test - run developer tests'
32 @echo ' docs - build documentation'
33 @echo ' docs-live - autobuild HTML documentation while editing'
34 @echo ' run - run developer instance'
35 @echo ' install - developer install (./local)'
36 @echo ' uninstall - uninstall (./local)'
37 @echo ' gh-pages - build docs & deploy on gh-pages branch'
38 @echo ' clean - drop builds and environments'
39 @echo ' project - re-build generic files of the searx project'
40 @echo ' buildenv - re-build environment files (aka brand)'
41 @echo ' themes - re-build build the source of the themes'
42 @echo ' docker - build Docker image'
43 @echo ' node.env - download & install npm dependencies locally'
44 @echo ''
45 @echo 'environment'
46 @echo ' SEARX_URL = $(SEARX_URL)'
47 @echo ' GIT_URL = $(GIT_URL)'
48 @echo ' DOCS_URL = $(DOCS_URL)'
49 @echo ''
50 @$(MAKE) -e -s make-help
52help-all: help-min
53 @echo ''
54 @$(MAKE) -e -s python-help
55 @echo ''
56 @$(MAKE) -e -s docs-help
58PHONY += install
59install: buildenv pyenvinstall
61PHONY += uninstall
62uninstall: pyenvuninstall
64PHONY += clean
65clean: pyclean docs-clean node.clean test.clean
66 $(call cmd,common_clean)
68PHONY += run
69run: buildenv pyenvinstall
70 $(Q) ( \
71 sleep 2 ; \
72 xdg-open http://127.0.0.1:8888/ ; \
73 ) &
74 SEARX_DEBUG=1 $(PY_ENV)/bin/python ./searx/webapp.py
76# docs
77# ----
79sphinx-doc-prebuilds:: buildenv pyenvinstall prebuild-includes
81PHONY += docs
82docs: sphinx-doc-prebuilds
83 $(call cmd,sphinx,html,docs,docs)
85PHONY += docs-live
86docs-live: sphinx-doc-prebuilds
87 $(call cmd,sphinx_autobuild,html,docs,docs)
89PHONY += prebuild-includes
90prebuild-includes:
91 $(Q)mkdir -p $(DOCS_BUILD)/includes
92 $(Q)./utils/searx.sh doc | cat > $(DOCS_BUILD)/includes/searx.rst
93 $(Q)./utils/filtron.sh doc | cat > $(DOCS_BUILD)/includes/filtron.rst
94 $(Q)./utils/morty.sh doc | cat > $(DOCS_BUILD)/includes/morty.rst
97$(GH_PAGES)::
98 @echo "doc available at --> $(DOCS_URL)"
100# update project files
101# --------------------
103PHONY += project engines.languages useragents.update buildenv
105project: buildenv useragents.update engines.languages
107engines.languages: pyenvinstall
108 $(Q)echo "fetch languages .."
109 $(Q)$(PY_ENV_ACT); python utils/fetch_languages.py
110 $(Q)echo "update searx/data/engines_languages.json"
111 $(Q)mv engines_languages.json searx/data/engines_languages.json
112 $(Q)echo "update searx/languages.py"
113 $(Q)mv languages.py searx/languages.py
115useragents.update: pyenvinstall
116 $(Q)echo "Update searx/data/useragents.json with the most recent versions of Firefox."
117 $(Q)$(PY_ENV_ACT); python utils/fetch_firefox_version.py
119buildenv:
120 $(Q)echo "build searx/brand.py"
121 $(Q)echo "GIT_URL = '$(GIT_URL)'" > searx/brand.py
122 $(Q)echo "GIT_BRANCH = '$(GIT_BRANCH)'" >> searx/brand.py
123 $(Q)echo "ISSUE_URL = 'https://github.com/searx/searx/issues'" >> searx/brand.py
124 $(Q)echo "SEARX_URL = '$(SEARX_URL)'" >> searx/brand.py
125 $(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py
126 $(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py
127 $(Q)echo "build utils/brand.env"
128 $(Q)echo "export GIT_URL='$(GIT_URL)'" > utils/brand.env
129 $(Q)echo "export GIT_BRANCH='$(GIT_BRANCH)'" >> utils/brand.env
130 $(Q)echo "export ISSUE_URL='https://github.com/searx/searx/issues'" >> utils/brand.env
131 $(Q)echo "export SEARX_URL='$(SEARX_URL)'" >> utils/brand.env
132 $(Q)echo "export DOCS_URL='$(DOCS_URL)'" >> utils/brand.env
133 $(Q)echo "export PUBLIC_INSTANCES='https://searx.space'" >> utils/brand.env
136# node / npm
137# ----------
139node.env: buildenv
140 $(Q)./manage.sh npm_packages
142node.clean:
143 $(Q)echo "CLEAN locally installed npm dependencies"
144 $(Q)rm -rf \
145 ./node_modules \
146 ./package-lock.json \
147 ./searx/static/themes/oscar/package-lock.json \
148 ./searx/static/themes/oscar/node_modules \
149 ./searx/static/themes/simple/package-lock.json \
150 ./searx/static/themes/simple/node_modules
152# build themes
153# ------------
155PHONY += themes.bootstrap themes themes.oscar themes.simple themes.legacy themes.courgette themes.pixart
156themes: buildenv themes.bootstrap themes.oscar themes.simple themes.legacy themes.courgette themes.pixart
158quiet_cmd_lessc = LESSC $3
159 cmd_lessc = PATH="$$(npm bin):$$PATH" \
160 lessc --clean-css="--s1 --advanced --compatibility=ie9" "searx/static/$2" "searx/static/$3"
162quiet_cmd_grunt = GRUNT $2
163 cmd_grunt = PATH="$$(npm bin):$$PATH" \
164 grunt --gruntfile "$2"
166themes.oscar: node.env
167 $(Q)echo '[!] build oscar theme'
168 $(call cmd,grunt,searx/static/themes/oscar/gruntfile.js)
170themes.simple: node.env
171 $(Q)echo '[!] build simple theme'
172 $(call cmd,grunt,searx/static/themes/simple/gruntfile.js)
174themes.legacy: node.env
175 $(Q)echo '[!] build legacy theme'
176 $(call cmd,lessc,themes/legacy/less/style-rtl.less,themes/legacy/css/style-rtl.css)
177 $(call cmd,lessc,themes/legacy/less/style.less,themes/legacy/css/style.css)
179themes.courgette: node.env
180 $(Q)echo '[!] build courgette theme'
181 $(call cmd,lessc,themes/courgette/less/style.less,themes/courgette/css/style.css)
182 $(call cmd,lessc,themes/courgette/less/style-rtl.less,themes/courgette/css/style-rtl.css)
184themes.pixart: node.env
185 $(Q)echo '[!] build pixart theme'
186 $(call cmd,lessc,themes/pix-art/less/style.less,themes/pix-art/css/style.css)
188themes.bootstrap: node.env
189 $(call cmd,lessc,less/bootstrap/bootstrap.less,css/bootstrap.min.css)
192# docker
193# ------
195PHONY += docker
196docker: buildenv
197 $(Q)./manage.sh docker_build
199docker.push: buildenv
200 $(Q)./manage.sh docker_build push
202# gecko
203# -----
205PHONY += gecko.driver
206gecko.driver:
207 $(PY_ENV_ACT); ./manage.sh install_geckodriver
209# test
210# ----
212PHONY += test test.sh test.pylint test.pep8 test.unit test.coverage test.robot
213test: buildenv test.pylint test.pep8 test.unit gecko.driver test.robot
215PYLINT_FILES=\
216 searx/preferences.py \
217 searx/testing.py \
218 searx/engines/gigablast.py \
219 searx/engines/deviantart.py \
220 searx/engines/digg.py
222test.pylint: pyenvinstall
223 $(call cmd,pylint,$(PYLINT_FILES))
224 $(call cmd,pylint,\
225 --disable=$(PYLINT_SEARX_DISABLE_OPTION) \
226 --additional-builtins=$(PYLINT_ADDITIONAL_BUILTINS_FOR_ENGINES) \
227 searx/engines \
228 )
229 $(call cmd,pylint,\
230 --disable=$(PYLINT_SEARX_DISABLE_OPTION) \
231 --ignore=searx/engines \
232 searx tests \
233 )
235# ignored rules:
236# E402 module level import not at top of file
237# W503 line break before binary operator
239# ubu1604: uses shellcheck v0.3.7 (from 04/2015), no longer supported!
240test.sh:
241 shellcheck -x -s bash utils/brand.env
242 shellcheck -x utils/lib.sh
243 shellcheck -x utils/filtron.sh
244 shellcheck -x utils/searx.sh
245 shellcheck -x utils/morty.sh
246 shellcheck -x utils/lxc.sh
247 shellcheck -x utils/lxc-searx.env
248 shellcheck -x .config.sh
250test.pep8: pyenvinstall
251 @echo "TEST pycodestyle (formerly pep8)"
252 $(Q)$(PY_ENV_ACT); pycodestyle --exclude='searx/static, searx/languages.py, $(foreach f,$(PYLINT_FILES),$(f),)' \
253 --max-line-length=120 --ignore "E117,E252,E402,E722,E741,W503,W504,W605" searx tests
255test.unit: pyenvinstall
256 @echo "TEST tests/unit"
257 $(Q)$(PY_ENV_ACT); python -m nose2 -s tests/unit
259test.coverage: pyenvinstall
260 @echo "TEST unit test coverage"
261 $(Q)$(PY_ENV_ACT); \
262 python -m nose2 -C --log-capture --with-coverage --coverage searx -s tests/unit \
263 && coverage report \
264 && coverage html \
266test.robot: pyenvinstall gecko.driver
267 @echo "TEST robot"
268 $(Q)$(PY_ENV_ACT); PYTHONPATH=. python searx/testing.py robot
270test.clean:
271 @echo "CLEAN intermediate test stuff"
272 $(Q)rm -rf geckodriver.log .coverage coverage/
275# travis
276# ------
278travis.codecov:
279 $(Q)$(PY_ENV_BIN)/python -m pip install codecov
281.PHONY: $(PHONY)