1-include ../../../petsckdir.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 54.PHONY: docs docs-html docs-pdf docs-misc 55docs: docs-html docs-pdf docs-misc 56docs-html: rst2html sphinx-html epydoc-html 57docs-pdf: sphinx-pdf epydoc-pdf 58docs-misc: sphinx-man sphinx-info 59 60#it appears some of the documentation requires a python2 installation to build 61PYTHON2 = python2 62 63checkdocutils: 64 @${PYTHON} -c $$'try:\n import docutils\nexcept:\n print("Run python -m pip install docutils and then try this command again");exit(1)' 65 @${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)' 66 @${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)' 67 68RST2HTML = $(shell command -v rst2html || command -v rst2html.py || false) 69RST2HTMLOPTS = --input-encoding=utf-8 70RST2HTMLOPTS += --no-compact-lists 71RST2HTMLOPTS += --cloak-email-addresses 72.PHONY: rst2html 73rst2html: checkdocutils 74 ${RST2HTML} ${RST2HTMLOPTS} ./LICENSE.rst > docs/LICENSE.html 75 ${RST2HTML} ${RST2HTMLOPTS} ./CHANGES.rst > docs/CHANGES.html 76 ${RST2HTML} ${RST2HTMLOPTS} docs/index.rst > docs/index.html 77 78SPHINXBUILD = sphinx-build 79SPHINXOPTS = 80.PHONY: sphinx sphinx-html sphinx-pdf sphinx-man sphinx-info 81sphinx: sphinx-html sphinx-pdf sphinx-man sphinx-info 82sphinx-html: 83 mkdir -p build/doctrees docs/usrman 84 ${SPHINXBUILD} -b html -d build/doctrees ${SPHINXOPTS} \ 85 docs/source docs/usrman 86 ${RM} docs/usrman/.buildinfo 87sphinx-pdf: 88 mkdir -p build/doctrees build/latex 89 ${SPHINXBUILD} -b latex -d build/doctrees ${SPHINXOPTS} \ 90 docs/source build/latex 91 ${MAKE} -C build/latex all-pdf > /dev/null 92 mv build/latex/*.pdf docs/ 93sphinx-man: 94 mkdir -p build/doctrees build/man 95 ${SPHINXBUILD} -b man -d build/doctrees ${SPHINXOPTS} \ 96 docs/source build/man 97 mv build/man/*.[137] docs/ 98sphinx-info: 99 mkdir -p build/doctrees build/texinfo 100 ${SPHINXBUILD} -b texinfo -d build/doctrees ${SPHINXOPTS} \ 101 docs/source build/texinfo 102 ${MAKE} -C build/texinfo info > /dev/null 103 mv build/texinfo/*.info docs/ 104 105EPYDOCBUILD = ${PYTHON2} ./conf/epydocify.py 106EPYDOCOPTS = 107.PHONY: epydoc epydoc-html epydoc-pdf 108epydoc: epydoc-html epydoc-pdf 109epydoc-html: srcbuild 110 mkdir -p docs/apiref 111 env CFLAGS=-O0 ${PYTHON2} setup.py -q build --build-lib build/lib.py2 112 env PYTHONPATH=$$PWD/build/lib.py2 ${PYTHON2} -c 'import ${package}.${MODULE}' 113 env PYTHONPATH=$$PWD/build/lib.py2 ${EPYDOCBUILD} ${EPYDOCOPTS} --html -o docs/apiref 114epydoc-pdf: 115 116.PHONY: docsclean 117docsclean: 118 -${RM} docs/*.info docs/*.[137] 119 -${RM} docs/*.html docs/*.pdf 120 -${RM} -r docs/usrman docs/apiref 121 122# ---- 123 124.PHONY: sdist 125sdist: srcbuild docs 126 ${PYTHON} setup.py sdist ${SDISTOPT} 127 128# ---- 129