Makefile 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. PYTHON?=python
  2. PYTHON3?=python3
  3. TESTFLAGS=-p -v
  4. TESTOPTS=
  5. SETUPFLAGS=
  6. LXMLVERSION=`cat version.txt`
  7. PYTHON_WITH_CYTHON=$(shell $(PYTHON) -c 'import Cython.Compiler' >/dev/null 2>/dev/null && echo " --with-cython" || true)
  8. PY3_WITH_CYTHON=$(shell $(PYTHON3) -c 'import Cython.Compiler' >/dev/null 2>/dev/null && echo " --with-cython" || true)
  9. all: inplace
  10. # Build in-place
  11. inplace:
  12. $(PYTHON) setup.py $(SETUPFLAGS) build_ext -i $(PYTHON_WITH_CYTHON) --warnings
  13. sdist:
  14. $(PYTHON) setup.py $(SETUPFLAGS) sdist $(PYTHON_WITH_CYTHON)
  15. build:
  16. $(PYTHON) setup.py $(SETUPFLAGS) build $(PYTHON_WITH_CYTHON)
  17. wheel:
  18. $(PYTHON) setup.py $(SETUPFLAGS) bdist_wheel $(PYTHON_WITH_CYTHON)
  19. wheel_static:
  20. $(PYTHON) setup.py $(SETUPFLAGS) bdist_wheel $(PYTHON_WITH_CYTHON) --static-deps
  21. test_build: build
  22. $(PYTHON) test.py $(TESTFLAGS) $(TESTOPTS)
  23. test_inplace: inplace
  24. $(PYTHON) test.py $(TESTFLAGS) $(TESTOPTS)
  25. PYTHONPATH=src:$(PYTHONPATH) $(PYTHON) selftest.py
  26. PYTHONPATH=src:$(PYTHONPATH) $(PYTHON) selftest2.py
  27. test_inplace3: inplace
  28. $(PYTHON3) setup.py $(SETUPFLAGS) build_ext -i $(PY3_WITH_CYTHON)
  29. $(PYTHON3) test.py $(TESTFLAGS) $(TESTOPTS)
  30. PYTHONPATH=src:$(PYTHONPATH) $(PYTHON3) selftest.py
  31. PYTHONPATH=src:$(PYTHONPATH) $(PYTHON3) selftest2.py
  32. valgrind_test_inplace: inplace
  33. valgrind --tool=memcheck --leak-check=full --num-callers=30 --suppressions=valgrind-python.supp \
  34. $(PYTHON) test.py
  35. gdb_test_inplace: inplace
  36. @echo -e "file $(PYTHON)\nrun test.py" > .gdb.command
  37. gdb -x .gdb.command -d src -d src/lxml
  38. bench_inplace: inplace
  39. $(PYTHON) benchmark/bench_etree.py -i
  40. $(PYTHON) benchmark/bench_xpath.py -i
  41. $(PYTHON) benchmark/bench_xslt.py -i
  42. $(PYTHON) benchmark/bench_objectify.py -i
  43. ftest_build: build
  44. $(PYTHON) test.py -f $(TESTFLAGS) $(TESTOPTS)
  45. ftest_inplace: inplace
  46. $(PYTHON) test.py -f $(TESTFLAGS) $(TESTOPTS)
  47. apihtml: inplace
  48. rm -fr doc/html/api
  49. @[ -x "`which epydoc`" ] \
  50. && (cd src && echo "Generating API docs ..." && \
  51. PYTHONPATH=. epydoc -v --docformat "restructuredtext en" \
  52. -o ../doc/html/api --exclude='[.]html[.]tests|[.]_' \
  53. --exclude-introspect='[.]usedoctest' \
  54. --name "lxml API" --url / lxml/) \
  55. || (echo "not generating epydoc API documentation")
  56. website: inplace
  57. PYTHONPATH=src:$(PYTHONPATH) $(PYTHON) doc/mkhtml.py doc/html . ${LXMLVERSION}
  58. html: inplace website apihtml s5
  59. s5:
  60. $(MAKE) -C doc/s5 slides
  61. apipdf: inplace
  62. rm -fr doc/pdf
  63. mkdir -p doc/pdf
  64. @[ -x "`which epydoc`" ] \
  65. && (cd src && echo "Generating API docs ..." && \
  66. PYTHONPATH=. epydoc -v --latex --docformat "restructuredtext en" \
  67. -o ../doc/pdf --exclude='([.]html)?[.]tests|[.]_' \
  68. --exclude-introspect='html[.]clean|[.]usedoctest' \
  69. --name "lxml API" --url / lxml/) \
  70. || (echo "not generating epydoc API documentation")
  71. pdf: apipdf
  72. $(PYTHON) doc/mklatex.py doc/pdf . ${LXMLVERSION}
  73. (cd doc/pdf && pdflatex lxmldoc.tex \
  74. && pdflatex lxmldoc.tex \
  75. && pdflatex lxmldoc.tex)
  76. @cp doc/pdf/lxmldoc.pdf doc/pdf/lxmldoc-${LXMLVERSION}.pdf
  77. @echo "PDF available as doc/pdf/lxmldoc-${LXMLVERSION}.pdf"
  78. # Two pdflatex runs are needed to build the correct Table of contents.
  79. test: test_inplace
  80. test3: test_inplace3
  81. valtest: valgrind_test_inplace
  82. gdbtest: gdb_test_inplace
  83. bench: bench_inplace
  84. ftest: ftest_inplace
  85. clean:
  86. find . \( -name '*.o' -o -name '*.so' -o -name '*.py[cod]' -o -name '*.dll' \) -exec rm -f {} \;
  87. rm -rf build
  88. docclean:
  89. $(MAKE) -C doc/s5 clean
  90. rm -f doc/html/*.html
  91. rm -fr doc/html/api
  92. rm -fr doc/pdf
  93. realclean: clean docclean
  94. find src -name '*.c' -exec rm -f {} \;
  95. rm -f TAGS
  96. $(PYTHON) setup.py clean -a --without-cython