aboutsummaryrefslogtreecommitdiff
path: root/net/openldap24-server/Makefile
blob: 15f4ad051253e93500969b97d60336f5a3ac5683 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
# Created by: Xin LI <delphij@FreeBSD.org>
# $FreeBSD$

PORTNAME=		openldap
DISTVERSION=		2.4.39
PORTREVISION=		${OPENLDAP_PORTREVISION}
CATEGORIES=		net databases
MASTER_SITES=		ftp://ftp.OpenLDAP.org/pub/OpenLDAP/%SUBDIR%/ \
			ftp://gd.tuwien.ac.at/infosys/network/OpenLDAP/%SUBDIR%/ \
			ftp://ftp.ntua.gr/mirror/OpenLDAP/%SUBDIR%/ \
			ftp://ftp.dti.ad.jp/pub/net/OpenLDAP/%SUBDIR%/ \
			ftp://ftp.u-aizu.ac.jp/pub/net/openldap/%SUBDIR%/ \
			ftp://ftp.nl.uu.net/pub/unix/db/openldap/%SUBDIR%/ \
			ftp://sunsite.cnlab-switch.ch/mirror/OpenLDAP/%SUBDIR%/ \
			http://www.openldap.org/software/download/OpenLDAP/%SUBDIR%/
MASTER_SITE_SUBDIR=	openldap-release

.if defined(CLIENT_ONLY)
.if ${CLIENT_ONLY} == sasl
PKGNAMESUFFIX=		-sasl-client
COMMENT=		Open source LDAP client implementation with SASL2 support
CONFLICTS=		${PKGNAMEPREFIX}${PORTNAME}-client-2.* \
			${PKGNAMEPREFIX}${PORTNAME}-sasl-client-2.[0-3].*
.else
PKGNAMESUFFIX=		-client
COMMENT=		Open source LDAP client implementation
CONFLICTS=		${PKGNAMEPREFIX}${PORTNAME}-client-2.[0-3].* \
			${PKGNAMEPREFIX}${PORTNAME}-sasl-client-2.*
.endif
.else
PKGNAMESUFFIX?=		-server
# Do not use ${PKGNAMESUFFIX} here has it can change later
OPTIONSFILE?=		${PORT_DBDIR}/${PORTNAME}24-server/options
.endif
EXTRACT_SUFX=		.tgz

MAINTAINER=		delphij@FreeBSD.org
COMMENT?=		Open source LDAP server implementation

LICENSE=		OPENLDAP
LICENSE_NAME=		OpenLDAP Public License
LICENSE_FILE=		${WRKSRC}/LICENSE
LICENSE_PERMS=		dist-mirror dist-sell pkg-mirror pkg-sell auto-accept

LATEST_LINK?=		${PKGNAMEPREFIX}openldap24${PKGNAMESUFFIX}
USE_OPENSSL=		yes
USE_AUTOTOOLS=		libtool
.if !defined(CLIENT_ONLY)
USE_AUTOTOOLS+=		autoconf
USERS=			ldap
GROUPS=			ldap
LDAP_USER?=		ldap
LDAP_GROUP?=		ldap
.endif

WANT_OPENLDAP_VER?=	24
.if ${WANT_OPENLDAP_VER} != 24
BROKEN=			incompatible OpenLDAP version: ${WANT_OPENLDAP_VER}
.endif

PORTREVISION_CLIENT=	0
PORTREVISION_SERVER=	1
OPENLDAP_SHLIB_MAJOR=	8
OPENLDAP_MAJOR=		${DISTVERSION:R}

OPTIONS_DEFINE=	FETCH

FETCH_DESC=	Enable fetch(3) support

