Makefile 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. # -*- coding: utf-8; mode: makefile-gmake -*-
  2. .DEFAULT_GOAL=help
  3. include ./.config.mk
  4. include utils/makefile.include
  5. PYOBJECTS = searx
  6. DOC = docs
  7. PY_SETUP_EXTRAS ?= \[test\]
  8. include utils/makefile.python
  9. include utils/makefile.sphinx
  10. all: clean install
  11. PHONY += help-min help-all help
  12. help: help-min
  13. @echo ''
  14. @echo 'to get more help: make help-all'
  15. help-min:
  16. @echo ' test - run developer tests'
  17. @echo ' docs - build documentation'
  18. @echo ' docs-live - autobuild HTML documentation while editing'
  19. @echo ' run - run developer instance'
  20. @echo ' install - developer install (./local)'
  21. @echo ' uninstall - uninstall (./local)'
  22. @echo ' gh-pages - build docs & deploy on gh-pages branch'
  23. @echo ' clean - drop builds and environments'
  24. @echo ' project - re-build generic files of the searx project'
  25. @echo ' themes - re-build build the source of the themes'
  26. @echo ' docker - build Docker image'
  27. @echo ' node.env - download & install npm dependencies locally'
  28. @echo ''
  29. @echo 'environment'
  30. @echo ' SEARX_URL = $(SEARX_URL)'
  31. @echo ' GIT_URL = $(GIT_URL)'
  32. @echo ' DOCS_URL = $(DOCS_URL)'
  33. @echo ''
  34. @$(MAKE) -e -s make-help
  35. help-all: help-min
  36. @echo ''
  37. @$(MAKE) -e -s python-help
  38. @echo ''
  39. @$(MAKE) -e -s docs-help
  40. PHONY += install
  41. install: pyenvinstall
  42. PHONY += uninstall
  43. uninstall: pyenvuninstall
  44. PHONY += clean
  45. clean: pyclean docs-clean node.clean test.clean
  46. $(call cmd,common_clean)
  47. PHONY += run
  48. run: pyenvinstall
  49. $(Q) ( \
  50. sed -i -e "s/debug : False/debug : True/g" ./searx/settings.yml ; \
  51. sleep 2 ; \
  52. xdg-open http://127.0.0.1:8888/ ; \
  53. sleep 3 ; \
  54. sed -i -e "s/debug : True/debug : False/g" ./searx/settings.yml ; \
  55. ) &
  56. $(PY_ENV)/bin/python ./searx/webapp.py
  57. # docs
  58. # ----
  59. PHONY += docs
  60. docs: pyenvinstall sphinx-doc prebuild-includes
  61. $(call cmd,sphinx,html,docs,docs)
  62. PHONY += docs-live
  63. docs-live: pyenvinstall sphinx-live prebuild-includes
  64. $(call cmd,sphinx_autobuild,html,docs,docs)
  65. prebuild-includes:
  66. @mkdir -p $(DOCS_BUILD)/includes
  67. @./utils/searx.sh doc | cat > $(DOCS_BUILD)/includes/searx.rst
  68. @./utils/filtron.sh doc | cat > $(DOCS_BUILD)/includes/filtron.rst
  69. @./utils/morty.sh doc | cat > $(DOCS_BUILD)/includes/morty.rst
  70. $(GH_PAGES)::
  71. @echo "doc available at --> $(DOCS_URL)"
  72. # update project files
  73. # --------------------
  74. PHONY += project engines.languages searx.brand useragents.update
  75. project: useragents.update engines.languages searx.brand
  76. engines.languages: pyenvinstall
  77. $(Q)echo "fetch languages .."
  78. $(Q)$(PY_ENV_ACT); python utils/fetch_languages.py
  79. $(Q)echo "update searx/data/engines_languages.json"
  80. $(Q)mv engines_languages.json searx/data/engines_languages.json
  81. $(Q)echo "update searx/languages.py"
  82. $(Q)mv languages.py searx/languages.py
  83. useragents.update: pyenvinstall
  84. $(Q)echo "Update searx/data/useragents.json with the most recent versions of Firefox."
  85. $(Q)$(PY_ENV_ACT); python utils/fetch_firefox_version.py
  86. searx.brand:
  87. $(Q)echo "build searx/brand.py"
  88. $(Q)echo "GIT_URL = '$(GIT_URL)'" > searx/brand.py
  89. $(Q)echo "ISSUE_URL = 'https://github.com/asciimoo/searx/issues'" >> searx/brand.py
  90. $(Q)echo "SEARX_URL = '$(SEARX_URL)'" >> searx/brand.py
  91. $(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py
  92. $(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py
  93. $(Q)echo "build utils/brand.env"
  94. $(Q)echo "export GIT_URL='$(GIT_URL)'" > utils/brand.env
  95. $(Q)echo "export ISSUE_URL='https://github.com/asciimoo/searx/issues'" >> utils/brand.env
  96. $(Q)echo "export SEARX_URL='$(SEARX_URL)'" >> utils/brand.env
  97. $(Q)echo "export DOCS_URL='$(DOCS_URL)'" >> utils/brand.env
  98. $(Q)echo "export PUBLIC_INSTANCES='https://searx.space'" >> utils/brand.env
  99. # node / npm
  100. # ----------
  101. node.env:
  102. $(Q)./manage.sh npm_packages
  103. node.clean:
  104. $(Q)echo "CLEAN locally installed npm dependencies"
  105. $(Q)rm -rf \
  106. ./node_modules \
  107. ./package-lock.json \
  108. ./searx/static/themes/oscar/package-lock.json \
  109. ./searx/static/themes/oscar/node_modules \
  110. ./searx/static/themes/simple/package-lock.json \
  111. ./searx/static/themes/simple/node_modules
  112. # build themes
  113. # ------------
  114. PHONY += themes.bootstrap themes themes.oscar themes.simple themes.legacy themes.courgette themes.pixart
  115. themes: themes.bootstrap themes.oscar themes.simple themes.legacy themes.courgette themes.pixart
  116. quiet_cmd_lessc = LESSC $3
  117. cmd_lessc = PATH="$$(npm bin):$$PATH" \
  118. lessc --clean-css="--s1 --advanced --compatibility=ie9" "searx/static/$2" "searx/static/$3"
  119. quiet_cmd_grunt = GRUNT $2
  120. cmd_grunt = PATH="$$(npm bin):$$PATH" \
  121. grunt --gruntfile "$2"
  122. themes.oscar:
  123. $(Q)echo '[!] build oscar theme'
  124. $(call cmd,grunt,searx/static/themes/oscar/gruntfile.js)
  125. themes.simple:
  126. $(Q)echo '[!] build simple theme'
  127. $(call cmd,grunt,searx/static/themes/simple/gruntfile.js)
  128. themes.legacy:
  129. $(Q)echo '[!] build legacy theme'
  130. $(call cmd,lessc,themes/legacy/less/style-rtl.less,themes/legacy/css/style-rtl.css)
  131. $(call cmd,lessc,themes/legacy/less/style.less,themes/legacy/css/style.css)
  132. themes.courgette:
  133. $(Q)echo '[!] build courgette theme'
  134. $(call cmd,lessc,themes/courgette/less/style.less,themes/courgette/css/style.css)
  135. $(call cmd,lessc,themes/courgette/less/style-rtl.less,themes/courgette/css/style-rtl.css)
  136. themes.pixart:
  137. $(Q)echo '[!] build pixart theme'
  138. $(call cmd,lessc,themes/pix-art/less/style.less,themes/pix-art/css/style.css)
  139. themes.bootstrap:
  140. $(call cmd,lessc,less/bootstrap/bootstrap.less,css/bootstrap.min.css)
  141. # docker
  142. # ------
  143. PHONY += docker
  144. docker:
  145. $(Q)./manage.sh docker_build
  146. # gecko
  147. # -----
  148. PHONY += gecko.driver
  149. gecko.driver:
  150. $(PY_ENV_ACT); ./manage.sh install_geckodriver
  151. # test
  152. # ----
  153. PHONY += test test.sh test.pylint test.pep8 test.unit test.coverage test.robot
  154. test: test.pylint test.pep8 test.unit gecko.driver test.robot
  155. # TODO: balance linting with pylint
  156. test.pylint: pyenvinstall
  157. $(call cmd,pylint,\
  158. searx/preferences.py \
  159. searx/testing.py \
  160. )
  161. # ignored rules:
  162. # E402 module level import not at top of file
  163. # W503 line break before binary operator
  164. # ubu1604: uses shellcheck v0.3.7 (from 04/2015), no longer supported!
  165. test.sh:
  166. shellcheck -x utils/lib.sh
  167. shellcheck -x utils/filtron.sh
  168. shellcheck -x utils/searx.sh
  169. shellcheck -x utils/morty.sh
  170. shellcheck -x utils/lxc.sh
  171. shellcheck -x utils/lxc-searx.env
  172. shellcheck -x .config.sh
  173. test.pep8: pyenvinstall
  174. @echo "TEST pep8"
  175. $(Q)$(PY_ENV_ACT); pep8 --exclude=searx/static --max-line-length=120 --ignore "E402,W503" searx tests
  176. test.unit: pyenvinstall
  177. @echo "TEST tests/unit"
  178. $(Q)$(PY_ENV_ACT); python -m nose2 -s tests/unit
  179. test.coverage: pyenvinstall
  180. @echo "TEST unit test coverage"
  181. $(Q)$(PY_ENV_ACT); \
  182. python -m nose2 -C --log-capture --with-coverage --coverage searx -s tests/unit \
  183. && coverage report \
  184. && coverage html \
  185. test.robot: pyenvinstall gecko.driver
  186. @echo "TEST robot"
  187. $(Q)$(PY_ENV_ACT); PYTHONPATH=. python searx/testing.py robot
  188. test.clean:
  189. @echo "CLEAN intermediate test stuff"
  190. $(Q)rm -rf geckodriver.log .coverage coverage/
  191. .PHONY: $(PHONY)