PORTNAME=	bcftools
DISTVERSION=	1.25
CATEGORIES=	biology
MASTER_SITES=	https://github.com/samtools/${PORTNAME}/releases/download/${DISTVERSION}/

MAINTAINER=	freebsd@alteholz.de
COMMENT=	Tools for manipulating next-generation sequencing data
WWW=		https://www.htslib.org/ \
		https://github.com/samtools/bcftools/

LICENSE=	MIT
LICENSE_FILE=	${WRKSRC}/LICENSE

BUILD_DEPENDS=	htslib>=1.25:biology/htslib
LIB_DEPENDS=	libhts.so:biology/htslib
RUN_DEPENDS=	bash:shells/bash
TEST_DEPENDS=	bash:shells/bash

USES=		autoreconf gmake localbase python:env shebangfix tar:bz2

SHEBANG_FILES=	misc/*
SHEBANG_GLOB=	*.pl *.py *.sh

GNU_CONFIGURE=	yes
CONFIGURE_ARGS=	--with-htslib=system

TEST_TARGET=	test

OPTIONS_DEFINE=		GPL PERL
OPTIONS_DEFAULT=	GPL PERL

GPL_DESC=		Enable modules that rely on GPL code
PERL_DESC=		Enable external PERL scripts for advanced filtering

GPL_LIB_DEPENDS=	libgsl.so:math/gsl
GPL_CONFIGURE_ENABLE=	libgsl
GPL_MAKE_ENV=		USE_GPL=1
GPL_VARS=		LICENSE+=GPLv3+ \
			LICENSE_COMB=multi
PERL_USES=		perl5
PERL_CONFIGURE_ENABLE=	perl-filters

post-patch:
	@${REINPLACE_CMD} -e 's|@PORTVERSION@|${PORTVERSION}|g' \
		${WRKSRC}/configure.ac

post-install:
	${MV} ${STAGEDIR}${PREFIX}/bin/color-chrs.pl \
		${STAGEDIR}${PREFIX}/bin/color-chrs
	${MV} ${STAGEDIR}${PREFIX}/bin/guess-ploidy.py\
	       ${STAGEDIR}${PREFIX}/bin/guess-ploidy
	${MV} /${STAGEDIR}${PREFIX}/bin/plot-roh.py \
		${STAGEDIR}${PREFIX}/bin/plot-roh
	${MV} ${STAGEDIR}${PREFIX}/bin/run-roh.pl \
		${STAGEDIR}${PREFIX}/bin/run-roh
	${MV} ${STAGEDIR}${PREFIX}/bin/vcfutils.pl \
		${STAGEDIR}${PREFIX}/bin/vcfutils
	${MV} ${STAGEDIR}${PREFIX}/bin/plot-vcfstats \
		${STAGEDIR}${PREFIX}/bin/

.include <bsd.port.mk>
