File: configure.ac

package info (click to toggle)
dar 2.6.13-2
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 10,364 kB
  • sloc: cpp: 77,385; sh: 6,192; ansic: 776; makefile: 435; python: 242; csh: 95; perl: 43; sed: 16
file content (2012 lines) | stat: -rw-r--r-- 94,797 bytes parent folder | download
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
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
#######################################################################
# dar - disk archive - a backup/restoration program
# Copyright (C) 2002-2020 Denis Corbin
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# to contact the author : http://dar.linux.free.fr/email.html
#######################################################################

# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.69)
AC_INIT([DAR], [2.6.13], [[http://sourceforge.net/tracker/?group_id=65612&atid=511612]])
AC_CONFIG_HEADERS([config.h])
AC_LANG([C++])
AC_CONFIG_SRCDIR([src/libdar/catalogue.cpp])
AC_DEFINE_UNQUOTED(DAR_VERSION, "AC_PACKAGE_VERSION", [dar and dar_suite version, definition in configure.ac])

AM_INIT_AUTOMAKE([subdir-objects])
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION
XGETTEXT_EXTRA_OPTIONS='--keyword=dar_gettext'
AM_ICONV

####
# configure checks what is available from the operational system:
# - it displays things on output for the user running the configure script has status information
# - it sets some shell variable that are not used outside the configuration script
# - it sets some shell variable that can be susbstitued in Makefile.in files (see AC_SUBST() and AC_CONFIG_FILES())
#   also known as "output variables"
# - it defines macros that get stored in config.h and used in source code (see AC_DEFINE())
#
# header files:
#   header files are #included in source code if they HAVE_... macro has been defined in config.h
#
# libraries:
#   necessary library flags are stored in the "output variables" LIBS substituable shell variable and passed to Makefile.in
#   as well as other like LIBTHREADAR_LIBS/CFLAGS and LIBCURL_LIBSS/CFLAGS due to the use of PKG_CHECK_MODULE macro
#   that get substitued in Makefiles.in when the @LIBS@ form is met.
#   In addition, the AM_PATH_GPGME defines he GPGME_CFLAGS and GPGME_LIBS output variable
#

# have a specific variable for pkgconfig, setting the default value:
AC_SUBST(pkgconfigdir, [${libdir}/pkgconfig])
AC_ARG_WITH([pkgconfigdir],
            AS_HELP_STRING(--with-pkgconfigdir=DIR, [defines an alternative directory to install pkconfig files, default is '${libdir}/pkgconfig']),
            [
                if [ ! -z "$withval" ] ; then
                 AC_SUBST(pkgconfigdir, $withval)
               fi
            ],
            []
           )

# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_LIBTOOL
AC_PROG_MAKE_SET
AC_PROG_RANLIB

AC_MSG_CHECKING([for C++ compiler usability])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
                                  [ class test { public: int test; }; ])],
                  [AC_MSG_RESULT(ok)],
                  [AC_MSG_ERROR([No C++ compiler found])])

# Defining _XOPEN_SOURCE to get extra field in struct stat
AC_DEFINE(_XOPEN_SOURCE, 700, [activates POSIX.1-2008 symbols in order to allow microsecond time setting, as well as ctime_r() call])

# Define _BSD_SOURCE in order to be able to call makedev(), minor() and major() under OpenBSD when _XOPEN_SOURCE is set
AC_DEFINE(_BSD_SOURCE, 1, [activate makedev(), major() and minor() when _XOPEN_SOURCE is set])
AC_DEFINE(_DEFAULT_SOURCE, 1, [disabling warning about _BSD_SOURCE to be deprecated])

###########
## THE FOLLOWING "DEFINE" USED TO RE-ENABLE FULL LIBC FEATURES ON DIFFERENT OPERATING SYSTEMS
## HAVE BEEN BORROWED FROM PYTHON's configure.in
##
##

# The later defininition of _XOPEN_SOURCE disables certain features
# on Linux, so we need _GNU_SOURCE to re-enable them (makedev, tm_zone).
AC_DEFINE(_GNU_SOURCE, 1, [Define on Linux to activate all library features])

# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
# certain features on NetBSD, so we need _NETBSD_SOURCE to re-enable
# them.
AC_DEFINE(_NETBSD_SOURCE, 1, [Define on NetBSD to activate all library features])

# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
# certain features on FreeBSD, so we need __BSD_VISIBLE to re-enable
# them.
AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features])

# The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables
# certain features on Mac OS X, so we need _DARWIN_C_SOURCE to re-enable
# them.
AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])

##
##
###########

# Checks for libraries.
AC_CHECK_LIB(socket, [socket], [], [])
AC_CHECK_LIB(nsl, [endnetconfig], [], [])
AC_CHECK_LIB(cap, [cap_get_proc], [], [])


AC_ARG_ENABLE( [libdl-linking],
               AS_HELP_STRING(--disable-libdl-linking, [ignore any libdl and avoid linking against it]),
               [
               AS_IF([test "x$enable_libdl_linking" != "xno"],
                     [AC_MSG_ERROR([invalid argument given to --disable-libdl-linking])]
                    )
               ],
               [
                 AC_CHECK_LIB(dl, [dlsym], [], [])
               ])


# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT

AC_CHECK_HEADERS([fcntl.h netinet/in.h arpa/inet.h stdint.h stdlib.h string.h sys/ioctl.h sys/socket.h termios.h unistd.h utime.h sys/types.h signal.h errno.h sys/un.h sys/stat.h time.h fnmatch.h regex.h pwd.h grp.h stdio.h pthread.h ctype.h getopt.h limits.h stddef.h sys/utsname.h libintl.h sys/capability.h linux/capability.h utimes.h sys/time.h wchar.h wctype.h stddef.h])

AC_SYS_LARGEFILE

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_CHECK_MEMBERS([struct stat.st_rdev])
AC_DECL_SYS_SIGLIST
AC_CHECK_TYPE(size_t, [AC_CHECK_SIZEOF(size_t)], [AC_MSG_ERROR([Cannot find size_t type])], [])
AC_CHECK_TYPE(time_t, [AC_CHECK_SIZEOF(time_t)], [AC_MSG_ERROR([Cannot find time_t type])], [])
AC_CHECK_TYPE(off_t, [AC_CHECK_SIZEOF(off_t)], [AC_MSG_ERROR([Cannot find off_t type])], [])


# Checks for library functions.
AC_FUNC_FNMATCH
AC_FUNC_FORK
AC_PROG_GCC_TRADITIONAL
AC_FUNC_LSTAT
AC_HEADER_MAJOR
AC_FUNC_MALLOC
AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_FUNC_UTIME_NULL
AC_HEADER_TIME
AC_CHECK_FUNCS([lchown mkdir regcomp rmdir strerr-or strerror_r utime fdopendir readdir_r ctime_r getgrnam_r getpwnam_r localtime_r])

AC_MSG_CHECKING([for c++11 support])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
                                   [ thread_local static int test = 0; ])
                  ],
                  [ AC_MSG_RESULT(yes) ],
                  [
                     AC_MSG_RESULT([no])
                     AC_MSG_CHECKING([for c++ support with -std=c++11 option set])
                     CXXSTDFLAGS="-std=c++11"
                     CXXFLAGS="$CXXFLAGS $CXXSTDFLAGS"
                     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
                                                        [ thread_local static int test = 0; ])
                                        ],
                                        [ AC_MSG_RESULT(yes) ],
                                        [
                                           AC_MSG_RESULT(no)
                                           AC_MSG_ERROR([C++ compiler lack support for c++11 standard])
                                        ]
                     )
                   ])

AC_MSG_CHECKING([for sed -r/-E option])
if sed -r -e 's/(c|o)+/\1/g' > /dev/null < /dev/null ; then
    local_sed="gnu"
    AC_MSG_RESULT([GNU sed, using -r option for regex])
else
   if sed -E -e 's/(c|o)+/\1/g' > /dev/null < /dev/null ; then
     local_sed="bsd"
     AC_MSG_RESULT([BSD sed, using -E option for regex])
   else
     local_sed=unknown
     AC_MSG_ERROR([unknown switch to use with sed to support regex])
   fi
fi

AC_MSG_CHECKING([for getopt() in <unistd.h>])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                    #if HAVE_UNISTD_H
                                    #include <unistd.h>
                                    #endif
                                    }]],
                                    [ getopt(0, 0, 0); ])
                  ],
                  [
                    AC_DEFINE(HAVE_GETOPT_IN_UNISTD_H, 1, [a getopt() call is declared in <unistd.h>])
                    AC_MSG_RESULT(present)
                  ],
                   [AC_MSG_RESULT(absent)])

AC_MSG_CHECKING([for getopt_long() in <unistd.h>])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                    #if HAVE_UNISTD_H
                                    #include <unistd.h>
                                    #endif
                                    }]],
                                    [ getopt_long(0, 0, 0, 0, 0); ])
                  ],
                  [
                    AC_DEFINE(HAVE_GETOPT_LONG_IN_UNISTD_H, 1, [a getopt_long() call is declared in <unistd.h>])
                    AC_MSG_RESULT(present)
                  ],
                   [AC_MSG_RESULT(absent)])


AC_MSG_CHECKING([for optreset presence])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                   #if HAVE_STDIO_H
                                   #include <stdio.h>
                                   #endif
                                   #if HAVE_GETOPT_H
                                   #include <getopt.h>
                                   #else
                                   #if HAVE_UNISTD_H
                                   #include <unistd.h>
                                   #endif
                                   #endif
                                   }]], [ int x = optreset; return 0; ])
                  ],
                  [
                   AC_DEFINE(HAVE_OPTRESET, 1, [the optreset external variable exists to reset getopt standard call])
                   AC_MSG_RESULT(available)
                  ],
                  [AC_MSG_RESULT([not available])])

