@@ -1,266 +1,107 @@
11# -*- coding: utf-8; mode: makefile-gmake -*-
2+# SPDX-License-Identifier: AGPL-3.0-or-later
3+
24.DEFAULT_GOAL=help
5+export MTOOLS=./manage
36
47include utils/makefile.include
58
6−PYOBJECTS = searx
7−DOC = docs
8−PY_SETUP_EXTRAS ?= \[test\]
9−PYLINT_SEARX_DISABLE_OPTION := I,C,R,W0105,W0212,W0511,W0603,W0613,W0621,W0702,W0703,W1401,E1136
10−PYLINT_ADDITIONAL_BUILTINS_FOR_ENGINES := supported_languages,language_aliases
11−
12−include utils/makefile.python
13−include utils/makefile.sphinx
14−
159all: clean install
1610
17−PHONY += help-min help-all help
18−
19−help: help-min
20− @echo ''
21− @echo 'to get more help: make help-all'
22−
23−help-min:
24− @echo ' test - run developer tests'
25− @echo ' docs - build documentation'
26− @echo ' docs-live - autobuild HTML documentation while editing'
27− @echo ' run - run developer instance'
28− @echo ' install - developer install (./local)'
29− @echo ' uninstall - uninstall (./local)'
30− @echo ' gh-pages - build docs & deploy on gh-pages branch'
31− @echo ' clean - drop builds and environments'
32− @echo ' project - re-build generic files of the searx project'
33− @echo ' buildenv - re-build environment files (aka brand)'
34− @echo ' themes - re-build build the source of the themes'
35− @echo ' docker - build Docker image'
36− @echo ' node.env - download & install npm dependencies locally'
37− @echo ''
38− @$(MAKE) -e -s make-help
39−
40−help-all: help-min
41− @echo ''
42− @$(MAKE) -e -s python-help
43− @echo ''
44− @$(MAKE) -e -s docs-help
11+PHONY += help
4512
46−PHONY += install
47−install: buildenv pyenvinstall
13+help:
14+ @./manage --help
15+ @echo '----'
16+ @echo 'run - run developer instance'
17+ @echo 'install - developer install of searx into virtualenv'
18+ @echo 'uninstall - uninstall developer installation'
19+ @echo 'clean - clean up working tree'
20+ @echo 'search.checker - check search engines'
21+ @echo 'test - run shell & CI tests'
22+ @echo 'test.sh - test shell scripts'
23+ @echo 'ci.test - run CI tests'
4824
49−PHONY += uninstall
50−uninstall: pyenvuninstall
51−
52−PHONY += clean
53−clean: pyclean docs-clean node.clean test.clean
54− $(call cmd,common_clean)
5525
5626PHONY += run
57−run: buildenv pyenvinstall
27+run: install
5828 $(Q) ( \
5929 sleep 2 ; \
6030 xdg-open http://127.0.0.1:8888/ ; \
6131 ) &
62− SEARX_DEBUG=1 $(PY_ENV)/bin/python ./searx/webapp.py
63−
64−# docs
65−# ----
66−
67−sphinx-doc-prebuilds:: buildenv pyenvinstall prebuild-includes
68−
69−PHONY += docs
70−docs: sphinx-doc-prebuilds
71− $(call cmd,sphinx,html,docs,docs)
72−
73−PHONY += docs-live
74−docs-live: sphinx-doc-prebuilds
75− $(call cmd,sphinx_autobuild,html,docs,docs)
76−
77−PHONY += prebuild-includes
78−prebuild-includes:
79− $(Q)mkdir -p $(DOCS_BUILD)/includes
80− $(Q)./utils/searx.sh doc | cat > $(DOCS_BUILD)/includes/searx.rst
81− $(Q)./utils/filtron.sh doc | cat > $(DOCS_BUILD)/includes/filtron.rst
82− $(Q)./utils/morty.sh doc | cat > $(DOCS_BUILD)/includes/morty.rst
83−
84−
85−$(GH_PAGES)::
86− @echo "doc available at --> $(DOCS_URL)"
87−
88−# update project files
89−# --------------------
90−
91−PHONY += project engines.languages useragents.update buildenv
92−
93−project: buildenv useragents.update engines.languages
94−
95−engines.languages: pyenvinstall
96− $(Q)echo "fetch languages .."
97− $(Q)$(PY_ENV_ACT); python ./searx_extra/update/update_languages.py
98− $(Q)echo "updated searx/data/engines_languages.json"
99− $(Q)echo "updated searx/languages.py"
100−
101−useragents.update: pyenvinstall
102− $(Q)echo "fetch useragents .."
103− $(Q)$(PY_ENV_ACT); python ./searx_extra/update/update_firefox_version.py
104− $(Q)echo "updated searx/data/useragents.json with the most recent versions of Firefox."
105−
106−buildenv: pyenv
107− $(Q)$(PY_ENV_ACT); SEARX_DEBUG=1 python utils/build_env.py
108−
109−# node / npm
110−# ----------
111−
112−node.env: buildenv
113− $(Q)./manage.sh npm_packages
32+ SEARX_DEBUG=1 ./manage pyenv.cmd python ./searx/webapp.py
11433
115−node.clean:
116− $(Q)echo "CLEAN locally installed npm dependencies"
117− $(Q)rm -rf \
118− ./node_modules \
119− ./package-lock.json \
120− ./searx/static/themes/oscar/package-lock.json \
121− ./searx/static/themes/oscar/node_modules \
122− ./searx/static/themes/simple/package-lock.json \
123− ./searx/static/themes/simple/node_modules
34+PHONY += install uninstall
35+install uninstall:
36+ $(Q)./manage pyenv.$@
12437
125−# build themes
126−# ------------
127−
128−PHONY += themes themes.oscar themes.simple
129−themes: buildenv themes.oscar themes.simple
130−
131−quiet_cmd_lessc = LESSC $3
132− cmd_lessc = PATH="$$(npm bin):$$PATH" \
133− lessc --clean-css="--s1 --advanced --compatibility=ie9" "searx/static/$2" "searx/static/$3"
134−
135−quiet_cmd_grunt = GRUNT $2
136− cmd_grunt = PATH="$$(npm bin):$$PATH" \
137− grunt --gruntfile "$2"
138−
139−themes.oscar: node.env
140− $(Q)echo '[!] build oscar theme'
141− $(call cmd,grunt,searx/static/themes/oscar/gruntfile.js)
142−
143−themes.simple: node.env
144− $(Q)echo '[!] build simple theme'
145− $(call cmd,grunt,searx/static/themes/simple/gruntfile.js)
146−
147−
148−# docker
149−# ------
150−
151−PHONY += docker
152−docker: buildenv
153− $(Q)./manage.sh docker_build
154−
155−docker.push: buildenv
156− $(Q)./manage.sh docker_build push
157−
158−# gecko
159−# -----
160−
161−PHONY += gecko.driver
162−gecko.driver:
163− $(PY_ENV_ACT); ./manage.sh install_geckodriver
164−
165−# search.checker
166−# --------------
167−
168−search.checker: pyenvinstall
169− $(Q)$(PY_ENV_ACT); searx-checker -v
170−
171−ENGINE_TARGETS=$(patsubst searx/engines/%.py,search.checker.%,$(wildcard searx/engines/[!_]*.py))
172−
173−$(ENGINE_TARGETS): pyenvinstall
174− $(Q)$(PY_ENV_ACT); searx-checker -v "$(subst _, ,$(patsubst search.checker.%,%,$@))"
175−
176−
177−# test
178−# ----
179−
180−PHONY += test test.sh test.pylint test.pep8 test.unit test.coverage test.robot
181−test: buildenv test.pylint test.pep8 test.unit gecko.driver test.robot
182−
183−PYLINT_FILES=\
184− searx/preferences.py \
185− searx/testing.py \
186− searx/engines/gigablast.py \
187− searx/engines/deviantart.py \
188− searx/engines/digg.py \
189− searx/engines/google.py \
190− searx/engines/google_news.py \
191− searx/engines/google_videos.py \
192− searx/engines/google_images.py \
193− searx/engines/mediathekviewweb.py \
194− searx/engines/meilisearch.py \
195− searx/engines/solidtorrents.py \
196− searx/engines/solr.py \
197− searx/engines/google_scholar.py \
198− searx/engines/yahoo_news.py \
199− searx/engines/apkmirror.py \
200− searx_extra/update/update_external_bangs.py
201−
202−test.pylint: pyenvinstall
203− $(call cmd,pylint,$(PYLINT_FILES))
204− $(call cmd,pylint,\
205− --disable=$(PYLINT_SEARX_DISABLE_OPTION) \
206− --additional-builtins=$(PYLINT_ADDITIONAL_BUILTINS_FOR_ENGINES) \
207− searx/engines \
208− )
209− $(call cmd,pylint,\
210− --disable=$(PYLINT_SEARX_DISABLE_OPTION) \
211− --ignore=searx/engines \
212− searx tests \
213− )
38+PHONY += clean
39+clean: py.clean docs.clean node.clean test.clean
40+ $(Q)./manage build_msg CLEAN "common files"
41+ $(Q)find . -name '*.orig' -exec rm -f {} +
42+ $(Q)find . -name '*.rej' -exec rm -f {} +
43+ $(Q)find . -name '*~' -exec rm -f {} +
44+ $(Q)find . -name '*.bak' -exec rm -f {} +
45+
46+PHONY += search.checker search.checker.%
47+search.checker: install
48+ $(Q)./manage pyenv.cmd searx-checker -v
49+
50+search.checker.%: install
51+ $(Q)./manage pyenv.cmd searx-checker -v "$(subst _, ,$(patsubst search.checker.%,%,$@))"
52+
53+PHONY += ci.test test test.sh
54+ci.test: test.pep8 test.pylint test.unit test.robot
55+test: ci.test
56+test.sh:
57+ $(Q)shellcheck -x -s bash \
58+ utils/brand.env \
59+ ./manage \
60+ utils/lib.sh \
61+ utils/filtron.sh \
62+ utils/searx.sh \
63+ utils/morty.sh \
64+ utils/lxc.sh \
65+ utils/lxc-searx.env \
66+ .config.sh
67+ $(Q)./manage build_msg TEST "$@ OK"
21468
215−# ignored rules:
216−# E402 module level import not at top of file
217−# W503 line break before binary operator
21869
219−# ubu1604: uses shellcheck v0.3.7 (from 04/2015), no longer supported!
220−test.sh:
221− shellcheck -x -s bash utils/brand.env
222− shellcheck -x utils/lib.sh
223− shellcheck -x utils/filtron.sh
224− shellcheck -x utils/searx.sh
225− shellcheck -x utils/morty.sh
226− shellcheck -x utils/lxc.sh
227− shellcheck -x utils/lxc-searx.env
228− shellcheck -x .config.sh
70+# wrap ./manage script
22971
230−test.pep8: pyenvinstall
231− @echo "TEST pycodestyle (formerly pep8)"
232− $(Q)$(PY_ENV_ACT); pycodestyle --exclude='searx/static, searx/languages.py, $(foreach f,$(PYLINT_FILES),$(f),)' \
233− --max-line-length=120 --ignore "E117,E252,E402,E722,E741,W503,W504,W605" searx tests
72+MANAGE += buildenv
73+MANAGE += babel.compile
74+MANAGE += data.all data.languages data.useragents
75+MANAGE += docs.html docs.live docs.gh-pages docs.prebuild docs.clean
76+MANAGE += docker.build docker.push
77+MANAGE += gecko.driver
78+MANAGE += node.env node.clean
79+MANAGE += py.build py.clean
80+MANAGE += pyenv pyenv.install pyenv.uninstall
81+MANAGE += pypi.upload pypi.upload.test
82+MANAGE += test.pylint test.pep8 test.unit test.coverage test.robot test.clean
83+MANAGE += themes.all themes.oscar themes.simple themes.bootstrap
23484
235−test.unit: pyenvinstall
236− @echo "TEST tests/unit"
237− $(Q)$(PY_ENV_ACT); python -m nose2 -s tests/unit
85+PHONY += $(MANAGE)
23886
239−test.coverage: pyenvinstall
240− @echo "TEST unit test coverage"
241− $(Q)$(PY_ENV_ACT); \
242− python -m nose2 -C --log-capture --with-coverage --coverage searx -s tests/unit \
243− && coverage report \
244− && coverage html \
87+$(MANAGE):
88+ $(Q)$(MTOOLS) $@
24589
246−test.robot: pyenvinstall gecko.driver
247− @echo "TEST robot"
248− $(Q)$(PY_ENV_ACT); PYTHONPATH=. python searx/testing.py robot
90+# deprecated
24991
250−test.clean:
251− @echo "CLEAN intermediate test stuff"
252− $(Q)rm -rf geckodriver.log .coverage coverage/
92+PHONY += docs docs-clean docs-live docker themes
25393
94+docs: docs.html
95+ $(Q)./manage build_msg WARN $@ is deprecated use docs.html
25496
255−# travis
256−# ------
97+docs-clean: docs.clean
98+ $(Q)./manage build_msg WARN $@ is deprecated use docs.clean
25799
258−PHONY += ci.test
259−ci.test:
260− $(PY_ENV_BIN)/python -c "import yaml" || make clean
261− $(MAKE) test
100+docs-live: docs.live
101+ $(Q)./manage build_msg WARN $@ is deprecated use docs.live
262102
263−travis.codecov:
264− $(Q)$(PY_ENV_BIN)/python -m pip install codecov
103+docker: docker.build
104+ $(Q)./manage build_msg WARN $@ is deprecated use docker.build
265105
266−.PHONY: $(PHONY)
106+themes: themes.all
107+ $(Q)./manage build_msg WARN $@ is deprecated use themes.all