2019-11-28 19:54:57 +01:00
|
|
|
# -*- coding: utf-8; mode: makefile-gmake -*-
|
2020-03-08 18:37:16 +01:00
|
|
|
.DEFAULT_GOAL=help
|
2020-03-29 15:09:34 +02:00
|
|
|
|
|
|
|
export GIT_URL=https://github.com/asciimoo/searx
|
2020-03-29 16:28:17 +02:00
|
|
|
export GIT_BRANCH=master
|
2020-03-29 15:09:34 +02:00
|
|
|
export SEARX_URL=https://searx.me
|
|
|
|
export DOCS_URL=https://asciimoo.github.io/searx
|
|
|
|
|
2020-03-15 17:01:36 +01:00
|
|
|
include utils/makefile.include
|
2019-12-04 16:48:36 +01:00
|
|
|
|
2019-11-28 19:54:57 +01:00
|
|
|
PYOBJECTS = searx
|
2019-12-12 12:10:32 +01:00
|
|
|
DOC = docs
|
2019-11-28 19:54:57 +01:00
|
|
|
PY_SETUP_EXTRAS ?= \[test\]
|
|
|
|
|
|
|
|
include utils/makefile.python
|
2019-12-12 12:10:32 +01:00
|
|
|
include utils/makefile.sphinx
|
2019-11-28 19:54:57 +01:00
|
|
|
|
|
|
|
all: clean install
|
|
|
|
|
2020-03-21 18:45:38 +01:00
|
|
|
PHONY += help-min help-all help
|
|
|
|
|
|
|
|
help: help-min
|
|
|
|
@echo ''
|
|
|
|
@echo 'to get more help: make help-all'
|
|
|
|
|
|
|
|
help-min:
|
2019-11-28 20:05:29 +01:00
|
|
|
@echo ' test - run developer tests'
|
2019-12-12 12:10:32 +01:00
|
|
|
@echo ' docs - build documentation'
|
|
|
|
@echo ' docs-live - autobuild HTML documentation while editing'
|
2019-11-28 19:54:57 +01:00
|
|
|
@echo ' run - run developer instance'
|
|
|
|
@echo ' install - developer install (./local)'
|
|
|
|
@echo ' uninstall - uninstall (./local)'
|
2019-12-12 14:15:41 +01:00
|
|
|
@echo ' gh-pages - build docs & deploy on gh-pages branch'
|
2019-12-18 16:11:05 +01:00
|
|
|
@echo ' clean - drop builds and environments'
|
2020-03-01 07:56:46 +01:00
|
|
|
@echo ' project - re-build generic files of the searx project'
|
2020-03-25 14:09:47 +01:00
|
|
|
@echo ' themes - re-build build the source of the themes'
|
2020-03-25 14:50:39 +01:00
|
|
|
@echo ' docker - build Docker image'
|
2020-03-25 16:38:52 +01:00
|
|
|
@echo ' node.env - download & install npm dependencies locally'
|
2019-11-28 19:54:57 +01:00
|
|
|
@echo ''
|
2020-02-17 18:58:59 +01:00
|
|
|
@echo 'environment'
|
|
|
|
@echo ' SEARX_URL = $(SEARX_URL)'
|
|
|
|
@echo ' GIT_URL = $(GIT_URL)'
|
|
|
|
@echo ' DOCS_URL = $(DOCS_URL)'
|
|
|
|
@echo ''
|
2020-03-21 18:45:38 +01:00
|
|
|
@$(MAKE) -e -s make-help
|
|
|
|
|
|
|
|
help-all: help-min
|
|
|
|
@echo ''
|
|
|
|
@$(MAKE) -e -s python-help
|
2019-11-28 19:54:57 +01:00
|
|
|
@echo ''
|
2020-03-21 18:45:38 +01:00
|
|
|
@$(MAKE) -e -s docs-help
|
2019-11-28 19:54:57 +01:00
|
|
|
|
|
|
|
PHONY += install
|
|
|
|
install: pyenvinstall
|
|
|
|
|
|
|
|
PHONY += uninstall
|
|
|
|
uninstall: pyenvuninstall
|
|
|
|
|
|
|
|
PHONY += clean
|
2020-03-29 13:03:27 +02:00
|
|
|
clean: pyclean docs-clean node.clean test.clean
|
2019-11-28 19:54:57 +01:00
|
|
|
$(call cmd,common_clean)
|
|
|
|
|
|
|
|
PHONY += run
|
|
|
|
run: pyenvinstall
|
|
|
|
$(Q) ( \
|
|
|
|
sed -i -e "s/debug : False/debug : True/g" ./searx/settings.yml ; \
|
|
|
|
sleep 2 ; \
|
|
|
|
xdg-open http://127.0.0.1:8888/ ; \
|
|
|
|
sleep 3 ; \
|
|
|
|
sed -i -e "s/debug : True/debug : False/g" ./searx/settings.yml ; \
|
|
|
|
) &
|
|
|
|
$(PY_ENV)/bin/python ./searx/webapp.py
|
|
|
|
|
2019-12-12 12:10:32 +01:00
|
|
|
# docs
|
|
|
|
# ----
|
|
|
|
|
|
|
|
PHONY += docs
|
2020-03-02 19:00:19 +01:00
|
|
|
|
|
|
|
docs: pyenvinstall sphinx-doc prebuild-includes
|
2019-12-12 12:10:32 +01:00
|
|
|
$(call cmd,sphinx,html,docs,docs)
|
|
|
|
|
2020-03-29 16:46:07 +02:00
|
|
|
PHONY += docs-live prebuild-includes
|
2020-03-02 19:00:19 +01:00
|
|
|
docs-live: pyenvinstall sphinx-live prebuild-includes
|
2019-12-12 12:10:32 +01:00
|
|
|
$(call cmd,sphinx_autobuild,html,docs,docs)
|
|
|
|
|
2020-03-02 19:00:19 +01:00
|
|
|
prebuild-includes:
|
|
|
|
@mkdir -p $(DOCS_BUILD)/includes
|
|
|
|
@./utils/searx.sh doc | cat > $(DOCS_BUILD)/includes/searx.rst
|
|
|
|
@./utils/filtron.sh doc | cat > $(DOCS_BUILD)/includes/filtron.rst
|
|
|
|
@./utils/morty.sh doc | cat > $(DOCS_BUILD)/includes/morty.rst
|
|
|
|
|
|
|
|
|
2019-12-13 12:58:46 +01:00
|
|
|
$(GH_PAGES)::
|
|
|
|
@echo "doc available at --> $(DOCS_URL)"
|
2019-12-12 12:10:32 +01:00
|
|
|
|
2020-03-01 07:56:46 +01:00
|
|
|
# update project files
|
|
|
|
# --------------------
|
|
|
|
|
2020-03-26 13:32:08 +01:00
|
|
|
PHONY += project engines.languages searx.brand useragents.update
|
2020-03-01 07:56:46 +01:00
|
|
|
|
2020-03-26 13:32:08 +01:00
|
|
|
project: useragents.update engines.languages searx.brand
|
2020-03-01 07:56:46 +01:00
|
|
|
|
2020-03-26 13:32:08 +01:00
|
|
|
engines.languages: pyenvinstall
|
|
|
|
$(Q)echo "fetch languages .."
|
|
|
|
$(Q)$(PY_ENV_ACT); python utils/fetch_languages.py
|
|
|
|
$(Q)echo "update searx/data/engines_languages.json"
|
|
|
|
$(Q)mv engines_languages.json searx/data/engines_languages.json
|
|
|
|
$(Q)echo "update searx/languages.py"
|
|
|
|
$(Q)mv languages.py searx/languages.py
|
|
|
|
|
|
|
|
useragents.update: pyenvinstall
|
|
|
|
$(Q)echo "Update searx/data/useragents.json with the most recent versions of Firefox."
|
|
|
|
$(Q)$(PY_ENV_ACT); python utils/fetch_firefox_version.py
|
2020-03-01 07:56:46 +01:00
|
|
|
|
2020-03-25 11:49:33 +01:00
|
|
|
searx.brand:
|
|
|
|
$(Q)echo "build searx/brand.py"
|
|
|
|
$(Q)echo "GIT_URL = '$(GIT_URL)'" > searx/brand.py
|
2020-03-29 16:28:17 +02:00
|
|
|
$(Q)echo "GIT_BRANCH = '$(GIT_BRANCH)'" >> searx/brand.py
|
2020-03-26 10:58:25 +01:00
|
|
|
$(Q)echo "ISSUE_URL = 'https://github.com/asciimoo/searx/issues'" >> searx/brand.py
|
2020-03-25 11:49:33 +01:00
|
|
|
$(Q)echo "SEARX_URL = '$(SEARX_URL)'" >> searx/brand.py
|
|
|
|
$(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py
|
|
|
|
$(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py
|
2020-03-29 11:41:59 +02:00
|
|
|
$(Q)echo "build utils/brand.env"
|
|
|
|
$(Q)echo "export GIT_URL='$(GIT_URL)'" > utils/brand.env
|
2020-03-29 16:28:17 +02:00
|
|
|
$(Q)echo "export GIT_BRANCH='$(GIT_BRANCH)'" >> utils/brand.env
|
2020-03-29 11:41:59 +02:00
|
|
|
$(Q)echo "export ISSUE_URL='https://github.com/asciimoo/searx/issues'" >> utils/brand.env
|
|
|
|
$(Q)echo "export SEARX_URL='$(SEARX_URL)'" >> utils/brand.env
|
|
|
|
$(Q)echo "export DOCS_URL='$(DOCS_URL)'" >> utils/brand.env
|
|
|
|
$(Q)echo "export PUBLIC_INSTANCES='https://searx.space'" >> utils/brand.env
|
|
|
|
|
2020-03-25 11:49:33 +01:00
|
|
|
|
2020-03-25 16:38:52 +01:00
|
|
|
# node / npm
|
|
|
|
# ----------
|
|
|
|
|
|
|
|
node.env:
|
|
|
|
$(Q)./manage.sh npm_packages
|
|
|
|
|
|
|
|
node.clean:
|
|
|
|
$(Q)echo "CLEAN locally installed npm dependencies"
|
|
|
|
$(Q)rm -rf \
|
|
|
|
./node_modules \
|
|
|
|
./package-lock.json \
|
|
|
|
./searx/static/themes/oscar/package-lock.json \
|
|
|
|
./searx/static/themes/oscar/node_modules \
|
|
|
|
./searx/static/themes/simple/package-lock.json \
|
|
|
|
./searx/static/themes/simple/node_modules
|
|
|
|
|
2020-03-25 14:09:47 +01:00
|
|
|
# build themes
|
|
|
|
# ------------
|
|
|
|
|
2020-03-29 11:29:57 +02:00
|
|
|
PHONY += themes.bootstrap themes themes.oscar themes.simple themes.legacy themes.courgette themes.pixart
|
|
|
|
themes: themes.bootstrap themes.oscar themes.simple themes.legacy themes.courgette themes.pixart
|
2020-03-25 14:09:47 +01:00
|
|
|
|
2020-03-29 11:29:57 +02:00
|
|
|
quiet_cmd_lessc = LESSC $3
|
|
|
|
cmd_lessc = PATH="$$(npm bin):$$PATH" \
|
|
|
|
lessc --clean-css="--s1 --advanced --compatibility=ie9" "searx/static/$2" "searx/static/$3"
|
2020-03-25 14:09:47 +01:00
|
|
|
|
2020-03-29 11:29:57 +02:00
|
|
|
quiet_cmd_grunt = GRUNT $2
|
|
|
|
cmd_grunt = PATH="$$(npm bin):$$PATH" \
|
|
|
|
grunt --gruntfile "$2"
|
2020-03-26 18:00:07 +01:00
|
|
|
|
2020-03-29 11:29:57 +02:00
|
|
|
themes.oscar:
|
|
|
|
$(Q)echo '[!] build oscar theme'
|
|
|
|
$(call cmd,grunt,searx/static/themes/oscar/gruntfile.js)
|
2020-03-26 18:00:07 +01:00
|
|
|
|
2020-03-29 11:29:57 +02:00
|
|
|
themes.simple:
|
|
|
|
$(Q)echo '[!] build simple theme'
|
|
|
|
$(call cmd,grunt,searx/static/themes/simple/gruntfile.js)
|
2020-03-26 18:00:07 +01:00
|
|
|
|
2020-03-29 11:29:57 +02:00
|
|
|
themes.legacy:
|
|
|
|
$(Q)echo '[!] build legacy theme'
|
2020-03-26 18:00:07 +01:00
|
|
|
$(call cmd,lessc,themes/legacy/less/style-rtl.less,themes/legacy/css/style-rtl.css)
|
|
|
|
$(call cmd,lessc,themes/legacy/less/style.less,themes/legacy/css/style.css)
|
|
|
|
|
2020-03-29 11:29:57 +02:00
|
|
|
themes.courgette:
|
|
|
|
$(Q)echo '[!] build courgette theme'
|
2020-03-26 18:00:07 +01:00
|
|
|
$(call cmd,lessc,themes/courgette/less/style.less,themes/courgette/css/style.css)
|
|
|
|
$(call cmd,lessc,themes/courgette/less/style-rtl.less,themes/courgette/css/style-rtl.css)
|
|
|
|
|
2020-03-29 11:29:57 +02:00
|
|
|
themes.pixart:
|
|
|
|
$(Q)echo '[!] build pixart theme'
|
2020-03-26 18:00:07 +01:00
|
|
|
$(call cmd,lessc,themes/pix-art/less/style.less,themes/pix-art/css/style.css)
|
|
|
|
|
2020-03-29 11:29:57 +02:00
|
|
|
themes.bootstrap:
|
2020-03-26 18:00:07 +01:00
|
|
|
$(call cmd,lessc,less/bootstrap/bootstrap.less,css/bootstrap.min.css)
|
|
|
|
|
|
|
|
|
2020-03-25 14:50:39 +01:00
|
|
|
# docker
|
|
|
|
# ------
|
|
|
|
|
|
|
|
PHONY += docker
|
|
|
|
docker:
|
|
|
|
$(Q)./manage.sh docker_build
|
|
|
|
|
2020-03-26 18:41:45 +01:00
|
|
|
# gecko
|
|
|
|
# -----
|
|
|
|
|
|
|
|
PHONY += gecko.driver
|
|
|
|
gecko.driver:
|
|
|
|
$(PY_ENV_ACT); ./manage.sh install_geckodriver
|
2020-03-01 07:56:46 +01:00
|
|
|
|
2019-11-28 20:05:29 +01:00
|
|
|
# test
|
|
|
|
# ----
|
|
|
|
|
2020-03-29 13:03:27 +02:00
|
|
|
PHONY += test test.sh test.pylint test.pep8 test.unit test.coverage test.robot
|
2020-03-26 18:41:45 +01:00
|
|
|
test: test.pylint test.pep8 test.unit gecko.driver test.robot
|
2020-02-23 20:52:00 +01:00
|
|
|
|
2019-11-28 20:07:10 +01:00
|
|
|
# TODO: balance linting with pylint
|
2020-02-25 11:27:08 +01:00
|
|
|
|
2020-02-24 08:14:09 +01:00
|
|
|
test.pylint: pyenvinstall
|
2020-03-26 18:41:45 +01:00
|
|
|
$(call cmd,pylint,\
|
|
|
|
searx/preferences.py \
|
|
|
|
searx/testing.py \
|
|
|
|
)
|
|
|
|
|
|
|
|
# ignored rules:
|
|
|
|
# E402 module level import not at top of file
|
|
|
|
# W503 line break before binary operator
|
2019-11-28 20:05:29 +01:00
|
|
|
|
2020-03-08 18:37:16 +01:00
|
|
|
# ubu1604: uses shellcheck v0.3.7 (from 04/2015), no longer supported!
|
2020-01-08 18:09:36 +01:00
|
|
|
test.sh:
|
2020-01-08 18:13:22 +01:00
|
|
|
shellcheck -x utils/lib.sh
|
2020-01-08 19:21:07 +01:00
|
|
|
shellcheck -x utils/filtron.sh
|
2020-01-14 19:26:54 +01:00
|
|
|
shellcheck -x utils/searx.sh
|
2020-02-04 10:39:42 +01:00
|
|
|
shellcheck -x utils/morty.sh
|
2020-02-25 20:20:17 +01:00
|
|
|
shellcheck -x utils/lxc.sh
|
2020-03-07 20:24:08 +01:00
|
|
|
shellcheck -x utils/lxc-searx.env
|
2020-02-04 10:39:42 +01:00
|
|
|
shellcheck -x .config.sh
|
2020-01-08 18:09:36 +01:00
|
|
|
|
2019-11-28 20:05:29 +01:00
|
|
|
test.pep8: pyenvinstall
|
2020-03-26 18:41:45 +01:00
|
|
|
@echo "TEST pep8"
|
|
|
|
$(Q)$(PY_ENV_ACT); pep8 --exclude=searx/static --max-line-length=120 --ignore "E402,W503" searx tests
|
2019-11-28 20:05:29 +01:00
|
|
|
|
|
|
|
test.unit: pyenvinstall
|
2020-03-26 18:41:45 +01:00
|
|
|
@echo "TEST tests/unit"
|
|
|
|
$(Q)$(PY_ENV_ACT); python -m nose2 -s tests/unit
|
|
|
|
|
|
|
|
test.coverage: pyenvinstall
|
|
|
|
@echo "TEST unit test coverage"
|
|
|
|
$(Q)$(PY_ENV_ACT); \
|
|
|
|
python -m nose2 -C --log-capture --with-coverage --coverage searx -s tests/unit \
|
|
|
|
&& coverage report \
|
|
|
|
&& coverage html \
|
|
|
|
|
|
|
|
test.robot: pyenvinstall gecko.driver
|
|
|
|
@echo "TEST robot"
|
|
|
|
$(Q)$(PY_ENV_ACT); PYTHONPATH=. python searx/testing.py robot
|
|
|
|
|
|
|
|
test.clean:
|
|
|
|
@echo "CLEAN intermediate test stuff"
|
|
|
|
$(Q)rm -rf geckodriver.log .coverage coverage/
|
2019-11-28 20:05:29 +01:00
|
|
|
|
2019-11-28 19:54:57 +01:00
|
|
|
.PHONY: $(PHONY)
|