# Created by: John Marino <draco@marino.st>
# $FreeBSD: branches/RELEASE_8_4_0/www/aws/Makefile 314915 2013-03-22 11:53:34Z bapt $

PORTNAME=	aws
PORTVERSION=	2.10.0
CATEGORIES=	www
MASTER_SITES=	http://downloads.dragonlace.net/src/ \
		http://dragonlace.mirrors.ada.cx/src/

MAINTAINER=	draco@marino.st
COMMENT=	Adacore Ada Web Server and framework

BUILD_DEPENDS=	gnat-aux>=20101204:${PORTSDIR}/lang/gnat-aux \
		gprbuild-aux>=20101120:${PORTSDIR}/devel/gprbuild-aux \
		xmlada>=3.2:${PORTSDIR}/textproc/xmlada \
		gnatpython>=20101207:${PORTSDIR}/devel/gnatpython

USE_PYTHON=	yes
USE_BZIP2=	yes
GNU_CONFIGURE=	yes
USE_GMAKE=	yes
USE_LDCONFIG=	yes
CC=		gnatgcc
DOTBUILD=	release
MAKE_ENV+=	ADA_PROJECT_PATH=${PREFIX}/lib/gnat

OPTIONS_DEFINE=	SSL IPV6 DEMOS DEBUG LDAP DSRT RELOC
OPTIONS_DEFAULT=	SSL
SSL_DESC=	Enable HTTPS/SSL support
DEMOS_DESC=	Build demo programs in examples/aws/demos
DSRT_DESC=	Disable shared runtime
RELOC_DESC=	Build shared libraries (default is static)

CONF_ARGS=	PROCESSORS=1
CONF_ARGS+=	GCC=gnatgcc
CONF_ARGS+=	PYTHON=python${PYTHON_VER}

.include <bsd.port.options.mk>

###################
##  SSL Support  ##
###################

.if ${PORT_OPTIONS:MSSL}
CONF_ARGS+=	SOCKET=openssl
BUILD_DEPENDS+=	openssl>=1:${PORTSDIR}/security/openssl
RUN_DEPENDS+=	openssl>=1:${PORTSDIR}/security/openssl
PLIST_SUB+=	YSSL=""
PLIST_SUB+=	NSSL="@comment "
.else
PLIST_SUB+=	YSSL="@comment "
PLIST_SUB+=	NSSL=""
.endif

####################
##  LDAP Support  ##
####################

.if ${PORT_OPTIONS:MLDAP}
CONF_ARGS+=	LDAP=true
RUN_DEPENDS+=	openldap24>=2.4:${PORTSDIR}/net/openldap24-client
.endif

####################
##  IPv6 Support  ##
####################

.if ${PORT_OPTIONS:MIPV6}
CONF_ARGS+=	IPv6=true
.endif

#####################
##  Debug Support  ##
#####################

.if ${PORT_OPTIONS:MDEBUG}
CONF_ARGS+=	DEBUG=true
.endif

##############################
##  Shared Runtime Library  ##
##############################

.if ${PORT_OPTIONS:MDSRT}
CONF_ARGS+=	ENABLE_SHARED=false
.endif

############################
##  Default Library Type  ##
############################

.if ${PORT_OPTIONS:MRELOC}
CONF_ARGS+=	DEFAULT_LIBRARY_TYPE=relocatable
.endif

#####################
##  DEMOS Support  ##
#####################

.if ${PORT_OPTIONS:MDEMOS}
DEMO_DIRS+=	agent
DEMO_DIRS+=	auth
DEMO_DIRS+=	com
DEMO_DIRS+=	dispatch
DEMO_DIRS+=	hello_world
DEMO_DIRS+=	hello_wsdl
DEMO_DIRS+=	hotplug
DEMO_DIRS+=	interoplab
DEMO_DIRS+=	jabber_demo
DEMO_DIRS+=	multiple_sessions
DEMO_DIRS+=	res_demo
DEMO_DIRS+=	runme
DEMO_DIRS+=	soap_demo
DEMO_DIRS+=	soap_disp
DEMO_DIRS+=	soap_vs
DEMO_DIRS+=	split
DEMO_DIRS+=	test_mail
DEMO_DIRS+=	text_input
DEMO_DIRS+=	vh_demo
DEMO_DIRS+=	web_block
DEMO_DIRS+=	web_block_ajax
DEMO_DIRS+=	web_block_ajax_templates
DEMO_DIRS+=	web_elements
DEMO_DIRS+=	web_mail
DEMO_DIRS+=	wps
DEMO_DIRS+=	ws
DEMO_DIRS+=	zdemo

.if ${PORT_OPTIONS:MLDAP}
DEMO_DIRS+=	test_ldap
PLIST_SUB+=	LDAP=""
.else
PLIST_SUB+=	LDAP="@comment "
.endif
PLIST_SUB+=	DEMO=""
.else
PLIST_SUB+=	DEMO="@comment "
PLIST_SUB+=	LDAP="@comment "
.endif

do-configure:
	cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} \
	${GMAKE} setup ${CONF_ARGS}

do-build:
	# docs are built, but the .pdf format is intentionally disabled
	# The taTeX dependency brings in ~100MB so it's not worth it.
	cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} build build_doc

test: install
	cd ${WRKSRC}/regtests && python${PYTHON_VER} testsuite.py

do-install:
	cd ${WRKSRC} && ${GMAKE} install
.if ${PORT_OPTIONS:MDEMOS}
	${MAKE} demos
	${MAKE} demos-install
.endif

demos:
.for dd in ${DEMO_DIRS}
	cd ${WRKSRC}/demos/${dd} && ${GMAKE}
.endfor

demos-install:
	${MKDIR} ${PREFIX}/share/examples/aws/demos
.for dd in ${DEMO_DIRS}
	${FIND} ${WRKSRC}/demos/${dd} -type f -perm -0001 \
	-exec ${INSTALL} {} ${PREFIX}/share/examples/aws/demos/ \;
.endfor

.include <bsd.port.mk>