AC_MSG_CHECKING([for Door file support])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                    #if HAVE_SYS_STAT_H
                                    #include <sys/stat.h>
                                    #endif
                                    #if HAVE_UNISTD_H
                                    #include <unistd.h>
                                    #endif
                                  }]],
                                  [ struct stat buf;
                                    if(S_ISDOOR(buf.st_mode))
                                      return 0;
                                    else
                                      return 1;
                                  ])
                  ],
                  [
                    AC_DEFINE(HAVE_DOOR, 1, [whether the system has the necessary routine to handle Door files])
                    AC_MSG_RESULT(available)
                  ],
                  [AC_MSG_RESULT([not available])])



AC_MSG_CHECKING([for POSIX.1e capabilities support])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                  #if HAVE_SYS_CAPABILITY_H
                                  #include <sys/capability.h>
                                  #else
                                  #if HAVE_LINUX_CAPABILITY_H
                                  #include <linux/capability.h>
                                  #endif
                                  #endif
                                  #if HAVE_SYS_TYPES_H
                                  #include <sys/types.h>
                                  #endif
                                  }]],
                                  [ cap_t capaset = cap_get_proc();
                                    (void)cap_free((void *)capset);
                                  ])
                   ],
                   [
                      AC_DEFINE(HAVE_CAPABILITIES, 1, [whether the system has support for POSIX.1e capabilities])
                      AC_MSG_RESULT(available)
                   ],
                   [  AC_MSG_RESULT([not available])  ])


AC_MSG_CHECKING([for fdatasync() availability])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                   #if HAVE_UNISTD_H
                                   #include <unistd.h>
                                   #endif
                                   }]],
                                   [
                                   (void)fdatasync(0);
                                   ])
                   ],
                   [ AC_DEFINE(HAVE_FDATASYNC, 1, [whether the system provides fdatasync() system call])
                     AC_MSG_RESULT(available)
                   ],
                   [ AC_MSG_RESULT([not available])
                   ])

AC_MSG_CHECKING([for syncfs() availability])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                   #if HAVE_UNISTD_H
                                   #include <unistd.h>
                                   #endif
                                   }]],
                                   [
                                   (void)syncfs(0);
                                   ])
                   ],
                   [ AC_DEFINE(HAVE_SYNCFS, 1, [whether the system provides syncfs() system call])
                     AC_MSG_RESULT(available)
                   ],
                   [ AC_MSG_RESULT([not available])
                   ])

AC_MSG_CHECKING([for the possibility to set timestamps at a microsecond precision])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                     #if HAVE_SYS_TYPES_H
                                     #include <sys/types.h>
                                     #endif
                                     #if HAVE_SYS_STAT_H
                                     #include <sys/stat.h>
                                     #endif
                                     #if HAVE_UNISTD_H
                                     #include <unistd.h>
                                     #endif
                                     #if HAVE_UTIMES_H
                                     #include <utimes.h>
                                     #endif
                                     #if HAVE_SYS_TIME_H
                                     #include <sys/time.h>
                                     #endif
                                     }]],
                                     [[
                                       struct timeval tv[2];
                                       tv[0].tv_sec = 1000;
                                       tv[1].tv_usec = 2000;

                                       (void)utimes("/tmp/testfile.tmp", tv);
                                        /* note that this test program is only compiled+linked not run */
                                        return 0;
                                     ]])
                  ],
                  [
                    AC_DEFINE(LIBDAR_MICROSECOND_WRITE_ACCURACY, 1, [support for timestamps microsecond write accuracy])
                    local_microsecond_write=yes
                    AC_MSG_RESULT(available)
                  ],
                  [ AC_MSG_RESULT([not available])
                  ])

AC_MSG_CHECKING([for the possibility to read timestamps at a microsecond precision])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                     #if HAVE_SYS_TYPES_H
                                     #include <sys/types.h>
                                     #endif
                                     #if HAVE_SYS_STAT_H
                                     #include <sys/stat.h>
                                     #endif
                                     #if HAVE_UNISTD_H
                                     #include <unistd.h>
                                     #endif
                                     }]],
                                     [[
                                       struct stat st;
                                        /* tv_nsec is nanosecond, but for now we
                                           do not keep more precised timing than microseconds
                                           because we have not portable way to restore nanoseconds
                                           but only seconds and microsecond
                                        */
                                       if(st.st_atim.tv_nsec != 0)
                                         return 0;
                                       else
                                         return 1;
                                         /* whatever, this test program is only compiled no run */
                                     ]])
                 ],
                 [
                    AC_DEFINE(LIBDAR_MICROSECOND_READ_ACCURACY, 1, [support for timestamps microsecond read accuracy])
                    local_microsecond_read=yes
                    AC_MSG_RESULT(available)
                  ],
                  [ AC_MSG_RESULT([not available])
                  ])


AC_MSG_CHECKING([for lutimes() availability])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                   #if HAVE_SYS_TIME_H
                                   #include <sys/time.h>
                                   #endif
                                   } // extern "C"
                                   ]],
                                   [[
                                      struct timeval tv[2];
                                      int lu = lutimes("/tmp/noway", tv);
                                   ]])
                  ],
                  [ AC_DEFINE(HAVE_LUTIMES, 1, [if lutimes() system call is available])
                    local_lutimes=yes
                    AC_MSG_RESULT(available)
                  ],
                  [ AC_MSG_RESULT([not available])]
                )

AC_MSG_CHECKING([for strerror_r flavor])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern "C"
                                     {
                                     #if HAVE_STRING_H
                                     #include <string.h>
                                     #endif
                                     } // externe "C"
                                   ]],
                                   [[
                                        char *ptr = strerror_r(0, 0, 0);
                                   ]])
                  ],
                  [ AC_DEFINE(HAVE_STRERROR_R_CHAR_PTR, 1, [strerror_r() returns a char *])
                    AC_MSG_RESULT([GNU specific])
                  ],
                  [
                    AC_MSG_RESULT([XSI compliant])
                  ])


# DAR's features

AC_ARG_ENABLE( [libz-linking],
               AS_HELP_STRING(--disable-libz-linking, [disable linking with libz and disable libz compression support]),
               [explicit_libz_linking=yes],
               [enable_libz_linking=yes])

AS_IF(       [test "x$enable_libz_linking" != "xyes"],
             [
                AC_MSG_WARN([libz compression support has been disabled by user])
                local_libz="no"
             ],
             [
               AC_CHECK_LIB(z, [deflate], [], [AC_MSG_WARN([library zlib not found])])
               AC_CHECK_HEADER(zlib.h, [local_libz="yes"
                                        AC_DEFINE(HAVE_ZLIB_H, 1, [zlib.h header file is available])
                                       ],
                                       [AC_MSG_WARN([Cannot find zlib.h header file])
                                        local_libz="no"
                                       ])
               if test "$local_libz" = "yes" ; then
               AC_LINK_IFELSE([AC_LANG_PROGRAM([[ extern "C" {
                                                           #if HAVE_ZLIB_H
                                                           #include <zlib.h>
                                                           #endif
                                              }]],
                                              [[
                                                         z_stream *ptr = (z_stream *)0;
                                                         deflate(ptr, 0);
                                              ]])
                              ],
                              [ AC_DEFINE(LIBZ_AVAILABLE, 1, [header and linking is available to have libz functions])],
                              [ local_libz="no" ])
               else
                 AC_MSG_WARN([libz compression support not available])
               fi

               AS_IF( [ test "x$explicit_libz_linking" = "xyes" -a "$local_libz" != "yes" ],
                      [  AC_MSG_ERROR([libz linking failed]) ]
                    )
             ]
     )

AC_ARG_ENABLE([libbz2-linking],
              AS_HELP_STRING(--disable-libbz2-linking, [disable linking with libbz2 and disables libbz2 compression support]),
              [explicit_libbz2_linking=yes],
              [enable_libbz2_linking=yes])

AS_IF(      [test "x$enable_libbz2_linking" != "xyes"],
            [
               AC_MSG_WARN([libbz2 compression support has been disabled by user])
               local_libbz2="no"
            ],
            [
               AC_CHECK_LIB(bz2, [BZ2_bzCompress], [], [AC_MSG_WARN([library libbz2 not found])])
               AC_CHECK_HEADER(bzlib.h, [local_libbz2="yes"
                                       AC_DEFINE(HAVE_BZLIB_H, 1, [bzlib.h header file is available])
                                      ],
                                      [AC_MSG_WARN([Cannot find bzlib.h header file])
                                       local_libbz2="no"
                                      ])
               if test "$local_libbz2" = "yes" ; then
                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ extern "C" {
                                                       #if HAVE_BZLIB_H
                                                       #include <bzlib.h>
                                                       #endif
                                              }]],
                                              [[
                                                        bz_stream *ptr = (bz_stream *)0;
                                                        BZ2_bzCompress(ptr, 0);
                                              ]])
                                ],
                                [ AC_DEFINE(LIBBZ2_AVAILABLE, 1, [header and linking is available to have libbz2 functions])],
                                [ local_libbz2="no" ])
               else
                  AC_MSG_WARN([libbz2 compression support not available])
               fi

               AS_IF( [ test "x$explicit_libbz2_linking" = "xyes" -a "$local_libbz2" != "yes" ],
                      [ AC_MSG_ERROR([libbz2 linking failed]) ]
                    )
           ]
     )

