Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. # -*- coding: utf-8; mode: makefile-gmake -*-
  2. export GIT_URL=https://github.com/asciimoo/searx
  3. export ISSUE_URL=$(GIT_URL)/issues
  4. export SEARX_URL=https://searx.me
  5. export DOCS_URL=https://asciimoo.github.io/searx
  6. PYOBJECTS = searx
  7. DOC = docs
  8. PY_SETUP_EXTRAS ?= \[test\]
  9. PYDIST=./dist/py
  10. PYBUILD=./build/py
  11. include utils/makefile.include
  12. include utils/makefile.python
  13. include utils/makefile.sphinx
  14. all: clean install
  15. PHONY += help
  16. help:
  17. @echo ' test - run developer tests'
  18. @echo ' docs - build documentation'
  19. @echo ' docs-live - autobuild HTML documentation while editing'
  20. @echo ' run - run developer instance'
  21. @echo ' install - developer install (./local)'
  22. @echo ' uninstall - uninstall (./local)'
  23. @echo ' gh-pages - build docs & deploy on gh-pages branch'
  24. @echo ' clean - drop builds and environments'
  25. @echo ' project - re-build generic files of the searx project'
  26. @echo ' themes - re-build build the source of the themes'
  27. @echo ' docker - build Docker image'
  28. @echo ' node.env - download & install npm dependencies locally'
  29. @echo ''
  30. @$(MAKE) -s -f utils/makefile.include make-help
  31. @echo ''
  32. @$(MAKE) -s -f utils/makefile.python python-help
  33. PHONY += install
  34. install: pyenvinstall
  35. PHONY += uninstall
  36. uninstall: pyenvuninstall
  37. PHONY += clean
  38. clean: pyclean node.clean
  39. $(call cmd,common_clean)
  40. PHONY += run
  41. run: pyenvinstall
  42. $(Q) ( \
  43. sed -i -e "s/debug : False/debug : True/g" ./searx/settings.yml ; \
  44. sleep 2 ; \
  45. xdg-open http://127.0.0.1:8888/ ; \
  46. sleep 3 ; \
  47. sed -i -e "s/debug : True/debug : False/g" ./searx/settings.yml ; \
  48. ) &
  49. $(PY_ENV)/bin/python ./searx/webapp.py
  50. # docs
  51. # ----
  52. PHONY += docs
  53. docs: pyenvinstall sphinx-doc
  54. $(call cmd,sphinx,html,docs,docs)
  55. PHONY += docs-live
  56. docs-live: pyenvinstall sphinx-live
  57. $(call cmd,sphinx_autobuild,html,docs,docs)
  58. $(GH_PAGES)::
  59. @echo "doc available at --> $(DOCS_URL)"
  60. # update project files
  61. # --------------------
  62. PHONY += project engines-languages searx.brand
  63. project: searx/data/engines_languages.json searx.brand
  64. engines-languages: pyenvinstall
  65. $(PY_ENV_ACT); python utils/fetch_languages.py
  66. mv engines_languages.json searx/data/engines_languages.json
  67. mv languages.py searx/languages.py
  68. searx.brand:
  69. $(Q)echo "build searx/brand.py"
  70. $(Q)echo "GIT_URL = '$(GIT_URL)'" > searx/brand.py
  71. $(Q)echo "ISSUE_URL = '$(ISSUE_URL)'" >> searx/brand.py
  72. $(Q)echo "SEARX_URL = '$(SEARX_URL)'" >> searx/brand.py
  73. $(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py
  74. $(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py
  75. # node / npm
  76. # ----------
  77. node.env:
  78. $(Q)./manage.sh npm_packages
  79. node.clean:
  80. $(Q)echo "CLEAN locally installed npm dependencies"
  81. $(Q)rm -rf \
  82. ./node_modules \
  83. ./package-lock.json \
  84. ./searx/static/themes/oscar/package-lock.json \
  85. ./searx/static/themes/oscar/node_modules \
  86. ./searx/static/themes/simple/package-lock.json \
  87. ./searx/static/themes/simple/node_modules
  88. # build themes
  89. # ------------
  90. PHONY += themes themes.oscar themes.simple
  91. themes: themes.oscar themes.simple
  92. themes.oscar:
  93. $(Q)echo '[!] Grunt build : oscar theme'
  94. $(Q)PATH="$$(npm bin):$$PATH" grunt --gruntfile "searx/static/themes/oscar/gruntfile.js"
  95. themes.simple:
  96. $(Q)echo '[!] Grunt build : simple theme'
  97. $(Q)PATH="$$(npm bin):$$PATH" grunt --gruntfile "searx/static/themes/simple/gruntfile.js"
  98. # docker
  99. # ------
  100. PHONY += docker
  101. docker:
  102. $(Q)./manage.sh docker_build
  103. # test
  104. # ----
  105. PHONY += test test.pylint test.pep8 test.unit test.robot
  106. test: test.pylint test.pep8 test.unit test.robot
  107. # TODO: balance linting with pylint
  108. test.pylint: pyenvinstall
  109. $(call cmd,pylint,searx/preferences.py)
  110. $(call cmd,pylint,searx/testing.py)
  111. test.pep8: pyenvinstall
  112. $(PY_ENV_ACT); ./manage.sh pep8_check
  113. test.unit: pyenvinstall
  114. $(PY_ENV_ACT); ./manage.sh unit_tests
  115. test.robot: pyenvinstall
  116. $(PY_ENV_ACT); ./manage.sh install_geckodriver
  117. $(PY_ENV_ACT); ./manage.sh robot_tests
  118. .PHONY: $(PHONY)