.if !defined(CLIENT_ONLY)
OPTIONS_DEFINE+=	DYNACL ACI BDB MDB DNSSRV PASSWD PERL RELAY SHELL
OPTIONS_DEFINE+=	SOCK ODBC RLOOKUPS SLP SLAPI TCP_WRAPPERS
OPTIONS_DEFINE+=	ACCESSLOG AUDITLOG COLLECT CONSTRAINT DDS
OPTIONS_DEFINE+=	DEREF DYNGROUP DYNLIST MEMBEROF PPOLICY PROXYCACHE
OPTIONS_DEFINE+=	REFINT RETCODE RWM SEQMOD SSSVLV SYNCPROV TRANSLUCENT
OPTIONS_DEFINE+=	UNIQUE VALSORT SMBPWD SHA2 DYNAMIC_BACKENDS SASL

OPTIONS_DEFAULT=	BDB MDB SYNCPROV DYNAMIC_BACKENDS

DYNACL_DESC=		Run-time loadable ACL (experimental)
ACI_DESC=		Per-object ACI (experimental)
BDB_DESC=		With BerkeleyDB backend (DEPRECATED)
MDB_DESC=		With Memory-Mapped DB backend
DNSSRV_DESC=		With Dnssrv backend
PASSWD_DESC=		With Passwd backend
PERL_DESC=		With Perl backend
RELAY_DESC=		With Relay backend
SHELL_DESC=		With Shell backend (disables threading)
SOCK_DESC=		With Sock backend
ODBC_DESC=		With SQL backend
RLOOKUPS_DESC=		With reverse lookups of client hostnames
SLP_DESC=		With SLPv2 (RFC 2608) support
SLAPI_DESC=		With Netscape SLAPI plugin API (experimental)
TCP_WRAPPERS_DESC=	With tcp wrapper support
ACCESSLOG_DESC=		With In-Directory Access Logging overlay
AUDITLOG_DESC=		With Audit Logging overlay
COLLECT_DESC=		With Collect overy Services overlay
CONSTRAINT_DESC=	With Attribute Constraint overlay
DDS_DESC=		With Dynamic Directory Services overlay
DEREF_DESC=		With Dereference overlay
DYNGROUP_DESC=		With Dynamic Group overlay
DYNLIST_DESC=		With Dynamic List overlay
MEMBEROF_DESC=		With Reverse Group Membership overlay
PPOLICY_DESC=		With Password Policy overlay
PROXYCACHE_DESC=	With Proxy Cache overlay
REFINT_DESC=		With Referential Integrity overlay
RETCODE_DESC=		With Return Code testing overlay
RWM_DESC=		With Rewrite/Remap overlay
SASL_DESC=		With (Cyrus) SASL2 support
SEQMOD_DESC=		With Sequential Modify overlay
SSSVLV_DESC=		With ServerSideSort/VLV overlay
SYNCPROV_DESC=		With Syncrepl Provider overlay
TRANSLUCENT_DESC=	With Translucent Proxy overlay
UNIQUE_DESC=		With attribute Uniqueness overlay
VALSORT_DESC=		With Value Sorting overlay
SMBPWD_DESC=		With Samba Password hashes overlay
SHA2_DESC=		With SHA2 Password hashes overlay
DYNAMIC_BACKENDS_DESC=	Build dynamic backends
.endif

.if defined(CLIENT_ONLY)
OPENLDAP_PORTREVISION=	${PORTREVISION_CLIENT}
OPENLDAP_PKGFILESUFX=	.client
.else
OPENLDAP_PORTREVISION=	${PORTREVISION_SERVER}
OPENLDAP_PKGFILESUFX=
.endif

CONFIGURE_SED=		-e 's,-kthread,${PTHREAD_LIBS},g' -e 's,uuid/uuid.h,xxuuid/uuid.h,g'

.include <bsd.port.pre.mk>

.if defined(CLIENT_ONLY)
PORTDOCS=		CHANGES drafts rfc

.if ${CLIENT_ONLY} == sasl
PORT_OPTIONS+=	SASL
.endif
.if defined(USE_OPENLDAP)
BROKEN=			You have 'USE_OPENLDAP' variable defined either in environment or in make(1) arguments. Please undefine and try again.
.endif
.else
USE_OPENLDAP=		yes
WANT_OPENLDAP_VER=	24

