aboutsummaryrefslogtreecommitdiffstats
path: root/net/samba4/Makefile
blob: fe399bb712387042b7bc6313f582450765f127b6 (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
# Created by: timur@FreeBSD.org
# $FreeBSD$

PORTNAME?=      ${SAMBA4_PORTNAME}
PORTVERSION?=       ${SAMBA4_VERSION}
PORTREVISION?=      0
CATEGORIES?=        net
MASTER_SITES=       ${MASTER_SITE_SAMBA}
MASTER_SITE_SUBDIR= samba/stable samba/rc
DISTNAME=       ${SAMBA4_DISTNAME}

MAINTAINER?=        timur@FreeBSD.org
COMMENT?=       A free SMB/CIFS and AD/DC server and client for UNIX

LICENSE=        GPLv3

CONFLICTS?=     *samba3[2-6]-3.*

SAMBA4_BASENAME=    samba
SAMBA4_PORTNAME=    ${SAMBA4_BASENAME}4
SAMBA4_VERSION=     4.0.8
SAMBA4_DISTNAME=    ${SAMBA4_BASENAME}-${SAMBA4_VERSION:S|.p|pre|:S|.r|rc|:S|.t|tp|:S|.a|alpha|}

WRKSRC?=        ${WRKDIR}/${DISTNAME}

.if !defined(SAMBA4_SUBPORT)
# Directories
VARDIR=         ${DESTDIR}/var
SAMBA4_RUNDIR=      ${VARDIR}/run/${SAMBA4_PORTNAME}
SAMBA4_LOGDIR=      ${VARDIR}/log/${SAMBA4_PORTNAME}
SAMBA4_LOCKDIR=     ${VARDIR}/db/${SAMBA4_PORTNAME}
SAMBA4_PRIVATEDIR=  ${SAMBA4_LOCKDIR}/private
SAMBA4_LIBDIR=      ${PREFIX}/lib
SAMBA4_MODULEDIR=   ${SAMBA4_LIBDIR}/shared-modules
SAMBA4_INCLUDEDIR=  ${PREFIX}/include/${SAMBA4_PORTNAME}
SAMBA4_CONFDIR=     ${PREFIX}/etc
SAMBA4_CONFIG=      smb4.conf

CONFIGURE_ARGS+=    --prefix="${PREFIX}" \
            --exec-prefix="${PREFIX}" \
            --mandir="${MANPREFIX}/man" \
            --sysconfdir="${SAMBA4_CONFDIR}" \
            --includedir="${SAMBA4_INCLUDEDIR}" \
            --datadir="${DATADIR}" \
            --libdir="${SAMBA4_LIBDIR}" \
            --with-pammodulesdir="${SAMBA4_LIBDIR}" \
            --with-privatelibdir="${SAMBA4_LIBDIR}/samba" \
            --with-modulesdir="${SAMBA4_MODULEDIR}" \
            --with-pkgconfigdir="${PKGCONFIGDIR}" \
            --localstatedir="${VARDIR}" \
            --with-piddir="${SAMBA4_RUNDIR}" \
            --with-sockets-dir="${SAMBA4_RUNDIR}" \
            --with-privileged-socket-dir="${SAMBA4_RUNDIR}" \
            --with-lockdir="${SAMBA4_LOCKDIR}" \
            --with-statedir="${SAMBA4_LOCKDIR}" \
            --with-cachedir="${SAMBA4_LOCKDIR}" \
            --with-privatedir="${SAMBA4_PRIVATEDIR}" \
            --with-logfilebase="${SAMBA4_LOGDIR}"

WAF_TOOL=       buildtools/bin/waf
HAS_CONFIGURE=      yes
CONFIGURE_SCRIPT=   ${WAF_TOOL} configure
CONFIGURE_LOG=      bin/config.log
# Flags
CONFIGURE_ENV+=     PTHREAD_CFLAGS="${PTHREAD_CFLAGS}" \
            PTHREAD_LDFLAGS="${PTHREAD_LIBS}"

USE_PYTHON_BUILD=   -2.7
USE_PERL5=      build

USE_GCC=        4.2+
USE_PYTHON=     yes
USES=           pkgconfig gettext iconv perl5
USE_LDCONFIG=       ${SAMBA4_LIBDIR}

PKGCONFIGDIR?=      ${PREFIX}/libdata/pkgconfig
PLIST_SUB+=     PKGCONFIGDIR=${PKGCONFIGDIR:S;${PREFIX}/;;}
# XXX: Unconditional dependencies which can't be switched off(if present in the system)
# popt
LIB_DEPENDS+=       popt:${PORTSDIR}/devel/popt
# XXX: We should try to switch to libunwind, libexecinfo is gcc specific(?)
# backtrace
LIB_DEPENDS+=       execinfo:${PORTSDIR}/devel/libexecinfo
# inotify
LIB_DEPENDS+=       inotify:${PORTSDIR}/devel/libinotify
# SASL
LIB_DEPENDS+=       sasl2:${PORTSDIR}/security/cyrus-sasl2
# GNUTLS
LIB_DEPENDS+=       gcrypt:${PORTSDIR}/security/libgcrypt
LIB_DEPENDS+=       gnutls:${PORTSDIR}/security/gnutls
# NFS4 ACL glue
LIB_DEPENDS+=       sunacl:${PORTSDIR}/sysutils/libsunacl
# External Samba dependencies
# IDL compiler
BUILD_DEPENDS+=     p5-Parse-Pidl>=${SAMBA4_VERSION}:${PORTSDIR}/devel/p5-Parse-Pidl
# talloc
BUILD_DEPENDS+=     talloc>=2.0.8:${PORTSDIR}/devel/talloc
RUN_DEPENDS+=       talloc>=2.0.8:${PORTSDIR}/devel/talloc
SAMBA4_BUNDLED_LIBS+=   !talloc
# tevent
BUILD_DEPENDS+=     tevent>=0.9.18:${PORTSDIR}/devel/tevent
RUN_DEPENDS+=       tevent>=0.9.18:${PORTSDIR}/devel/tevent
SAMBA4_BUNDLED_LIBS+=   !tevent
# tdb
BUILD_DEPENDS+=     tdb>=1.2.11:${PORTSDIR}/databases/tdb
RUN_DEPENDS+=       tdb>=1.2.11:${PORTSDIR}/databases/tdb
SAMBA4_BUNDLED_LIBS+=   !tdb
# ldb
BUILD_DEPENDS+=     ldb>=1.1.15:${PORTSDIR}/databases/ldb
RUN_DEPENDS+=       ldb>=1.1.15:${PORTSDIR}/databases/ldb
SAMBA4_BUNDLED_LIBS+=   !ldb
##############################################################################
# Options
OPTIONS_DEFINE=     ACL_SUPPORT ADS AIO_SUPPORT AVAHI CUPS DEBUG \
            DNSUPDATE FAM_SUPPORT LDAP PAM_SMBPASS \
            PTHREADPOOL QUOTAS SWAT SYSLOG UTMP WINBIND

OPTIONS_DEFAULT:=   ${OPTIONS_DEFINE}

ACL_SUPPORT_DESC=   File system ACL support
ADS_DESC=       Active Directory support
AIO_SUPPORT_DESC=   Asyncronous IO support
DNSUPDATE_DESC=     Dynamic DNS update(require ADS)
EXP_MODULES_DESC=   Experimental modules
FAM_SUPPORT_DESC=   File Alteration Monitor support
DEBUG_DESC=     With debug information in the binaries
PAM_SMBPASS_DESC=   PAM authentication via passdb backends
PTHREADPOOL_DESC=   Pthread pool
QUOTAS_DESC=        Disk quota support
SWAT_DESC=      SWAT WebGUI
UTMP_DESC=      UTMP accounting support
WINBIND_DESC=       WinBIND support
##############################################################################
OPTIONS_DEFINE+=    DEVELOPER MANPAGES EXP_MODULES

DEVELOPER_DESC=     With development support

OPTIONS_SINGLE=     DNS
OPTIONS_SINGLE_DNS= NSUPDATE BIND98 BIND99

BIND98_DESC=        Use bind98 as a DNS server frontend
BIND99_DESC=        Use bind99 as a DNS server frontend
NSUPDATE_DESC=      Use internal DNS with NSUPDATE utility

OPTIONS_DEFAULT+=   NSUPDATE

NO_STAGE=   yes
.include <bsd.port.options.mk>

# !SAMBA4_SUBPORT
.endif

.include <bsd.port.pre.mk>

.if !defined(SAMBA4_SUBPORT)

CONFIGURE_ARGS+=    \
            --with-pam \
            --with-iconv \
            --with-sendfile-support \
            --builtin-libraries=smbclient \
            ${ICONV_CONFIGURE_BASE} \
            --with-gettext="${LOCALBASE}"

# for libexecinfo: (so that __builtin_frame_address() finds the top of the stack)
.if ${ARCH} == "amd64"
CFLAGS+=        -fno-omit-frame-pointer
.endif

.if ${PORT_OPTIONS:MBIND98}
RUN_DEPENDS+=       bind98>=9.8.0.0:${PORTSDIR}/dns/bind98
SUB_LIST+=      NSUPDATE="@comment "
.elif ${PORT_OPTIONS:MBIND99}
RUN_DEPENDS+=       bind99>=9.9.0.0:${PORTSDIR}/dns/bind99
SUB_LIST+=      NSUPDATE="@comment "
.else
RUN_DEPENDS+=       samba-nsupdate:${PORTSDIR}/dns/samba-nsupdate
SUB_LIST+=      NSUPDATE=""
.endif

.if ${PORT_OPTIONS:MDEBUG}
WITH_DEBUG=     yes
CONFIGURE_ARGS+=    --verbose
_MAKE_JOBS+=        --verbose
CONFIGURE_ARGS+=    --enable-debug
.endif

# https://bugzilla.samba.org/show_bug.cgi?id=8969
.if ${PORT_OPTIONS:MDEVELOPER}
GDB_CMD?=       gdb76
BUILD_DEPENDS+=     ${GDB_CMD}:${PORTSDIR}/devel/gdb
RUN_DEPENDS+=       ${GDB_CMD}:${PORTSDIR}/devel/gdb
SAMBA4_MODULES+=    auth_skel perfcount_test pdb_test vfs_shadow_copy_test vfs_skel_opaque vfs_skel_transparent vfs_fake_acls
CONFIGURE_ARGS+=    --enable-developer --enable-socket-wrapper --enable-nss-wrapper --enable-selftest
PLIST_SUB+=     DEVELOPER=""
.else
GDB_CMD=        /usr/bin/true
PLIST_SUB+=     DEVELOPER="@comment "
.endif
##############################################################################
# XXX: That will blow up your installation
# https://bugzilla.samba.org/show_bug.cgi?id=9302
.if defined(CRAZY)
WANT_EXP_MODULES=   auth_samba4 auth_script auth_skel auth_unix auth_wbc \
            gpext_registry gpext_scripts gpext_security idmap_ad \
            idmap_autorid idmap_hash idmap_ldap idmap_passdb \
            idmap_rid idmap_tdb idmap_tdb2 idmap_nss nss_info_template \
            pdb_ldap pdb_samba_dsdb pdb_smbpasswd pdb_tdbsam \
            pdb_test pdb_wbc_sam perfcount_test vfs_acl_tdb \
            vfs_acl_xattr vfs_aio_fork vfs_aio_posix \
            vfs_aio_pthread vfs_audit vfs_cacheprime vfs_cap \
            vfs_catia vfs_commit vfs_crossrename vfs_default_quota \
            vfs_dfs_samba4 vfs_dirsort vfs_expand_msdfs vfs_extd_audit \
            vfs_fake_acls vfs_fake_perms vfs_full_audit vfs_media_harmony \
            vfs_netatalk vfs_posix_eadb vfs_preopen vfs_readahead \
            vfs_readonly vfs_recycle vfs_scannedonly vfs_shadow_copy \
            vfs_shadow_copy2 vfs_shadow_copy_test vfs_skel_opaque \
            vfs_skel_transparent vfs_smb_traffic_analyzer vfs_streams_depot \
            vfs_streams_xattr vfs_syncops vfs_time_audit \
            vfs_xattr_tdb vfs_zfsacl
.endif

.if ${PORT_OPTIONS:MEXP_MODULES}
.   if !defined(WANT_EXP_MODULES) || empty(WANT_EXP_MODULES)
WANT_EXP_MODULES=   idmap_ad vfs_cacheprime gpext_scripts gpext_security gpext_registry
.   endif
.endif

.if ${PORT_OPTIONS:MACL_SUPPORT}
.   if ${OSVERSION} > 800000
LIB_DEPENDS+=       sunacl:${PORTSDIR}/sysutils/libsunacl
WANT_EXP_MODULES+=  vfs_zfsacl
SAMBA4_MODULES+=    vfs_zfsacl
.   endif
CONFIGURE_ARGS+=    --with-acl-support
.else
CONFIGURE_ARGS+=    --without-acl-support
.endif

.if ${PORT_OPTIONS:MADS}
SAMBA4_WANT_ADS=    yes
SAMBA4_WANT_LDAP=   yes
.endif

.if ${PORT_OPTIONS:MAIO_SUPPORT}
CONFIGURE_ARGS+=    --with-aio-support
SAMBA4_MODULES+=    vfs_aio_posix
.else
CONFIGURE_ARGS+=    --without-aio-support
.endif

.if ${PORT_OPTIONS:MAVAHI}
LIB_DEPENDS+=       avahi-client:${PORTSDIR}/net/avahi-app
CONFIGURE_ARGS+=    --enable-avahi
.else
CONFIGURE_ARGS+=    --disable-avahi
.endif

.if ${PORT_OPTIONS:MCUPS}
LIB_DEPENDS+=       cups:${PORTSDIR}/print/cups-client
CONFIGURE_ARGS+=    --enable-cups --enable-iprint
.else
CONFIGURE_ARGS+=    --disable-cups --disable-iprint
.endif

.if ${PORT_OPTIONS:MDNSUPDATE}
SAMBA_WANT_ADS=     yes
CONFIGURE_ARGS+=    --with-dnsupdate
.else
CONFIGURE_ARGS+=    --without-dnsupdate
.endif

# https://bugzilla.samba.org/show_bug.cgi?id=9545
.if ${PORT_OPTIONS:MFAM_SUPPORT}
USE_FAM=        yes
CONFIGURE_ARGS+=    --with-fam
WANT_EXP_MODULES+=  vfs_notify_fam
SAMBA4_MODULES+=    vfs_notify_fam
.else
CONFIGURE_ARGS+=    --without-fam
.endif

.if ${PORT_OPTIONS:MLDAP}
SAMBA4_WANT_LDAP=   yes
.endif

.if ${PORT_OPTIONS:MPAM_SMBPASS}
CONFIGURE_ARGS+=    --with-pam_smbpass
PLIST_SUB+=     SMBPASS=""
.else
CONFIGURE_ARGS+=    --without-pam_smbpass
PLIST_SUB+=     SMBPASS="@comment "
.endif

.if ${PORT_OPTIONS:MPTHREADPOOL}
CONFIGURE_ARGS+=    --enable-pthreadpool
SAMBA4_MODULES+=    vfs_aio_pthread
.else
CONFIGURE_ARGS+=    --disable-pthreadpool
.endif

.if ${PORT_OPTIONS:MQUOTAS}
CONFIGURE_ARGS+=    --with-quotas
.else
CONFIGURE_ARGS+=    --without-quotas
.endif

.if ${PORT_OPTIONS:MSYSLOG}
CONFIGURE_ARGS+=    --with-syslog
.else
CONFIGURE_ARGS+=    --without-syslog
.endif

.if ${PORT_OPTIONS:MSWAT}
CONFIGURE_ARGS+=    --with-swat
PLIST_SUB+=     SWAT=""
.else
CONFIGURE_ARGS+=    --without-swat
PLIST_SUB+=     SWAT="@comment "
.endif

.if ${PORT_OPTIONS:MUTMP}
CONFIGURE_ARGS+=    --with-utmp
.else
CONFIGURE_ARGS+=    --without-utmp
.endif

.if ${PORT_OPTIONS:MWINBIND}
CONFIGURE_ARGS+=    --with-winbind
PLIST_SUB+=     WINBIND=""
.else
CONFIGURE_ARGS+=    --without-winbind
PLIST_SUB+=     WINBIND="@comment "
.endif

.if defined(SAMBA4_WANT_ADS)
CONFIGURE_ARGS+=    --with-ads
.else
CONFIGURE_ARGS+=    --without-ads
.endif

.if defined(SAMBA4_WANT_LDAP)
USE_OPENLDAP=       yes
CONFIGURE_ARGS+=    --with-ldap
PLIST_SUB+=     LDAP=""
.else
CONFIGURE_ARGS+=    --without-ldap
PLIST_SUB+=     LDAP="@comment "
.endif

.if defined(WANT_EXP_MODULES) && !empty(WANT_EXP_MODULES)
SAMBA4_MODULES+=    ${WANT_EXP_MODULES}
CONFIGURE_ARGS+=    --with-shared-modules="${WANT_EXP_MODULES:Q:C|(\\\\ )+|,|g:S|\\||g}"
.endif

.if defined(SAMBA4_BUNDLED_LIBS) && !empty(SAMBA4_BUNDLED_LIBS)
CONFIGURE_ARGS+=    --bundled-libraries="${SAMBA4_BUNDLED_LIBS:Q:C|(\\\\ )+|,|g:S|\\||g}"
.endif

# XXX
.for m in ${SAMBA4_MODULES}
PLIST_REINPLACE+=   ${m}
PLIST_REINPLACE_${m:U}= s|^@comment ${m} ||g
.endfor
##############################################################################
.if ! ${PORT_OPTIONS:MMANPAGES}
CONFIGURE_ENV+=     XSLTPROC="/usr/bin/true"
.else
BUILD_DEPENDS+=     ${LOCALBASE}/share/xsl/docbook/manpages/docbook.xsl:${PORTSDIR}/textproc/docbook-xsl \
            xsltproc:${PORTSDIR}/textproc/libxslt
.endif

SAMBA4_SUB=     SAMBA4_LOGDIR="${SAMBA4_LOGDIR}" \
            SAMBA4_RUNDIR="${SAMBA4_RUNDIR}" \
            SAMBA4_LOCKDIR="${SAMBA4_LOCKDIR}" \
            SAMBA4_MODULEDIR="${SAMBA4_MODULEDIR}" \
            SAMBA4_PRIVATEDIR="${SAMBA4_PRIVATEDIR}" \
            SAMBA4_CONFDIR="${SAMBA4_CONFDIR}" \
            SAMBA4_CONFIG="${SAMBA4_CONFIG}"

PLIST_SUB+=     ${SAMBA4_SUB}
SUB_LIST+=      ${SAMBA4_SUB}

USE_RC_SUBR=        ${SAMBA4_PORTNAME}
SUB_FILES=      pkg-install pkg-message README.FreeBSD

CONFIGURE_ENV+=     NOCOLOR=yes
MAKE_ENV+=      NOCOLOR=yes

.if !defined(DISABLE_MAKE_JOBS) && !defined(MAKE_JOBS_UNSAFE)
CONFIGURE_ARGS+=    --jobs=${MAKE_JOBS_NUMBER}
_MAKE_JOBS+=        --jobs=${MAKE_JOBS_NUMBER}
.endif

MAN1+=          dbwrap_tool.1 findsmb.1 gentest.1 locktest.1 \
            log2pcap.1 masktest.1 ndrdump.1 nmblookup.1 \
            nmblookup4.1 ntlm_auth.1 oLschema2ldif.1 \
            profiles.1 regdiff.1 regpatch.1 regshell.1 \
            regtree.1 rpcclient.1 sharesec.1 smbcacls.1 \
            smbclient.1 smbcontrol.1 smbcquotas.1 smbget.1 \
            smbstatus.1 smbtar.1 smbtorture.1 smbtree.1 \
            testparm.1 vfstest.1 wbinfo.1

MAN5+=          lmhosts.5 smbgetrc.5 smbpasswd.5 pam_winbind.conf.5 \
            smb.conf.5

MAN7+=          samba.7 winbind_krb5_locator.7

MAN8+=          eventlogadm.8 idmap_ad.8 idmap_autorid.8 idmap_hash.8 \
            idmap_ldap.8 idmap_nss.8 idmap_rid.8 idmap_tdb.8 \
            idmap_tdb2.8 net.8 nmbd.8 pam_winbind.8 pdbedit.8 \
            samba-tool.8 samba.8 smbd.8 smbpasswd.8 smbspool.8 \
            smbta-util.8 swat.8 vfs_acl_tdb.8 vfs_acl_xattr.8 \
            vfs_aio_fork.8 vfs_aio_linux.8 vfs_aio_pthread.8 \
            vfs_audit.8 vfs_cacheprime.8 vfs_cap.8 vfs_catia.8 \
            vfs_commit.8 vfs_crossrename.8 vfs_default_quota.8 \
            vfs_dirsort.8 vfs_extd_audit.8 vfs_fake_perms.8 vfs_fileid.8 \
            vfs_full_audit.8 vfs_gpfs.8 vfs_media_harmony.8 \
            vfs_netatalk.8 vfs_notify_fam.8 vfs_prealloc.8 \
            vfs_preopen.8 vfs_readahead.8 vfs_readonly.8 \
            vfs_recycle.8 vfs_scannedonly.8 vfs_shadow_copy.8 \
            vfs_shadow_copy2.8 vfs_smb_traffic_analyzer.8 \
            vfs_streams_depot.8 vfs_streams_xattr.8 vfs_time_audit.8 \
            vfs_tsmsm.8 vfs_xattr_tdb.8 winbindd.8

MLINKS=         smb.conf.5 smb4.conf.5 samba.8 samba4.8

PORTDOCS=       README.FreeBSD

ALL_TARGET=     build
INSTALL_TARGET=     install

IGNORE_NONTHREAD_PYTHON=needs port lang/python${PYTHON_SUFFIX} to be build with THREADS support

post-extract:
            @${RM} -rf ${WRKSRC}/pidl

# Use threading (or multiprocessing) but not thread (renamed in python 3+).
pre-configure:
            @if ! ${PYTHON_CMD} -c "import multiprocessing;" 2>/dev/null; then \
                ${ECHO_CMD}; \
                ${ECHO_MSG} "===>  ${PKGNAME} "${IGNORE_NONTHREAD_PYTHON:Q}.; \
                ${ECHO_CMD}; \
                ${FALSE}; \
            fi

post-patch:
            @${REINPLACE_CMD} -e 's|$${PKGCONFIGDIR}|${PKGCONFIGDIR}|g' \
                ${PATCH_WRKSRC}/buildtools/wafsamba/pkgconfig.py
            @${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \
                ${PATCH_WRKSRC}/buildtools/wafsamba/samba_pidl.py \
                ${PATCH_WRKSRC}/buildtools/wafsamba/wafsamba.py
            @${REINPLACE_CMD} -e 's|%%GDB_CMD%%|${GDB_CMD}|g' \
                ${PATCH_WRKSRC}/buildtools/scripts/abi_gen.sh
            @${REINPLACE_CMD} -e 's|%%SAMBA4_CONFIG%%|${SAMBA4_CONFIG}|g' \
                ${PATCH_WRKSRC}/dynconfig/wscript \
                ${PATCH_WRKSRC}/dynconfig/config.m4
# Make sure that the right version of Python is used by the tools
# https://bugzilla.samba.org/show_bug.cgi?id=7305
            @for f in ${PATCH_WRKSRC}/source4/scripting/bin/*; do \
                ${REINPLACE_CMD} -e '1,1 s|.*python.*|#!${PYTHON_CMD}|' $${f}; \
            done

pre-build:
.if ! ${PORT_OPTIONS:MMANPAGES}
.   for man in  libcli/nbt/man/nmblookup4.1 \
            librpc/tools/ndrdump.1 \
            source4/lib/registry/man/regdiff.1 \
            source4/lib/registry/man/regpatch.1 \
            source4/lib/registry/man/regshell.1 \
            source4/lib/registry/man/regtree.1 \
            source4/torture/man/gentest.1 \
            source4/torture/man/locktest.1 \
            source4/torture/man/masktest.1 \
            source4/torture/man/smbtorture.1 \
            source4/utils/man/ntlm_auth4.1 \
            source4/utils/man/oLschema2ldif.1
            -@${MKDIR} `dirname ${BUILD_WRKSRC}/bin/default/${man}`
            @${INSTALL_MAN} ${FILESDIR}/man/`basename ${man}` ${BUILD_WRKSRC}/bin/default/${man}
.   endfor
            -@${MKDIR} ${BUILD_WRKSRC}/bin/default/docs-xml/manpages
.   for man in ${MAN1} ${MAN5} ${MAN7} ${MAN8}
            -@${INSTALL_MAN} ${BUILD_WRKSRC}/docs/manpages/${man} ${BUILD_WRKSRC}/bin/default/docs-xml/manpages
.   endfor
.endif

do-build:
            @(cd ${BUILD_WRKSRC}; \
            if ! ${SETENV} ${MAKE_ENV} ${PYTHON_CMD} ${BUILD_WRKSRC}/${WAF_TOOL} ${_MAKE_JOBS} ${MAKE_ARGS} ${ALL_TARGET}; then \
                if [ x != x${BUILD_FAIL_MESSAGE} ] ; then \
                    ${ECHO_MSG} "===> Compilation failed unexpectedly."; \
                    (${ECHO_CMD} ${BUILD_FAIL_MESSAGE}) | ${FMT} 75 79 ; \
                fi; \
            ${FALSE}; \
            fi)

do-install:
            @(cd ${INSTALL_WRKSRC} && ${SETENV} ${MAKE_ENV} ${PYTHON_CMD} ${INSTALL_WRKSRC}/${WAF_TOOL} ${MAKE_ARGS} ${INSTALL_TARGET})

post-install:
.if ${PORT_OPTIONS:MDOCS}
            @${MKDIR} ${DOCSDIR}
.   for doc in ${PORTDOCS}
            @${INSTALL_DATA} ${WRKDIR}/${doc} ${DOCSDIR}
.   endfor
.endif
            @${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
            @${CAT} ${PKGMESSAGE}

.if ${PORT_OPTIONS:MDEVELOPER}
test: build
            @(cd ${INSTALL_WRKSRC} && ${SETENV} ${MAKE_ENV} ${PYTHON_CMD} ${INSTALL_WRKSRC}/${WAF_TOOL} ${MAKE_ARGS} $@)
.endif

# !SAMBA4_SUBPORT
.endif

.include <bsd.port.post.mk>