AC_ARG_ENABLE( [liblzo2-linking],
               AS_HELP_STRING(--disable-liblzo2-linking, [disable linking with liblzo2 and disables lzo compression support]),
               [explicit_liblzo2_linking=yes],
               [enable_liblzo2_linking=yes]
             )

AS_IF(      [test "x$enable_liblzo2_linking" != "xyes"],
            [
               AC_MSG_WARN([lzo compression support has been disabled by user])
               local_liblzo2="no"
            ],
            [
             AC_CHECK_LIB(lzo2, [lzo1x_1_compress], [], [AC_MSG_WARN([library liblzo2 not found])])
             AC_CHECK_HEADER(lzo/lzo1x.h, [local_liblzo2="yes"
                                       AC_DEFINE(HAVE_LZO_LZO1X_H, 1, [lzo/lzo1x.h header file is available])
                                      ],
                                      [AC_MSG_WARN([Cannot find lzo/lzo1x.h header file])
                                       local_liblzo2="no"
                                      ])
              if test "$local_liblzo2" = "yes" ; then
                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ extern "C" {
                                                       #if HAVE_LZO_LZO1X_H
                                                       #include <lzo/lzo1x.h>
                                                       #endif
                                              }]],
                                              [[
                                                        (void)lzo1x_1_compress(0, 0, 0, 0, 0);
                                              ]])
                                ],
                                [ AC_DEFINE(LIBLZO2_AVAILABLE, 1, [header and linking is available to have lzo functions])],
                                [ local_liblzo2="no" ])
             else
                 AC_MSG_WARN([lzo compression support not available])
             fi

             AS_IF( [ test "x$explicit_liblzo2_linking" = "xyes" -a "$local_liblzo2" != "yes" ],
                    [ AC_MSG_ERROR([liblzo linking failed]) ]
                  )
           ]
     )

AC_ARG_ENABLE( [libxz-linking],
               AS_HELP_STRING(--disable-libxz-linking, [disable linking with libxz/liblzma and disable libxz compression support]),
               [explicit_libxz_linking=yes],
               [enable_libxz_linking=yes]
             )

AS_IF(       [test "x$enable_libxz_linking" != "xyes"],
               AC_MSG_WARN([libxz compression support has been disabled by user])
               local_libxz="no"
             ],
             [
               AC_CHECK_LIB(lzma, [lzma_code], [], [AC_MSG_WARN([library liblzma not found])])
               AC_CHECK_HEADER(lzma.h, [local_libxz="yes"
                                        AC_DEFINE(HAVE_LZMA_H, 1, [lzma.h header file is available])
                                       ],
                                       [AC_MSG_WARN([Cannot find lzma.h header file])
                                        local_libxz="no"
                                       ])
               if test "$local_libxz" = "yes" ; then
               AC_LINK_IFELSE([AC_LANG_PROGRAM([[ extern "C" {
                                                           #if HAVE_LZMA_H
                                                           #include <lzma.h>
                                                           #endif
                                              }]],
                                              [[
                                                         lzma_stream ptr = LZMA_STREAM_INIT;
                                                         lzma_ret tmp = lzma_easy_encoder(&ptr,
                                                                                  2,
                                                                                  LZMA_CHECK_CRC32);
                                              ]])
                              ],
                              [ AC_DEFINE(LIBLZMA_AVAILABLE, 1, [header and linking is available to have liblzma functions])],
                              [ local_libxz="no" ])
               else
                 AC_MSG_WARN([libxz compression support not available])
               fi

               AS_IF( [ test "x$explicit_libxz_linking" = "xyes" -a "$local_libxz" != "yes" ],
                      [ AC_MSG_ERROR([libxz linking failed]) ]
                    )
             ]
     )


AC_ARG_ENABLE( [libgcrypt-linking],
               AS_HELP_STRING(--disable-libgcrypt-linking, [disable linking with libgcrypt which disables strong encryption support]),
               [explicit_libgcrypt_linking=yes],
               [enable_libgcrypt_linking=yes])

AS_IF(      [test "x$enable_libgcrypt_linking" != "xyes"],
            [
               AC_MSG_WARN([strong encryption support has been disabled by user])
               local_crypto="no"
            ],
            [
              AC_CHECK_LIB(gpg-error, [gpg_err_init], [], [])
              AC_CHECK_LIB(gcrypt, [gcry_check_version], [], [])
              AC_CHECK_HEADER(gcrypt.h, [local_crypto="yes"
                                         AC_DEFINE(HAVE_GCRYPT_H, 1, [gcrypt.h header file is available])
                                        ],
                                        [AC_MSG_WARN([Cannt find gcrypt.h header file])
                                         local_crypto="no"
                                        ])
              if test "$local_crypto" = "yes" ; then
                 min_version_gcrypt="1.4.0"
                 AC_DEFINE_UNQUOTED(MIN_VERSION_GCRYPT, "$min_version_gcrypt", [libgcrypt minimum version])
                 min_version_gcrypt_hash_bug="1.6.0"
                 AC_DEFINE_UNQUOTED(MIN_VERSION_GCRYPT_HASH_BUG, "$min_version_gcrypt_hash_bug", [ligcrypt minimum version without hash bug])
                 AC_MSG_CHECKING([for libgcrypt usability])
                 AC_RUN_IFELSE([AC_LANG_PROGRAM([[ extern "C"
                                                  {
                                                       #if HAVE_GCRYPT_H
                                                       #include <gcrypt.h>
                                                       #endif
                                                  }
                                                  #include <iostream>
                                                  using namespace std;
                                              ]],
                                              [[
                                                 if(!gcry_check_version(MIN_VERSION_GCRYPT))
                                                 {
                                                   cout << "ligcrypt version too low, minimum version is " << MIN_VERSION_GCRYPT << endl;
                                                   exit(1);
                                                 }
                                                 else
                                                   exit(0);
                                              ]])
                                ],
                                [ AC_DEFINE(CRYPTO_AVAILABLE, 1, [header and linking is available to have strong encryption works])
                                  AC_MSG_RESULT([ok])
                                  AC_RUN_IFELSE([AC_LANG_PROGRAM([[ extern "C"
                                                                    {
                                                                     #if HAVE_GCRYPT_H
                                                                     #include <gcrypt.h>
                                                                     #endif
                                                                    }
                                                                 ]],
                                                                 [[
                                                                     if(!gcry_check_version(MIN_VERSION_GCRYPT_HASH_BUG))
                                                                       exit(1);
                                                                     else
                                                                       exit(0);
                                                                 ]])
                                                ],
                                                [],
                                                [ libgcrypt_hash_bug="yes" ])
                                ],
                                [
                                  if test "$?" = "1" ; then
                                    AC_MSG_RESULT([failed: need libgcypt >= $min_version_gcrypt, disabling strong encryption support])
                                  else
                                    AC_MSG_RESULT([failed: libgcrypt is unusable, cannot even call gcry_check_version(). Disabling strong encryption support])
                                  fi
                                  local_crypto="no"
                                ])
             else
                AC_MSG_WARN([strong encryption support not available])
             fi

             AS_IF( [ test "x$explicit_libgcrypt_linking" = "xyes" -a "$local_crypto" != "yes" ],
                    [ AC_MSG_ERROR([ligcrypt linking failed]) ]
                  )
           ]
     )


AC_ARG_ENABLE(  [ea-support],
                AS_HELP_STRING(--disable-ea-support,[disable Extended Attributes support]),
                [explicit_ea_support=yes],
                [enable_ea_support=yes])

AS_IF(          [test "x$enable_ea_support" != "xyes"],
                [
                  AC_MSG_CHECKING([for Extended Attribute support])
                  AC_MSG_RESULT([disabled])
                  local_ea_support="no"
                ],
                [ AC_CHECK_HEADERS([attr/xattr.h sys/xattr.h])
                  AC_CHECK_LIB(attr, [lgetxattr], [], [])
                  AC_MSG_CHECKING([for Unix Extended Attribute support])
                  AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                                     #if HAVE_SYS_TYPES_H
                                                     #include <sys/types.h>
                                                     #endif
                                                     #if HAVE_ATTR_XATTR_H && ! HAVE_SYS_XATTR_H
                                                     #include <attr/xattr.h>
                                                     #endif
                                                     #if HAVE_SYS_XATTR_H
                                                     #include <sys/xattr.h>
                                                     #endif
                                                    }]],
                                                    [ lgetxattr((char *)0, (char *)0, (void *)0, 0); ])
                                 ],
                                 [
                                        AC_DEFINE(EA_SUPPORT, [], [if defined, activates support for Extended Attributes])
                                        local_ea_support="yes"
                                        AC_MSG_RESULT([yes])
                                 ],
                                 [
                                        AC_MSG_RESULT([no])
                                        AC_CHECK_HEADERS([sys/xattr.h])
                                        AC_CHECK_LIB(c, [fgetxattr])
                                        AC_MSG_CHECKING([for Mac OS X Extended Attribute support])
                                        AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                                                         #if HAVE_SYS_XATTR_H
                                                                         #include <sys/xattr.h>
                                                                         #endif
                                                                       }]],
                                                                       [ getxattr((char *)0, (char *)0, (void *)0, 0, 0, XATTR_NOFOLLOW); ])
                                                       ],
                                                       [
                                                          AC_DEFINE(EA_SUPPORT, [], [if defined, activates support for Extended Attributes])
                                                          AC_DEFINE(OSX_EA_SUPPORT, [], [if defined, activates support for Mac OS X Extended Attributes])
                                                          local_ea_support="yes"
                                                          AC_MSG_RESULT([yes])
                                                       ],
                                                       [
                                                          local_ea_support="no"
                                                          AC_MSG_RESULT([no])
                                                       ])
                                 ])
                   AS_IF( [ test "x$explicit_ea_support" = "xyes" -a "$local_ea_support" != "yes" ],
                          [ AC_MSG_ERROR([Failed finding Extended Attribute support]) ]
                        )
                 ]
     )

