1-include ../../../petscdir.mk 2.PHONY: default 3default: build 4 5package = petsc4py 6MODULE = PETSc 7 8PYTHON = python$(py) 9MPIEXEC = mpiexec 10 11# ---- 12 13.PHONY: config build test 14config: 15 ${PYTHON} setup.py config ${CONFIGOPT} ${opt} 16build: 17 ${PYTHON} setup.py build ${BUILDOPT} ${opt} 18test: 19 ${VALGRIND} ${PYTHON} ${PWD}/test/runtests.py ${TESTOPT} ${opt} 20test-%: 21 ${MPIEXEC} -n $* ${VALGRIND} ${PYTHON} ${PWD}/test/runtests.py ${TESTOPT} ${opt} 22 23.PHONY: srcbuild srcclean 24srcbuild: 25 ${PYTHON} setup.py build_src ${SRCOPT} ${opt} 26srcclean: 27 -${RM} src/${package}/${MODULE}.c 28 -${RM} src/${package}/${MODULE}.h 29 -${RM} src/${package}/${MODULE}_api.h 30 31.PHONY: clean distclean fullclean 32clean: 33 ${PYTHON} setup.py clean --all 34distclean: clean 35 -${RM} -r build _configtest.* *.py[co] 36 -${RM} -r MANIFEST dist ${package}.egg-info 37 -${RM} -r `find . -name '__pycache__'` 38 -${RM} `find . -name '*.py[co]'` 39fullclean: distclean srcclean docsclean 40 -find . -name '*~' -exec rm -f {} ';' 41 42# ---- 43 44.PHONY: install uninstall 45install: build 46 ${PYTHON} setup.py install --prefix='' --user ${INSTALLOPT} 47uninstall: 48 -${RM} -r $(shell ${PYTHON} -m site --user-site)/${package} 49 -${RM} -r $(shell ${PYTHON} -m site --user-site)/${package}-*-py*.egg-info 50 51# ---- 52 53website: 54 virtualenv -p ${PYTHON2} petsc-doc-env && . petsc-doc-env/bin/activate && ${PYTHON2} -m pip install -r docs/source/requirements.txt && make epydoc-website && deactivate 55 56.PHONY: docs docs-html docs-pdf docs-misc 57docs: docs-html docs-pdf docs-misc 58docs-html: rst2html sphinx-html epydoc-html 59docs-pdf: sphinx-pdf epydoc-pdf 60docs-misc: sphinx-man sphinx-info 61 62#it appears some of the documentation requires a python2 installation to build 63PYTHON2 = python2 64 65checkdocutils: 66 @${PYTHON} -c $$'try:\n import docutils\nexcept:\n print("Run `python -m pip install docutils` and then try this command again");exit(1)' 67 @${PYTHON2} -c $$'try:\n import docutils\nexcept:\n print("Run `python2 -m pip install docutils` or `pip2 install docutils` or `[sudo] easy_install docutils` and then try the command again");exit(1)' 68 @${PYTHON2} -c $$'try:\n import epydoc\nexcept:\n print("Run `python2 -m pip install epydoc` or `pip2 install epydoc` or `[sudo] easy_install epydoc` and then try the command again");exit(1)' 69 70RST2HTML = $(shell command -v rst2html || command -v rst2html.py || false) 71RST2HTMLOPTS = --input-encoding=utf-8 72RST2HTMLOPTS += --no-compact-lists 73RST2HTMLOPTS += --cloak-email-addresses 74.PHONY: rst2html 75rst2html: checkdocutils 76 ${RST2HTML} ${RST2HTMLOPTS} ./LICENSE.rst > docs/LICENSE.html 77 ${RST2HTML} ${RST2HTMLOPTS} ./CHANGES.rst > docs/CHANGES.html 78 ${RST2HTML} ${RST2HTMLOPTS} docs/index.rst > docs/index.html 79 80SPHINXBUILD = sphinx-build 81SPHINXOPTS = 82.PHONY: sphinx sphinx-html sphinx-pdf sphinx-man sphinx-info 83sphinx: sphinx-html sphinx-pdf sphinx-man sphinx-info 84sphinx-html: 85 mkdir -p build/doctrees docs/usrman 86 ${SPHINXBUILD} -b html -d build/doctrees ${SPHINXOPTS} \ 87 docs/source docs/usrman 88 ${RM} docs/usrman/.buildinfo 89sphinx-pdf: 90 mkdir -p build/doctrees build/latex 91 ${SPHINXBUILD} -b latex -d build/doctrees ${SPHINXOPTS} \ 92 docs/source build/latex 93 ${MAKE} -C build/latex all-pdf > /dev/null 94 mv build/latex/*.pdf docs/ 95sphinx-man: 96 mkdir -p build/doctrees build/man 97 ${SPHINXBUILD} -b man -d build/doctrees ${SPHINXOPTS} \ 98 docs/source build/man 99 mv build/man/*.[137] docs/ 100sphinx-info: 101 mkdir -p build/doctrees build/texinfo 102 ${SPHINXBUILD} -b texinfo -d build/doctrees ${SPHINXOPTS} \ 103 docs/source build/texinfo 104 ${MAKE} -C build/texinfo info > /dev/null 105 mv build/texinfo/*.info docs/ 106 107EPYDOCBUILD = ${PYTHON2} ./conf/epydocify.py 108EPYDOCOPTS = 109.PHONY: epydoc epydoc-html epydoc-pdf 110epydoc: epydoc-html epydoc-pdf 111epydoc-html: srcbuild 112 mkdir -p docs/apiref 113 env CFLAGS=-O0 ${PYTHON2} setup.py -q build --build-lib build/lib.py2 114 env PYTHONPATH=$$PWD/build/lib.py2 ${PYTHON2} -c 'import ${package}.${MODULE}' 115 env PYTHONPATH=$$PWD/build/lib.py2 ${EPYDOCBUILD} ${EPYDOCOPTS} --html -o docs/apiref 116epydoc-pdf: 117 118epydoc-website: 119 env CFLAGS=-O0 ${PYTHON2} setup.py -q build --build-lib build/lib.py2 120 env PYTHONPATH=$$PWD/build/lib.py2 ${PYTHON2} -c 'import ${package}.${MODULE}' 121 env PYTHONPATH=$$PWD/build/lib.py2 ${EPYDOCBUILD} ${EPYDOCOPTS} -q -q -q --html -o ${LOC}/petsc4py 122 123.PHONY: docsclean 124docsclean: 125 -${RM} docs/*.info docs/*.[137] 126 -${RM} docs/*.html docs/*.pdf 127 -${RM} -r docs/usrman docs/apiref 128 129# ---- 130 131.PHONY: sdist 132sdist: 133 ${PYTHON} setup.py sdist ${SDISTOPT} 134 135# ---- 136