.if ${PORT_OPTIONS:MSASL}
WANT_OPENLDAP_SASL=	yes
CONFLICTS=		${PKGNAMEPREFIX}${PORTNAME}-client-2.*
PKGNAMESUFFIX=		-sasl-server
.else
CONFLICTS=		${PKGNAMEPREFIX}${PORTNAME}-sasl-client-2.*
.endif

.endif

DESCR=			${PKGDIR}/pkg-descr${OPENLDAP_PKGFILESUFX}
PLIST=			${PKGDIR}/pkg-plist${OPENLDAP_PKGFILESUFX}

SCHEMATA=		collective corba core cosine duaconf dyngroup \
			inetorgperson java misc \
			nis openldap pmi ppolicy

LDAP_RUN_DIR?=		/var/run/openldap
LOCALSTATEDIR?=		/var/db
DATABASEDIR?=		${LOCALSTATEDIR}/openldap-data

SUB_LIST+=		LDAP_RUN_DIR=${LDAP_RUN_DIR} \
			LDAP_USER=${LDAP_USER} \
			LDAP_GROUP=${LDAP_GROUP} \
			DATABASEDIR=${DATABASEDIR} \
			PKGNAME=${PKGNAME}

CONFIGURE_ARGS=		--with-threads=posix \
			--with-tls=openssl \
			--disable-dependency-tracking \
			--enable-dynamic

# XXX FreeBSD does not implement O_DSYNC and fdatasync at this time.
CFLAGS+=		-DMDB_DSYNC=O_SYNC -Dfdatasync=fsync

.if !${PORT_OPTIONS:MFETCH}
CONFIGURE_ARGS+=	--without-fetch
.endif

.if ${PORT_OPTIONS:MSASL}
LIB_DEPENDS+=		sasl2:${PORTSDIR}/security/cyrus-sasl2
CONFIGURE_ARGS+=	--with-cyrus-sasl
.else
CONFIGURE_ARGS+=	--without-cyrus-sasl
.endif

.if defined(CLIENT_ONLY)
# client specific configuration

CONFIGURE_ARGS+=	--disable-slapd \
			--disable-monitor \
			--disable-bdb \
			--disable-relay \
			--disable-syncprov
SUB_FILES+=		pkg-message.client
PKGMESSAGE=		${WRKSRC}/pkg-message.client

USE_LDCONFIG=		yes

.else
# server specific configuration

USE_LDCONFIG=		${PREFIX}/libexec/openldap
SUB_FILES+=		pkg-message pkg-deinstall
USE_RC_SUBR=		slapd

EXTRA_PATCHES+=		${FILESDIR}/extrapatch-Makefile.in

.if ${PORT_OPTIONS:MMODULES} || ${PORT_OPTIONS:MDYNAMIC_BACKENDS} || ${PORT_OPTIONS:MSLAPI}
USE_AUTOTOOLS+=		libltdl
CONFIGURE_ARGS+=	--enable-modules
PLIST_SUB+=		MODULES=""
.else
PLIST_SUB+=		MODULES="@comment "
.endif

SED_MODULES=		-e 's/\(moduleload[ 	]*back_[a-z]*\)\.la/\1/'

.if ${PORT_OPTIONS:MDYNAMIC_BACKENDS}
BACKEND_ENABLE=		"mod"
BACKEND_PLIST=		""
SED_MODULES+=		-e 's/\# *\(modulepath\)/\1/' \
			-e 's/\# *\(moduleload[ 	]*back_bdb\)/\1/'
.else
BACKEND_ENABLE=		"yes"
BACKEND_PLIST=		"@comment "
.endif

OVERLAY_ENABLE=		yes

