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