File: Makefile.am

package info (click to toggle)
cyrus-imapd 3.0.11-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 62,292 kB
  • sloc: ansic: 189,169; perl: 10,440; sh: 6,155; yacc: 2,197; makefile: 1,970; cpp: 926; python: 361; lex: 320; awk: 303; asm: 262; xml: 1
file content (1970 lines) | stat: -rw-r--r-- 53,040 bytes parent folder | download | duplicates (2)
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
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
#
# @configure_input@
#
# Copyright (c) 1994-2008 Carnegie Mellon University.  All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in
#    the documentation and/or other materials provided with the
#    distribution.
#
# 3. The name "Carnegie Mellon University" must not be used to
#    endorse or promote products derived from this software without
#    prior written permission. For permission or any legal
#    details, please contact
#      Carnegie Mellon University
#      Center for Technology Transfer and Enterprise Creation
#      4615 Forbes Avenue
#      Suite 302
#      Pittsburgh, PA  15213
#      (412) 268-7393, fax: (412) 268-7395
#      innovation@andrew.cmu.edu
#
# 4. Redistributions of any form whatsoever must retain the following
#    acknowledgment:
#    "This product includes software developed by Computing Services
#     at Carnegie Mellon University (http://www.cmu.edu/computing/)."
#
# CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO
# THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS, IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY BE LIABLE
# FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
# AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
# OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

ACLOCAL_AMFLAGS = -I cmulocal
AM_CFLAGS = @PERL_CCCDLFLAGS@ $(GCOV_CFLAGS)
AM_CXXFLAGS = $(GCOV_CXXFLAGS)

AM_CPPFLAGS = \
	$(COM_ERR_CPPFLAGS) \
	-I${top_builddir} \
	-I${top_builddir}/lib \
	-I${top_srcdir} \
	-I${top_srcdir}/lib \
	-DLIBEXEC_DIR=\"$(libexecdir)\" \
	-DSBIN_DIR=\"$(sbindir)\" \
	-DSYSCONF_DIR=\"$(sysconfdir)\" \
	${DEFS} \
	${LOCALDEFS} \
	$(SASLFLAGS) \
	$(SSL_CPPFLAGS) \
	$(ICU_CFLAGS)

if HAVE_LDAP
AM_CPPFLAGS += $(LDAP_CPPFLAGS)
endif # HAVE_LDAP

AM_LDFLAGS = $(COV_LDFLAGS) $(ICU_LIBS)
BUILT_SOURCES = \
	imap/imap_err.c \
	lib/imapopts.c \
	lib/imapopts.h

CLEANFILES = \
	lib/chartable.c \
	lib/imapopts.c \
	lib/imapopts.h

DISTCLEANFILES = \
	imap/imap_err.c \
	imap/imap_err.h \
	imap/mupdate_err.c \
	imap/mupdate_err.h \
	imap/nntp_err.c \
	imap/nntp_err.h \
	imap/http_caldav_js.h \
	imap/http_carddav_js.h \
	imap/http_err.c \
	imap/http_err.h \
	imap/tz_err.c \
	imap/tz_err.h \
	com_err/et/compile_et \
	perl/sieve/scripts/installsieve \
	perl/sieve/scripts/sieveshell \
	sieve/sieve_err.c \
	sieve/sieve_err.h

MAINTAINERCLEANFILES = \
	doc/legacy/murder.png \
	doc/legacy/netnews.png \
	man/imapd.conf.5 \
	man/sieveshell.1 \
	imap/lmtpstats.h \
	imap/pushstats.h \
	sieve/addr.h \
	sieve/sieve.h