CONFIGURE_ARGS+=	--localstatedir=${LOCALSTATEDIR} \
			--enable-crypt \
			--enable-lmpasswd \
			--enable-ldap=${BACKEND_ENABLE} \
			--enable-meta=${BACKEND_ENABLE} \
			--enable-rewrite \
			--enable-null=${BACKEND_ENABLE} \
			--enable-monitor=${BACKEND_ENABLE}

PLIST_SUB+=		BACKEND=${BACKEND_PLIST}

.if ${PORT_OPTIONS:MACCESSLOG}
CONFIGURE_ARGS+=	--enable-accesslog=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MAUDITLOG}
CONFIGURE_ARGS+=	--enable-auditlog=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MCOLLECT}
CONFIGURE_ARGS+=	--enable-collect=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MCONSTRAINT}
CONFIGURE_ARGS+=	--enable-constraint=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MDDS}
CONFIGURE_ARGS+=	--enable-dds=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MDEREF}
CONFIGURE_ARGS+=	--enable-deref=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MDYNGROUP}
CONFIGURE_ARGS+=	--enable-dyngroup=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MDYNLIST}
CONFIGURE_ARGS+=	--enable-dynlist=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MMEMBEROF}
CONFIGURE_ARGS+=	--enable-memberof=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MPPOLICY}
CONFIGURE_ARGS+=	--enable-ppolicy=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MPROXYCACHE}
CONFIGURE_ARGS+=	--enable-proxycache=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MREFINT}
CONFIGURE_ARGS+=	--enable-refint=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MRETCODE}
CONFIGURE_ARGS+=	--enable-retcode=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MRWM}
CONFIGURE_ARGS+=	--enable-rwm=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MSEQMOD}
CONFIGURE_ARGS+=	--enable-seqmod=${OVERLAY_ENABLE}
.else
CONFIGURE_ARGS+=	--disable-seqmod
.endif

.if ${PORT_OPTIONS:MSSSVLV}
CONFIGURE_ARGS+=	--enable-sssvlv=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MSYNCPROV}
CONFIGURE_ARGS+=	--enable-syncprov=${OVERLAY_ENABLE}
.else
CONFIGURE_ARGS+=	--disable-syncprov
.endif

.if ${PORT_OPTIONS:MTRANSLUCENT}
CONFIGURE_ARGS+=	--enable-translucent=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MUNIQUE}
CONFIGURE_ARGS+=	--enable-unique=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MVALSORT}
CONFIGURE_ARGS+=	--enable-valsort=${OVERLAY_ENABLE}
.endif

.if ${PORT_OPTIONS:MACI}
CONFIGURE_ARGS+=	--enable-aci
.endif

.if ${PORT_OPTIONS:MDYNACL}
CONFIGURE_ARGS+=	--enable-dynacl
.endif

.if !${PORT_OPTIONS:MBDB}
CONFIGURE_ARGS+=	--disable-bdb \
			--disable-hdb
PLIST_SUB+=		BACK_BDB="@comment " \
			BACK_HDB="@comment "
.else

WITH_BDB_VER?=		46
USE_BDB=		44+

# XXX Can BDB 5.x use XY instead of X as version?
.if ${WITH_BDB_VER} >= 43 || ${WITH_BDB_VER} == 5 || ${WITH_BDB_VER} == 6
CONFIGURE_ARGS+=	--enable-bdb=${BACKEND_ENABLE} \
			--enable-hdb=${BACKEND_ENABLE}
PLIST_SUB+=		BACK_BDB=${BACKEND_PLIST} \
			BACK_HDB=${BACKEND_PLIST}
.elif ${WITH_BDB_VER} >= 4
CONFIGURE_ARGS+=	--disable-bdb \
			--enable-hdb=${BACKEND_ENABLE}
PLIST_SUB+=		BACK_BDB="@comment " \
			BACK_HDB=${BACKEND_PLIST}
.elif ${WITH_BDB_VER} == 3
CONFIGURE_ARGS+=	--disable-bdb \
			--disable-hdb
PLIST_SUB+=		BACK_BDB="@comment " \
			BACK_HDB="@comment "