AC_MSG_CHECKING([ext2fs.h availability])
AC_ARG_ENABLE(  [nodump-flag],
                AS_HELP_STRING(--disable-nodump-flag, [disable the ext2/3/4 Filesystem Specific Attribute support, in particular the --nodump feature]),
                [explicit_nodump_flag=yes],
                [enable_nodump_flag=yes])

AS_IF(          [test "x$enable_nodump_flag" != "xyes"],
                [AC_MSG_RESULT([extX FSA disabled])],
                [AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                                    #include <ext2fs/ext2_fs.h>
                                                    #if HAVE_SYS_IOCTL_H
                                                    #include <sys/ioctl.h>
                                                    #endif
                                                    }]],[[int fd, f; ioctl(fd, EXT2_IOC_GETFLAGS, &f);]]
                                                )
                                ],
                                [
                                AC_DEFINE(LIBDAR_NODUMP_FEATURE, [NODUMP_EXT2FS], [if defined, activates the ext2/3 nodump flag feature])
                                local_nodump_feature="yes"
                                AC_MSG_RESULT([found <ext2fs/ext2_fs.h>])
                                ],
                                [
                                AC_LINK_IFELSE(  [AC_LANG_PROGRAM([[extern "C" {
                                                                    #include <linux/ext2_fs.h>
                                                                    #if HAVE_SYS_IOCTL_H
                                                                    #include <sys/ioctl.h>
                                                                    #endif
                                                                    }]],[[int fd, f; ioctl(fd, EXT2_IOC_GETFLAGS, &f);]])
                                                 ],
                                                 [
                                                   AC_DEFINE(LIBDAR_NODUMP_FEATURE, [NODUMP_LINUX], [if defined, activates the ext2/3 nodump flag feature])
                                                   local_nodump_feature="yes"
                                                   AC_MSG_RESULT([found <linux/ext2_fs.h>])
                                                 ],
                                                 [
                                                   AC_MSG_RESULT([NOT FOUND])
                                                   local_nodump_feature="no"
                                                   AC_MSG_WARN([cannot find ext2_fs.h header file, nodump-flag and extX FSA features will not be available])
                                                 ])
                                ])
                  AS_IF( [ test "x$explicit_nodump_flag" = "xyes" -a "$local_nodump_feature" != "yes" ],
                         [ AC_MSG_ERROR([Failed activating nodump feature]) ]
                       )
                ]
     )

AC_MSG_CHECKING([birth time availability])
AC_ARG_ENABLE( [birthtime],
               AS_HELP_STRING(--disable-birthtime, [disable the HFS+ Filesystem Specific Attribute support]),
               [explicit_birthtime=yes],
               [enable_birthtime=yes])

AS_IF(         [test "x$enable_birthtime" != "xyes"],
               [AC_MSG_RESULT([hfs+ FSA disabled])],
               [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
                                                extern "C" {
                                                #if HAVE_SYS_TYPE_H
                                                #include <sys/types.h>
                                                #endif
                                                #if HAVE_SYS_STAT_H
                                                #include <sys/stat.h>
                                                #endif
                                                #if HAVE_UNISTD_H
                                                #include <unistd.h>
                                                #endif
                                                }]],
                                                [[
                                                struct stat tmp;
                                                int ret = stat("/", &tmp);
                                                time_t birth = tmp.st_birthtime;
                                                ]])
                                ],
                                [
                                  AC_DEFINE(LIBDAR_BIRTHTIME, 1, [if defined, activates the support for HFS+ create time FSA])
                                  local_birthtime="yes"
                                  AC_MSG_RESULT([found])
                                ],
                                [
                                  AC_MSG_RESULT([NOT FOUND])
                                  AC_MSG_WARN([Cannot find support for birthtime, HFS+ FSA support will not be available])
                                ])
                  AS_IF( [ test "x$explicit_birthtime" = "xyes" -a "$local_birthtime" != "yes" ],
                         [ AC_MSG_ERROR([birth time support not available]) ]
                       )
                ]
     )

AC_ARG_ENABLE(  [gnugetopt],
                AS_HELP_STRING(--disable-gnugetopt, [avoid linking with libgnugetopt]),
                [explicit_gnugetopt=yes],
                [enable_gnugetopt=yes])

AS_IF(          [test "x$enable_gnugetopt" != "xyes"],
                [],
                AC_CHECK_LIB(gnugetopt,
                             [getopt_long],
                             [],
                             [
                               AS_IF( [ test "x$explicit_gnugetopt" = "xyes"],
                                      [ AC_MSG_ERROR([gnugetopt linking failed]) ]
                                    )
                             ])
     )

AC_ARG_ENABLE( [librsync-linking],
               AS_HELP_STRING(--disable-librsync-linking, [disable linking with librsync and disable delta compression support]),
               [explicit_librsync_linking=yes],
               [enable_librsync_linking=yes])

AS_IF(        [test "x$enable_librsync_linking" != "xyes"],
              [
                 AC_MSG_WARN([librsync delta-compression support has been disabled by user])
                 local_librsync="no"
              ],
              [
               AC_CHECK_LIB(rsync, [rs_strerror], [], [AC_MSG_WARN([librsync library not found])])
               AC_CHECK_HEADER(librsync.h, [local_librsync="yes"
                                        AC_DEFINE(HAVE_LIBRSYNC_H, 1, [librsync.h header file is available])
                                       ],
                                       [AC_MSG_WARN([Cannot find librsync.h header file])
                                         local_librsync="no"
                                        ])
                if test "$local_librsync" = "yes" ; then
                AC_LINK_IFELSE([AC_LANG_PROGRAM([[ extern "C" {
                                                            #if HAVE_LIBRSYNC_H
                                                            #include <stdio.h>
                                                            #include <librsync.h>
                                                            #endif
                                               }]],
                                               [[
                                                           rs_result err = RS_DONE;
                                                           (void) rs_strerror(err);
                                               ]])
                              ],
                               [ AC_DEFINE(LIBRSYNC_AVAILABLE, 1, [librsync is usable])],
                               [ local_librsync="no" ])
                else
                  AC_MSG_WARN([librsync compression support not available])
                fi

                AS_IF( [ test "x$explicit_librsync_linking" = "xyes" -a "$local_librsync" != "yes" ],
                       [ AC_MSG_ERROR([librsync linking failed]) ]
                     )
              ]
     )

AC_ARG_ENABLE( [libcurl-linking],
               AS_HELP_STRING(--disable-libcurl-linking, [ignore libcurl and avoid linking against it]),
               [explicit_libcurl_linking=yes],
               [enable_libcurl_linking=yes])

AS_IF(         [test "x$enable_libcurl_linking" != "xyes"],
               [
                 AC_MSG_WARN([libcurl and thus remote repository support has been disabled by user])
                 local_libcurl="no"
               ],
               [
                  PKG_CHECK_EXISTS(libcurl,
                        [ PKG_CHECK_MODULES(LIBCURL, libcurl, [], [AC_MSG_ERROR([libcurl not found, but reported to exist !?!])])
                          AC_DEFINE(HAVE_LIBCURL, 1, [Libcurl library availability])
                        ],
                        [
                          AC_CHECK_LIB(curl, [curl_global_init], [], [AC_MSG_WARN([libcurl library not found])])
                          AC_DEFINE(HAVE_LIBCURL, 1, [Libcurl library availability])
                        ])

                  CPPFLAGS__cache="$CFLAGS"
                  CPPFLAGS="$LIBCURL_CFLAGS $CPPFLAGS"
                  LIBS___cache="$LIBS"
                  LIBS="$LIBCURL_LIBS $LIBS"
                  AC_CHECK_HEADER(curl/curl.h,
                        [
                                local_libcurl="yes"
                                AC_DEFINE(HAVE_CURL_CURL_H, 1, [libcurl.h header file is available])
                        ],
                        [
                                AC_MSG_WARN([Cannot find libcurl.h header file])
                                local_libcurl="no"
                        ])

                 if test "$local_libcurl" = "yes" ; then
                        AC_LINK_IFELSE([AC_LANG_PROGRAM([[ extern "C" {
                                                                  #if HAVE_CURL_CURL_H
                                                                  #include <curl/curl.h>
                                                                  #endif
                                                           }
                                                        ]],
                                                        [[
                                                            (void) curl_global_init(CURL_GLOBAL_ALL);
                                                        ]])
                                        ],
                                        [AC_DEFINE(LIBCURL_AVAILABLE, 1, [libcurl is usable])],
                                        [ local_libcurl="no" ])
                 else
                        AC_MSG_WARN([remote repository support not available])
                 fi
                 CPPFLAGS="$CPPFLAGS___cache"
                 LIBS="$LIBS___cache"
                 unset CPPFLAGS___cache
                 unset LIBS___cache
                 AS_IF( [ test "x$explicit_libcurl_linking" = "xyes" -a "$local_libcurl" != "yes" ],
                        [ AC_MSG_ERROR([libcurl linking failed]) ]
                      )
                ]
     )

AC_ARG_ENABLE(  [fadvise],
                AS_HELP_STRING(--disable-fadvise, [avoid using fadvise(2) system call]),
                [explicit_fadvise=yes],
                [enable_fadvise=yes])