SUBDIRS = .
DIST_SUBDIRS = . perl/annotator perl/imap perl/sieve/managesieve
dist_sysconf_DATA =
lib_LTLIBRARIES = lib/libcyrus_min.la lib/libcyrus.la
EXTRA_PROGRAMS =
check_PROGRAMS =
libexec_PROGRAMS =
sbin_PROGRAMS =
noinst_HEADERS =
noinst_LTLIBRARIES =
noinst_PROGRAMS =
EXTRA_DIST = \
	$(wildcard tools/vzic/*) \
	VERSION

if COM_ERR
COMPILE_ET_DEP = com_err/et/compile_et
BUILT_SOURCES += com_err/et/compile_et com_err/et/libcyrus_com_err.la
lib_LTLIBRARIES += com_err/et/libcyrus_com_err.la
endif # COM_ERR

bin_PROGRAMS = imtest/imtest

if SERVER
BUILT_SOURCES += \
	imap/mupdate_err.c \
	imap/nntp_err.c \
	imap/lmtpstats.c \
	imap/pushstats.c \
	lib/htmlchar.c \
	lib/htmlchar.h \
	imap/rfc822_header.c \
	imap/rfc822_header.h

lib_LTLIBRARIES += imap/libcyrus_imap.la

libexec_PROGRAMS += \
	master/master \
	imap/imapd \
	imap/lmtpd \
	imap/pop3d \
	imap/smmapd

sbin_PROGRAMS += \
	imap/arbitron \
	imap/chk_cyrus \
	imap/ctl_conversationsdb \
	imap/ctl_cyrusdb \
	imap/ctl_deliver \
	imap/ctl_mboxlist \
	imap/cvt_cyrusdb \
	imap/cyr_df \
	imap/cyrdump \
	imap/cyr_dbtool \
	imap/cyr_deny \
	imap/cyr_expire \
	imap/cyr_info \
	imap/cyr_buildinfo \
	imap/cyr_sequence \
	imap/cyr_synclog \
	imap/cyr_userseen \
	imap/cyr_virusscan \
	imap/deliver \
	imap/ipurge \
	imap/mbexamine \
	imap/mbpath \
	imap/mbtool \
	imap/quota \
	imap/reconstruct \
	imap/cvt_xlist_specialuse

noinst_PROGRAMS += \
	imap/message_test \
	imap/search_test

if USE_SPHINX
sbin_PROGRAMS += imap/cyr_sphinxmgr
endif

if USE_SQUAT
noinst_PROGRAMS += imap/squat_dump
endif
if SQUATTER
# Despite the name, the squatter program handles any search engine
sbin_PROGRAMS += imap/squatter
endif

if NNTPD
libexec_PROGRAMS += imap/nntpd
sbin_PROGRAMS += imap/fetchnews
endif # NNTPD

libexec_PROGRAMS += imap/fud

if IDLED
libexec_PROGRAMS += imap/idled
endif # IDLED

if MURDER
libexec_PROGRAMS += imap/mupdate
endif # MURDER

if NNTPD
libexec_PROGRAMS += imap/nntpd
endif

if CALALARMD
libexec_PROGRAMS += imap/calalarmd
endif

if HTTPD
AM_CPPFLAGS += $(HTTP_CPPFLAGS)
AM_LDFLAGS += $(HTTP_LIBS)

BUILT_SOURCES += \
	imap/http_caldav_js.h \
	imap/http_carddav_js.h \
	imap/http_err.c \
	imap/http_err.h \
	imap/tz_err.c \
	imap/tz_err.h

libexec_PROGRAMS += imap/httpd
sbin_PROGRAMS += \
	imap/ctl_zoneinfo \
	imap/dav_reconstruct
endif # HTTPD

if REPLICATION
libexec_PROGRAMS += imap/sync_server
sbin_PROGRAMS += imap/sync_client imap/sync_reset
endif # REPLICATION

if BACKUP
noinst_LTLIBRARIES += backup/libcyrus_backup.la
noinst_HEADERS += backup/backup.h
libexec_PROGRAMS += backup/backupd
sbin_PROGRAMS += backup/ctl_backups backup/cyr_backup backup/restore
endif # BACKUP

if HAVE_SSL
sbin_PROGRAMS += imap/tls_prune
endif # HAVE_SSL

sbin_PROGRAMS += imap/unexpunge

if SIEVE
check_PROGRAMS += notifyd/notifytest
libexec_PROGRAMS += notifyd/notifyd
endif # SIEVE

else # SERVER
EXTRA_DIST += \
    imap/mupdate_err.c \
    imap/nntp_err.c \
    imap/lmtpstats.c \
    imap/pushstats.c \
    imap/rfc822_header.c \
    imap/rfc822_header.h

if !HTTPD
EXTRA_DIST += \
	imap/http_err.c \
	imap/http_err.h \
	imap/tz_err.c \
	imap/tz_err.h
endif # HTTPD

endif # SERVER

if CMULOCAL
dist_sysconf_DATA += depot/rc.local.imap depot/rc.local.ptclient
sbin_PROGRAMS += netnews/remotepurge
endif # CMULOCAL

if PTCLIENT
sbin_PROGRAMS += ptclient/ptdump ptclient/ptexpire
libexec_PROGRAMS += \
	ptclient/ptloader
endif # PTCLIENT

if PERL
SUBDIRS += perl/annotator perl/imap
noinst_LTLIBRARIES += perl/libcyrus.la perl/libcyrus_min.la
endif # PERL

if SIEVE

if PERL
SUBDIRS += perl/sieve/managesieve
noinst_LTLIBRARIES += perl/sieve/lib/libisieve.la
endif # PERL

BUILT_SOURCES += sieve/addr.c sieve/sieve.c sieve/sieve_err.c
noinst_LTLIBRARIES += sieve/libcyrus_sieve_lex.la
lib_LTLIBRARIES += sieve/libcyrus_sieve.la
check_PROGRAMS += sieve/test
sbin_PROGRAMS += sieve/sievec sieve/sieved

if SERVER
libexec_PROGRAMS += timsieved/timsieved
endif # SERVER

endif # SIEVE

EXTRA_DIST += \
	COPYING \
	README.md \
	SMakefile \
	com_err/et/et_c.awk \
	com_err/et/et_h.awk \
	com_err/et/test1.et \
	com_err/et/test2.et \
	com_err/et/test_et.c \
	contrib/drac_auth.patch \
	contrib/sieve-spamasssassin \
	contrib/fud-client.c \
	contrib/deliver-notify-zephyr.patch \
	contrib/add-cyrus-user \
	contrib/README \
	contrib/cyrus-graphtools.1.0 \
	contrib/cyrus-graphtools.1.0/cgi-bin/cyrus_master.pl \
	contrib/cyrus-graphtools.1.0/cgi-bin/graph_cyrus_db.pl \
	contrib/cyrus-graphtools.1.0/cgi-bin/graph_cyrus_db-sum.pl \
	contrib/cyrus-graphtools.1.0/html \
	contrib/cyrus-graphtools.1.0/html/index.html \
	contrib/cyrus-graphtools.1.0/README \
	contrib/cyrus-graphtools.1.0/script \
	contrib/cyrus-graphtools.1.0/script/cyrus.pl \
	contrib/cyrus-graphtools.1.0/script/run \
	contrib/cyrus-graphtools.1.0/script/cyrusrc \
	contrib/cyrusv2.mc \
	contrib/dkim_canon_ischedule.patch \
	contrib/notify_unix/notify \
	contrib/notify_unix/net-server-prefork-0.01.tgz \
	contrib/notify_unix/README \
	contrib/notify_unix/sql_notify.pl \
	contrib/notify_unix/simple_notify.pl \
	contrib/squatrunner.pl \
	contrib/mupdate-test.pl \
	contrib/squatrunner.txt \
	cunit/cacert.pem \
	cunit/cert.pem \
	cunit/cunit.pl \
	cunit/cunit-to-junit.pl \
	cunit/key.pem \
	cunit/vg.supp \
	doc/legacy/murder.png \
	doc/legacy/netnews.png \
	doc \
	docsrc \
	imap/dav_util.h \
	imap/http_caldav_js.h \
	imap/http_caldav.js \
	imap/http_carddav_js.h \
	imap/http_carddav.js \
	imap/http_err.et \
	imap/imap_err.et \
	imap/mupdate_err.et \
	imap/nntp_err.et \
	imap/rfc822_header.st \
	imap/tz_err.et \
	lib/charset/aliases.txt \
	lib/charset/UnicodeData.txt \
	lib/charset/unifix.txt \
	lib/charset/us-ascii.t \
	lib/htmlchar.st \
	lib/imapoptions \
	lib/test/cyrusdb.c \
	lib/test/cyrusdb.INPUT \
	lib/test/cyrusdblong.INPUT \
	lib/test/cyrusdblong.OUTPUT \
	lib/test/cyrusdb.OUTPUT \
	lib/test/cyrusdbtxn.INPUT \
	lib/test/cyrusdbtxn.OUTPUT \
	lib/test/pool.c \
	lib/test/rnddb.c \
	master/CYRUS-MASTER.mib \
	master/README \
	netnews/inn.diffs \
	perl/annotator/Daemon.pm \
	perl/annotator/Makefile.PL \
	perl/annotator/Makefile.PL.in \
	perl/annotator/MANIFEST \
	perl/annotator/MANIFEST.in \
	perl/annotator/Message.pm \
	perl/annotator/README \
	perl/imap/Changes \
	perl/imap/cyradm.sh \
	perl/imap/cyrperl.h \
	perl/imap/examples/auditmbox.pl \
	perl/imap/examples/imapcollate.pl \
	perl/imap/examples/imapdu.pl \
	perl/imap/examples/test-imsp.pl \
	perl/imap/IMAP/Admin.pm \
	perl/imap/IMAP/IMSP.pm \
	perl/imap/IMAP/Shell.pm \
	perl/imap/IMAP.pm \
	perl/imap/IMAP.xs \
	perl/imap/Makefile.PL \
	perl/imap/Makefile.PL.in \
	perl/imap/MANIFEST \
	perl/imap/MANIFEST.in \
	perl/imap/README \
	perl/imap/t/01-imclient.t \
	perl/imap/t/02-admin.t \
	perl/imap/typemap \
	perl/imap/xsutil.c \
	perl/sieve/managesieve/Makefile.PL \
	perl/sieve/managesieve/Makefile.PL.in \
	perl/sieve/managesieve/managesieve.h \
	perl/sieve/managesieve/managesieve.pm \
	perl/sieve/managesieve/managesieve.xs \
	perl/sieve/managesieve/MANIFEST \
	perl/sieve/managesieve/MANIFEST.in \
	perl/sieve/managesieve/typemap \
	ptclient/README \
	ptclient/test.c \
	ptclient/test2.c \
	sieve/addr.h \
	sieve/sieve.h \
	sieve/sieve_err.et \
	sieve/tests/testExtension \
	sieve/tests/testExtension/uberExtensionTestScript.key \
	sieve/tests/testExtension/testm \
	sieve/tests/testExtension/testm/uetest-envelope \
	sieve/tests/testExtension/testm/uetest-asub \
	sieve/tests/testExtension/testm/uetest-areg \
	sieve/tests/testExtension/testm/uetest-count \
	sieve/tests/testExtension/testm/uetest-value \
	sieve/tests/testExtension/testm/uetest-hreg \
	sieve/tests/testExtension/serverm \
	sieve/tests/testExtension/serverm/uetmail-hreg \
	sieve/tests/testExtension/serverm/uetmail-value \
	sieve/tests/testExtension/serverm/uetmail-count2 \
	sieve/tests/testExtension/serverm/uetmail-envelope \
	sieve/tests/testExtension/serverm/uetmail-asub \
	sieve/tests/testExtension/serverm/uetmail-value2 \
	sieve/tests/testExtension/serverm/uetmail-areg \
	sieve/tests/testExtension/serverm/uetmail-count \
	sieve/tests/testExtension/uberExtensionTestScript.s \
	sieve/tests/README \
	sieve/tests/action \
	sieve/tests/action/testm \
	sieve/tests/action/testm/uatest-keep \
	sieve/tests/action/testm/uatest-redirect \
	sieve/tests/action/testm/uatest-discard \
	sieve/tests/action/testm/uatest-stop2 \
	sieve/tests/action/testm/uatest-stop \
	sieve/tests/action/serverm \
	sieve/tests/action/serverm/uamail-stop2 \
	sieve/tests/action/serverm/uamail-redirect \
	sieve/tests/action/serverm/uamail-stop \
	sieve/tests/action/serverm/uamail-keep \
	sieve/tests/action/serverm/uamail-discard \
	sieve/tests/action/uberActionScript.key \
	sieve/tests/action/uberActionScript.s \
	sieve/tests/test \
	sieve/tests/test/uberTestScript.key \
	sieve/tests/test/testm \
	sieve/tests/test/testm/utest-header \
	sieve/tests/test/testm/utest-address \
	sieve/tests/test/serverm \
	sieve/tests/test/serverm/utmail-address \
	sieve/tests/test/serverm/utmail-header \
	sieve/tests/test/uberTestScript.s \
	sieve/tests/actionExtensions \
	sieve/tests/actionExtensions/uberExtensionActionScript.s \
	sieve/tests/actionExtensions/testm \
	sieve/tests/actionExtensions/testm/ueatest-flag4 \
	sieve/tests/actionExtensions/testm/ueatest-flag2 \
	sieve/tests/actionExtensions/testm/ueatest-fileinto \
	sieve/tests/actionExtensions/testm/ueatest-denotify \
	sieve/tests/actionExtensions/testm/ueatest-vacation \
	sieve/tests/actionExtensions/testm/ueatest-reject \
	sieve/tests/actionExtensions/testm/ueatest-mark \
	sieve/tests/actionExtensions/testm/ueatest-denotify2 \
	sieve/tests/actionExtensions/testm/ueatest-flag5 \
	sieve/tests/actionExtensions/testm/ueatest-notify2 \
	sieve/tests/actionExtensions/testm/ueatest-notify \
	sieve/tests/actionExtensions/testm/ueatest-flag1 \
	sieve/tests/actionExtensions/testm/ueatest-flag3 \
	sieve/tests/actionExtensions/testm/ueatest-unmark \
	sieve/tests/actionExtensions/uberExtensionActionScript.key \
	sieve/tests/actionExtensions/serverm \
	sieve/tests/actionExtensions/serverm/ueamail-flag4 \
	sieve/tests/actionExtensions/serverm/ueamail-denotify \
	sieve/tests/actionExtensions/serverm/ueamail-mark \
	sieve/tests/actionExtensions/serverm/ueamail-denotify2 \
	sieve/tests/actionExtensions/serverm/ueamail-flag2 \
	sieve/tests/actionExtensions/serverm/ueamail-unmark \
	sieve/tests/actionExtensions/serverm/ueamail-reject \
	sieve/tests/actionExtensions/serverm/ueamail-flag3 \
	sieve/tests/actionExtensions/serverm/ueamail-fileinto \
	sieve/tests/actionExtensions/serverm/ueamail-flag1 \
	sieve/tests/actionExtensions/serverm/ueamail-notify \
	sieve/tests/actionExtensions/serverm/ueamail-flag5 \
	sieve/tests/actionExtensions/serverm/ueamail-notify2 \
	sieve/tests/actionExtensions/serverm/ueamail-vacation \
	timsieved/TODO

TEXINFO_TEX = com_err/et/texinfo.tex
dist_noinst_SCRIPTS = \
	com_err/et/compile_et.sh \
	com_err/et/config_script \
	imap/lmtpstats.snmp \
	imap/pushstats.snmp \
	lib/mkchartable.pl \
	lib/test/run \
	perl/sieve/scripts/installsieve.pl \
	perl/sieve/scripts/sieveshell.pl \
	tools/arbitronsort.pl \
	tools/compile_st.pl \
	tools/config2header \
	tools/config2man \
	tools/config2rst \
	tools/config2sample \
	tools/fixsearchpath.pl \
	tools/git-version.sh \
	tools/jenkins-build.sh \
	tools/masssievec \
	tools/mkimap \
	tools/mknewsgroups \
	tools/rehash \
	tools/translatesieve \
	snmp/snmpgen
noinst_MAN = \
	com_err/et/com_err.3 \
	com_err/et/compile_et.1
noinst_TEXINFOS = com_err/et/com_err.texinfo

pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libcyrus_min.pc libcyrus.pc libcyrus_sieve.pc libcyrus_imap.pc

com_err_et_libcyrus_com_err_la_SOURCES = \
	com_err/et/com_err.c \
	com_err/et/com_err.h \
	com_err/et/error_message.c \
	com_err/et/error_table.h \
	com_err/et/et_name.c \
	com_err/et/init_et.c \
	com_err/et/internal.h \
	com_err/et/mit-sipb-copyright.h
com_err_et_libcyrus_com_err_la_CFLAGS = $(AM_CFLAGS) $(CFLAG_VISIBILITY)

com_err/et/compile_et: com_err/et/compile_et.sh com_err/et/config_script \
	config.h
	@${top_srcdir}/com_err/et/config_script ${top_srcdir}/com_err/et/compile_et.sh ${AWK} ${SED} > $@
	@chmod 755 $@

# ---- Libraries ----

# BASIC is the libraries that every Cyrus program (except master) will
# need to link with.
#
# Note that several places in the code use -lcrypto, e.g. for SHA1 or
# MD5 algorithms, without needing SSL.  Currently we have no way of
# minimally linking such code.
LD_BASIC_ADD = lib/libcyrus.la lib/libcyrus_min.la ${LIBS} \
	${LIB_SASL} $(SSL_LIBS) $(GCOV_LIBS)

# UTILITY is the libraries that utility programs which use Cyrus'
# mailbox and message handling code need to link with.

LD_UTILITY_ADD = imap/libcyrus_imap.la $(LD_BASIC_ADD) $(COM_ERR_LIBS)

# SERVER is the libraries that network-facing servers need to link with
#
# Note that the code is horribly intertwingled e.g. in imap/global.c
# so that even utilities which never open a socket need to link against
# the SASL library.
LD_SERVER_ADD = $(LD_UTILITY_ADD) $(LIB_WRAP)

# SIEVE is the libraries that sieve-using components need to link with
#
# This is empty if sieve is not enabled, so it can be used unconditionally
# elsewhere.

if SIEVE
LD_SIEVE_ADD = sieve/libcyrus_sieve.la $(LD_BASIC_ADD)
else
LD_SIEVE_ADD =
endif

# ----

if CUNIT

CUNIT_PROJECT = cunit/default.cunit
BUILT_SOURCES += cunit/registers.h $(CUNIT_PROJECT)
CLEANFILES += cunit/registers.h $(CUNIT_PROJECT)
check_PROGRAMS += cunit/unit

cunit_FRAMEWORK = \
	cunit/unit.c \
	cunit/cunit.h \
	cunit/syslog.c \
	cunit/cunit-syslog.h \
	cunit/timeout.c \
	cunit/timeout.h \
	cunit/timezones.c \
	cunit/timezones.h \
	cunit/timeofday.c \
	cunit/timeofday.h

cunit_TESTS = \
	cunit/aaa-db.testc \
	cunit/annotate.testc \
	cunit/backend.testc \
	cunit/binhex.testc \
	cunit/bitvector.testc \
	cunit/buf.testc \
	cunit/byteorder64.testc \
	cunit/charset.testc \
	cunit/command.testc \
	cunit/conversations.testc \
	cunit/crc32.testc \
	cunit/dlist.testc \
	cunit/duplicate.testc \
	cunit/getxstring.testc \
	cunit/glob.testc \
	cunit/guid.testc \
	cunit/hash.testc \
	cunit/imapurl.testc \
	cunit/libconfig.testc \
	cunit/mboxname.testc \
	cunit/md5.testc \
	cunit/message.testc \
	cunit/msgid.testc \
	cunit/parseaddr.testc \
	cunit/parse.testc \
	cunit/prot.testc \
	cunit/ptrarray.testc \
	cunit/quota.testc \
	cunit/rfc822tok.testc \
	cunit/search_expr.testc \
	cunit/seqset.testc

if SIEVE
cunit_TESTS += cunit/sieve.testc
endif

cunit_TESTS += \
	cunit/spool.testc \
	cunit/squat.testc \
	cunit/strarray.testc \
	cunit/strconcat.testc \
	cunit/times.testc \
	cunit/tok.testc \
	cunit/vparse.testc

cunit_unit_SOURCES = $(cunit_FRAMEWORK) $(cunit_TESTS) \
		imap/mutex_fake.c imap/spool.c
cunit_unit_LDADD = $(LD_SIEVE_ADD) $(LD_UTILITY_ADD) -lcunit

CUNIT_PL = $(top_srcdir)/cunit/cunit.pl --project $(CUNIT_PROJECT)

# don't discard the temporary source file if building with coverage
if HAVE_COVERAGE
    CUNIT_RM = true
else
    CUNIT_RM = $(RM)
endif

.testc.o:
	$(AM_V_at)$(CUNIT_PL) --generate-wrapper $<
	$(AM_V_CC)$(COMPILE) -c -o $@ $<-cunit.c
	$(AM_V_at)$(CUNIT_RM) $<-cunit.c

$(CUNIT_PROJECT):
	$(AM_V_at)$(RM) $@
	$(AM_V_GEN)$(CUNIT_PL) --add-sources $(addprefix $(top_srcdir)/,$(cunit_TESTS))

cunit/registers.h: $(CUNIT_PROJECT)
	$(AM_V_GEN)$(CUNIT_PL) --generate-register-function $@

# To run under Valgrind, do: make VG=1 check
VALGRIND = libtool --mode=execute valgrind --tool=memcheck --leak-check=full --suppressions=vg.supp

check-local:
	@echo "Running unit tests"
	@vg= ; \
		test -z "$$VG" || vg="$(VALGRIND)" ; \
		f="-v" ; \
		test "x$$CUFORMAT" = xjunit && f="-x" ; \
		cd cunit ; \
		$$vg ./unit $$f ; \
		retval=$$? ; \
		if [ "x$$CUFORMAT" = xjunit ] ; then \
			$(RM) -rf reports ; mkdir reports ; ./cunit-to-junit.pl ; \
		fi ; \
		exit $$retval

check-%: cunit/unit
	@echo "Running unit tests for $*"
	@vg= ; \
		test -z "$$VG" || vg="$(VALGRIND)" ; \
		cd cunit ; \
		$$vg ./unit -v $* ; \
		retval=$$? ; \
		exit $$retval

endif

includedir=@includedir@/cyrus

include_HEADERS = \
	lib/acl.h \
	lib/arrayu64.h \
	lib/assert.h \
	lib/auth.h \
	lib/auth_pts.h \
	lib/bitvector.h \
	lib/bloom.h \
	lib/bsearch.h \
	lib/bufarray.h \
	lib/charset.h \
	lib/chartable.h \
	lib/command.h \
	lib/crc32.h \
	lib/crc32c.h \
	lib/cyr_lock.h \
	lib/cyrusdb.h \
	lib/exitcodes.h \
	lib/glob.h \
	lib/gmtoff.h \
	lib/hash.h \
	lib/hashu64.h \
	lib/imapurl.h \
	lib/imclient.h \
	lib/imparse.h \
	lib/iostat.h \
	lib/iptostring.h \
	lib/libcyr_cfg.h \
	lib/lsort.h \
	lib/map.h \
	lib/mappedfile.h \
	lib/mkgmtime.h \
	lib/mpool.h \
	lib/murmurhash2.h \
	lib/nonblock.h \
	lib/parseaddr.h \
	lib/retry.h \
	lib/rfc822tok.h \
	lib/signals.h \
	lib/sqldb.h \
	lib/strarray.h \
	lib/strhash.h \
	lib/stristr.h \
	lib/sysexits.h \
	lib/times.h \
	lib/tok.h \
	lib/vparse.h \
	lib/wildmat.h \
	lib/xmalloc.h

nodist_include_HEADERS = \
	lib/imapopts.h

nobase_include_HEADERS = sieve/sieve_interface.h
nobase_nodist_include_HEADERS = sieve/sieve_err.h

noinst_HEADERS += \
	lib/byteorder64.h \
	lib/gai.h \
	lib/libconfig.h \
	lib/md5.h \
	lib/prot.h \
	lib/ptrarray.h \
	lib/util.h \
	lib/xsha1.h \
	lib/xstrlcat.h \
	lib/xstrlcpy.h \
	lib/xstrnchr.h

backup_libcyrus_backup_la_SOURCES = \
    lib/gzuncat.c \
    lib/gzuncat.h \
    backup/lcb.c \
    backup/lcb_append.c \
    backup/lcb_backupdb.c \
    backup/lcb_compact.c \
    backup/lcb_indexr.c \
    backup/lcb_indexw.c \
    backup/lcb_internal.c \
    backup/lcb_internal.h \
    backup/lcb_partlist.c \
    backup/lcb_read.c \
    backup/lcb_sqlconsts.c \
    backup/lcb_sqlconsts.h \
    backup/lcb_verify.c
backup_libcyrus_backup_la_LIBADD = $(LD_BASIC_ADD)

backup_backupd_SOURCES = \
    imap/mutex_fake.c \
    imap/sync_support.c \
    imap/sync_support.h \
    master/service.c \
    backup/backupd.c
backup_backupd_LDADD = backup/libcyrus_backup.la $(LD_SIEVE_ADD) $(LD_SERVER_ADD)

backup_ctl_backups_SOURCES = \
    imap/mutex_fake.c \
    imap/sync_support.c \
    imap/sync_support.h \
    backup/ctl_backups.c
backup_ctl_backups_LDADD = backup/libcyrus_backup.la $(LD_SIEVE_ADD) $(LD_UTILITY_ADD)

backup_cyr_backup_SOURCES = \
    imap/mutex_fake.c \
    backup/cyr_backup.c
backup_cyr_backup_LDADD = backup/libcyrus_backup.la $(LD_UTILITY_ADD) $(JANSSON_LIBS)

backup_restore_SOURCES = \
    imap/mutex_fake.c \
    imap/sync_support.c \
    imap/sync_support.h \
    backup/restore.c
backup_restore_LDADD = backup/libcyrus_backup.la $(LD_SIEVE_ADD) $(LD_UTILITY_ADD)

imap_arbitron_SOURCES = imap/arbitron.c imap/cli_fatal.c imap/mutex_fake.c
imap_arbitron_LDADD = $(LD_UTILITY_ADD)

imap_chk_cyrus_SOURCES = imap/chk_cyrus.c imap/cli_fatal.c imap/mutex_fake.c
imap_chk_cyrus_LDADD = $(LD_UTILITY_ADD)

imap_ctl_conversationsdb_SOURCES = imap/ctl_conversationsdb.c imap/mutex_fake.c
imap_ctl_conversationsdb_LDADD = $(LD_UTILITY_ADD)

imap_ctl_cyrusdb_SOURCES = imap/cli_fatal.c imap/ctl_cyrusdb.c imap/mutex_fake.c
imap_ctl_cyrusdb_LDADD = $(LD_UTILITY_ADD)

imap_ctl_deliver_SOURCES = imap/cli_fatal.c imap/ctl_deliver.c imap/mutex_fake.c
imap_ctl_deliver_LDADD = $(LD_UTILITY_ADD)

imap_ctl_mboxlist_SOURCES = imap/cli_fatal.c imap/ctl_mboxlist.c imap/mutex_fake.c
imap_ctl_mboxlist_LDADD = $(LD_UTILITY_ADD)

imap_cvt_cyrusdb_SOURCES = imap/cli_fatal.c imap/cvt_cyrusdb.c imap/mutex_fake.c
imap_cvt_cyrusdb_LDADD = $(LD_UTILITY_ADD)

imap_cyrdump_SOURCES = imap/cli_fatal.c imap/cyrdump.c imap/mutex_fake.c
imap_cyrdump_LDADD = $(LD_UTILITY_ADD)

imap_cyr_dbtool_SOURCES = imap/cli_fatal.c imap/cyr_dbtool.c imap/mutex_fake.c
imap_cyr_dbtool_LDADD = $(LD_UTILITY_ADD)

imap_cyr_deny_SOURCES = imap/cli_fatal.c imap/cyr_deny.c imap/mutex_fake.c
imap_cyr_deny_LDADD = $(LD_UTILITY_ADD)

imap_cyr_df_SOURCES = imap/cli_fatal.c imap/cyr_df.c imap/mutex_fake.c
imap_cyr_df_LDADD = $(LD_UTILITY_ADD)

imap_cyr_expire_SOURCES = imap/cli_fatal.c imap/cyr_expire.c imap/mutex_fake.c
imap_cyr_expire_LDADD = $(LD_UTILITY_ADD)

imap_cyr_info_SOURCES = imap/cli_fatal.c imap/cyr_info.c imap/mutex_fake.c master/masterconf.c
imap_cyr_info_LDADD = $(LD_UTILITY_ADD)

imap_cyr_buildinfo_SOURCES = imap/cli_fatal.c imap/cyr_buildinfo.c imap/mutex_fake.c master/masterconf.c
imap_cyr_buildinfo_LDADD = $(LD_UTILITY_ADD) $(JANSSON_LIBS)

imap_cyr_sequence_SOURCES = imap/cli_fatal.c imap/cyr_sequence.c imap/mutex_fake.c
imap_cyr_sequence_LDADD = $(LD_UTILITY_ADD)

imap_cyr_synclog_SOURCES = imap/cli_fatal.c imap/cyr_synclog.c imap/mutex_fake.c
imap_cyr_synclog_LDADD = $(LD_UTILITY_ADD)

imap_cyr_userseen_SOURCES = imap/cli_fatal.c imap/cyr_userseen.c imap/mutex_fake.c
imap_cyr_userseen_LDADD = $(LD_UTILITY_ADD)

imap_cyr_sphinxmgr_SOURCES = imap/cli_fatal.c imap/cyr_sphinxmgr.c imap/mutex_fake.c
imap_cyr_sphinxmgr_LDADD = $(LD_UTILITY_ADD)

imap_cyr_virusscan_SOURCES = imap/cli_fatal.c imap/cyr_virusscan.c imap/mutex_fake.c
imap_cyr_virusscan_CFLAGS = $(AM_CFLAGS) $(CLAMAV_CFLAGS) $(CFLAG_VISIBILITY)
imap_cyr_virusscan_LDADD = $(LD_UTILITY_ADD) $(CLAMAV_LIBS)

imap_ctl_zoneinfo_SOURCES = imap/cli_fatal.c imap/ctl_zoneinfo.c imap/mutex_fake.c imap/zoneinfo_db.c
imap_ctl_zoneinfo_LDADD = $(LD_UTILITY_ADD)

imap_deliver_SOURCES = \
	imap/deliver.c \
	imap/lmtpengine.c \
	imap/lmtpstats.c \
	imap/mutex_fake.c \
	imap/proxy.c \
	imap/spool.c

imap_deliver_LDADD = $(LD_UTILITY_ADD)

imap_fetchnews_SOURCES = imap/cli_fatal.c imap/fetchnews.c imap/mutex_fake.c
imap_fetchnews_LDADD = $(LD_UTILITY_ADD)

imap_fud_SOURCES = imap/fud.c imap/mutex_fake.c master/service.c
imap_fud_LDADD = $(LD_SERVER_ADD)

imap_idled_SOURCES = imap/idled.c imap/mutex_fake.c
imap_idled_LDADD = $(LD_UTILITY_ADD)

imap_calalarmd_SOURCES = imap/calalarmd.c imap/mutex_fake.c
imap_calalarmd_LDADD = $(LD_SERVER_ADD)

imap_imapd_SOURCES = \
	imap/imap_proxy.c \
	imap/imap_proxy.h \
	imap/imapd.c \
	imap/imapd.h \
	imap/mutex_fake.c \
	imap/pushstats.c \
	imap/pushstats.h \
	imap/proxy.c \
	imap/proxy.h \
	imap/sync_support.c \
	imap/sync_support.h \
	master/service.c

if AUTOCREATE
imap_imapd_SOURCES += \
	imap/autocreate.h \
	imap/autocreate.c
endif

imap_imapd_LDADD = $(LD_SIEVE_ADD) $(LD_SERVER_ADD)

imap_ipurge_SOURCES = imap/cli_fatal.c imap/ipurge.c imap/mutex_fake.c
imap_ipurge_LDADD = $(LD_UTILITY_ADD)

nodist_imap_libcyrus_imap_la_SOURCES = \
	imap/imap_err.c \
	imap/mupdate_err.c \
	imap/mupdate_err.h

dist_imap_libcyrus_imap_la_SOURCES =

imap_libcyrus_imap_la_LIBADD = \
    $(COM_ERR_LIBS) \
    $(LIB_UUID) \
    $(GCOV_LIBS) \
    $(JANSSON_LIBS) \
    lib/libcyrus_min.la \
    lib/libcyrus.la

imap_libcyrus_imap_la_CFLAGS = $(AM_CFLAGS) $(CFLAG_VISIBILITY) $(JANSSON_CFLAGS)
imap_libcyrus_imap_la_CXXFLAGS = $(AM_CXXFLAGS)

imap_libcyrus_imap_la_SOURCES = \
	imap/annotate.c \
	imap/annotate.h \
	imap/append.c \
	imap/append.h \
	imap/backend.c \
	imap/backend.h \
	imap/conversations.c \
	imap/conversations.h \
	imap/convert_code.c \
	imap/convert_code.h \
	imap/dlist.c \
	imap/dlist.h \
	imap/duplicate.c \
	imap/duplicate.h \
	imap/global.c \
	imap/global.h \
	imap/idle.c \
	imap/idle.h \
	imap/idlemsg.c \
	imap/idlemsg.h \
	imap/imapparse.c \
	imap/imapparse.h \
	imap/index.c \
	imap/index.h \
	imap/mailbox.c \
	imap/mailbox.h \
	imap/mbdump.c \
	imap/mbdump.h \
	imap/mboxkey.c \
	imap/mboxkey.h \
	imap/mboxlist.c \
	imap/mboxlist.h \
	imap/mboxevent.c \
	imap/mboxevent.h \
	imap/mboxname.c \
	imap/mboxname.h \
	imap/message_guid.c \
	imap/message_guid.h \
	imap/message.c \
	imap/message.h \
	imap/message_priv.h \
	imap/mupdate-client.c \
	imap/mupdate-client.h \
	imap/mutex.h \
	imap/notify.c \
	imap/notify.h \
	imap/partlist.c \
	imap/partlist.h \
	imap/proc.c \
	imap/proc.h \
	imap/protocol.h \
	imap/quota_db.c \
	imap/rfc822_header.c \
	imap/rfc822_header.h \
	imap/saslclient.c \
	imap/saslclient.h \
	imap/saslserver.c \
	imap/search_engines.c \
	imap/search_engines.h \
	imap/search_expr.c \
	imap/search_expr.h \
	imap/search_query.c \
	imap/search_query.h \
	imap/search_part.h \
	imap/seen.h \
	imap/seen_db.c \
	imap/sequence.c \
	imap/sequence.h \
	imap/setproctitle.c \
	imap/statuscache.h \
	imap/statuscache_db.c \
	imap/sync_log.c \
	imap/sync_log.h \
	imap/telemetry.c \
	imap/telemetry.h \
	imap/tls.c \
	imap/tls.h \
	imap/tls_th-lock.c \
	imap/tls_th-lock.h \
	imap/user.c \
	imap/user.h \
	imap/userdeny_db.c \
	imap/userdeny.h \
	imap/version.c \
	imap/version.h \
	imap/xstats.c \
	imap/xstats.h \
	imap/xstats_metrics.h

if OBJECTSTORE
imap_libcyrus_imap_la_SOURCES += \
    imap/objectstore_db.c \
    imap/objectstore_db.h \
    imap/objectstore.h
if WITH_OPENIO
imap_libcyrus_imap_la_SOURCES += imap/objectstore_openio.c
else
if WITH_CARINGO
imap_libcyrus_imap_la_SOURCES += imap/objectstore_caringo.c
else
if WITH_OBJSTR_DUMMY
imap_libcyrus_imap_la_SOURCES += imap/objectstore_dummy.c
endif
endif
endif
endif

if USE_SQUAT
imap_libcyrus_imap_la_SOURCES += \
	imap/search_squat.c \
	imap/squat.c \
	imap/squat.h \
	imap/squat_build.c \
	imap/squat_internal.c \
	imap/squat_internal.h
endif

if USE_SPHINX
imap_libcyrus_imap_la_SOURCES += \
	imap/search_sphinx.c \
	imap/sphinxmgr_client.c \
	imap/sphinxmgr_client.h
endif

if HTTPD
imap_libcyrus_imap_la_SOURCES += \
	imap/caldav_alarm.c \
	imap/caldav_alarm.h \
	imap/caldav_db.c \
	imap/caldav_db.h \
	imap/carddav_db.c \
	imap/carddav_db.h \
	imap/dav_db.c \
	imap/dav_db.h \
	imap/dav_util.c \
	imap/dav_util.h \
	imap/ical_support.c \
	imap/ical_support.h \
	imap/vcard_support.c \
	imap/vcard_support.h \
	imap/webdav_db.c \
	imap/webdav_db.h

endif # HTTPD

if USE_XAPIAN
imap_libcyrus_imap_la_SOURCES += \
	imap/search_xapian.c \
	imap/xapian_wrap.h \
	imap/xapian_wrap.cpp
imap_libcyrus_imap_la_LIBADD += $(XAPIAN_LIBS)
imap_libcyrus_imap_la_CXXFLAGS += $(XAPIAN_CXXFLAGS)
endif

imap_lmtpd_SOURCES = \
	imap/lmtpd.c \
	imap/lmtpd.h \
	imap/lmtpengine.c \
	imap/lmtpengine.h \
	imap/lmtpstats.c \
	imap/lmtpstats.h \
	imap/mutex_fake.c \
	imap/proxy.c \
	imap/spool.c \
	master/service.c

if AUTOCREATE
imap_lmtpd_SOURCES += \
	imap/autocreate.c \
	imap/autocreate.h
endif # AUTOCREATE

if SIEVE
imap_lmtpd_SOURCES += imap/lmtp_sieve.c imap/lmtp_sieve.h imap/smtpclient.c
endif # SIEVE

imap_lmtpd_LDADD = $(LD_SIEVE_ADD) $(LD_SERVER_ADD)

SNMPGEN = $(abs_top_srcdir)/snmp/snmpgen

imap/lmtpstats.c: imap/lmtpstats.snmp $(SNMPGEN)
	$(AM_V_GEN)(cd $(@D) && $(SNMPGEN) $(realpath $<))

imap/pushstats.c: imap/pushstats.snmp $(SNMPGEN)
	$(AM_V_GEN)(cd $(@D) && $(SNMPGEN) $(realpath $<))

imap_mbexamine_SOURCES = imap/cli_fatal.c imap/mbexamine.c imap/mutex_fake.c
imap_mbexamine_LDADD = $(LD_UTILITY_ADD)

imap_mbpath_SOURCES = imap/cli_fatal.c imap/mbpath.c imap/mutex_fake.c
imap_mbpath_LDADD = $(LD_UTILITY_ADD)

imap_mbtool_SOURCES = imap/cli_fatal.c imap/mbtool.c imap/mutex_fake.c
imap_mbtool_LDADD = $(LD_UTILITY_ADD)

imap_message_test_SOURCES = imap/message_test.c imap/mutex_fake.c
imap_message_test_LDADD = $(LD_UTILITY_ADD)

imap_mupdate_SOURCES = \
	imap/mupdate.c \
	imap/mupdate.h \
	imap/mupdate-slave.c \
	imap/mutex_pthread.c \
	imap/tls_th-lock.c \
	master/service-thread.c
imap_mupdate_LDADD = $(LD_SERVER_ADD) -lpthread
imap_mupdate_CFLAGS =  $(AM_CFLAGS) -pthread

nodist_imap_nntpd_SOURCES = \
	imap/nntp_err.c \
	imap/nntp_err.h
imap_nntpd_SOURCES = \
	imap/mutex_fake.c \
	imap/nntpd.c \
	imap/proxy.c \
	imap/smtpclient.c \
	imap/smtpclient.h \
	imap/spool.c \
	imap/spool.h \
	master/service.c
imap_nntpd_LDADD = $(LD_SERVER_ADD)

nodist_imap_httpd_SOURCES = \
	imap/http_caldav_js.h \
	imap/http_carddav_js.h \
	imap/http_err.c \
	imap/http_err.h \
	imap/tz_err.c \
	imap/tz_err.h

imap_httpd_SOURCES = \
	imap/caldav_db.c \
	imap/http_admin.c \
	imap/http_applepush.c \
	imap/http_caldav.c \
	imap/http_caldav.h \
	imap/http_caldav_sched.c \
	imap/http_caldav_sched.h \
	imap/http_carddav.c \
	imap/http_carddav.h \
	imap/http_client.c \
	imap/http_client.h \
	imap/http_dav.c \
	imap/http_dav.h \
	imap/http_dblookup.c \
	imap/http_ischedule.c \
	imap/http_proxy.c \
	imap/http_proxy.h \
	imap/http_rss.c \
	imap/http_tzdist.c \
	imap/http_webdav.c \
	imap/httpd.c \
	imap/httpd.h \
	imap/ical_support.c \
	imap/jcal.c \
	imap/jcal.h \
	imap/json_support.h \
	imap/mutex_fake.c \
	imap/proxy.c \
	imap/smtpclient.c \
	imap/spool.c \
	imap/vcard_support.c \
	imap/xcal.c \
	imap/xcal.h \
	imap/xml_support.c \
	imap/xml_support.h \
	imap/zoneinfo_db.c \
	imap/zoneinfo_db.h \
	master/masterconf.c \
	master/service.c

imap_httpd_LDADD = $(LD_SERVER_ADD)

imap_pop3d_SOURCES = \
	imap/mutex_fake.c \
	imap/pop3d.c \
	imap/proxy.c \
	master/service.c

if AUTOCREATE
imap_pop3d_SOURCES += \
	imap/autocreate.c \
	imap/autocreate.h
endif # AUTOCREATE

imap_pop3d_LDADD = $(LD_SIEVE_ADD) $(LD_SERVER_ADD)

imap_quota_SOURCES = imap/cli_fatal.c imap/mutex_fake.c imap/quota.c imap/quota.h
imap_quota_LDADD = $(LD_UTILITY_ADD) $(JANSSON_LIBS)

imap_reconstruct_SOURCES = imap/cli_fatal.c imap/mutex_fake.c imap/reconstruct.c
imap_reconstruct_LDADD = $(LD_UTILITY_ADD)

imap_dav_reconstruct_SOURCES = imap/cli_fatal.c imap/mutex_fake.c imap/dav_reconstruct.c
imap_dav_reconstruct_LDADD = $(LD_UTILITY_ADD)

imap_search_test_SOURCES = imap/search_test.c imap/mutex_fake.c
imap_search_test_LDADD = $(LD_UTILITY_ADD)

imap_smmapd_SOURCES = imap/mutex_fake.c imap/proxy.c imap/smmapd.c master/service.c
imap_smmapd_LDADD = $(LD_SERVER_ADD)

imap_squatter_SOURCES = imap/cli_fatal.c imap/mutex_fake.c imap/squatter.c
imap_squatter_LDADD = $(LD_UTILITY_ADD)

imap_squat_dump_SOURCES = imap/cli_fatal.c imap/mutex_fake.c imap/squat_dump.c
imap_squat_dump_LDADD = $(LD_UTILITY_ADD)

imap_sync_client_SOURCES = imap/mutex_fake.c imap/sync_client.c imap/sync_support.c imap/sync_support.h
imap_sync_client_LDADD = $(LD_SIEVE_ADD) $(LD_UTILITY_ADD)

imap_sync_reset_SOURCES = imap/mutex_fake.c imap/sync_reset.c imap/sync_support.c imap/sync_support.h
imap_sync_reset_LDADD = $(LD_SIEVE_ADD) $(LD_UTILITY_ADD)

imap_sync_server_SOURCES = imap/mutex_fake.c imap/sync_server.c imap/sync_support.c imap/sync_support.h master/service.c
imap_sync_server_LDADD = $(LD_SIEVE_ADD) $(LD_SERVER_ADD)

imap_tls_prune_SOURCES = imap/cli_fatal.c imap/mutex_fake.c imap/tls_prune.c
imap_tls_prune_LDADD = $(LD_UTILITY_ADD)

imap_unexpunge_SOURCES = imap/cli_fatal.c imap/mutex_fake.c imap/unexpunge.c
imap_unexpunge_LDADD = $(LD_UTILITY_ADD)

# $(COMPILE_ET) creates its output files in the directory it's run from,
# so do a tricky directory change
imap/imap_err.h imap/imap_err.c: imap/imap_err.et $(COMPILE_ET_DEP)
	$(AM_V_GEN)(cd $(@D) && $(COMPILE_ET) $(realpath $<))

imap/mupdate_err.h imap/mupdate_err.c: imap/mupdate_err.et $(COMPILE_ET_DEP)
	$(AM_V_GEN)(cd $(@D) && $(COMPILE_ET) $(realpath $<))

imap/nntp_err.h imap/nntp_err.c: imap/nntp_err.et $(COMPILE_ET_DEP)
	$(AM_V_GEN)(cd $(@D) && $(COMPILE_ET) $(realpath $<))

imap/http_err.h imap/http_err.c: imap/http_err.et $(COMPILE_ET_DEP)
	$(AM_V_GEN)(cd $(@D) && $(COMPILE_ET) $(realpath $<))

imap/tz_err.h imap/tz_err.c: imap/tz_err.et $(COMPILE_ET_DEP)
	$(AM_V_GEN)(cd $(@D) && $(COMPILE_ET) $(realpath $<))

# xxd cannot have path details in its input filename, otherwise it junks up
# the variable names in the output file.  so do a tricky directory change.
# the /dev/null redirection on cd is to prevent shell environments with
# CDPATH echoing the path change on stdout and consequently into the .h file
imap/http_caldav_js.h: imap/http_caldav.js
	$(AM_V_GEN)(cd $(<D) > /dev/null && xxd -i $(<F)) > $@

imap/http_carddav_js.h: imap/http_carddav.js
	$(AM_V_GEN)(cd $(<D) > /dev/null && xxd -i $(<F)) > $@

if MAINTAINER_MODE
imap/rfc822_header.c: imap/rfc822_header.st
	$(AM_V_GEN)${top_srcdir}/tools/compile_st.pl -c $< > $@.NEW && mv $@.NEW $@

imap/rfc822_header.h: imap/rfc822_header.st
	$(AM_V_GEN)${top_srcdir}/tools/compile_st.pl -h $< > $@.NEW && mv $@.NEW $@

lib/htmlchar.c: lib/htmlchar.st
	$(AM_V_GEN)${top_srcdir}/tools/compile_st.pl -c $< > $@.NEW && mv $@.NEW $@

lib/htmlchar.h: lib/htmlchar.st
	$(AM_V_GEN)${top_srcdir}/tools/compile_st.pl -h $< > $@.NEW && mv $@.NEW $@
endif

imtest_imtest_SOURCES = imtest/imtest.c
imtest_imtest_LDADD = $(LD_BASIC_ADD)
imtest_imtest_CFLAGS = $(AM_CFLAGS) $(CFLAG_VISIBILITY)

nodist_lib_libcyrus_la_SOURCES = lib/chartable.c
lib_libcyrus_la_SOURCES = \
	lib/acl.c \
	lib/acl_afs.c \
	lib/auth.c \
	lib/auth_krb.c \
	lib/auth_krb5.c \
	lib/auth_pts.c \
	lib/auth_unix.c \
	lib/bitvector.c \
	lib/bloom.c \
	lib/bsearch.c \
	lib/charset.c \
	lib/command.c \
	lib/cyrusdb.c \
	lib/cyrusdb_flat.c \
	lib/cyrusdb_quotalegacy.c \
	lib/cyrusdb_skiplist.c \
	lib/cyrusdb_twoskip.c \
	lib/glob.c \
	lib/htmlchar.c \
	lib/htmlchar.h \
	lib/imapurl.c \
	lib/imclient.c \
	lib/imparse.c \
	lib/iostat.c \
	lib/iptostring.c \
	lib/libcyr_cfg.c \
	lib/lsort.c \
	lib/mappedfile.c \
	lib/murmurhash.c \
	lib/mkgmtime.c \
	lib/parseaddr.c \
	lib/prot.c \
	lib/ptrarray.c \
	lib/rfc822tok.c \
	lib/signals.c \
	lib/stristr.c \
	lib/times.c \
	lib/tok.c \
	lib/wildmat.c
if USE_CYRUSDB_SQL
lib_libcyrus_la_SOURCES += lib/cyrusdb_sql.c
endif
if USE_CYRUSDB_LMDB
lib_libcyrus_la_SOURCES += lib/cyrusdb_lmdb.c
endif
if USE_SQLITE
lib_libcyrus_la_SOURCES += lib/sqldb.c
endif
if GMTOFF_TM
lib_libcyrus_la_SOURCES += lib/gmtoff_tm.c
else
lib_libcyrus_la_SOURCES += lib/gmtoff_gmtime.c
endif
if NONBLOCK_FCNTL
lib_libcyrus_la_SOURCES += lib/nonblock_fcntl.c
else
lib_libcyrus_la_SOURCES += lib/nonblock_ioctl.c
endif
lib_libcyrus_la_LIBADD = libcrc32.la ${LIB_SASL} $(SSL_LIBS) $(GCOV_LIBS)
if USE_CYRUSDB_LMDB
lib_libcyrus_la_LIBADD += -llmdb
endif
lib_libcyrus_la_CFLAGS = $(AM_CFLAGS) $(CFLAG_VISIBILITY)

noinst_LTLIBRARIES += libcrc32.la
libcrc32_la_SOURCES = lib/crc32.c lib/crc32c.c
libcrc32_la_CFLAGS = -O3 $(AM_CFLAGS) $(CFLAG_VISIBILITY)

nodist_lib_libcyrus_min_la_SOURCES = \
	lib/imapopts.c

lib_libcyrus_min_la_SOURCES = \
	lib/arrayu64.c \
	lib/assert.c \
	lib/bufarray.c \
	lib/byteorder64.c \
	lib/hash.c \
	lib/hashu64.c \
	lib/libconfig.c \
	lib/mpool.c \
	lib/retry.c \
	lib/strarray.c \
	lib/strhash.c \
	lib/util.c \
	lib/vparse.c \
	lib/xmalloc.c \
	lib/xstrlcat.c \
	lib/xstrlcpy.c \
	lib/xstrnchr.c
if !HAVE_SSL
lib_libcyrus_min_la_SOURCES += lib/xsha1.c
endif
if IPV6_noGETADDRINFO
lib_libcyrus_min_la_SOURCES += lib/getaddrinfo.c
endif
if IPV6_noGETNAMEINFO
lib_libcyrus_min_la_SOURCES += lib/getnameinfo.c
endif
if LOCK_FCNTL
lib_libcyrus_min_la_SOURCES += lib/lock_fcntl.c
else
lib_libcyrus_min_la_SOURCES += lib/lock_flock.c
endif
if MAP_SHARED
lib_libcyrus_min_la_SOURCES += lib/map_shared.c
else
if MAP_STUPIDSHARED
lib_libcyrus_min_la_SOURCES += lib/map_stupidshared.c
else
lib_libcyrus_min_la_SOURCES += lib/map_nommap.c
endif
endif
lib_libcyrus_min_la_LIBADD = $(LTLIBOBJS) $(LIB_UUID) $(GCOV_LIBS)
lib_libcyrus_min_la_CFLAGS = $(AM_CFLAGS) $(CFLAG_VISIBILITY)

lib/chartable.c: lib/mkchartable.pl lib/charset/unifix.txt \
	$(top_srcdir)/lib/charset/*.t \
	/usr/share/unicode/UnicodeData.txt lib/charset/aliases.txt
	@echo "### Building chartables..."
	$(AM_V_GEN)perl $(top_srcdir)/lib/mkchartable.pl -m $(top_srcdir)/lib/charset/unifix.txt -m /usr/share/unicode/UnicodeData.txt -a $(top_srcdir)/lib/charset/aliases.txt -o $@ $(top_srcdir)/lib/charset/*.t || (rm -f $@ && exit 1)
	@echo "### Done building chartables."

lib/imapopts.h: lib/imapopts.c

lib/imapopts.c: lib/imapoptions tools/config2header
	$(AM_V_GEN)$(top_srcdir)/tools/config2header CC="$(CC)" $(top_builddir)/lib/imapopts.c $(top_builddir)/lib/imapopts.h < $(top_srcdir)/lib/imapoptions

imap_cvt_xlist_specialuse_SOURCES = imap/mutex_fake.c imap/cvt_xlist_specialuse.c
imap_cvt_xlist_specialuse_LDADD = $(LD_UTILITY_ADD)

@SET_MAKE@

dist_man1_MANS = \
	man/imtest.1 \
	man/installsieve.1 \
	man/httptest.1 \
	man/lmtptest.1 \
	man/mupdatetest.1 \
	man/nntptest.1 \
	man/pop3test.1 \
	man/sieveshell.1 \
	man/sivtest.1 \
	man/smtptest.1

dist_man3_MANS = \
	man/imclient.3

dist_man5_MANS = \
	man/cyrus.conf.5 \
	man/imapd.conf.5 \
	man/krb.equiv.5

dist_man8_MANS = \
	man/arbitron.8 \
	man/backupd.8 \
	man/chk_cyrus.8 \
	man/ctl_backups.8 \
	man/ctl_conversationsdb.8 \
	man/ctl_cyrusdb.8 \
	man/ctl_deliver.8 \
	man/ctl_mboxlist.8 \
	man/cvt_cyrusdb.8 \
	man/cyr_backup.8 \
	man/cyr_buildinfo.8 \
	man/cyr_dbtool.8 \
	man/cyr_deny.8 \
	man/cyr_df.8 \
	man/cyr_expire.8 \
	man/cyr_info.8 \
	man/cyr_synclog.8 \
	man/cyr_virusscan.8 \
	man/deliver.8 \
	man/fud.8 \
	man/idled.8 \
	man/imapd.8 \
	man/ipurge.8 \
	man/lmtpd.8 \
	man/master.8 \
	man/mbexamine.8 \
	man/mbpath.8 \
	man/mbtool.8 \
	man/notifyd.8 \
	man/pop3d.8 \
	man/quota.8 \
	man/reconstruct.8 \
	man/restore.8 \
	man/smmapd.8 \
	man/timsieved.8 \
	man/tls_prune.8 \
	man/unexpunge.8

if SQUATTER
dist_man8_MANS += \
	man/squatter.8

else
EXTRA_DIST += \
	man/squatter.8

endif # SQUATTER

if NNTPD
dist_man8_MANS += \
	man/fetchnews.8 \
	man/nntpd.8

else # NNTPD
EXTRA_DIST += \
	man/fetchnews.8 \
	man/nntpd.8

endif # NNTPD

if HTTPD
dist_man8_MANS += \
	man/ctl_zoneinfo.8 \
	man/httpd.8

else # HTTPD
EXTRA_DIST += \
	man/ctl_zoneinfo.8 \
	man/httpd.8

endif # HTTPD

if REPLICATION
dist_man8_MANS += \
	man/sync_client.8 \
	man/sync_reset.8 \
	man/sync_server.8

else
EXTRA_DIST += \
	man/sync_client.8 \
	man/sync_reset.8 \
	man/sync_server.8

endif

master_master_SOURCES = \
	master/cyrusMasterMIB.c \
	master/cyrusMasterMIB.h \
	master/master.c \
	master/master.h \
	master/masterconf.c \
	master/masterconf.h \
	master/service.h
master_master_LDADD = lib/libcyrus_min.la $(LIB_UCDSNMP) $(LIBS) $(GCOV_LIBS) -lm


netnews_remotepurge_SOURCES = \
	netnews/macros.h \
	netnews/readconfig.c \
	netnews/readconfig.h \
	netnews/remotepurge.c
netnews_remotepurge_LDADD = $(LD_BASIC_ADD)

notifyd_notifyd_SOURCES = \
	imap/mutex_fake.c \
	master/service.c \
	notifyd/notify_external.c \
	notifyd/notify_external.h \
	notifyd/notify_log.c \
	notifyd/notify_log.h \
	notifyd/notify_mailto.c \
	notifyd/notify_mailto.h \
	notifyd/notify_null.c \
	notifyd/notify_null.h \
	notifyd/notifyd.c \
	notifyd/notifyd.h
if ZEPHYR
notifyd_notifyd_SOURCES += notifyd/notify_zephyr.c notifyd/notify_zephyr.h
endif
notifyd_notifyd_LDADD = $(LD_SERVER_ADD) $(ZEPHYR_LIBS)

notifyd_notifytest_SOURCES = notifyd/notifytest.c imap/mutex_fake.c
notifyd_notifytest_LDADD = $(LD_BASIC_ADD)

nodist_perl_libcyrus_la_SOURCES = $(nodist_lib_libcyrus_la_SOURCES)
perl_libcyrus_la_SOURCES = $(lib_libcyrus_la_SOURCES)
perl_libcyrus_la_LIBADD = $(lib_libcyrus_la_LIBADD)
nodist_perl_libcyrus_min_la_SOURCES = $(nodist_lib_libcyrus_min_la_SOURCES)
perl_libcyrus_min_la_SOURCES = $(lib_libcyrus_min_la_SOURCES)
perl_libcyrus_min_la_LIBADD = $(lib_libcyrus_min_la_LIBADD)

perl_sieve_lib_libisieve_la_SOURCES = \
	perl/sieve/lib/codes.h \
	perl/sieve/lib/isieve.c \
	perl/sieve/lib/isieve.h \
	perl/sieve/lib/lex.c \
	perl/sieve/lib/lex.h \
	perl/sieve/lib/request.c \
	perl/sieve/lib/request.h

ptclient_ptdump_SOURCES = imap/cli_fatal.c imap/mutex_fake.c ptclient/ptdump.c
ptclient_ptdump_LDADD = $(LD_UTILITY_ADD)
ptclient_ptexpire_SOURCES = imap/cli_fatal.c imap/mutex_fake.c ptclient/ptexpire.c
ptclient_ptexpire_LDADD = $(LD_UTILITY_ADD)

ptclient_ptloader_SOURCES = \
	imap/mutex_fake.c \
	ptclient/ptloader.c \
	ptclient/ptloader.h \
	master/service-thread.c
ptclient_ptloader_LDFLAGS =
ptclient_ptloader_LDADD = $(LD_SERVER_ADD)

if HAVE_LDAP
ptclient_ptloader_SOURCES += ptclient/ldap.c
ptclient_ptloader_LDADD += $(LDAP_LIBS)
ptclient_ptloader_LDFLAGS += $(LDAP_LDFLAGS)
endif

if USE_AFSKRB
ptclient_ptloader_SOURCES += ptclient/afskrb.c
ptclient_ptloader_LDADD += $(AFS_LIBS)
ptclient_ptloader_LDFLAGS += $(AFS_LDFLAGS)
endif

# Each new version of flex seems to generate new sign-comparison
# warnings, while they switch code around between int/yy_size_t.
#
# This is a pain because most of us Cyrus devs build with -Werror.
#
# Instead of continuing to maintain an ever-growing, increasingly
# precarious set of post-hoc fixes (see: the former lex-fix rule),
# let's just ignore sign-comparison warnings from flex-generated
# sources only.
sieve_libcyrus_sieve_lex_la_SOURCES = \
	sieve/addr-lex.l \
	sieve/sieve-lex.l
sieve_libcyrus_sieve_lex_la_LIBADD =
sieve_libcyrus_sieve_lex_la_CFLAGS = $(AM_CFLAGS) $(CFLAG_VISIBILITY) $(NOWARN_SIGN_COMPARE)

nodist_sieve_libcyrus_sieve_la_SOURCES = \
	sieve/sieve_err.c \
	sieve/sieve_err.h
sieve_libcyrus_sieve_la_SOURCES = \
	sieve/bytecode.h \
	sieve/addr.y \
	sieve/bc_emit.c \
	sieve/bc_eval.c \
	sieve/bc_generate.c \
	sieve/comparator.c \
	sieve/comparator.h \
	sieve/flags.c \
	sieve/flags.h \
	sieve/grammar.c \
	sieve/grammar.h \
	sieve/interp.c \
	sieve/interp.h \
	sieve/message.c \
	sieve/message.h \
	sieve/rebuild.c \
	sieve/script.c \
	sieve/script.h \
	sieve/sieve.y \
	sieve/tree.c \
	sieve/tree.h \
	sieve/variables.c \
	sieve/variables.h \
	sieve/varlist.c \
	sieve/varlist.h
sieve_libcyrus_sieve_la_LIBADD = \
    sieve/libcyrus_sieve_lex.la \
    $(COM_ERR_LIBS) \
    lib/libcyrus_min.la \
    lib/libcyrus.la
sieve_libcyrus_sieve_la_CFLAGS = $(AM_CFLAGS) $(CFLAG_VISIBILITY)

sieve_sievec_LDADD = $(LD_SIEVE_ADD)
sieve_sieved_LDADD = $(LD_SIEVE_ADD)

sieve/sieve_err.h sieve/sieve_err.c: sieve/sieve_err.et $(COMPILE_ET_DEP)
	$(AM_V_GEN)(cd $(@D) && $(COMPILE_ET) $(realpath $<))

sieve_test_SOURCES = sieve/test.c imap/mutex_fake.c
sieve_test_LDADD = $(LD_SIEVE_ADD) $(LD_UTILITY_ADD)

timsieved_timsieved_SOURCES = \
	imap/mutex_fake.c \
	imap/proxy.c \
	master/service.c \
	timsieved/actions.c \
	timsieved/actions.h \
	timsieved/codes.h \
	timsieved/lex.c \
	timsieved/lex.h \
	timsieved/parser.c \
	timsieved/parser.h \
	timsieved/timsieved.c

timsieved_timsieved_LDADD = $(LD_SIEVE_ADD) $(LD_SERVER_ADD)

# The lex-fix rule is now obsolete, but let's leave a crumb here for a
# while so that custom build scripts that expect it to exist don't choke.
lex-fix:

snapshot::
	@echo "Creating snapshot $(PACKAGE_NAME)-$(PACKAGE_VERSION)"
	@$(MKDIR_P) snapshot
	@git archive --format=tar --prefix=$(PACKAGE_NAME)-$(PACKAGE_VERSION)/ HEAD | tar -C snapshot/ -x -f -
	@echo "creating tarfile"
	tar -C snapshot -c -f - $(PACKAGE_NAME)-$(PACKAGE_VERSION) | gzip -9 > $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz
	@rm -rf snapshot

docsrc/imap/reference/manpages/systemcommands/cyradm.rst: $(top_srcdir)/perl/imap/IMAP/Shell.pm
	@$(MKDIR_P) $(@D)
	$(AM_V_GEN)$(top_srcdir)/tools/perl2rst cyradm < $< > $@

docsrc/imap/reference/manpages/configs/imapd.conf.rst: $(top_srcdir)/tools/config2rst $(top_srcdir)/lib/imapoptions
	@$(MKDIR_P) $(@D)
	$(AM_V_GEN)$(top_srcdir)/tools/config2rst $(top_srcdir)/lib/imapoptions > $@

doc/examples/imapd_conf/imapd.conf.sample: $(top_srcdir)/tools/config2sample $(top_srcdir)/lib/imapoptions
	@$(MKDIR_P) $(@D)
	$(AM_V_GEN)$(top_srcdir)/tools/config2sample $(top_srcdir)/lib/imapoptions > $@

docsrc/imap/reference/manpages/usercommands/sieveshell.rst: $(top_srcdir)/perl/sieve/scripts/sieveshell.pl
	@$(MKDIR_P) $(@D)
	$(AM_V_GEN)$(top_srcdir)/tools/perl2rst sieveshell < $< > $@

%.1: man/.sphinx-build.stamp
	@$(MKDIR_P) $(@D)
	$(AM_V_GEN)touch $@

%.3: man/.sphinx-build.stamp
	@$(MKDIR_P) $(@D)
	$(AM_V_GEN)touch $@

%.5: man/.sphinx-build.stamp
	@$(MKDIR_P) $(@D)
	$(AM_V_GEN)touch $@

%.8: man/.sphinx-build.stamp
	@$(MKDIR_P) $(@D)
	$(AM_V_GEN)touch $@

## define this unconditionally because dist-hook references it
SPHINX_CACHE = docsrc/.doctrees

.PHONY: clean-sphinx-cache clean-docsrc
clean-sphinx-cache:
	@$(RM) -r $(SPHINX_CACHE)

if HAVE_SPHINX_BUILD
GENERATED_RSTS = docsrc/imap/reference/manpages/configs/imapd.conf.rst \
                 docsrc/imap/reference/manpages/systemcommands/cyradm.rst \
                 docsrc/imap/reference/manpages/usercommands/sieveshell.rst

SPHINX_OPTS = -d $(SPHINX_CACHE) -n -q

## detect when source directory is not build directory (i.e. VPATH
## build), and clone the docsrc tree into the build directory, so
## that we have a single "source directory" for sphinx-build to use.
docsrc/.sphinx-build.stamp:
	$(AM_V_GEN)test x"$(top_srcdir)" = x"$(top_builddir)" || \
        (cd $(top_srcdir) && tar cf - --mode=gu+w docsrc doc/examples) | tar xf -
	@touch $@

clean-docsrc:
	test x"$(top_srcdir)" = x"$(top_builddir)" || \
		$(RM) -r $(top_builddir)/docsrc $(top_builddir)/doc/examples

## XXX doesn't detect if other rst sources are updated...
man/.sphinx-build.stamp: $(GENERATED_RSTS) docsrc/.sphinx-build.stamp
	$(AM_V_GEN)DOCSRC=$(top_builddir)/docsrc $(SPHINX_BUILD) $(SPHINX_OPTS) -b cyrman $(top_builddir)/docsrc $(top_builddir)/man
	@touch $@

clean-man:
	@$(RM) -r man

## XXX doesn't detect if other rst sources are updated...
doc/html/.sphinx-build.stamp: $(GENERATED_RSTS) docsrc/.sphinx-build.stamp
	$(AM_V_GEN)DOCSRC=$(top_builddir)/docsrc $(SPHINX_BUILD) $(SPHINX_OPTS) -b html $(top_builddir)/docsrc $(top_builddir)/doc/html
	@touch $@

## XXX doesn't detect if other rst sources are updated...
doc/text/.sphinx-build.stamp: $(GENERATED_RSTS) docsrc/.sphinx-build.stamp
	$(AM_V_GEN)DOCSRC=$(top_builddir)/docsrc $(SPHINX_BUILD) $(SPHINX_OPTS) -b text $(top_builddir)/docsrc $(top_builddir)/doc/text
	@touch $@
else
clean-docsrc:

man/.sphinx-build.stamp:
	@$(MKDIR_P) $(@D)
	$(AM_V_GEN)touch $@
	@echo "warning: missing documentation dependencies. man pages will be empty" 1>&2

clean-man:

doc/html/.sphinx-build.stamp:
	@echo "error: missing documentation dependencies. cannot build html documentation" 1>&2
	@false

doc/text/.sphinx-build.stamp:
	@echo "error: missing documentation dependencies. cannot build text documentation" 1>&2
	@false
endif

.PHONY: man man-force clean-man
man-force:
	## trash the timestamps, so we always re-run sphinx-build.
	## sphinx-build tracks source modifications itself, so forced
	## rebuilds will still be a lot quicker once it has run once.
	@$(RM) docsrc/.sphinx-build.stamp man/.sphinx-build.stamp

man: man-force $(dist_man1_MANS) $(dist_man3_MANS) $(dist_man5_MANS) $(dist_man8_MANS)

# clean-man is conditionally defined above. We do not want to remove
# man pages if the user is unable to rebuild them.

.PHONY: doc-html doc-html-force clean-doc-html
doc-html-force:
	@$(RM) docsrc/.sphinx-build.stamp doc/html/.sphinx-build.stamp

doc-html: doc-html-force doc/html/.sphinx-build.stamp

clean-doc-html:
	@$(RM) -r doc/html

.PHONY: doc-text doc-text-force clean-doc-text
doc-text-force:
	@$(RM) docsrc/.sphinx-build.stamp doc/text/.sphinx-build.stamp

doc-text: doc-text-force doc/text/.sphinx-build.stamp

clean-doc-text:
	@$(RM) -r doc/text

.PHONY: doc clean-doc
doc: man doc-html doc-text

clean-doc: clean-man clean-doc-html clean-doc-text

.PHONY: clean-local
clean-local: clean-doc clean-sphinx-cache clean-docsrc

dist-old:: distgit
	@echo "creating configure"
	@cd dist/cyrus-imapd-$(PACKAGE_VERSION) ; sh SMakefile
	@for d in $(DIST_SUBDIRS); \
	do \
	(cd dist/cyrus-imapd-$(PACKAGE_VERSION)/$$d; \
	if [ -f Makefile.dist ]; then \
	echo "### Making" dist "in" `pwd`; \
	$(MAKE) $(MFLAGS) YACC='$(YACC)' LEX='$(LEX)' \
	COMPILE_ET='$(COMPILE_ET)' -f Makefile.dist dist ; \
	fi) || exit 1; \
	done
	@echo "creating tarfile"
	@cd dist ; tar cf - cyrus-imapd-$(PACKAGE_VERSION) | \
	gzip -9 > ../cyrus-imapd-$(PACKAGE_VERSION).tar.gz
	rm -f distgit
	rm -rf dist

distgit:
	$(MKDIR_P) dist
	@echo "checking out the distribution from tag $(PACKAGE_NAME)-$(PACKAGE_VERSION)"
	git archive --format=tar --prefix=$(PACKAGE_NAME)-$(PACKAGE_VERSION)/ $(PACKAGE_NAME)-$(PACKAGE_VERSION) | tar -C dist -x -f -
	touch distgit

dist-hook:
	find $(top_distdir) -type f -name .sphinx-build.stamp -delete
	rm -rf $(top_distdir)/$(SPHINX_CACHE)

VERSION: tools/git-version.sh
	$(AM_V_GEN)$< > $@.NEW && mv $@.NEW $@

install-data-hook:
if CMULOCAL
	$(INSTALL) -m 644 $(top_srcdir)/depot/depot.conf $(DESTDIR)/
endif

install-exec-hook:
if PERL
	for s in installsieve sieveshell; \
	do \
	  $(MKDIR_P) $(top_builddir)/perl/sieve/scripts ; \
	  $(PERL_PREINSTALL) < $(top_srcdir)/perl/sieve/scripts/$$s.pl > $(top_builddir)/perl/sieve/scripts/$$s ;\
	  $(INSTALL) -m 755 $(top_builddir)/perl/sieve/scripts/$$s $(DESTDIR)$(bindir)/$$s ; \
	done
endif

## The @$(MKDIR_P) line is added due to a bug in Automake 1.10 and can be removed if using Automake 1.12.
	@$(MKDIR_P) $(DESTDIR)$(libexecdir)
if SERVER
	cd $(DESTDIR)$(libexecdir) && \
	  $(LN_S) -f pop3d pop3proxyd && \
	  $(LN_S) -f imapd proxyd && \
	  $(LN_S) -f lmtpd lmtpproxyd
endif
## The @$(MKDIR_P) line is added due to a bug in Automake 1.10 and can be removed if using Automake 1.12.
	@$(MKDIR_P) $(DESTDIR)$(bindir)
	cd $(DESTDIR)$(bindir) && \
	  $(LN_S) -f imtest httptest && \
	  $(LN_S) -f imtest lmtptest && \
	  $(LN_S) -f imtest mupdatetest && \
	  $(LN_S) -f imtest nntptest && \
	  $(LN_S) -f imtest pop3test && \
	  $(LN_S) -f imtest sivtest && \
	  $(LN_S) -f imtest smtptest && \
	  $(LN_S) -f imtest synctest

uninstall-hook: cyrus-makemaker-uninstall-workaround
if PERL
	for s in installsieve sieveshell; do \
	    rm -f $(DESTDIR)$(bindir)/$$s; \
	done
endif

.PHONY: cyrus-makemaker-uninstall-workaround

# Workaround for deprecated no-op MakeMaker uninstall.
# Don't remove the packlists themselves, otherwise MakeMaker uninstall will
# crash.  Just remove the files MakeMaker uninstall won't remove itself.
#
# We have another layer of workaround in each module's Makefile that
# removes the packlist after MakeMaker uninstall has finished ignoring it.
cyrus-makemaker-uninstall-workaround:
if PERL
	( packlists=`find $(DESTDIR)$(libdir) -type f -name .packlist` && \
	  echo "uninstalling files from packlists: $$packlists" && \
	  rm -f `cat $$packlists` )
	( podfiles=`find $(DESTDIR)$(libdir) -type f -name perllocal.pod` && \
	  rm -f `echo $$podfiles` )
endif

install-binsymlinks:
## Let's symlink everything else
	for prog in $(sbin_PROGRAMS); do $(LN_S) -f $(sbindir)/`basename $$prog` $(DESTDIR)$(bindir)/; done
	for prog in $(libexec_PROGRAMS); do $(LN_S) -f $(libexecdir)/`basename $$prog` $(DESTDIR)$(bindir)/; done

SUFFIXES = .fig.png

.fig.png:
	fig2dev -L png $< $@

valgrind:
	$(MAKE) VG=yes check

libtool: $(LIBTOOL_DEPS)
	$(SHELL) ./config.status libtool

# Install for Cassandane
cassandane:
	$(MAKE) DESTDIR=`cd ../inst ; /bin/pwd` install