.endif

CPPFLAGS+=		-I${BDB_INCLUDE_DIR}
CONFIGURE_SED+=		-e 's,ol_DB_LIB=$$,&-l${BDB_LIB_NAME:R},' \
			-e 's,(ol_cv_lib_db=)yes$$,\1-l${BDB_LIB_NAME:R},'
.endif

.if ${PORT_OPTIONS:MDNSSRV}
CONFIGURE_ARGS+=	--enable-dnssrv=${BACKEND_ENABLE}
PLIST_SUB+=		BACK_DNSSRV=${BACKEND_PLIST}
.else
PLIST_SUB+=		BACK_DNSSRV="@comment "
.endif

.if ${PORT_OPTIONS:MMDB}
CONFIGURE_ARGS+=	--enable-mdb=${BACKEND_ENABLE}
PLIST_SUB+=		BACK_MDB=${BACKEND_PLIST}
.else
PLIST_SUB+=		BACK_MDB="@comment "
.endif

.if ${PORT_OPTIONS:MPASSWD}
CONFIGURE_ARGS+=	--enable-passwd=${BACKEND_ENABLE}
PLIST_SUB+=		BACK_PASSWD=${BACKEND_PLIST}
.else
PLIST_SUB+=		BACK_PASSWD="@comment "
.endif

.if ${PORT_OPTIONS:MRELAY}
CONFIGURE_ARGS+=	--enable-relay=${BACKEND_ENABLE}
PLIST_SUB+=		BACK_RELAY=${BACKEND_PLIST}
.else
PLIST_SUB+=		BACK_RELAY="@comment "
.endif

.if ${PORT_OPTIONS:MSHELL}
CONFIGURE_ARGS+=	--without-threads --enable-shell=${BACKEND_ENABLE}
PLIST_SUB+=		BACK_SHELL=${BACKEND_PLIST}
.else
PLIST_SUB+=		BACK_SHELL="@comment "
WANT_OPENLDAP_THREADS=	yes
.endif

.if ${PORT_OPTIONS:MSOCK}
CONFIGURE_ARGS+=	--enable-sock=${BACKEND_ENABLE}
PLIST_SUB+=		BACK_SOCK=${BACKEND_PLIST}
.else
PLIST_SUB+=		BACK_SOCK="@comment "
.endif

.if ${PORT_OPTIONS:MPERL}
USES+=			perl5
CONFIGURE_ARGS+=	--enable-perl=${BACKEND_ENABLE}
CONFIGURE_ENV+=		PERLBIN="${PERL}"
PLIST_SUB+=		BACK_PERL=${BACKEND_PLIST}
.else
PLIST_SUB+=		BACK_PERL="@comment "
.endif

.if ${PORT_OPTIONS:MSASL}
CONFIGURE_ARGS+=	--enable-spasswd
.endif

.if ${PORT_OPTIONS:MODBC}
CONFIGURE_ARGS+=	--enable-sql=${BACKEND_ENABLE}
PLIST_SUB+=		BACK_SQL=${BACKEND_PLIST}
WITH_ODBC_TYPE?=	iODBC
.if ${WITH_ODBC_TYPE:tl} == iodbc
LIB_DEPENDS+=		iodbc.3:${PORTSDIR}/databases/libiodbc
.elif ${WITH_ODBC_TYPE:tl} == unixodbc
LIB_DEPENDS+=		odbc.2:${PORTSDIR}/databases/unixODBC
.else
BROKEN=			choose either iODBC or unixODBC for WITH_ODBC_TYPE
.endif
.else
PLIST_SUB+=		BACK_SQL="@comment "
.endif

.if ${PORT_OPTIONS:MSMBPWD}
PLIST_SUB+=		SMBPWD=""
.else
PLIST_SUB+=		SMBPWD="@comment "
.endif

.if ${PORT_OPTIONS:MSHA2}
PLIST_SUB+=		SHA2=""
.else
PLIST_SUB+=		SHA2="@comment "
.endif

