1PORTNAME=		openldap
2DISTVERSION=		2.6.13
3CATEGORIES=		net databases
4MASTER_SITES=		https://www.openldap.org/software/download/OpenLDAP/%SUBDIR%/ \
5			http://gpl.savoirfairelinux.net/pub/mirrors/openldap/%SUBDIR%/ \
6			http://repository.linagora.org/OpenLDAP/%SUBDIR%/ \
7			http://mirror.eu.oneandone.net/software/openldap/%SUBDIR%/ \
8			ftp://ftp.ntua.gr/mirror/OpenLDAP/%SUBDIR%/ \
9			https://mirror-hk.koddos.net/OpenLDAP/%SUBDIR%/ \
10			ftp://ftp.dti.ad.jp/pub/net/OpenLDAP/%SUBDIR%/ \
11			https://mirror.koddos.net/OpenLDAP/%SUBDIR%/ \
12			https://mirror.lyrahosting.com/OpenLDAP/%SUBDIR%/ \
13			ftp://ftp.OpenLDAP.org/pub/OpenLDAP/%SUBDIR%/ \
14			http://www.openldap.org/software/download/OpenLDAP/%SUBDIR%/
15MASTER_SITE_SUBDIR=	openldap-release
16.if defined(CLIENT_ONLY)
17PKGNAMESUFFIX=		26-client
18.else
19PKGNAMESUFFIX=		26-server
20.endif
21
22MAINTAINER=		ports@MidnightBSD.org
23WWW=		https://www.OpenLDAP.org/
24.if defined(CLIENT_ONLY)
25COMMENT=		Open source LDAP client implementation
26.else
27COMMENT=		Open source LDAP server implementation
28.endif
29
30LICENSE=		openldap2.8
31LICENSE_FILE=		${WRKSRC}/LICENSE
32
33# :keepla because port uses lt_dlopen
34USES=			cpe gmake libtool:keepla localbase ssl tar:tgz
35BUILD_DEPENDS+=		autoconf>0:devel/autoconf
36
37NO_TEST=	yes
38
39.if defined(CLIENT_ONLY)
40CONFLICTS_INSTALL=	${PORTNAME}2[0-57-9]-client ${PORTNAME}-client
41.else
42CONFLICTS_INSTALL=	${PORTNAME}2[0-57-9]-server ${PORTNAME}-server
43.endif
44
45GNU_CONFIGURE=		yes
46GNU_CONFIGURE_MANPREFIX=${PREFIX}/share
47
48PORTREVISION_CLIENT=	0
49PORTREVISION_SERVER=	1
50OPENLDAP_SHLIB_MAJOR=	2
51OPENLDAP_SHLIB_MINOR=	0.200
52
53OPTIONS_DEFINE=		DEBUG FETCH GSSAPI
54OPTIONS_DEFAULT+=	DEBUG
55
56FETCH_DESC=		Enable fetch(3) support
57GSSAPI_DESC=		With GSSAPI support
58
59FETCH_CONFIGURE_WITH=	fetch
60
61GSSAPI_RUN_DEPENDS=		cyrus-sasl-gssapi>0:security/cyrus-sasl2-gssapi
62
63.if defined(CLIENT_ONLY)
64OPTIONS_DEFINE+=	DOCS
65.else
66OPTIONS_GROUP=		BKNDS OVLYS
67BKNDS_DESC=		OpenLDAP backends
68BKNDS_DEFAULTS=		ASYNCMETA DNSSRV MDB PASSWD RELAY SOCK
69OPTIONS_GROUP_BKNDS+=	${BKNDS_DEFAULTS}
70OPTIONS_GROUP_BKNDS+=	PERL SQL
71
72OVLYS_DESC=		OpenLDAP overlays
73OPTIONS_GROUP_OVLYS+=	ACCESSLOG
74OPTIONS_GROUP_OVLYS+=	ADDPARTIAL
75OPTIONS_GROUP_OVLYS+=	ALLOP
76OPTIONS_GROUP_OVLYS+=	AUTOCA
77OPTIONS_GROUP_OVLYS+=	AUDITLOG
78OPTIONS_GROUP_OVLYS+=	AUTOGROUP
79OPTIONS_GROUP_OVLYS+=	CLOAK
80OPTIONS_GROUP_OVLYS+=	COLLECT
81OPTIONS_GROUP_OVLYS+=	CONSTRAINT
82OPTIONS_GROUP_OVLYS+=	DDS
83OPTIONS_GROUP_OVLYS+=	DENYOP
84OPTIONS_GROUP_OVLYS+=	DEREF
85OPTIONS_GROUP_OVLYS+=	DYNGROUP
86OPTIONS_GROUP_OVLYS+=	DYNLIST
87OPTIONS_GROUP_OVLYS+=	EMPTYDS
88OPTIONS_GROUP_OVLYS+=	HOMEDIR
89OPTIONS_GROUP_OVLYS+=	LASTBIND
90OPTIONS_GROUP_OVLYS+=	LASTMOD
91OPTIONS_GROUP_OVLYS+=	MEMBEROF
92OPTIONS_GROUP_OVLYS+=	NOPS
93OPTIONS_GROUP_OVLYS+=	NESTGROUP
94OPTIONS_GROUP_OVLYS+=	OTP
95OPTIONS_GROUP_OVLYS+=	PROXYCACHE
96OPTIONS_GROUP_OVLYS+=	PPOLICY
97OPTIONS_GROUP_OVLYS+=	REFINT
98OPTIONS_GROUP_OVLYS+=	REMOTEAUTH
99OPTIONS_GROUP_OVLYS+=	RETCODE
100OPTIONS_GROUP_OVLYS+=	RWM
101OPTIONS_GROUP_OVLYS+=	SEQMOD
102OPTIONS_GROUP_OVLYS+=	SHA2
103OPTIONS_GROUP_OVLYS+=	SMBPWD
104OPTIONS_GROUP_OVLYS+=	SSSVLV
105OPTIONS_GROUP_OVLYS+=	SYNCPROV
106OPTIONS_GROUP_OVLYS+=	TRACE
107OPTIONS_GROUP_OVLYS+=	TRANSLUCENT
108OPTIONS_GROUP_OVLYS+=	UNIQUE
109OPTIONS_GROUP_OVLYS+=	VALSORT
110
111OPTIONS_DEFINE+=	DYNACL ACI
112OPTIONS_DEFINE+=	RLOOKUPS SLP SLAPI
113OPTIONS_DEFINE+=	PBKDF2
114OPTIONS_DEFINE+=	OUTLOOK
115OPTIONS_DEFINE+=	ARGON2
116OPTIONS_DEFINE+=	LLOADD
117
118OPTIONS_DEFAULT+=	${BKNDS_DEFAULTS}
119OPTIONS_DEFAULT+=	${OPTIONS_GROUP_OVLYS}
120OPTIONS_DEFAULT+=	ARGON2 LLOADD
121
122OPTIONS_SUB=		yes
123
124ACI_DESC=		Per-object ACI (experimental)
125ARGON2_DESC=		Argon2 password hashing module
126DYNACL_DESC=		Run-time loadable ACL (experimental)
127LLOADD_DESC=		Enable load balancer
128OUTLOOK_DESC=		Force caseIgnoreOrderingMatch on name attribute (experimental)
129RLOOKUPS_DESC=		With reverse lookups of client hostnames
130SLAPI_DESC=		With Netscape SLAPI plugin API (experimental)
131SLP_DESC=		With SLPv2 (RFC 2608) support
132
133ASYNCMETA_DESC=		With asynchronous metadirectory backend
134DNSSRV_DESC=		With Dnssrv backend
135MDB_DESC=		With Memory-Mapped DB backend
136SQL_DESC=		With SQL backend
137PASSWD_DESC=		With Passwd backend
138PERL_DESC=		With Perl backend
139RELAY_DESC=		With Relay backend
140SOCK_DESC=		With Sock backend
141
142ACCESSLOG_DESC=		With In-Directory Access Logging overlay
143AUDITLOG_DESC=		With Audit Logging overlay
144AUTOCA_DESC=		With Automatic Certificate Authority overlay
145COLLECT_DESC=		With Collect overy Services overlay
146CONSTRAINT_DESC=	With Attribute Constraint overlay
147DDS_DESC=		With Dynamic Directory Services overlay
148DEREF_DESC=		With Dereference overlay
149DYNGROUP_DESC=		With Dynamic Group overlay
150DYNLIST_DESC=		With Dynamic List overlay
151HOMEDIR_DESC=		With Home Directory Management overlay
152MEMBEROF_DESC=		With Reverse Group Membership overlay
153NESTGROUP_DESC=		With nestgroup overlay
154NOPS_DESC=		With nops overlay
155OTP_DESC=		With OTP 2-factor authentication overlay
156PPOLICY_DESC=		With Password Policy overlay
157PROXYCACHE_DESC=	With Proxy Cache overlay
158REFINT_DESC=		With Referential Integrity overlay
159REMOTEAUTH_DESC=	With Deferred Authentication overlay
160RETCODE_DESC=		With Return Code testing overlay
161RWM_DESC=		With Rewrite/Remap overlay
162SEQMOD_DESC=		With Sequential Modify overlay
163SSSVLV_DESC=		With ServerSideSort/VLV overlay
164SYNCPROV_DESC=		With Syncrepl Provider overlay
165TRANSLUCENT_DESC=	With Translucent Proxy overlay
166UNIQUE_DESC=		With attribute Uniqueness overlay
167VALSORT_DESC=		With Value Sorting overlay
168
169ADDPARTIAL_DESC=	With addpartial overlay (experimental)
170ALLOP_DESC=		With allop overlay (experimental)
171AUTOGROUP_DESC=		With autogroup overlay (experimental)
172CLOAK_DESC=		With cloak overlay (experimental)
173DENYOP_DESC=		With denyop overlay (experimental)
174EMPTYDS_DESC=		With emptyds overlay (experimental)
175LASTBIND_DESC=		With lastbind overlay
176LASTMOD_DESC=		With lastmod overlay (experimental)
177TRACE_DESC=		With Trace overlay
178
179PBKDF2_DESC=		With PBKDF2 hash password support
180SHA2_DESC=		With SHA2 Password hashes overlay
181SMBPWD_DESC=		With Samba Password hashes overlay
182
183ACCESSLOG_CONFIGURE_ENABLE=	accesslog=mod
184ACI_CONFIGURE_ENABLE=		aci
185ARGON2_CONFIGURE_ENABLE=	argon2
186ARGON2_CONFIGURE_WITH=		argon2=libsodium
187ARGON2_LIB_DEPENDS=		libsodium.so:security/libsodium
188ASYNCMETA_CONFIGURE_ENABLE=	asyncmeta=mod
189AUDITLOG_CONFIGURE_ENABLE=	auditlog=mod
190AUTOCA_CONFIGURE_ENABLE=	autoca=mod
191COLLECT_CONFIGURE_ENABLE=	collect=mod
192CONSTRAINT_CONFIGURE_ENABLE=	constraint=mod
193DDS_CONFIGURE_ENABLE=		dds=mod
194DEBUG_CONFIGURE_ENABLE=		debug
195DEREF_CONFIGURE_ENABLE=		deref=mod
196DNSSRV_CONFIGURE_ENABLE=	dnssrv=mod
197DYNACL_CONFIGURE_ENABLE=	dynacl
198DYNGROUP_CONFIGURE_ENABLE=	dyngroup=mod
199DYNLIST_CONFIGURE_ENABLE=	dynlist=mod
200HOMEDIR_CONFIGURE_ENABLE=	homedir=mod
201LLOADD_CONFIGURE_ENABLE=	balancer=mod
202LLOADD_LIB_DEPENDS=		libevent.so:devel/libevent
203MDB_CONFIGURE_ENABLE=		mdb=yes
204MEMBEROF_CONFIGURE_ENABLE=	memberof=mod
205NESTGROUP_CONFIGURE_ENABLE=	nestgroup=mod
206OTP_CONFIGURE_ENABLE=		otp=mod
207PASSWD_CONFIGURE_ENABLE=	passwd=mod
208PERL_CONFIGURE_ENABLE=		perl=mod
209PERL_CONFIGURE_ENV=		PERLBIN="${PERL}"
210PERL_USES=			perl5
211PPOLICY_CONFIGURE_ENABLE=	ppolicy=mod
212PROXYCACHE_CONFIGURE_ENABLE=	proxycache=mod
213REFINT_CONFIGURE_ENABLE=	refint=mod
214RELAY_CONFIGURE_ENABLE=		relay=yes
215REMOTEAUTH_CONFIGURE_ENABLE=	remoteauth=mod
216RETCODE_CONFIGURE_ENABLE=	retcode=mod
217RLOOKUPS_CONFIGURE_ENABLE=	rlookups
218RWM_CONFIGURE_ENABLE=		rwm=mod
219SEQMOD_CONFIGURE_ENABLE=	seqmod=mod
220SLAPI_CONFIGURE_ENABLE=		slapi
221SLAPI_USE=			LDCONFIG
222SLP_CONFIGURE_ENABLE=		slp
223SLP_LIB_DEPENDS=		libslp.so:net/openslp
224SOCK_CONFIGURE_ENABLE=		sock=mod
225SQL_CONFIGURE_ENABLE=		sql=mod
226SQL_LDFLAGS=			-L${LOCALBASE}/lib
227SQL_LIB_DEPENDS=		libodbc.so:databases/unixODBC
228SSSVLV_CONFIGURE_ENABLE=	sssvlv=mod
229SYNCPROV_CONFIGURE_ENABLE=	syncprov=yes
230TRANSLUCENT_CONFIGURE_ENABLE=	translucent=mod
231UNIQUE_CONFIGURE_ENABLE=	unique=mod
232VALSORT_CONFIGURE_ENABLE=	valsort=mod
233
234# Force using caseIgnoreOrderingMatch on 'name' attribute.
235# This may be a violation of RFC 4519 2.18 definition.
236# See http://www.openldap.org/lists/openldap-technical/201211/msg00175.html
237OUTLOOK_EXTRA_PATCHES=		${FILESDIR}/extrapatch-outlook-servers__slapd__schema_prep.c
238.endif
239
240CONFIGURE_SED=		-e 's,uuid/uuid.h,xxuuid/uuid.h,g'
241
242.include <bsd.mport.options.mk>
243
244.if defined(CLIENT_ONLY)
245OPENLDAP_PORTREVISION=	${PORTREVISION_CLIENT}
246OPENLDAP_PKGFILESUFX=	.client
247
248PORTDOCS=		CHANGES drafts rfc
249
250CONFIGURE_ARGS+=	--disable-slapd \
251			--disable-monitor \
252			--disable-relay \
253			--disable-syncprov
254USE_LDCONFIG=		yes
255.else
256OPENLDAP_PORTREVISION=	${PORTREVISION_SERVER}
257OPENLDAP_PKGFILESUFX=
258
259LIB_DEPENDS+=		libicudata.so:devel/icu \
260			libldap.so:net/openldap26-client \
261			libltdl.so:devel/libltdl
262
263SUB_LIST+=		RC_DIR=${PREFIX} \
264			LDAP_RUN_DIR=${LDAP_RUN_DIR} \
265			DATABASEDIR=${DATABASEDIR}
266
267USERS=			ldap
268GROUPS=			ldap
269LDAP_USER?=		ldap
270LDAP_GROUP?=		ldap
271USE_LDCONFIG=		${PREFIX}/libexec/openldap
272SUB_FILES+=		pkg-deinstall
273USE_RC_SUBR=		slapd
274
275EXTRA_PATCHES+=		${FILESDIR}/extrapatch-Makefile.in
276
277LDFLAGS+=		-L${LOCALBASE}/lib
278
279SED_MODULES=		-e 's/\(moduleload[ 	]*back_[a-z]*\)\.la/\1/' \
280			-e 's/\# *\(modulepath\)/\1/'
281
282CONFIGURE_ARGS+=	--enable-modules \
283			--localstatedir=${LOCALSTATEDIR} \
284			--enable-crypt \
285			--enable-ldap=mod \
286			--enable-meta=mod \
287			--enable-null=mod
288.endif
289
290LDAP_RUN_DIR?=		/var/run/openldap
291LOCALSTATEDIR?=		/var/db
292DATABASEDIR?=		${LOCALSTATEDIR}/openldap-data
293BACKUPDIR?=		/var/backups/openldap
294
295DESCR=			${PKGDIR}/pkg-descr${OPENLDAP_PKGFILESUFX}
296PLIST=			${PKGDIR}/pkg-plist${OPENLDAP_PKGFILESUFX}
297
298SUB_FILES+=		pkg-message${OPENLDAP_PKGFILESUFX}
299PKGMESSAGE=		${WRKSRC}/pkg-message${OPENLDAP_PKGFILESUFX}
300
301SUB_LIST+=		LDAP_RUN_DIR=${LDAP_RUN_DIR} \
302			LDAP_USER=${LDAP_USER} \
303			LDAP_GROUP=${LDAP_GROUP} \
304			BACKUPDIR=${BACKUPDIR} \
305			DATABASEDIR=${DATABASEDIR} \
306			PORTNAME=${PORTNAME} \
307			PKGNAME=${PKGNAME} \
308			PKGNAMESUFFIX=${PKGNAMESUFFIX}
309
310CONFIGURE_ARGS+=	--with-threads=posix \
311			--with-tls=openssl \
312			--enable-dynamic
313
314LIB_DEPENDS+=		libsasl2.so:security/cyrus-sasl2
315CONFIGURE_ARGS+=	--with-cyrus-sasl --enable-spasswd
316MAKE_ENV+=		STRIP=${STRIP}
317
318CPPFLAGS+=		-I${LOCALBASE}/include
319LIBS+=			-L${LOCALBASE}/lib
320
321PLIST_SUB+=		${SUB_LIST}
322PLIST_SUB+=		SHLIB_MAJOR=${OPENLDAP_SHLIB_MAJOR}
323PLIST_SUB+=		SHLIB_MINOR=${OPENLDAP_SHLIB_MINOR}
324
325.if ${PORT_OPTIONS:MFETCH} && (defined(OPENSSL_INSTALLED) && ${OPENSSL_INSTALLED} != "" || ${SSL_DEFAULT} != base)
326BROKEN=	using OpenSSL from ports and OPTION FETCH together is not supported
327. endif
328
329.if ${PORT_OPTIONS:MADDPARTIAL}
330CONTRIB_MODULES+=	slapd-modules/addpartial
331CONTRIB_CLEANFILES+=	addpartial.a
332.endif
333.if ${PORT_OPTIONS:MALLOP}
334CONTRIB_MODULES+=	slapd-modules/allop
335CONTRIB_CLEANFILES+=	allop.a
336.endif
337.if ${PORT_OPTIONS:MAUTOGROUP}
338CONTRIB_MODULES+=	slapd-modules/autogroup
339CONTRIB_CLEANFILES+=	autogroup.a
340.endif
341.if ${PORT_OPTIONS:MCLOAK}
342CONTRIB_MODULES+=	slapd-modules/cloak
343CONTRIB_CLEANFILES+=	cloak.a
344.endif
345.if ${PORT_OPTIONS:MDENYOP}
346CONTRIB_MODULES+=	slapd-modules/denyop
347CONTRIB_CLEANFILES+=	denyop.a
348.endif
349.if ${PORT_OPTIONS:MEMPTYDS}
350CONTRIB_MODULES+=	slapd-modules/emptyds
351CONTRIB_CLEANFILES+=	emptyds.a
352.endif
353.if ${PORT_OPTIONS:MLASTBIND}
354CONTRIB_MODULES+=	slapd-modules/lastbind
355CONTRIB_CLEANFILES+=	lastbind.a
356.endif
357.if ${PORT_OPTIONS:MLASTMOD}
358CONTRIB_MODULES+=	slapd-modules/lastmod
359CONTRIB_CLEANFILES+=	lastmod.a
360.endif
361.if ${PORT_OPTIONS:MNOPS}
362CONTRIB_MODULES+=	slapd-modules/nops
363CONTRIB_CLEANFILES+=	nops.a
364.endif
365.if ${PORT_OPTIONS:MTRACE}
366CONTRIB_MODULES+=	slapd-modules/trace
367CONTRIB_CLEANFILES+=	trace.a
368.endif
369.if ${PORT_OPTIONS:MSHA2}
370CONTRIB_MODULES+=	slapd-modules/passwd/sha2
371CONTRIB_CLEANFILES+=	pw-sha2.a
372.endif
373.if ${PORT_OPTIONS:MPBKDF2}
374CONTRIB_MODULES+=	slapd-modules/passwd/pbkdf2
375CONTRIB_CLEANFILES+=	pw-pbkdf2.a
376.endif
377.if ${PORT_OPTIONS:MSMBPWD}
378CONTRIB_MODULES+=	slapd-modules/smbk5pwd
379CONTRIB_CLEANFILES+=	smbk5pwd.a
380.endif
381
382post-patch:
383	@${REINPLACE_CMD} -e 's|%LOCALSTATEDIR%/run/|${LDAP_RUN_DIR}/|g' \
384		${SED_MODULES} ${WRKSRC}/servers/slapd/slapd.conf
385	@${REINPLACE_CMD} -e 's|%LOCALSTATEDIR%/run/|${LDAP_RUN_DIR}/|g' \
386		${SED_MODULES} ${WRKSRC}/servers/slapd/slapd.ldif
387	@${REINPLACE_CMD} -e 's|^OPT =.*|OPT = ${CFLAGS}|g' \
388		-e 's|^CC =.*|CC = ${CC}|g' \
389		${SED_MODULES} ${WRKSRC}/contrib/slapd-modules/*/Makefile \
390		${WRKSRC}/contrib/slapd-modules/*/*/Makefile
391.if defined(CONFIGURE_SED)
392	@${REINPLACE_CMD} -E ${CONFIGURE_SED} \
393		${CONFIGURE_WRKSRC}/${CONFIGURE_SCRIPT}
394.endif
395.if !${PORT_OPTIONS:MDEBUG}
396	@${REINPLACE_CMD} -E \
397		-e '/ldap_dump_(connection|requests_and_responses);/d' \
398		${WRKSRC}/libraries/libldap/ldap.map
399.endif
400
401pre-configure:
402	@(cd ${WRKSRC} && ${LOCALBASE}/bin/autoconf)
403
404.if !defined(CLIENT_ONLY)
405
406post-build:
407.for module in ${CONTRIB_MODULES}
408	@(cd ${BUILD_WRKSRC}/contrib/${module} && \
409		${SETENVI} ${WRK_ENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_FLAGS} ${MAKEFILE} \
410		${MAKE_ARGS} prefix="${PREFIX}" all)
411.endfor
412.endif
413
414pre-install:
415.if !defined(CLIENT_ONLY)
416	${MKDIR} ${DATABASEDIR}
417.endif
418
419post-install:
420.if defined(CLIENT_ONLY)
421	${MKDIR} ${DOCSDIR}
422	${INSTALL_DATA} ${WRKSRC}/CHANGES ${DOCSDIR}
423	for dir in drafts rfc; do \
424		${MKDIR} ${DOCSDIR}/$${dir}; \
425		${INSTALL_DATA} ${WRKSRC}/doc/$${dir}/* ${DOCSDIR}/$${dir}; \
426	done
427	for prog in ldapcompare ldapdelete ldapexop ldapmodify ldapmodrdn ldappasswd ldapsearch ldapurl ldapvc ldapwhoami; do\
428		${STRIP_CMD} ${PREFIX}/bin/$${prog}; \
429	done
430	for library in lber ldap; do \
431		${STRIP_CMD} ${PREFIX}/lib/lib$${library}.so.${OPENLDAP_SHLIB_MAJOR}; \
432	done
433.else
434	${MKDIR} ${LDAP_RUN_DIR}
435.for module in ${CONTRIB_MODULES}
436	(cd ${WRKSRC}/contrib/${module} && \
437		${SETENVI} ${WRK_ENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_FLAGS} ${MAKEFILE} \
438		${MAKE_ARGS} prefix="${PREFIX}" install)
439.endfor
440.for cleanfile in ${CONTRIB_CLEANFILES}
441	${RM} ${PREFIX}/libexec/openldap/${cleanfile}
442.endfor
443	${STRIP_CMD} ${PREFIX}/libexec/openldap/*.so
444	${STRIP_CMD} ${PREFIX}/libexec/slapd
445	${MKDIR} ${PREFIX}/libexec/openldap
446.endif # defined(CLIENT_ONLY)
447
448post-install-SLAPI-on:
449	for library in slapi; do \
450		${STRIP_CMD} ${FAKE_DESTDIR}${PREFIX}/lib/lib$${library}.so.${OPENLDAP_SHLIB_MAJOR}; \
451	done
452
453.include <bsd.port.mk>
454