aboutsummaryrefslogtreecommitdiffstats
path: root/mail/dspam/Makefile
blob: b1f36d2c4287c1121c6b8e1b150c9179854dda37 (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
# New ports collection makefile for:    dspam
# Date created:         3 August 2003
# Whom:             Dominic Marks <dom@wirespeed.org.uk>
#
# $FreeBSD$
#

PORTNAME=   dspam
PORTVERSION=    ${PORTVER_MAJ}${SNAP_DATE}
PORTREVISION=   0
CATEGORIES= mail
MASTER_SITES=   http://people.tecnik93.com/~itetcu/FreeBSD/ports/dspam/sources/

MAINTAINER= itetcu@people.tecnik93.com
COMMENT=    Bayesian spam filter - stable maintenance version

PORTVER_MAJ=    3.2.4
#SNAP_DATE= .20041229.1945

.ifdef(SNAP_DATE)
DISTFILES=  dspam.${PORTVER_MAJ}.cvs.stable${SNAP_DATE}.tar.gz
WRKSRC=     ${WRKDIR}/dspam-cvs-stable${SNAP_DATE}
.endif

## debug / log / admin options
OPTIONS=    DEBUG "Enable debugging logging" on
OPTIONS+=   VERBOSE_DEBUG "Enable debug in LOGDIR/dspam.debug" off
OPTIONS+=   PREF_EXT "Preferences in database not in files" off

## algorithm options
OPTIONS+=   GRAHAM_BAYES "Enable Graham (traditional) bayesian" on
OPTIONS+=   BURTON_BAYES "Enable Burton (alternative) bayesian" on
OPTIONS+=   RNB "Use Robinson Naive Bayesian calculation" off
OPTIONS+=   CHI_SQUARE "Use Fisher-Robinson Inv Chi-Square" off
OPTIONS+=   RPV "Use Robinson technique combining p-values" off
OPTIONS+=   TEST_COND "More inoculous results rapidly, risk fps" on
OPTIONS+=   NO_BIAS "No bias toward innocent mail" off
OPTIONS+=   NEURAL_NET "Enable neural networking" off

## run-time configure  options
OPTIONS+=   USER_HOMEDIR "Store user data in ~/.dspam" off
OPTIONS+=   TRUSTED_USERS "Disable trusted user security" off

## back-end
OPTIONS+=   MYSQL40 "Use MySQL 4.0.x as back-end" off
OPTIONS+=   MYSQL41 "Use MySQL 4.1.x as back-end" off
OPTIONS+=   MYSQL50 "Use MySQL 5.0.x as back-end" off
OPTIONS+=   MYSQL_COMPRESS "Compress dspam <--> MySQL" off
OPTIONS+=   POSTGRESQL73 "Use PostgreSQL v.7.3 as back-end" off
OPTIONS+=   POSTGRESQL74 "Use PostgreSQL v.7.4 as back-end" off
OPTIONS+=   ORACLE "Use Oracle as back-end (BROKEN)" off
OPTIONS+=   BDB4 "Use BDB4 as back-end (not recomanded)" off
OPTIONS+=   SQLITE2 "Use SQLite v2.x as back-end" on
OPTIONS+=   VIRT_USERS "Enable virtual users (needs SQL back-end)" off
OPTIONS+=   LONG_USERNAMES "Usernames longer that OS supports" off
OPTIONS+=   LARGE_SCALE "File structure for large scale" off
OPTIONS+=   DOMAIN_SCALE "File structure for multiple domains" off
#OPTIONS+=  SIGNATURE_ATACH "Put server-side signature in mails" off

## MTA and LDA
OPTIONS+=   CYRUS21_LDA "Use Cyrus's 2.1 deliver as LDA" off
OPTIONS+=   CYRUS22_LDA "Use Cyrus's 2.2 deliver as LDA" off
OPTIONS+=   EXIM_LDA "Use Exim as local delivery agent" off
OPTIONS+=   MAILDROP_LDA "Use Maildrop as local delivery agent" off
OPTIONS+=   PROCMAIL_LDA "Use Procmail as local delivery agent" off
OPTIONS+=   SENDMAIL_LDA "Use Sendmail as local delivery agent" off

OPTIONS+=   SENDMAIL "Play nice with sendmail server" off
OPTIONS+=   POSTFIX_MBC "Dspam as mailbox_command in Postfix" off
OPTIONS+=   QMAIL "Play nice with Qmail mail server" off

OPTIONS+=   CGI "Install CGI (pulls in apache)" off

USE_GNOME=  pkgconfig
USE_LIBTOOL_VER=15
USE_REINPLACE=  yes
INSTALLS_SHLIB= yes
GNU_CONFIGURE=  yes
CONFIGURE_ENV=  LDFLAGS="-L${LOCALBASE}/lib"
CONFIGURE_TARGET=   --build=${MACHINE_ARCH}-portbld-freebsd${OSREL}

PKGMESSAGE= ${WRKSRC}/README.FreeBSD

UPD_LINE_NO=    11

CONFLICTS=  dspam-2* dspam-devel-[0-9]*

SIGNATURE_LIFE?=    15

_VAR_DIR=   /var
LOG_DIR?=   ${_VAR_DIR}/log/dspam

DSPAM_MODE?=    4510
DSPAM_OWNER?=   root
DSPAM_GROUP?=   mail

DSPAM_HOME?=    ${_VAR_DIR}/db/dspam
DSPAM_HOME_OWNER?=  ${DSPAM_OWNER}
DSPAM_HOME_GROUP?=  ${DSPAM_GROUP}
DSPAM_HOME_MODE?=   0770

.include <bsd.port.pre.mk>

CONFIGURE_ARGS+=    --with-logdir=${LOG_DIR}
PLIST_SUB+= LOG_DIR=${LOG_DIR}

CONFIGURE_ARGS+=    --with-dspam-home=${DSPAM_HOME}
PLIST_SUB+= DSPAM_HOME=${DSPAM_HOME}

CONFIGURE_ARGS+=    --with-dspam-home-owner=${DSPAM_HOME_OWNER}
CONFIGURE_ARGS+=    --with-dspam-home-group=${DSPAM_HOME_GROUP}
CONFIGURE_ARGS+=    --with-dspam-home-mode=${DSPAM_HOME_MODE}
PLIST_SUB+= DSPAM_HOME=${DSPAM_HOME}

CONFIGURE_ARGS+=    --with-dspam-owner=${DSPAM_OWNER}
CONFIGURE_ARGS+=    --with-dspam-group=${DSPAM_GROUP}
# we set DSPAM_MODE at the end as some LDA whant specific mode

SED_SCRIPT= -e 's,%%DOCSDIR%%,${DOCSDIR},g' \
        -e 's,%%EXAMPLESDIR%%,${EXAMPLESDIR},g' \
        -e 's,%%LOCALBASE%%,${LOCALBASE},g' \
        -e 's,%%PREFIX%%,${PREFIX},g' \
        -e 's,%%PKGNAME%%,${PKGNAME},g' \
        -e 's,%%DSPAM_HOME%%,${DSPAM_HOME},g'

.if defined(WITH_DEBUG)
CONFIGURE_ARGS+=    --enable-debug
.endif

.if defined(WITH_VERBOSE_DEBUG)
CONFIGURE_ARGS+=    --enable-verbose-debug
.endif

.if defined(WITH_PREF_EXT)
CONFIGURE_ARGS+=    --enable-preferences-extension
.endif

.if !defined(WITH_GRAHAM_BAYES)
CONFIGURE_ARGS+=    --disable-traditional-bayesian
.endif

.if !defined(WITH_BURTON_BAYES)
CONFIGURE_ARGS+=    --disable-alternative-bayesian
.endif

.if defined(WITH_RNB)
CONFIGURE_ARGS+=     --enable-robinson
.endif

.if defined(WITH_CHI_SQUARE)
CONFIGURE_ARGS+=     --enable-robinson
.endif

.if defined(WITH_RPV)
CONFIGURE_ARGS+=     --enable-robinson-pvalues
.endif

.if !defined(WITH_TEST_COND)
CONFIGURE_ARGS+=     --disable-test-conditional
.endif

.if defined(WITH_NO_BIAS)
CONFIGURE_ARGS+=    --disable-bias
.endif

.if defined(WITH_NEURAL_NET)
CONFIGURE_ARGS+=    --enable-neural-networking
.endif

.if defined(WITH_USER_HOMEDIR)
CONFIGURE_ARGS+=    --enable-homedir
.endif

.if defined(WITH_TRUSTED_USERS)
CONFIGURE_ARGS+=    --disable-trusted-user-security
.endif

DBDRV_TOTAL_COUNT=  oooooooo # 8
DBDRV_COUNT=    ${DBDRV_TOTAL_COUNT}

.ifdef(WITH_MYSQL40)
WANT_MYSQL_VER= 40
#PKGNAMESUFFIX= -mysql40
.elifdef(WITH_MYSQL41)
WANT_MYSQL_VER= 41
#PKGNAMESUFFIX= -mysql41
.elifdef(WITH_MYSQL50)
WANT_MYSQL_VER= 50
#PKGNAMESUFFIX= -mysql50
.endif

.if defined(WITH_MYSQL40) || defined(WITH_MYSQL41) || defined(WITH_MYSQL50)
USE_MYSQL=  yes
CONFIGURE_ARGS+=    --with-storage-driver=mysql_drv \
        --with-mysql-includes=${LOCALBASE}/include/mysql \
        --with-mysql-libraries=${LOCALBASE}/lib/mysql
PLIST_SUB+= DB4="@comment "
PLIST_SUB+= MYSQL=""
PLIST_SUB+= PGSQL="@comment "
PLIST_SUB+= SQLITE="@comment "
SED_SCRIPT+=    -e 's,%%MYSQL%%,,g'
SED_SCRIPT+=    -e '/%%PGSQL%%/D'
SED_SCRIPT+=    -e '/%%SQLITE%%/D'
DBDRV_COUNT:=   ${DBDRV_COUNT:S/o//}
.if defined(WITH_MYSQL_COMPRESS)
CONFIGURE_ARGS+=    --enable-client-compression
.endif
.endif

.if defined(WITH_POSTGRESQL73)
LIB_DEPENDS+=   pq.3:${PORTSDIR}/databases/postgresql73
#BUILD_DEPENDS= ${LIB_DEPENDS}
CONFIGURE_ARGS+=    --with-storage-driver=pgsql_drv \
        --with-pgsql-includes=${LOCALBASE}/include \
        --with-pgsql-libraries=${LOCALBASE}/lib
PLIST_SUB+= DB4="@comment "
PLIST_SUB+= MYSQL="@comment "
PLIST_SUB+= PGSQL=""
PLIST_SUB+= SQLITE="@comment "
SED_SCRIPT+=    -e '/%%MYSQL%%/D'
SED_SCRIPT+=    -e 's,%%PGSQL%%,,g'
SED_SCRIPT+=    -e '/%%SQLITE%%/D'
#PKGNAMESUFFIX= -pgsql73
DBDRV_COUNT:=   ${DBDRV_COUNT:S/o//}
.endif

.if defined(WITH_POSTGRESQL74)
LIB_DEPENDS+=   ecpg.4:${PORTSDIR}/databases/postgresql7
#BUILD_DEPENDS= ${LIB_DEPENDS}
CONFIGURE_ARGS+=    --with-storage-driver=pgsql_drv \
        --with-pgsql-includes=${LOCALBASE}/include \
        --with-pgsql-libraries=${LOCALBASE}/lib
PLIST_SUB+= DB4="@comment "
PLIST_SUB+= MYSQL="@comment "
PLIST_SUB+= PGSQL=""
PLIST_SUB+= SQLITE="@comment "
SED_SCRIPT+=    -e '/%%MYSQL%%/D'
SED_SCRIPT+=    -e 's,%%PGSQL%%,,g'
SED_SCRIPT+=    -e '/%%SQLITE%%/D'
#PKGNAMESUFFIX= -pgsql74
DBDRV_COUNT:=   ${DBDRV_COUNT:S/o//}
.endif

.if defined(WITH_ORACLE)
BUILD_DEPENDS+= ${LOCALBASE}/oracle7/rdbms/lib/libnlsrtl3.a:\
    ${PORTSDIR}/databases/oracle7-client
CONFIGURE_ARGS+=    --with-storage-driver=ora_drv \
        --with-oracle-home= ${LOCALBASE}/oracle7
#PKGNAMESUFFIX= -oracle
DBDRV_COUNT:=   ${DBDRV_COUNT:S/o//}
.endif

.if defined(WITH_BDB4)
LIB_DEPENDS+=   db41.1:${PORTSDIR}/databases/db41
CONFIGURE_ARGS+=    --with-storage-driver=libdb4_drv \
    --with-db4-includes=${LOCALBASE}/include/db41
PLIST_SUB+= DB4=""
PLIST_SUB+= MYSQL="@comment "
PLIST_SUB+= PGSQL="@comment "
PLIST_SUB+= SQLITE="@comment "
SED_SCRIPT+=    -e '/%%MYSQL%%/D'
SED_SCRIPT+=    -e '/%%PGSQL%%/D'
SED_SCRIPT+=    -e '/%%SQLITE%%/D'
#PKGNAMESUFFIX= -bdb
DBDRV_COUNT:=   ${DBDRV_COUNT:S/o//}
.endif

.if ${DBDRV_TOTAL_COUNT}==${DBDRV_COUNT} || defined(WITH_SQLITE2)
WITH_SQLITE2=   on
LIB_DEPENDS+=   sqlite.2:${PORTSDIR}/databases/sqlite2
CONFIGURE_ARGS+=    --with-storage-driver=sqlite_drv \
    --with-sqlite-includes=${LOCALBASE}/include \
    --with-sqlite-libraries=${LOCALBASE}/lib
PLIST_SUB+= DB4="@comment "
PLIST_SUB+= MYSQL="@comment "
PLIST_SUB+= PGSQL="@comment "
PLIST_SUB+= SQLITE=""
SED_SCRIPT+=    -e '/%%MYSQL%%/D'
SED_SCRIPT+=    -e '/%%PGSQL%%/D'
SED_SCRIPT+=    -e 's,%%SQLITE%%,,g'
#PKGNAMESUFFIX= -sqlite2
DBDRV_COUNT:=   ${DBDRV_COUNT:S/o//}
.endif

.if defined(WITH_VIRT_USERS)
CONFIGURE_ARGS+=    --enable-virtual-users
.endif

.if defined(WITH_LONG_USERNAMES)
CONFIGURE_ARGS+=    --enable-long-usernames
.endif
.if defined(WITH_LARGE_SCALE)
CONFIGURE_ARGS+=    --enable-large-scale
.endif
.if defined(WITH_DOMAIN_SCALE)
CONFIGURE_ARGS+=    --enable-domain-scale
.endif

# add one 'o' here for each new LDA
LDA_TOTAL_COUNT=    ooooooo # 7
LDA_COUNT=  ${LDA_TOTAL_COUNT}

.if defined(WITH_CYRUS21_LDA)
RUN_DEPENDS+=   ${LOCALBASE}/cyrus/bin/deliver:${PORTSDIR}/mail/cyrus-imapd2
CONFIGURE_ARGS+=    --with-delivery-agent='${LOCALBASE}/cyrus/bin/deliver'
LDA_COUNT:= ${LDA_COUNT:S/o//}
.endif

.if defined(WITH_CYRUS22_LDA)
RUN_DEPENDS+=   ${LOCALBASE}/cyrus/bin/deliver:${PORTSDIR}/mail/cyrus-imapd22
CONFIGURE_ARGS+=    --with-delivery-agent='${LOCALBASE}/cyrus/bin/deliver'
LDA_COUNT:= ${LDA_COUNT:S/o//}
.endif

.if defined(WITH_EXIM_LDA)
.   if defined(WITH_MYSQL40) || (WITH_MYSQL41)
_EXIM_EXT=  -mysql
.   elseif defined(WITH_POSTGRESQL74) || defined(WITH_POSTGRESQL73)
####
### fix me for pg 7.3: how to pass the db option to exim port ?
###
_EXIM_EXT=  -postgresql
.   endif
RUN_DEPENDS+=   exim:${PORTSDIR}/mail/exim${_EXIM_EXT}
CONFIGURE_ARGS+=    --with-delivery-agent='${LOCALBASE}/sbin/exim'
LDA_COUNT:= ${LDA_COUNT:S/o//}
.endif

.if defined(WITH_MAILDROP_LDA)
RUN_DEPENDS+=   maildrop:${PORTSDIR}/mail/maildrop
CONFIGURE_ARGS+=    --with-delivery-agent='${LOCALBASE}/bin/maildrop -d $$u'
LDA_COUNT:= ${LDA_COUNT:S/o//}
.endif

.if defined(WITH_PROCMAIL_LDA)
RUN_DEPENDS+=   procmail:${PORTSDIR}/mail/procmail
CONFIGURE_ARGS+=    --with-delivery-agent='${LOCALBASE}/bin/procmail -d $$u'
LDA_COUNT:= ${LDA_COUNT:S/o//}
.endif

.if defined(WITH_SENDMAIL_LDA) && exists(/usr/sbin/sendmail)
CONFIGURE_ARGS+=    --with-delivery-agent=/usr/sbin/sendmail
LDA_COUNT:= ${LDA_COUNT:S/o//}
.else
.   if defined(WITH_SENDMAIL_LDA) && exists(${LOCALBASE}/sbin/sendmail)
CONFIGURE_ARGS+=    --with-delivery-agent='${LOCALBASE}/sbin/sendmail'
LDA_COUNT:= ${LDA_COUNT:S/o//}
.   endif
.endif

.if defined(WITH_SENDMAIL)
DSPAM_MODE= 4511
.endif

.if defined(WITH_POSTFIX_MBC)
DSPAM_MODE= 4511
SED_SCRIPT+=    -e 's,%%POSTFIX_MBC%%,,g'
.else
SED_SCRIPT+=    -e '/%%POSTFIX_MBC%%/D'
.endif

.if defined(WITH_QMAIL)
DSPAM_MODE= 4511
.endif

.if defined(DSPAM_MODE)
CONFIGURE_ARGS+=    --with-dspam-mode=${DSPAM_MODE}
.endif

.if defined(WITH_CGI)
LIB_DEPENDS+=   gd.4:${PORTSDIR}/graphics/gd
RUN_DEPENDS+=   ${LOCALBASE}/sbin/apachectl:${PORTSDIR}/${APACHE_PORT}
RUN_DEPENDS+=   ${SITE_PERL}/mach/GD.pm:${PORTSDIR}/graphics/p5-GD
RUN_DEPENDS+=   ${SITE_PERL}/GD/Graph.pm:${PORTSDIR}/graphics/p5-GD-Graph
RUN_DEPENDS+=   ${SITE_PERL}/GD/Graph3d.pm:${PORTSDIR}/graphics/p5-GD-Graph3d
RUN_DEPENDS+=   ${SITE_PERL}/GD/Text.pm:${PORTSDIR}/graphics/p5-GD-TextUtil
CONFIGURE_ARGS+=--enable-logging
CONFIGURE_ARGS+=--enable-user-logging
USE_PERL5_RUN=  yes
PLIST_SUB+= CGI=""
CGI_PATH?=  ${PREFIX}/www/vhosts/dspam
SED_SCRIPT+=    -e 's,%%CGI%%,,g'
SED_SCRIPT+=    -e 's,%%CGI_PATH%%,${CGI_PATH},g'
#SED_FILES=      ${LS} ${WRKSRC}/cgi/*.pl
#SED_FILES+=     ${LS} $PWRKSRC}/cgi/*.cgi
.else
PLIST_SUB+= CGI="@comment "
SED_SCRIPT+=    -e '/%%CGI%%/D'
.endif

MAN1=   dspam.1 dspam_clean.1 dspam_corpus.1 dspam_dump.1 dspam_merge.1 \
    dspam_stats.1
MAN3=   libdspam.3
MLINKS=     libdspam.3 dspam_init.3
MLINKS+=    libdspam.3 dspam_create.3
MLINKS+=    libdspam.3 dspam_addattribute.3
MLINKS+=    libdspam.3 dspam_attach.3
MLINKS+=    libdspam.3 dspam_process.3
MLINKS+=    libdspam.3 dspam_getsource.3
MLINKS+=    libdspam.3 dspam_destroy.3
MLINKS+=    libdspam.3 dspam_detach.3

DOCS=   CHANGELOG LICENSE README README.FreeBSD README.courier README.exim \
    README.pop3filter README.postfix README.qmail README.sendmail \
    RELEASE.NOTES

pre-everything::
    @${ECHO_CMD} ""
    @${ECHO_CMD} "Last ${FILESDIR}/UPDATING entry:"
    @${GREP} -B 1 -A ${UPD_LINE_NO} ${PKGNAME} ${FILESDIR}/UPDATING
    @${ECHO_CMD} ""
    @${ECHO_CMD} ""

pre-extract:
.if defined(WITH_EXIM_LDA) && defined(WITH_POSTGRESQL73)
    @${ECHO_CMD} "******************************************************************"
    @${ECHO_CMD} "You have both EXIM_LDA and POSTGRESQL73 defined. To have exim"
    @${ECHO_CMD} "built with the right pgsql please hit Ctrl-C now and do:"
    @${ECHO_CMD} "cd ${PORTSDIR}/mail/exim-postgresql && make POSTGRESQL_PORT=postgresql73 install"
    @${ECHO_CMD} "then return here and do:"
    @${ECHO_CMD} "make clean && make install"
    @${ECHO_CMD} "******************************************************************"
    @${ECHO_CMD} ""
.endif

    @${ECHO_CMD} "Define vars below before make-ing if you need:"
    @${ECHO_CMD} ""
    @${ECHO_CMD} "SIGNATURE_LIFE=${SIGNATURE_LIFE} (default 15)"
    @${ECHO_CMD} "DSPAM_OWNER=${DSPAM_OWNER} (default: root)"
    @${ECHO_CMD} "DSPAM_GROUP=${DSPAM_GROUP} (default: mail)"
    @${ECHO_CMD} "DSPAM_MODE=${DSPAM_MODE}"
    @${ECHO_CMD} "DSPAM_HOME=${DSPAM_HOME} (default: ${_VAR_DIR}/db/dspam)"
    @${ECHO_CMD} "DSPAM_HOME_OWNER=${DSPAM_HOME_OWNER}"
    @${ECHO_CMD} "DSPAM_HOME_GROUP=${DSPAM_HOME_GROUP}"
    @${ECHO_CMD} "DSPAM_HOME_MODE=${DSPAM_HOME_MODE} (default: 0770)"
    @${ECHO_CMD} "LOG_DIR=${LOG_DIR} (default: ${_VAR_DIR}/log/dspam)"
.   if defined(WITH_CGI)
        @${ECHO_CMD} "Define CGI_PATH before make-ing if you need the CGI files"
        @${ECHO_CMD} "installed in other place that this installation's default"
        @${ECHO_CMD} "${PREFIX}/www/vhosts/dspam"
.   endif
    @${ECHO_CMD} ""
    @sleep 5

.for old_opt in MAILDROP PROCMAIL TRAD_BAYES ALT_BAYES SPAM_SUBJ \
    USER_LOGGING SYSTEM_LOGGING WEBMAIL OPT_IN SAT PARSE_TO_HEADERS \
    BROKEN_MTA BROKEN_ERR_CODES SIGNATURE_HEADERS SIGNATURE_ATACH \
    HOMEDIR_DOT SIGNATURE_LIFE SQLITE QUARANTINE_AGENT WHITELIST
.   if defined(WITH_${old_opt}) || defined(WITHOUT_${old_opt})
    @${ECHO_CMD} ""
    @${ECHO_CMD} "******************************************************************"
    @${ECHO_CMD} "******************************************************************"
    @${ECHO_CMD} "Either:"
    @${ECHO_CMD} "an old option ${old_opt} or "
    @${ECHO_CMD} "OPTIONS config-file ${_OPTIONS_READ} has been detected !!!"
    @${ECHO_CMD} "Trying to prevent self-shooting this port's make ends here."
    @${ECHO_CMD} "You shold always read ${PORTSDIR}/UPDATING before installing/updating"
    @${ECHO_CMD} "any port. Please remove/adjust your pkgtools.conf, environment and"
    @${ECHO_CMD} "your make command-line and/or do 'make rmconfig' as appropiate."
    @${ECHO_CMD} "But before read ${FILESDIR}/UPDATING"
    @${ECHO_CMD} "as a lot of things have changed, notably the majority of"
    @${ECHO_CMD} "compile-time options can/must now be set in"
    @${ECHO_CMD} "${PREFIX}/etc/dspam.conf"
    @${ECHO_CMD} "******************************************************************"
    @${ECHO_CMD} "******************************************************************"
    @${ECHO_CMD} ""
    @${FALSE}
.   endif
.endfor

post-patch:
    @${REINPLACE_CMD} -e 's|%%PORTNAME%%|${PORTNAME}|; \
        s|%%PKGNAME%%|${PKGNAME}|; s|%%MAINTAINER%%|${MAINTAINER}|; \
        s|%%LIBTOOLFLAGS%%|${LIBTOOLFLAGS}|g; \
        s|-ldb-4.1|-ldb41|g;' ${WRKSRC}/configure

    @${REINPLACE_CMD} -e 's|where @a-14 > to_days(created_on);|where @a-${SIGNATURE_LIFE} > to_days(created_on);|' ${WRKSRC}/tools.mysql_drv/purge.sql
    @${REINPLACE_CMD} -e 's|WHERE CURRENT_DATE - created_on > 14;|WHERE CURRENT_DATE - created_on > ${SIGNATURE_LIFE};|' ${WRKSRC}/tools.pgsql_drv/purge.sql
    @${REINPLACE_CMD} -e 's|where SYSDATE-created_on > 14|where SYSDATE-created_on > ${SIGNATURE_LIFE};|' ${WRKSRC}/tools.ora_drv/purge.sql
    @${REINPLACE_CMD} -e "s|where date('now')-date(created_on) > 14;|where date('now')-date(created_on) > ${SIGNATURE_LIFE};|" ${WRKSRC}/tools.sqlite_drv/purge.sql

pre-configure:
    @${ECHO_CMD}
.if !( ${LDA_TOTAL_COUNT:S/o//}==${LDA_COUNT} || ${LDA_TOTAL_COUNT}==${LDA_COUNT} )
    @${ECHO_CMD} "You can only use one local delivery agent at once."
    @${ECHO_CMD} "See ${LOCALBASE}/etc/dspam.conf for how to chage it at run time."
    @${FALSE}
.endif
.if ${DBDRV_TOTAL_COUNT:S/o//}!=${DBDRV_COUNT}
    @${ECHO_CMD}
    @${ECHO_CMD} "You can use one and only one database back-end at once."
    @${FALSE}
.endif
.if defined(WITH_NEURAL_NET) && !(defined(HAVE_MYSQL) || defined(WITH_POSTGRESQL73) || defined(WITH_POSTGRESQL74))
    @${ECHO_CMD} "You need MySQL or POSTGRESQL to use neural networking."
    @${FALSE}
.endif
.if defined(WITH_VIRT_USERS) && !(defined(USE_MYSQL) || \
    defined(WITH_POSTGRESQL73) || defined(WITH_POSTGRESQL74) || defined(WITH_ORACLE))
    @${ECHO_CMD} "You need MySQL, POSTGRESQL or ORACLE for virtual users."
    @${FALSE}
.endif
.if defined(WITH_PREF_EXT) && !( defined(USE_MYSQL) || \
    defined(WITH_POSTGRESQL73) || defined(WITH_POSTGRESQL74) )
    @${ECHO_CMD} "You need MySQL or Postgres for preferences extension"
    @${FALSE}
.endif
.if defined(WITH_USER_HOMEDIR) && defined(WITH_CGI)
    @${ECHO_CMD} "USER_HOMEDIR and CGI are incopatible"
    @${FALSE}
.endif

post-install:
    ${CP} ${WRKSRC}/dspam.conf ${WRKSRC}/dspam.conf.sample
    cd ${WRKSRC}/ && \
        ${INSTALL} -o ${DSPAM_OWNER} -g ${DSPAM_GROUP} -m 0640 \
             dspam.conf.sample ${PREFIX}/etc
#   @${MKDIR} ${LOG_DIR}
#   @${MKDIR} ${DSPAM_HOME}

.if defined(USE_MYSQL)
    @${MKDIR} ${EXAMPLESDIR}/mysql
    cd ${WRKSRC}/tools.mysql_drv && \
        ${INSTALL_DATA} README mysql_objects-space.sql \
            mysql_objects-speed.sql purge.sql \
            virtual_users.sql mysql_objects-4.1.sql \
            purge-4.1.sql neural.sql  ${EXAMPLESDIR}/mysql
    @${INSTALL_DATA} ${FILESDIR}/2x_to_3x_db.sql ${EXAMPLESDIR}/mysql
    @${INSTALL_DATA} ${FILESDIR}/310_to_320.my.sql ${EXAMPLESDIR}/mysql
.endif
.if defined(WITH_POSTGRESQL73) || defined(WITH_POSTGRESQL74)
    @${MKDIR} ${EXAMPLESDIR}/pgsql
    @cd ${WRKSRC}/tools.pgsql_drv && \
        ${INSTALL_DATA} README *.sql ${EXAMPLESDIR}/pgsql
.endif
.if defined(WITH_SQLITE2)
    @${MKDIR} ${EXAMPLESDIR}/sqlite
    cd ${WRKSRC}/tools.sqlite_drv && \
        ${INSTALL_DATA} README *.sql ${EXAMPLESDIR}/sqlite
.endif
.if defined(WITH_ORACLE)
    @${MKDIR} ${EXAMPLESDIR}/oracle
    cd ${WRKSRC}/tools.ora_drv && \
        ${INSTALL_DATA} README *.sql ${EXAMPLESDIR}/oracle
.endif

.if defined(WITH_CGI)
.   for I in admin.cgi admingraph.cgi configure.pl dspam.cgi graph.cgi
        @${SED} -i '' -e "s,/usr/bin/perl,${PERL},g" ${WRKSRC}/cgi/${I}
.   endfor
    cd ${WRKSRC}/cgi && ${MV} configure.pl configure.pl.sample
    cd ${WRKSRC}/cgi && ${MKDIR} ${CGI_PATH} && \
        ${INSTALL_SCRIPT} configure.pl.sample ${CGI_PATH}/ && \
        ${INSTALL_SCRIPT} *.cgi ${CGI_PATH}
    cd ${WRKSRC}/cgi && \
        ${INSTALL_DATA} base.css dspam-logo-small.gif rgb.txt ${CGI_PATH}/
    cd ${WRKSRC}/cgi && \
        ${INSTALL_DATA} default.prefs ${CGI_PATH}/default.prefs.sample
    cd ${WRKSRC}/cgi && \
        ${INSTALL_DATA} admins ${CGI_PATH}/admins.sample
    @${MKDIR} ${CGI_PATH}/templates && cd ${WRKSRC}/cgi/templates && \
        ${INSTALL_DATA} *.html ${CGI_PATH}/templates/
.endif

    @${SED} ${SED_SCRIPT} ${.CURDIR}/pkg-message > ${WRKSRC}/README.FreeBSD
.if !defined(NOPORTDOCS)
    @${MKDIR} ${DOCSDIR}
    cd ${WRKSRC} && ${INSTALL_DATA} ${DOCS} ${DOCSDIR}
    cd ${FILESDIR} && ${INSTALL_DATA} UPDATING ${DOCSDIR}
.endif

    @${MKDIR} -m ${DSPAM_HOME_MODE} ${DSPAM_HOME}
    @${CHOWN} ${DSPAM_HOME_OWNER}:${DSPAM_HOME_GROUP} ${DSPAM_HOME}
.for _file in firstrun.txt firstspam.txt quarantinefull.txt
    if ! ${TEST} -e ${WRKSRC}/txt/${_file}.sample;\
    then\
        cd ${WRKSRC}/txt && \
        ${MV} ${_file} ${_file}.sample;\
    fi
    cd ${WRKSRC}/txt && \
        ${INSTALL_DATA} ${_file}.sample ${DSPAM_HOME}
.endfor

    @${MKDIR} -m ${DSPAM_HOME_MODE} ${LOG_DIR}

    @${CAT} ${WRKSRC}/README.FreeBSD
    @${ECHO_CMD} "If you haven't defined NOPORTDOCS you can review this"
    @${ECHO_CMD} "message in ${DOCSDIR}/README.FreeBSD"
    @${ECHO_CMD}

.include <bsd.port.post.mk>