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