.if ${PORT_OPTIONS:MRLOOKUPS}
CONFIGURE_ARGS+=	--enable-rlookups
PLIST_SUB+=		RLOOKUPS=""
.else
PLIST_SUB+=		RLOOKUPS="@comment "
.endif

.if ${PORT_OPTIONS:MSLAPI}
CONFIGURE_ARGS+=	--enable-slapi
PLIST_SUB+=		SLAPI=""
USE_LDCONFIG=		yes
.else
PLIST_SUB+=		SLAPI="@comment "
.endif

.if ${PORT_OPTIONS:MSLP}
CONFIGURE_ARGS+=	--enable-slp
LIB_DEPENDS+=		slp.1:${PORTSDIR}/net/openslp
.endif

# Include tcp-wrapper support
.if ${PORT_OPTIONS:MTCP_WRAPPERS}
CONFIGURE_ARGS+=	--enable-wrappers
.endif

# end of client/server specific configuration
.endif

.if defined(WITH_CLDAP)
CPPFLAGS+=		-DLDAP_CONNECTIONLESS
.endif

CPPFLAGS+=		${PTHREAD_CFLAGS} \
			-I${LOCALBASE}/include
LDFLAGS+=		-L${LOCALBASE}/lib
#LIBS+=			${PTHREAD_LIBS}

CONFIGURE_ENV+=		LIBS="${LIBS}"

.if defined(CLIENT_ONLY)
.else
SUB_LIST+=		RC_DIR=${PREFIX} \
			LDAP_RUN_DIR=${LDAP_RUN_DIR} \
			DATABASEDIR=${DATABASEDIR}
.endif

PLIST_SUB+=		${SUB_LIST}
PLIST_SUB+=		SHLIB_MAJOR=${OPENLDAP_SHLIB_MAJOR}
PLIST_SUB+=		OPENLDAP_MAJOR=${OPENLDAP_MAJOR}

post-patch:
	@${REINPLACE_CMD} -e 's,%LOCALSTATEDIR%/run/,${LDAP_RUN_DIR}/,g' \
		${SED_MODULES} ${WRKSRC}/servers/slapd/slapd.conf
	@${REINPLACE_CMD} -e 's,^OPT =.*,OPT = ${CFLAGS},g' \
		-e 's,^CC =.*,CC = ${CC},g' \
		${SED_MODULES} ${WRKSRC}/contrib/slapd-modules/*/Makefile \
		${WRKSRC}/contrib/slapd-modules/*/*/Makefile
.if defined(CONFIGURE_SED)
	@${REINPLACE_CMD} -E ${CONFIGURE_SED} \
		${CONFIGURE_WRKSRC}/${CONFIGURE_SCRIPT}
.endif

pre-configure:
	@if [ -n "`${PKG_INFO} -xI '^bind\(84\)\{0,1\}-base-8\.' 2>/dev/null`" ]; then \
		${ECHO_CMD} "${PKGNAME}: bind installed with PORT_REPLACES_BASE_BIND causes build problems."; \
		${FALSE}; \
	fi