AS_IF(          [test "x$enable_fadvise" != "xyes"],
                [ AC_MSG_WARN([avoiding the use of fadvise(2) system call, per user request])],
                [
                  AC_MSG_CHECKING([for posix_fadvise support])
                  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                                       #if HAVE_FCNTL_H
                                                       #include <fcntl.h>
                                                       #endif
                                                       }]],
                                                       [ (void)posix_fadvise(0,0,1,POSIX_FADV_NORMAL); ])
                                    ],
                                    [
                                      AC_DEFINE(HAVE_POSIX_FADVISE, 1, [whether the system has support for posix_fadvise()])
                                      local_posix_fadvise="yes"
                                      AC_MSG_RESULT(available)
                                    ],
                                    [
                                      AC_MSG_RESULT([not available])
                                      AS_IF( [ test "x$explicit_fadvise" = "xyes" ],
                                             [ AC_MSG_ERROR([fadvise not available]) ]
                                           )
                                    ]
                                   )
                ]
     )

AC_MSG_CHECKING([for getopt() availability]);
AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                   #if HAVE_STDIO_H
                                   #include <stdio.h>
                                   #endif
                                   #if HAVE_GETOPT_H
                                   #include <getopt.h>
                                   #else
                                   #if HAVE_UNISTD_H
                                   #include <unistd.h>
                                   #endif
                                   #endif
                                   }]], [ getopt(0, 0, 0); ])
                  ],
                  [
                    AC_MSG_RESULT([ok])
                  ],
                  [AC_MSG_ERROR([absent but required])])

AC_MSG_CHECKING([for getopt_long() availability]);
AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                   #if HAVE_STDIO_H
                                   #include <stdio.h>
                                   #endif
                                   #if HAVE_GETOPT_H
                                   #include <getopt.h>
                                   #else
                                   #if HAVE_UNISTD_H
                                   #include <unistd.h>
                                   #endif
                                   #endif
                                   }]], [ getopt_long(0, 0, 0, 0, 0); ])
                  ],
                  [
                    local_have_getopt_long="yes"
                    AC_DEFINE(HAVE_GETOPT_LONG, 1, [whether getopt_long() is available])
                    AC_MSG_RESULT([available])
                  ],
                  [AC_MSG_RESULT([NOT AVAILABLE])])


AC_ARG_ENABLE(  [examples],
                AS_HELP_STRING(--enable-examples, [buld example and testing programs]),
                [
                   AS_IF([ test "x$enable_examples" != "xyes" ],
                         [ AC_MSG_ERROR([invalid argument given to --enable-examples]) ]
                        )
                   examples="yes"
                ],
                [examples="false"])

AC_ARG_ENABLE(  [os-bits],
                AS_HELP_STRING(--enable-os-bits=arg, [arg is 32 or 64. If for some reason, one wants to overcome detected system value]),
                [AC_DEFINE_UNQUOTED(OS_BITS, $enableval, [manually set CPU's registers' size])],
                [
                        AC_CHECK_HEADER(inttypes.h,
                                [
                                  AC_COMPILE_IFELSE(
                                        [AC_LANG_PROGRAM([extern "C" {
                                                          #include <inttypes.h>
                                                          }],
                                                         [ uint16_t a  = 0; uint32_t b = 0; uint64_t c = 0;
                                                           int16_t d = 0; int32_t e = 0; int64_t f = 0;
                                                           return a+b+c+d+e+f;
                                                         ])
                                        ],
                                        [ AC_DEFINE(HAVE_INTTYPES_H, 1, inttypes.h header availability) ],
                                        [ AC_MSG_ERROR([Cannot find *int*_t type declarations in headerfile, --enable-os-bits=... option must be used]) ])
                                ],
                                [ AC_MSG_ERROR([Cannot find inttypes.h headerfile, --enable-os-bits=... option must be used]) ]
                        )
                ]
             )

AC_ARG_ENABLE( [mode],
                AS_HELP_STRING(--enable-mode=arg, [where arg is either 32 or infinint. Makes dar internally use 32 bits or limitless integers in place of 64 bits integers (which is the case if this option is not given)]),
                [
                   build_mode=$enableval
                   if test "$build_mode" != "32" -a "$build_mode" != "64" -a "$build_mode" != "infinint" ; then
                      AC_MSG_ERROR([Invalid argument given to --enable-mode option])
                   fi
                ],
                [build_mode=64])

AC_ARG_ENABLE( [furtive-read],
               AS_HELP_STRING(--disable-furtive-read,
                              [Ignore furtive read mode availability on systems that support it]),
               [explicit_furtive_read=yes],
               [enable_furtive_read=yes])

AS_IF(         [test "x$enable_furtive_read" != "xyes"],
               [
                 local_furtive_read_mode="no"
                 AC_MSG_WARN([Furtive read mode disabled])
               ],
               [ AC_MSG_CHECKING([furtive read mode availability])
                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ extern "C" {
                                                 #if HAVE_SYS_TYPE_H
                                                 #include <sys/types.h>
                                                 #endif
                                                 #if HAVE_SYS_STAT_H
                                                 #include <sys/stat.h>
                                                 #endif
                                                 #if HAVE_FCNTL_H
                                                 #include <fcntl.h>
                                                 #endif
                                                 #if HAVE_DIRENT_H
                                                 #include <dirent.h>
                                                 #endif
                                                 }
                                                 ]],
                                                 [[
                                                 int x = O_NOATIME;
                                                 int fd = open("/",O_RDONLY|O_NOATIME);
                                                 #if HAVE_FDOPENDIR
                                                 (void)fdopendir(fd);
                                                 #else
                                                 syntaxically incorrect statement here to force compilation to fail!
                                                 #endif
                                                 ]])
                                ],
                                [ AC_DEFINE(FURTIVE_READ_MODE_AVAILABLE, 1, [furtive read mode is available])
                                  AC_MSG_RESULT(available)
                                  local_furtive_read_mode="yes"
                                ],
                                [ AC_MSG_RESULT(no available)
                                  local_furtive_read_mode="no"
                                ])
                 AS_IF(  [ test "x$explicit_furtive_read" = "xyes" -a "$local_furtive_read_mode" != "yes" ],
                         [ AC_MSG_ERROR([furtive read mode not available]) ]
                      )
               ]
     )


AC_ARG_ENABLE( [debug],
                AS_HELP_STRING(--enable-debug, [build targets with debugging option and no optimization]),
                [
                        AS_IF([ test "x$enable_debug" != "xyes" ],
                              [ AC_MSG_ERROR([invalid argument given to --enable-debug]) ]
                             )

                        CXXFLAGS="-g -Wall"
                        CFLAGS="-g -Wall"
                        LDFLAGS="-g -Wall"
                        debug_static="yes"
                        AC_DEFINE(LIBDAR_NO_OPTIMIZATION, 1, [if defined, informs the code that no optimization has been used for compilation])
                ],
                [
                        debug_static="no"
                ])


AC_ARG_ENABLE( [pedantic],
               AS_HELP_STRING(--enable-pedantic, [enable pedantic syntaxical check at compilation, use only for debugging purposes !]),
               [
                        AS_IF([ test "x$enable_pedantic" != "xyes" ],
                              [ AC_MSG_ERROR([invalid argument given to --enable-pedantic]) ]
                             )

                        CXXFLAGS="$CXXFLAGS -pedantic -Wno-long-long"
               ],
               [])


