# New ports collection makefile for:	quantis
# Date created:			10 May 2010
# Whom:				Alex Dupre <ale@FreeBSD.org>
#
# $FreeBSD$
#

PORTNAME=	quantis
DISTVERSION=	v10.05.10
CATEGORIES=	security devel java
MASTER_SITES=	http://www.idquantique.com/files/products/quantis/ \
		${MASTER_SITE_LOCAL}
MASTER_SITE_SUBDIR=	ale

MAINTAINER=	ale@FreeBSD.org
COMMENT=	Libraries and utilities to access Quantis devices

OPTIONS=	PCI "Enable Quantis PCI support (FreeBSD >= 7.0)" on \
		USB "Enable Quantis USB support (FreeBSD >= 8.1)" on \
		JAVA "Enable Java support" on \
		TOOL "Build EasyQuantis CLI/GUI tool" on

USE_ZIP=	yes
EXTRACT_BEFORE_ARGS=	-aqo
USE_CMAKE=	yes
USE_QT_VER=	4
USE_LDCONFIG=	yes

WRKSRC=		${WRKDIR}/Quantis-${DISTVERSION}/Libs-Apps

KMODDIR?=	/boot/modules

PORTDOCS=	*
PORTEXAMPLES=	*

.if defined(WITH_DEBUG)
CMAKE_BUILD_TYPE=Debug
.endif

.include <bsd.port.pre.mk>

.if defined(WITH_PCI) && ${OSVERSION} >= 700000
RUN_DEPENDS+=	${KMODDIR}/quantis.ko:${PORTSDIR}/security/quantis-kmod
.else
CMAKE_ARGS+=	-DDISABLE_QUANTIS_PCI=ON
.endif

.if defined(WITH_USB) && ${OSVERSION} >= 801000
CMAKE_ARGS+=	-DUSB1_INCLUDE_DIR=/usr/include \
		-DUSB1_LIBRARY=/usr/lib/libusb.so
.else
CMAKE_ARGS+=	-DDISABLE_QUANTIS_USB=ON
.endif

.if defined(WITH_JAVA)
USE_JAVA=	yes
CMAKE_ARGS+=	-DJAVA_INCLUDE_PATH=${JAVA_HOME}/include \
		-DJAVA_INCLUDE_PATH2=${JAVA_HOME}/include/freebsd \
		-DJAVA_AWT_INCLUDE_PATH=${JAVA_HOME}/include
.else
CMAKE_ARGS+=	-DDISABLE_QUANTIS_JAVA=ON
.endif

.if defined(WITH_TOOL)
QT_COMPONENTS+=	gui moc_build uic_build rcc_build qmake_build
BUILD_DEPENDS+=	${LOCALBASE}/lib/libboost_date_time.a:${PORTSDIR}/devel/boost-libs
CXXFLAGS+=	-I${LOCALBASE}/include

PLIST_SUB+=	TOOL=""
.else
PLIST_SUB+=	TOOL="@comment "
.endif

post-patch:
	${REINPLACE_CMD} '/if(CMAKE_COMPILER_IS_GNU/s/)/ MATCHES "0")/' \
		${WRKSRC}/CMakeLists.txt
.if defined(WITHOUT_TOOL)
	${REINPLACE_CMD} '/add_subdirectory (EasyQuantis)/s/^/#/' \
		${WRKSRC}/CMakeLists.txt
.endif

post-install:
.if !defined(WITHOUT_PORTDOCS)
	@${MKDIR} ${DOCSDIR}
	@${INSTALL_DATA} ${WRKSRC}/../User_Manual.pdf ${DOCSDIR}
.endif
.if !defined(WITHOUT_PORTEXAMPLES)
	@${MKDIR} ${EXAMPLESDIR}
	@(cd ${WRKSRC}/../Samples; ${COPYTREE_SHARE} . ${EXAMPLESDIR})
.if defined(WITH_USB) && ${OSVERSION} >= 801000
	@${MKDIR} ${EXAMPLESDIR}/devd
	${INSTALL_DATA} ${FILESDIR}/quantis.conf ${EXAMPLESDIR}/devd
	@${CAT} ${PKGMESSAGE}
.endif
.endif

.include <bsd.port.post.mk>
