# -*- makefile -*-

.PHONY: default tree-arch config src swig build install \
	home_install home_uninstall \
        install_home uninstall_home \
        insthome uinsthome \
        epydoc pylint \
	sdist \
	clean distclean

PYTHON=python
PACKAGE=petsc4py

default: build

tree-arch:
	-@for ARCH in ${PETSC_DIR}/lib/*; do \
	  PETSC_ARCH=`basename $$ARCH` $(MAKE) ${ACTION}; \
	 done;

all-arch:
	$(MAKE) ACTION=build tree-arch

config: 
	${PYTHON} setup.py config

src:
	${PYTHON} setup.py build_src

swig:
	${PYTHON} setup.py build_src --force

build:
	${PYTHON} setup.py build

test:
	${PYTHON} tests/runalltests.py

install: build
	su -c '${PYTHON} setup.py install'

sdist:
	${PYTHON} setup.py sdist

epydoc:
	${RM} -r /tmp/${PACKAGE}-doc
	epydoc --verbose --config=epydoc.cfg --output=/tmp/${PACKAGE}-doc
pylint:
	export PYLINTRC=${PWD}/pylint.cfg; \
	pylint --disable-msg=W0142,W0232,W1001,E1002 petsc/
#	pylint --rcfile ./pyling.cfg --disable-msg=W0142,W0232,W1001,E1002 petsc

home_install:
	${PYTHON} setup.py install --home=${HOME}
install_home: home_install
insthome: home_install

home_uninstall:
	-${RM} -r ${HOME}/lib/python/$(shell ${PYTHON} setup.py --name)
	-${RM} -r ${HOME}/lib/python/$(shell ${PYTHON} setup.py --name)-*-py*.egg-info

uninstall_home: home_uninstall
uinsthome:  home_uninstall


clean:
	${PYTHON} setup.py clean --all
	-${RM} configure/*.py[co]
	-${MAKE} -C docs clean


distclean: clean 
	-${RM} -r build
	-${RM} -r MANIFEST dist petsc4py.egg-info
	-${MAKE} -C docs distclean
	-${RM} `find . -name '*~'`
	-${RM} `find . -name '*.py[co]'`