.if !defined(CLIENT_ONLY)
test: build
	@cd ${BUILD_WRKSRC}; ${SETENV} ${MAKE_ENV} \
		${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${MAKE_ARGS} test

post-build:
	@${DO_NADA}
.if ${PORT_OPTIONS:MSMBPWD}
	@cd ${BUILD_WRKSRC}/contrib/slapd-modules/smbk5pwd; ${SETENV} ${MAKE_ENV} \
		${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${MAKE_ARGS} DEFS="-DDO_SAMBA" all
.endif
.if ${PORT_OPTIONS:MSHA2}
	@cd ${BUILD_WRKSRC}/contrib/slapd-modules/passwd/sha2; ${SETENV} ${MAKE_ENV} \
		${MAKE} ${MAKE_FLAGS} ${MAKEFILE} ${MAKE_ARGS} all
.endif
.endif

pre-su-install:
	@if [ -f ${PKGINSTALL} ]; then \
		${SETENV} PKG_PREFIX="${PREFIX}" ${SH} ${PKGINSTALL} ${PKGNAME} PRE-INSTALL; \
	fi
.if ${PORT_OPTIONS:MMODULES} || ${PORT_OPTIONS:MDYNAMIC_BACKENDS} || ${PORT_OPTIONS:MSLAPI}
	@${MKDIR} ${STAGEDIR}${PREFIX}/libexec/openldap
.endif
.if !defined(CLIENT_ONLY)
	@${MKDIR} ${STAGEDIR}${DATABASEDIR}
.endif

post-install:
.if defined(CLIENT_ONLY)
	@${MKDIR} ${STAGEDIR}${DOCSDIR}
	@${INSTALL_DATA} ${WRKSRC}/CHANGES ${STAGEDIR}${DOCSDIR}
	@for dir in drafts rfc; do \
		${MKDIR} ${STAGEDIR}${DOCSDIR}/$${dir}; \
		${INSTALL_DATA} ${WRKSRC}/doc/$${dir}/* ${STAGEDIR}${DOCSDIR}/$${dir}; \
	done
	@for library in lber ldap ldap_r; do \
		${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/lib$${library}-${OPENLDAP_MAJOR}.so.${OPENLDAP_SHLIB_MAJOR}; \
	done
.else
	@${MKDIR} ${STAGEDIR}${LDAP_RUN_DIR}
	@for schema in ${SCHEMATA}; do \
		${ECHO_CMD} "@unexec if cmp -s %D/etc/openldap/schema/$${schema}.schema " \
			"%D/etc/openldap/schema/$${schema}.schema.default; then" \
			"rm -f %D/etc/openldap/schema/$${schema}.schema; fi"; \
		${ECHO_CMD} "etc/openldap/schema/$${schema}.schema.default"; \
		${ECHO_CMD} "@exec [ -f %B/$${schema}.schema ] || ${CP} %B/%f %B/$${schema}.schema"; \
	done >>${TMPPLIST}
	@${ECHO_CMD} "@unexec ${RMDIR} %D/etc/openldap/schema 2>/dev/null || true" >>${TMPPLIST}
	@${ECHO_CMD} "@unexec ${RMDIR} %D/etc/openldap 2>/dev/null || true" >>${TMPPLIST}
.if ${PORT_OPTIONS:MDYNAMIC_BACKENDS}
	@${STRIP_CMD} ${STAGEDIR}${PREFIX}/libexec/openldap/*.so.${OPENLDAP_SHLIB_MAJOR}
.endif
.if ${PORT_OPTIONS:MSMBPWD}
	@${INSTALL_DATA} ${WRKSRC}/contrib/slapd-modules/smbk5pwd/smbk5pwd.la \
		${STAGEDIR}${PREFIX}/libexec/openldap/
	@${INSTALL_PROGRAM} ${WRKSRC}/contrib/slapd-modules/smbk5pwd/.libs/smbk5pwd.so.0 \
		${STAGEDIR}${PREFIX}/libexec/openldap/
	@${LN} -s smbk5pwd.so.0 ${STAGEDIR}${PREFIX}/libexec/openldap/smbk5pwd.so
.endif
.if ${PORT_OPTIONS:MSHA2}
	@${INSTALL_DATA} ${WRKSRC}/contrib/slapd-modules/passwd/sha2/pw-sha2.la \
		${STAGEDIR}${PREFIX}/libexec/openldap/
	@${INSTALL_PROGRAM} ${WRKSRC}/contrib/slapd-modules/passwd/sha2/.libs/pw-sha2.so.0 \
		${STAGEDIR}${PREFIX}/libexec/openldap/
	@${LN} -s pw-sha2.so.0 ${STAGEDIR}${PREFIX}/libexec/openldap/pw-sha2.so
.endif
.endif

.include <bsd.port.post.mk>