# $OpenBSD: Makefile.template,v 1.54 2008/01/13 16:43:57 espie Exp $

COMMENT-main=		mail indexer (and not much of an email program)
COMMENT-emacs=		Emacs bindings for notmuch
COMMENT-python=		Python 2 bindings for notmuch
COMMENT-python3=	Python 3 bindings for notmuch

V=			0.28.3
DISTNAME=		notmuch-${V}
PKGNAME-main=		notmuch-${V}
PKGNAME-emacs=		notmuch-emacs-${V}
PKGNAME-python=		py-notmuch-${V}
PKGNAME-python3=	py3-notmuch-${V}

SHARED_LIBS +=		notmuch 5.2 # XXX
# this should start with 0.0 and the build needs to follow what is set
# by ports - needs fixing in (at least) lib/notmuch.h and Makefile.local
# XXX

CATEGORIES=		mail databases

HOMEPAGE=		https://notmuchmail.org/
MASTER_SITES=		https://notmuchmail.org/releases/

# GPLv3+
PERMIT_PACKAGE_CDROM=	Yes

MULTI_PACKAGES=	-main -emacs -python -python3

WANTLIB-main += ${COMPILER_LIBCXX} c gio-2.0 glib-2.0 gmime-2.6 gobject-2.0
WANTLIB-main += intl m talloc xapian z

MODULES=	lang/python
MODPY_EGG_VERSION= ${V}
MODPY_VERSION=	${MODPY_DEFAULT_VERSION_3}
MODPY_RUNDEP=	No

BUILD_DEPENDS=	devel/doxygen \
		editors/emacs \
		lang/python/${MODPY_DEFAULT_VERSION_2} \
		lang/python/${MODPY_DEFAULT_VERSION_3} \
		textproc/py-sphinx

LIB_DEPENDS=	databases/xapian-core \
		devel/libtalloc \
		mail/gmime

RUN_DEPENDS-main=	devel/desktop-file-utils

RUN_DEPENDS-emacs=	devel/desktop-file-utils \
			editors/emacs \
			mail/notmuch

RUN_DEPENDS-python=	lang/python/${MODPY_DEFAULT_VERSION_2} \
			mail/notmuch

RUN_DEPENDS-python3=	lang/python/${MODPY_DEFAULT_VERSION_3} \
			mail/notmuch

USE_GMAKE=		Yes
MAKE_FLAGS=		V=1
NO_TEST=		Yes
CONFIGURE_STYLE=	simple
CONFIGURE_ARGS=		--mandir=${PREFIX}/man \
			--infodir=${PREFIX}/info \
			--sysconfdir=${SYSCONFDIR} \
			--bashcompletiondir=${PREFIX}/share/notmuch/bash_completion.d

post-build:
	@cd "${WRKBUILD}/bindings/python" && python2 setup.py build
	@cd "${WRKBUILD}/bindings/python" && python3 setup.py build

post-install:
	@cd "${WRKBUILD}/bindings/python" && python2 setup.py install --root="${WRKINST}"
	@cd "${WRKBUILD}/bindings/python" && python3 setup.py install --root="${WRKINST}"

.include <bsd.port.mk>