AC_ARG_ENABLE( [build-html],
               AS_HELP_STRING(--disable-build-html, [don't build programming documentation (in particular libdar API documentation) and html man page]),
               [explicit_build_html=yes],
               [enable_build_html=yes])

AS_IF(         [ test "x$enable_build_html" != "xyes"],
               [
                 AC_MSG_WARN([documentation no built per user request])
                 doxygen="no"
                 groff="no"
               ],
               [ AC_CHECK_PROG(doxygen, doxygen, [yes], [no], [$PATH])
                 AC_MSG_CHECKING([for doxygen version])
                   if test "$doxygen" = "yes" ; then
                       n1=`doxygen --version | cut -d '.' -f 1`
                       n2=`doxygen --version | cut -d '.' -f 2`
                       if test $n1 -gt 1 -o $n2 -ge 3 ; then
                           AC_MSG_RESULT([ >= 1.3])
                       else
                           AC_MSG_RESULT([ too old (< 1.3) ignoring doxygen])
                           doxygen="no"
                       fi
                   fi
                 AC_CHECK_PROG(dot, dot, [YES], [NO], [$PATH])
                 # upper case value for dot variable because it goes as is into doxyfile file

                 AC_CHECK_PROG(tmp, man, [yes], [no], [$PATH])
                 if test "$tmp" = "yes" ; then
                    AC_CHECK_PROG(groff, groff, [yes], [no], [$PATH])
                 else
                    groff = "no";
                 fi
                 AS_IF( [ test "x$explicit_build_html" = "xyes" -a \( "$doxygen" != "yes" -o "$groff" != "yes" \) ],
                        [ AC_MSG_ERROR([lacking prerequisit to build documentation]) ]
                      )
               ]
     )

AC_ARG_ENABLE( [upx],
                AS_HELP_STRING(--disable-upx, [by default configure looks for UPX and if available make executables compressed at installation time, you can disable this feature]),
                [explicit_upx=yes],
                [enable_upx=yes])

AS_IF(          [ test "x$enable_upx" != "xyes" ],
                [
                   AC_MSG_NOTICE([ignoring UPX])
                   upx="no"
                ],
                [
                   AC_CHECK_PROG(upx, upx, [yes], [no], [$PATH])
                   AS_IF( [ test "x$explicit_upx" = "xyes" -a "$upx" != "yes" ],
                          [ AC_MSG_ERROR([upx is missing]) ]
                        )
                ]
             )

AC_ARG_ENABLE( [fast-dir],
               AS_HELP_STRING(--disable-fast-dir, [disable optimization for large directories, doing so has a little positive impact on memory requirement but a huge drawback on execution time]),
               [
                    AS_IF([ test "x$enable_fast_dir" != "xno" ],
                          [ AC_MSG_ERROR([invalid argument given to --disable-fast_dir]) ]
                         )
               ],
               [AC_DEFINE(LIBDAR_FAST_DIR, 1, [activation of speed optimization for large directories])
                local_fast_dir="yes"
               ]
             )


AC_ARG_ENABLE(  [gpgme-linking],
                AS_HELP_STRING(--disable-gpgme-linking, [disable linking with gpgme which disables asymetric crypto algorithms]),
                [explicit_gpgme_linking=yes],
                [enable_gpgme_linking=yes])

AS_IF(          [ test "x$enable_gpgme_linking" != "xyes" ],
                [
                  AC_MSG_WARN([asymetrical encryption support has been disabled by user])
                  local_gpgme="no"
                ],
                [
                  if test $local_crypto != no ; then
                    gpgme_min_version="1.2.0"
                    AC_DEFINE_UNQUOTED(GPGME_MIN_VERSION, "$gpgme_min_version", [minimum version expected of GPGME])
                    m4_ifdef([AM_PATH_GPGME],
                        [ AM_PATH_GPGME($gpgme_min_version,
                                [
                                  CPPFLAGS___cache="$CPPFLAGS"
                                  CPPFLAGS="$GPGME_CFLAGS $CPPFLAGS"
                                  LIBS___cache="$LIBS"
                                  LIBS="$GPGME_LIBS $LIBS"
                                  AC_CHECK_HEADERS([gpgme.h])
                                  AC_CHECK_LIB(gpgme, [gpgme_signers_add], [], [])
                                  AC_MSG_CHECKING([for libgpgme usability])
                                  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
                                                                    #if HAVE_GPGME_H
                                                                    #include <gpgme.h>
                                                                    #endif
                                                                 ]],
                                                                 [[
                                                                    gpgme_ctx_t context;
                                                                    gpgme_error_t err = gpgme_new(&context);
                                                                    gpgme_release(context);
                                                                    return err;
                                                                 ]])
                                                 ],
                                                 [
                                                   local_gpgme="yes"
                                                   AC_DEFINE(GPGME_SUPPORT, 1, [GPGME is available to support public key based ciphering])
                                                   AC_MSG_RESULT(ok)
                                                 ],
                                                 [
                                                   local_gpgme="no"
                                                   AC_MSG_RESULT([not usable! See config.log for details])
                                                 ])
                                  CPPFLAGS="$CPPFLAGS___cache"
                                  unset CPPFLAGS___cache
                                  LIBS="$LIBS___cache"
                                  unset LIBS___cache
                                ],
                                [ AC_MSG_WARN([Public key support (GPGME linking) requires version greater than $gpgme_min_version]) ]
                               )
                        ],
                        [AC_MSG_WARN([AM_PATH_GPGME macro not found!])])
                 else
                    AC_MSG_WARN([Public key support (GPGME linking) requires libgcrypt (strong encryption support)])
                 fi

                 AS_IF( [ test "x$explicit_gpgme_linking" = "xyes" -a "$local_gpgme" != "yes" ],
                        [ AC_MSG_ERROR([gpgme linking failed]) ]
                      )
                ]
     )

AC_ARG_ENABLE(  [thread-safe],
                AS_HELP_STRING(--disable-thread-safe, [libdar is thread safe if POSIX mutex are available, you can manually disable the use of POSIX mutex, the resulting libdar library will not be thread-safe anymore]),
                [explicit_thread_safe=yes],
                [enable_thread_safe=yes])

AS_IF(          [ test "x$enable_thread_safe" != "xyes" ],
                [ AC_MSG_NOTICE([thread-safe support disabled])],
                [ AC_CHECK_LIB(pthread, [pthread_mutex_init], [], [])
                  AC_MSG_CHECKING([for POSIX mutex])
                  AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                                        #if HAVE_PTHREAD_H
                                                        #include <pthread.h>
                                                        #endif
                                                     }]],
                                                    [[ pthread_mutex_t mutex;
                                                       pthread_mutex_init(&mutex, (const pthread_mutexattr_t*)0);
                                                       pthread_mutex_lock(&mutex);
                                                       pthread_mutex_unlock(&mutex);]])
                                 ],
                                 [ AC_DEFINE(MUTEX_WORKS, 1, [POSIX mutex (pthread_mutex_t) is available])
                                      local_mutex_works="yes"
                                      AC_MSG_RESULT(yes)
                                 ],
                                 [ AC_MSG_RESULT(no)])
                  AC_MSG_CHECKING([for reentrant stdlib calls])
                  AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                                         #if HAVE_TIME_H
                                                         #include <time.h>
                                                         #endif
                                                         #if HAVE_SYS_TYPE_H
                                                         #include <sys/type.h>
                                                         #endif
                                                         #if HAVE_GRP_H
                                                         #include <grp.h>
                                                         #endif
                                                         #if HAVE_PWD_H
                                                         #include <pwd.h>
                                                         #endif
                                                         #if HAVE_DIRENT_H
                                                         #include <dirent.h>
                                                         #endif
                                                }]],
                                                [[ #if HAVE_CTIME_R
                                                     char *val1 = ctime_r(0, 0);
                                                   #else
                                                     error(); // should not compile as expected
                                                   #endif

                                                   #if HAVE_GETGRNAM_R
                                                     int val2 = getgrnam_r(0, 0, 0, 0, 0);
                                                   #else
                                                     error(); // should not compile as expected
                                                   #endif

                                                   #if HAVE_GETPWNAM_R
                                                     int val3 = getpwnam_r(0, 0, 0, 0, 0);
                                                   #else
                                                     error(); // should not compile as expected
                                                   #endif

                                                   #if HAVE_LOCALTIME_R
                                                     struct tm *val4 = localtime_r(0, 0);
                                                   #else
                                                     error(); // should not compile as expected
                                                   #endif

                                                   #if HAVE_READDIR_R
                                                     int val5 = readdir_r(0, 0, 0);
                                                   #else
                                                     error(); // should not compile as expected
                                                   #endif
                                                 ]])
                                ],
                                [AC_MSG_RESULT([all could be found])],
                                [
                                  AC_DEFINE(MISSING_REENTRANT_LIBCALL, 1, [Some *_r() stdlib call are missing to permit complete thread-safe support by libdar])
                                  local_mutex="no"
                                  AC_MSG_RESULT([some are missing])
                                ]
                        )
                  AS_IF( [ test "x$explicit_thread_safe" = "xyes" -a "$local_mutex" != "yes" ],
                         [ AC_MSG_ERROR([thread safe support not available]) ]
                       )
                ]
     )


AC_ARG_ENABLE( [execinfo],
               AS_HELP_STRING(--disable-execinfo, [disable reporting stack information on self diagnostic bugs even]),
               [explicit_execinfo=yes],
               [enable_execinfo=yes])

AS_IF(       [ test "x$enable_execinfo" != "xyes" ],
             [ AC_MSG_WARN([ignoring execinfo even if available]) ],
             [
               AC_CHECK_HEADERS([execinfo.h])
               AC_CHECK_LIB(execinfo, [backtrace], [], [])
               AC_MSG_CHECKING([for backtrace() usability])
               AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern "C" {
                                               #if HAVE_EXECINFO_H
                                               #include <execinfo.h>
                                               #endif
                                               }]],
                                               [[
                                               const int buf_size = 20;
                                               void *buffer[buf_size];
                                               int x = backtrace(buffer, buf_size);
                                               ]])
                               ],
                               [ AC_DEFINE(BACKTRACE_AVAILABLE, 1, [backtrace() call supported])
                                 AC_MSG_RESULT(yes)
                               ],
                               [
                                 AC_MSG_RESULT(no)
                                 AS_IF( [ test "x$explicit_execinfo" = "xyes" ],
                                        [ AC_MSG_ERROR([execinfo not found]) ]
                                      )
                               ])
             ]
     )


AC_ARG_ENABLE( [profiling],
               AS_HELP_STRING(--enable-profiling, [enable executable profiling]),
               [
                 AS_IF([ test "x$enable_profiling" != "xyes" ],
                       [ AC_MSG_ERROR([invalid argument given to --enable-profiling]) ]
                      )
                 profiling="yes"
               ])

AC_ARG_ENABLE( [debug-memory],
               AS_HELP_STRING(--enable-debug-memory, [log memory allocations and releases to /tmp/dar_debug_mem_allocation.txt this debugging option lead to a slow executable]),
               [
                 AS_IF([ test "x$enable_debug_memory" != "xyes" ],
                       [ AC_MSG_ERROR([invalid argument given to --enable-debug-memory]) ]
                      )
                 AC_DEFINE(LIBDAR_DEBUG_MEMORY, 1, [if defined, builds a very slow executable
               ])])

AC_ARG_ENABLE( [dar-static],
               AS_HELP_STRING(--disable-dar-static, [avoids building dar_static, a dar statically linked version]),
               [
                 explicit_dar_static=yes
                 AS_IF([ test "x$enable_dar_static" != "xyes" ],
                       [ build_static="no" ],
                       [ build_static="yes" ])
               ],
               [build_static="yes"])


AC_ARG_ENABLE( [threadar],
               AS_HELP_STRING(--disable-threadar, [avoid linking with libthreadar if available to prevent the use several threads inside libdar]),
               [explicit_threadar=yes],
               [enable_threadar=yes])

AS_IF(       [ test "x$enable_threadar" != "xyes" ],
             [ AC_MSG_WARN([libthreadar support has been disabled by user]) ],
             [
               PKG_CHECK_EXISTS(libthreadar,
                                [
                                  PKG_CHECK_MODULES(LIBTHREADAR, libthreadar, [], [AC_MSG_ERROR([libthreadar not found, but reported to exist !?!])])
                                ],
                                [
                                  AC_CHECK_LIB(threadar, [for_autoconf], [], [])
                                ])
               CPPFLAGS__cache="$CPPFLAGS"
               CPPFLAGS="$LIBTHREADAR_CFLAGS $CPPFLAGS"
               CXXFLAGS__cache="$CXXFLAGS"
               CXXFLAGS="$LIBTHREADAR_CFLAGS $CXXFLAGS"
               LIBS__cache="$LIBS"
               LIBS="$LIBTHREADAR_LIBS $LIBS"
               AC_CHECK_HEADER(libthreadar/libthreadar.hpp,
                               [ AC_DEFINE(HAVE_LIBTHREADAR_LIBTHREADAR_HPP, 1, [libthreadar.h header file availability]) ],
                               [ AC_MSG_WARN([Cannot find libthreadar.h header file]) ]
                              )
               AC_MSG_CHECKING([for libthreadar() operationability])
               AC_RUN_IFELSE([AC_LANG_PROGRAM( [[
                                    #if HAVE_LIBTHREADAR_LIBTHREADAR_HPP
                                    #include <libthreadar/libthreadar.hpp>
                                    #endif
                                    #include <iostream>
                                   ]],
                                   [[
                                        class mythread: public libthreadar::thread
                                        {
                                        public:
                                            mythread(int x): myx(x) {};
                                            int getx() const { return myx; };

                                        protected:
                                            virtual void inherited_run() { --myx; };

                                        private:
                                           int myx;
                                        };

                                        mythread toto(10);

                                        toto.run();
                                        toto.join();
                                        toto.getx();
                                        std::cout << "ok" << std::endl;
                                   ]])
                               ],
                               [
                                 local_threadar=yes
                                 AC_DEFINE(LIBTHREADAR_AVAILABLE, 1, [when libthreadar could be found and linked against])
                                 AC_MSG_RESULT(fine)
                               ],
                               [
                                 local_threadar=no
                                 AC_MSG_RESULT(wrong)
                               ]
                             )
              CPPFLAGS="$CPPFLAGS__cache"
              unset CPPFLAGS__cache
              CXXFLAGS="$CXXFLAGS__cache"
              unset CXXFLAGS__cache
              LIBS="$LIBS__cache"
              unset LIBS__cache
              AS_IF( [ test "x$explicit_threadar" = "xyes" -a "$local_threadar" != "yes" ],
                     [ AC_MSG_ERROR([libthreadar linking failed]) ]
                   )
            ]
     )

CPPFLAGS__cache="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $GPGME_CFLAGS $LIBCURL_CFLAGS $LIBTHREADAR_CFLAGS $CXXSTDFLAGS"
CXXFLAGS__cache="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS"
LDFLAGS__cache="$LDFLAGS"
LDFLAGS="$LDFLAGS -static"
LIBS__cache="$LIBS"
LIBS="$LIBS $GPGME_LIBS $LIBCURL_LIBS $LIBTHREADAR_LIBS $CXXSTDFLAGS"
AC_MSG_CHECKING([static linking])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[ extern "C" {
                                                #if HAVE_STDIO_H
                                                #include <stdio.h>
                                                #endif
                                                #if HAVE_EXECINFO_H
                                                #include <execinfo.h>
                                                #endif
                                                #if HAVE_STDLIB_H
                                                #include <stdlib.h>
                                                #endif
                                                #if HAVE_PTHREAD_H
                                                #include <pthread.h>
                                                #endif
                                                #if HAVE_LIBRSYNC_H
                                                #include <librsync.h>
                                                #endif
                                                #if HAVE_PTHREAD_H
                                                #include <pthread.h>
                                                #endif
                                                #if HAVE_LIBRSYNC_H
                                                #include <stdio.h>
                                                #include <librsync.h>
                                                #endif
                                                #if HAVE_ZLIB_H
                                                #include <zlib.h>
                                                #endif
                                                #if HAVE_BZLIB_H
                                                #include <bzlib.h>
                                                #endif
                                                #if HAVE_LZO_LZO1X_H
                                                #include <lzo/lzo1x.h>
                                                #endif
                                                #if HAVE_LZMA_H
                                                #include <lzma.h>
                                                #endif
                                                #if HAVE_GCRYPT_H
                                                #include <gcrypt.h>
                                                #endif
                                                #if HAVE_CURL_CURL_H
                                                #include <curl/curl.h>
                                                #endif
                                                #if HAVE_GPGME_H
                                                #include <gpgme.h>
                                                #endif
                                             }
                               ]],
                               [[
                               #if BACKTRACE_AVAILABLE
                                  const int buf_size = 20;
                                  void *buffer[buf_size];
                                  int size = backtrace(buffer, buf_size);
                                  char **symbols = backtrace_symbols(buffer, size);

                                  if(symbols != 0)
                                    free(symbols);
                                  printf("testing execinfo info in static linked mode...");
                               #endif

                               #if MUTEX_WORKS
                               if(1)
                               {
                                 pthread_mutex_t test;
                                 if(pthread_mutex_init(&test, NULL) == 0)
                                 {
                                    if(pthread_mutex_lock(&test) == 0)
                                       pthread_mutex_unlock(&test);
                                 }
                                 pthread_mutex_destroy(&test);
                                 printf("testing mutex availability in static linked mode...");
                               }
                               #endif

                               #if LIBRSYNC_AVAILABLE
                               if(1)
                               {
                                 rs_result err = RS_DONE;
                                 (void) rs_strerror(err);
                                 printf("testing librsync availability in static linked mode...");
                               }
                               #endif

                               #if LIBZ_AVAILABLE
                               if(1)
                               {
                                  z_stream *ptr = (z_stream *)0;
                                  deflate(ptr, 0);
                                  printf("testing libz availability in static linked mode...");
                               }
                               #endif

                               #if LIBBZ2_AVAILABLE
                               if(1)
                               {
                                  bz_stream *ptr = (bz_stream *)0;
                                  BZ2_bzCompress(ptr, 0);
                                  printf("testing libbz2 availability in static linked mode...");
                               }
                               #endif

                               #if LIBLZO2_AVAILABLE
                               if(1)
                               {
                                  int x;
                                  printf("testing liblzo2 availability in static linked mode...");
                                  x = lzo1x_1_compress(0, 0, 0, 0, 0);
                               }
                               #endif

                               #if LIBLZMA_AVAILABLE
                               if(1)
                               {
                                  lzma_stream ptr = LZMA_STREAM_INIT;
                                  lzma_ret tmp = lzma_easy_encoder(&ptr,
                                                                   2,
                                                                   LZMA_CHECK_CRC32);
                                  printf("testing libxz/lzma availability in static linked mode...");
                               }
                               #endif

                               #if CRYPTO_AVAILABLE
                                  printf("testing gcrypt availability in static linked mode...");
                                  if(!gcry_check_version(MIN_VERSION_GCRYPT))
                                  {
                                    printf("ligcrypt version too low");
                                    exit(1);
                                  }
                                  else
                                    exit(0);
                               #endif

                               #if LIBCURL_AVAILABLE
                                  printf("testing librsync availability in static linked mode...");
                                  (void) curl_global_init(CURL_GLOBAL_ALL);
                               #endif

                               #if GPGME_SUPPORT
                               if(1)
                               {
                                 gpgme_ctx_t context;
                                 gpgme_error_t err = gpgme_new(&context);
                                 gpgme_release(context);
                               }
                               #endif

                                 return 0;
                               ]])
               ],
               [
                 AC_MSG_RESULT([yes, perfect!])
                 static_pb="no"
               ],
               [
                 AC_MSG_RESULT([failed])
                 static_pb="yes"
                 AS_IF( [ test "x$explicit_dar_static" = "xyes" -a "$build_static" = "yes" ],
                        [ AC_MSG_ERROR([Cannot build dar-static on this system, check config.log]) ]
                      )
               ])
CPPFLAGS="$CPPFLAGS__cache"
unset CPPFLAGS__cache
CXXFLAGS="$CXXFLAGS__cache"
unset CXXFLAGS__cache
LDFLAGS="$LDFLAGS__cache"
unset LDFLAGS__cache
LIBS="$LIBS__cache"
unset LIBS__cache

AC_ARG_ENABLE( [python-binding],
               AS_HELP_STRING(--disable-python-binding, [ignore python binding even if it is possible to build it]),
               [explicit_python_binding=yes],
               [enable_python_binding=yes])

AS_IF(         [ test "x$enable_python_binding" != "xyes" ],
               [
                 AC_MSG_WARN([python binding disabled per user request])
                 local_python="no"
               ],
               [
	         if test "x$enable_shared" != "xyes" -o "$debug_static" == "yes" ; then
		   AC_MSG_WARN([Cannot build python binding without shared library support])
		   local_python="no"
		 else
                   AC_MSG_CHECKING([for python binding])
                   pyext="python3-config --extension-suffix"
                   if  $pyext 1> /dev/null 2> /dev/null ; then
                      PYEXT="`$pyext`"
                   else
                       local_python="no"
                   fi

                   pyflags="python3 -m pybind11 --includes"
                   if test "$local_python" != "no" && $pyflags 1> /dev/null 2> /dev/null ; then
                      PYFLAGS="`$pyflags`"
                      local_python="yes"
                      AC_MSG_RESULT([ok])
                      AC_SUBST(PYEXT, [$PYEXT])
                      AC_SUBST(PYFLAGS, [$PYFLAGS])
                   else
                      local_python="no"
                      AC_MSG_RESULT([failed])
                   fi
                 fi
                 AS_IF( [ test "x$explicit_python_binding" = "xyes" -a "$local_python" != "yes" ],
                        [ AC_MSG_ERROR([prerequisit for python binding not met]) ]
                      )
               ]
     )

AM_CONDITIONAL([MAKE_ALL_DIR], [test $examples = "yes"])
AM_CONDITIONAL([BUILD_DAR_STATIC], [test $build_static = "yes" -a $static_pb = "no"])
AM_CONDITIONAL([DEBUG_STATIC], [test $debug_static = "yes" -a $static_pb = "no"])
AM_CONDITIONAL([BUILD_MODE32], [test "$build_mode" = "32"])
AM_CONDITIONAL([BUILD_MODE64], [test "$build_mode" = "64" -o -z "$build_mode"])
AM_CONDITIONAL([USE_UPX], [test "$upx" = "yes"])
AM_CONDITIONAL([USE_DOXYGEN], [test "$doxygen" = "yes"])
AM_CONDITIONAL([USE_GROFF], [test "$groff" = "yes"])
AM_CONDITIONAL([PROFILING], [test "$profiling" = "yes"])
AM_CONDITIONAL([BSD_SED], [test "$local_sed" = "bsd"])
AM_CONDITIONAL([WITH_LIBTHREADAR], [test "$local_threadar" = "yes"])
AM_CONDITIONAL([PYTHON_BINDING], [test "$local_python" = "yes"])
AC_SUBST([CXXSTDFLAGS], [$CXXSTDFLAGS])
AC_SUBST(UPX_PROG, [upx])
AC_SUBST(DOXYGEN_PROG, [doxygen])
AC_SUBST(HAS_DOT, [$dot])

# defaults
AC_PREFIX_DEFAULT(/usr/local)

# hack from libtool mailing-list to know from source point of view whether we are compiling for dynamic or static way

AC_CONFIG_COMMANDS([hack-libtool], [
                                    sed 's,^pic_flag=,pic_flag=" -D__DYNAMIC__ ",' libtool > libtoolT \
                                    && mv -f libtoolT libtool && chmod 755 libtool
])


AC_CONFIG_FILES([Makefile man/Makefile src/Makefile src/libdar/Makefile src/dar_suite/Makefile src/testing/Makefile src/examples/Makefile doc/Makefile doc/samples/Makefile misc/Makefile doc/mini-howto/Makefile src/libdar/libdar.pc.tmpl doc/man/Makefile src/check/Makefile src/python/Makefile po/Makefile.in])
AC_OUTPUT
[echo ""
echo "--"
echo "dar and libdar have been successfully configured with the following parameters:"
echo ""
echo "  LIBDAR parameters:"

printf "   Zlib compression (gzip)    : "
if [ "$local_libz" = "yes" ] ; then
  echo "YES"
else
  echo "NO"
fi

printf "   Libbz2 compression (bzip2) : "
if [ "$local_libbz2" = "yes" ] ; then
  echo "YES"
else
  echo "NO"
fi

printf "   Liblzo2 compression (lzo)  : "
if [ "$local_liblzo2" = "yes" ] ; then
  echo "YES"
else
  echo "NO"
fi

printf "   Liblxz compression (xz)    : "
if [ "$local_libxz" = "yes" ] ; then
  echo "YES"
else
  echo "NO"
fi

printf "   Strong encryption support  : "
if [ "$local_crypto" = "yes" ] ; then
  echo "YES"
else
  echo "NO"
fi

printf "   Public key cipher support  : "
if [ "$local_gpgme" = "yes" ] ; then
  echo "YES"
else
  echo "NO"
fi

printf "   Extended Attributes support: "
if [ "$local_ea_support" = "yes" ] ; then
  echo "YES"
else
  echo "NO"
fi

printf "   Large files support (> 2GB): "
if [ ! -z "$ac_cv_sys_file_offset_bits" -o ! -z "$ac_cv_sys_large_files" ] ; then
  echo "YES"
else
  echo "NO"
fi

printf "   extX FSA / nodump support  : "
if [ "$local_nodump_feature" = "yes" ] ; then
  echo "YES"
else
  echo "NO"
fi

printf "   HFS+ FSA support           : "
if [ "$local_birthtime" = "yes" ] ; then
  echo "YES"
else
  echo "NO"
fi

printf "   Integer size used          : "
if [ "$build_mode" = "infinint" ] ; then
  echo "infinint"
else
  if [ -z "$build_mode" ] ; then
     build_mode=64
  fi
  echo "$build_mode"
fi

printf "   Thread safe support        : "
if [ "$local_mutex_works" = "yes" -a -z "$local_test_memory" ] ; then
  echo "YES"
else
  echo "NO"
fi

printf "   Furtive read mode          : "
if [ "$local_furtive_read_mode" = "yes" ]; then
   echo "YES"
else
   echo "NO"
fi

printf "   Large directory optim.     : "
if [ "$local_fast_dir" = "yes" ] ; then
   echo "YES"
else
   echo "NO"
fi

printf "   posix fadvise support      : "
if  [ "$local_posix_fadvise" = "yes" ] ; then
    echo "YES"
else
    echo "NO"
fi

printf "   microsecond read accuracy  : "
if [ "$local_microsecond_read" = "yes" ] ; then
    echo "YES"
else
    echo "NO"
fi

printf "   microsecond write accuracy : "
if [ "$local_microsecond_write" = "yes" ] ; then
    echo "YES"
else
    echo "NO"
fi

printf "   can restore symlink dates  : "
if [ "$local_lutimes" = "yes" ] ; then
    echo "YES"
else
    echo "NO"
fi

printf "   can uses multiple threads  : "
if [ "$local_threadar" = "yes" ] ; then
   echo "YES"
else
   echo "NO"
fi

printf "   Delta-compression support  : "
if [ "$local_librsync" = "yes" ] ; then
  echo "YES"
else
  echo "NO"
fi

printf "   Remote repository support  : "
if [ "$local_libcurl" = "yes" -a "$local_threadar" = "yes" ] ; then
  echo "YES"
else
  echo "NO"
fi

echo ""
echo "  DAR SUITE command line programs:"
printf "   Long options available : "
if [ "$local_have_getopt_long" = "yes" ] ; then
  echo "YES"
else
  echo "NO"
fi

printf "   Building examples      : "
if [ "$examples" = "yes" ] ; then
  echo "YES"
else
  echo "NO"
fi

printf "   Building dar_static    : "
if  [ "$build_static" = "yes" ]; then
  if [ "$static_pb" = "yes" ]; then
     echo "NO  (system does not support static linking, see note below)"
  else
     echo "YES"
  fi
else
  echo "NO"
fi

printf "   using upx at install   : "
if  [ "$upx" = "yes" ] ; then
  echo "YES"
else
  echo "NO"
fi

printf "   building documentation : "
if  [ "$doxygen" = "yes" ] ; then
  echo "YES"
else
  echo "NO"
fi

printf "   building python binding: "
if [ "$local_python" = "yes" ] ; then
   echo "YES"
else
   echo "NO"
fi

if [ "$static_pb" = "yes" -a "$build_static" = "yes" ] ; then
   echo ""
   echo "  Note:"
   echo ""
   echo "    If  you  want to know  which libraries  are not available  as  static"
   echo "    libraries check the logs in the config.log generated file. the command"
   echo ""
   echo "         'grep -e -static -A 2 config.log'"
   echo ""
   echo "    should bring you to the essentials."
   echo ""
   echo "You also might want to speed up the compilation process running ./configure"
   echo "with the --disable-static option"
   echo ""
fi

if [ -z "$build_mode" ] ; then
   echo ""
   echo "--------------------- N O T E -------------------------------------------"
   echo "Note: You are about to build a libdar/dar binary relying on \"infinint\""
   echo "integer type. You shall also consider using 64 bits integers (whatever"
   echo "your CPU has 32 or 64 bits registers) for better performances and reduced"
   echo "memory requirements, at the cost of the limitations explained here:"
   echo "   ./doc/Limitations.html (Paragraph about Integers)"
   echo "Document which is also available online at:"
   echo "   http://dar.linux.free.fr/doc/Limitations.html#Integers"
   echo "Unless you are impacted by these limitations, you can rerun ./configure"
   echo "adding the option --enable-mode=64 for dar/libdar better performances"
   echo "-------------------------------------------------------------------------"
fi

if [ "$libgcrypt_hash_bug" = "yes" ] ; then
   echo ""
   echo ""
   echo "#################### W A R N I N G ######################################"
   echo ""
   echo "libgcrypt version is lower than $min_version_gcrypt_hash_bug and has a bug"
   echo "concerning hash calculation for large files. Expect sha1 and md5 hash"
   echo "results for slices larger than 256 Gio (gibioctet) to be incorrect."
   echo ""
   echo "#################### W A R N I N G ######################################"
fi

echo ""
]