File: aclocal.m4

package info (click to toggle)
dcmtk 3.6.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 54,900 kB
  • sloc: cpp: 274,805; ansic: 47,345; makefile: 5,313; sh: 4,250; perl: 277; xml: 182; lex: 103
file content (2093 lines) | stat: -rw-r--r-- 60,955 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
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
dnl
dnl Filename: aclocal.m4
dnl
dnl Purpose: additional M4 macros for GNU autoconf
dnl
dnl Authors: Andreas Barth, Marco Eichelberg
dnl


dnl AC_CHECK_GXXLIB works like AC_CHECK_LIB, but for libg++.
dnl   This additional macro is necessary because the /bin/sh will
dnl   not allow you to define a variable "ac_cv_lib_g++" and
dnl   thus AC_CHECK_LIB will fail for libg++.
dnl   All symbols #defined by this macro replace G++ by GXX.

dnl AC_CHECK_GXXLIB
AC_DEFUN(AC_CHECK_GXXLIB,
[AC_MSG_CHECKING([for -lg++])
AC_CACHE_VAL(ac_cv_lib_gxx,
[ac_save_LIBS="$LIBS"
LIBS="-lg++ $LIBS"
AC_TRY_LINK(, [main()], eval "ac_cv_lib_gxx=yes", eval "ac_cv_lib_gxx=no")
LIBS="$ac_save_LIBS"
])dnl
if eval "test \"`echo '$ac_cv_lib_gxx'`\" = yes"; then
  AC_MSG_RESULT(yes)
  ifelse([$3], ,
[changequote(, )dnl
  ac_tr_lib=HAVE_LIBGXX
changequote([, ])dnl
  AC_DEFINE_UNQUOTED($ac_tr_lib)
  LIBS="-lg++ $LIBS"
], [$3])
else
  AC_MSG_RESULT(no)
ifelse([$4], , , [$4
])dnl
fi
])

dnl AC_CHECK_PROTOTYPE checks if there is a prototype declaration
dnl   for the given function. If header file(s) are given as argument 2, they
dnl   are #included in the search. Otherwise only predefined functions will
dnl   be found.  The header files are only included in the search if they
dnl   have already been found using the AC_CHECK_HEADERS(header) macro.
dnl Note:
dnl   Since GNU autoheader does not support this macro, you must create entries
dnl   in your acconfig.h for each function which is tested.
dnl Examples:
dnl   in configure.in:
dnl     AC_CHECK_PROTOTYPE(setsockopt, sys/types.h sys/socket.h)
dnl     AC_CHECK_PROTOTYPE(gethostid)
dnl   in acconfig.h:
dnl     #undef HAVE_PROTOTYPE_SETSOCKOPT
dnl     #undef HAVE_PROTOTYPE_GETHOSTID

dnl AC_CHECK_PROTOTYPE(FUNCTION, HEADER-FILE..., ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
AC_DEFUN(AC_CHECK_PROTOTYPE,
[AC_MSG_CHECKING([ifelse([$2], , [predefined prototype for $1], [prototype for $1 (in $2)])])
AH_TEMPLATE(AS_TR_CPP(HAVE_PROTOTYPE_$1), [Define if your system has a prototype for $1 in $2.])
ifelse([$3], , :, [$3])

ifelse([$2], , [ac_includes=""
],
[ac_includes=""
for ac_header in $2
do
  ac_safe=`echo "$ac_header" | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'}'`\" = yes"; then
    ac_includes="$ac_includes
#include<$ac_header>"
  fi
done])
tmp_save_1=`echo $1 | tr ' :' '__'`
AC_CACHE_VAL(ac_cv_prototype_$tmp_save_1,
[AC_TRY_COMPILE(
[#ifdef __cplusplus
extern "C" {
#endif
$ac_includes
#ifdef __cplusplus
}
#endif
typedef union { int member; } dummyStruct;
#ifdef __cplusplus
extern "C"
#endif
dummyStruct $1(dummyStruct);
]
, ,eval "ac_cv_prototype_$tmp_save_1=no", eval "ac_cv_prototype_$tmp_save_1=yes")])dnl
if eval "test \"`echo '$''{'ac_cv_prototype_$tmp_save_1'}'`\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_prototype=HAVE_PROTOTYPE_`echo $tmp_save_1 | tr '[a-z]' '[A-Z]'`
changequote([, ])dnl
  AC_DEFINE_UNQUOTED([$ac_tr_prototype])
  ifelse([$3], , :, [$3])
else
  AC_MSG_RESULT(no)
ifelse([$4], , , [$4
])dnl
fi
])

dnl AC_CHECK_COMPILES verifies that the given code fragment can be compiled.
dnl   It is assumed that successfully compiling means that the specified
dnl   function is available. If header file(s) are given as argument 2, they
dnl   #included in the search. Otherwise only predefined functions will be
dnl   available. The header files are only included in the search if they have
dnl   already been found using the AC_CHECK_HEADERS(header) macro.

dnl AC_CHECK_COMPILES(FUNCTION, HEADER-FILE..., CODE, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
AC_DEFUN(AC_CHECK_COMPILES,
[AC_MSG_CHECKING([ifelse([$2], , [for $1], [for $1 (in $2)])])
AH_TEMPLATE(AS_TR_CPP(HAVE_PROTOTYPE_$1), [Define if your system has a prototype for $1 in $2.])
ifelse([$2], , [ac_includes=""
],
[ac_includes=""
for ac_header in $2
do
  ac_safe=`echo "$ac_header" | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'}'`\" = yes"; then
    ac_includes="$ac_includes
#include<$ac_header>"
  fi
done])
tmp_save_1=`echo $1 | tr ' :' '__'`
AC_CACHE_VAL(ac_cv_compiles_$tmp_save_1,
[AC_TRY_COMPILE([$ac_includes], [$3],
eval "ac_cv_compiles_$tmp_save_1=yes", eval "ac_cv_compiles_$tmp_save_1=no")])dnl
if eval "test \"`echo '$''{'ac_cv_compiles_$tmp_save_1'}'`\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_prototype=HAVE_PROTOTYPE_`echo $tmp_save_1 | tr '[a-z]' '[A-Z]'`
changequote([, ])dnl
  AC_DEFINE_UNQUOTED([$ac_tr_prototype])
  ifelse([$4], , :, [$4])
else
  AC_MSG_RESULT(no)
ifelse([$5], , , [$5
])dnl
fi
])

dnl AC_CHECK_DECLARATION checks if a certain type is declared in the include files given as argument 2 or 3.
dnl   Files given as argument 2 are included extern "C" in C++ mode,
dnl   files given as argument 3 are included "as is".
dnl   Header files are only included in the search if they
dnl   have already been found using the AC_CHECK_HEADERS(header) macro.

dnl AC_CHECK_DECLARATION(FUNCTION, C-HEADER-FILE..., C++-HEADER-FILE..., ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
AC_DEFUN(AC_CHECK_DECLARATION,
[
AC_MSG_CHECKING([ifelse([$2 $3], , [predefined type $1], [ifelse([$2], , [declaration for $1 (in $3)], [ifelse([$3], , [declaration for $1 (in $2)], [declaration for $1 (in $2 $3)])])])])
AH_TEMPLATE(AS_TR_CPP(HAVE_DECLARATION_$1), [Define if your system has a declaration for $1 in $2 $3.])
ifelse([$2], , [ac_includes=""
],
[ac_includes=""
for ac_header in $2
do
  ac_safe=`echo "$ac_header" | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'}'`\" = yes"; then
    ac_includes="$ac_includes
#include<$ac_header>"
  fi
done
])
ifelse([$3], , [ac_cpp_includes=""
],
[ac_cpp_includes=""
for ac_header in $3
do
  ac_safe=`echo "$ac_header" | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'}'`\" = yes"; then
    ac_cpp_includes="$ac_cpp_includes
#include<$ac_header>"
  fi
done
])
[ac_cv_declaration=`echo 'ac_cv_declaration_$1' | tr ' :' '__'`
]
AC_CACHE_VAL($ac_cv_declaration,
[AC_TRY_COMPILE(
[#ifdef __cplusplus
extern "C" {
#endif
$ac_includes
#ifdef __cplusplus
}
#endif
$ac_cpp_includes
$1 dummy;
]
, ,eval "$ac_cv_declaration=yes", eval "$ac_cv_declaration=no")])dnl
if eval "test \"\$$ac_cv_declaration\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_declaration=HAVE_DECLARATION_`echo $1 | tr ' :[a-z]' '__[A-Z]'`
changequote([, ])dnl
  AC_DEFINE_UNQUOTED([$ac_tr_declaration])
  ifelse([$4], , :, [$4])
else
  AC_MSG_RESULT(no)
ifelse([$5], , , [$5
])dnl
fi
unset ac_cv_declaration
])


dnl AC_CHECK_INTP_SELECT checks if the prototype for select()
dnl   specifies arguments 2-4 to be int* instead of struct fd_set *.
dnl   This is true for HP UX 9.x and causes C++ code to break.

dnl AC_CHECK_INTP_SELECT(HEADER-FILE..., ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
AC_DEFUN(AC_CHECK_INTP_SELECT,
[AC_MSG_CHECKING([ifelse([$1], , [if select() needs int* parameters],
[if select() needs int* parameters (in $1)])])
AH_TEMPLATE([HAVE_INTP_SELECT], [Define if your system declares argument 2-4 of select()
   as int * instead of struct fd_set *.])
ifelse([$1], , [ac_includes=""
],
[ac_includes=""
for ac_header in $1
do
  ac_safe=`echo "$ac_header" | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'}'`\" = yes"; then
    ac_includes="$ac_includes
#include<$ac_header>"
  fi
done])
AC_CACHE_VAL(ac_cv_prototype_intp_select,
[AC_TRY_COMPILE(
[#ifdef __cplusplus
extern "C" {
#endif
$ac_includes
#ifdef __cplusplus
}
#endif
]
,
[
  int i;
  fd_set fds;
  i = select(1, &fds, &fds, &fds, NULL);
],
eval "ac_cv_prototype_intp_select=no",
[AC_TRY_COMPILE(
[#ifdef __cplusplus
extern "C" {
#endif
$ac_includes
#ifdef __cplusplus
}
#endif
]
,
[
  int i;
  int fds;
  i = select(1, &fds, &fds, &fds, NULL);
],
eval "ac_cv_prototype_intp_select=yes", eval "ac_cv_prototype_intp_select=no")])])
if eval "test \"`echo $ac_cv_prototype_intp_select`\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_prototype=HAVE_INTP_SELECT
changequote([, ])dnl
  AC_DEFINE_UNQUOTED($ac_tr_prototype)
  ifelse([$2], , :, [$2])
else
  AC_MSG_RESULT(no)
  ifelse([$3], , , [$3])
fi
])



dnl AC_TRY_COMPILE_AND_LINK compiles a Source file into an object file
dnl  and links the object file. This can create a different behaviour
dnl  than compiling and linking the object file directly (e.g.
dnl  Sun C++ 3.0.1 with template functions)

dnl AC_TRY_COMPILE_AND_LINK(SOURCE, MAIN_BODY
dnl                         [, ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])
AC_DEFUN(AC_TRY_COMPILE_AND_LINK,
[ac_link_o='${CXX-g++} -o conftest $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.o $LIBS 1>&AC_FD_CC'
cat > conftest.$ac_ext <<EOF
dnl This sometimes fails to find confdefs.h, for some reason.
dnl [#]line __oline__ "[$]0"
[#]line __oline__ "configure"
#include "confdefs.h"
[$1]
int main() {
[$2]
; return 0; }
EOF
if AC_TRY_EVAL(ac_compile); then
  if AC_TRY_EVAL(ac_link_o); then
    ifelse([$3], , :, [rm -rf conftest*
    $3])
  else
    echo "configure: failed link was:" >&AC_FD_CC
    cat conftest.$ac_ext >&AC_FD_CC
    ifelse([$4], , , [  rm -rf conftest*
      $4
    ])dnl
  fi
else
  echo "configure: failed compile was:" >&AC_FD_CC
  cat conftest.$ac_ext >&AC_FD_CC
ifelse([$4], , , [  rm -rf conftest*
  $4
])dnl
fi
rm -f conftest*])

dnl AC_CHECK_STD_NAMESPACE checks if the C++-Compiler supports the
dnl   standard name space.

dnl AC_CHECK_STD_NAMESPACE
AC_DEFUN(AC_CHECK_STD_NAMESPACE,
[AC_MSG_CHECKING([for C++ standard namespace])
AH_TEMPLATE([HAVE_STD_NAMESPACE], [Define if ANSI standard C++ includes use std namespace.])
AC_CACHE_VAL(ac_cv_check_std_namespace,
[AC_TRY_COMPILE_AND_LINK([
#include <iostream>
using namespace std;
],[
  cout << "Hello World" << endl;
], eval "ac_cv_check_std_namespace=yes", eval "ac_cv_check_std_namespace=no")dnl
])dnl
if eval "test \"`echo '$ac_cv_check_std_namespace'`\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_std_namespace=HAVE_STD_NAMESPACE
changequote([, ])dnl
  AC_DEFINE_UNQUOTED($ac_tr_std_namespace)
else
  AC_MSG_RESULT(no)
fi
])



dnl AC_CHECK_CLASS_TEMPLATE checks if the C++-Compiler is capable of
dnl   using class templates in the easiest form i. e. all methods are
dnl   inline, no template methods and no typedefs in the class

dnl AC_CHECK_CLASS_TEMPLATE
AC_DEFUN(AC_CHECK_CLASS_TEMPLATE,
[AC_MSG_CHECKING([for C++ class template])
AH_TEMPLATE([HAVE_CLASS_TEMPLATE], [Define if your C++ compiler can work with class templates.])
AC_CACHE_VAL(ac_cv_check_class_template,
[AC_TRY_COMPILE_AND_LINK([
template <class T>
class x
{
private:
	T a;
public:
	void set(T i) { a = i; }
	x(T i) { set(i); }
	T get() { return a; }
};
],[
  int i;
  x<int> a(4);
  i = a.get();
  a.set(18);
  i = a.get();
  a.set(i-1);
], eval "ac_cv_check_class_template=yes", eval "ac_cv_check_class_template=no")dnl
])dnl
if eval "test \"`echo '$ac_cv_check_class_template'`\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_class_template=HAVE_CLASS_TEMPLATE
changequote([, ])dnl
  AC_DEFINE_UNQUOTED($ac_tr_class_template)
else
  AC_MSG_RESULT(no)
fi
])



dnl AC_CHECK_FUNCTION_TEMPLATE checks if the C++-Compiler is capable of
dnl   using function templates.

dnl AC_CHECK_FUNCTION_TEMPLATE
AC_DEFUN(AC_CHECK_FUNCTION_TEMPLATE,
[AC_MSG_CHECKING([for C++ function template])
AH_TEMPLATE([HAVE_FUNCTION_TEMPLATE], [Define if your C++ compiler can work with function templates.])
AC_CACHE_VAL(ac_cv_check_function_template,
[AC_TRY_COMPILE_AND_LINK([
template <class T>
int f(T* a)
{
 if (a) return 1;
 return 0;
}
],[
  int i, a;
  i = f(&a);
], eval "ac_cv_check_function_template=yes", eval "ac_cv_check_function_template=no")dnl
])dnl
if eval "test \"`echo '$ac_cv_check_function_template'`\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_function_template=HAVE_FUNCTION_TEMPLATE
changequote([, ])dnl
  AC_DEFINE_UNQUOTED($ac_tr_function_template)
else
  AC_MSG_RESULT(no)
fi
])


dnl AC_CHECK_STATIC_TEMPLATE_METHOD checks if the C++-Compiler is capable of
dnl   using static methods in template classes

dnl AC_CHECK_STATIC_TEMPLATE_METHOD
AC_DEFUN(AC_CHECK_STATIC_TEMPLATE_METHOD,
[AC_MSG_CHECKING([for C++ static methods in class templates])
AH_TEMPLATE([HAVE_STATIC_TEMPLATE_METHOD], [Define if your C++ compiler can work with static methods in class templates.])
AC_CACHE_VAL(ac_cv_check_static_template_method,
[AC_TRY_COMPILE_AND_LINK([
void additive(int & i)
{
        i++;
}

template <class T, class Function>
class x
{
public:
	x() { }
	static void do1(Function f, int & a) { f(a); }
        static void do2(T b) { T a = b; };
};
],[
  int a = 1;
  x<int, void (*)(int &)>::do1(additive, a);
  x<int, void (*)(int &)>::do2(a);
], eval "ac_cv_check_static_template_method=yes", eval "ac_cv_check_static_template_method=no")dnl
])dnl
if eval "test \"`echo '$ac_cv_check_static_template_method'`\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_static_template_method=HAVE_STATIC_TEMPLATE_METHOD
changequote([, ])dnl
  AC_DEFINE_UNQUOTED($ac_tr_static_template_method)
else
  AC_MSG_RESULT(no)
fi
])


dnl AC_CHECK_EXPLICIT_TEMPLATE_SPECIALIZATION checks if the C++-Compiler
dnl   supports the explicit template specialization syntax, i.e.
dnl     template<> int classname<int>::functionname()

dnl AC_CHECK_EXPLICIT_TEMPLATE_SPECIALIZATION
AC_DEFUN(AC_CHECK_EXPLICIT_TEMPLATE_SPECIALIZATION,
[AC_MSG_CHECKING([for C++ explicit template specialization syntax])
AH_TEMPLATE([HAVE_EXPLICIT_TEMPLATE_SPECIALIZATION], [Define if your C++ compiler supports the explicit template specialization syntax.])
AC_CACHE_VAL(ac_cv_check_explicit_template_specialization,
[AC_TRY_COMPILE([
template<class T>
class X
{
  public:
    int fn();
};

template<>
int X<int>::fn()
{
    return 0;
}
],[X<int> x], eval "ac_cv_check_explicit_template_specialization=yes", eval "ac_cv_check_explicit_template_specialization=no")dnl
])dnl
if eval "test \"`echo '$ac_cv_check_explicit_template_specialization'`\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_explicit_template_specialization=HAVE_EXPLICIT_TEMPLATE_SPECIALIZATION
changequote([, ])dnl
  AC_DEFINE_UNQUOTED($ac_tr_explicit_template_specialization)
else
  AC_MSG_RESULT(no)
fi
])


dnl AC_CHECK_GNU_LIBTOOL checks whether libtool is GNU libtool.
dnl   This macro requires that 'libtool' exists in the current path,
dnl   i.e. AC_CHECK_PROGS(LIBTOOL, libtool, :) should be executed and evaluated
dnl   before performing this test.
dnl   If libtool is identified as GNU libtool, the environment variable $ac_cv_check_gnu_libtool
dnl   is set to the value "yes", otherwise to "no".
dnl
dnl AC_CHECK_GNU_LIBTOOL
AC_DEFUN(AC_CHECK_GNU_LIBTOOL,
[AC_MSG_CHECKING([whether libtool is GNU libtool])
AC_CACHE_VAL(ac_cv_check_gnu_libtool,
[ ac_cv_check_gnu_libtool=`libtool --version 2>/dev/null | grep "GNU libtool" | sed -e "s/.*\(GNU libtool\).*/\1/" `
  if test "${ac_cv_check_gnu_libtool}set" = "GNU libtoolset" ; then
    ac_cv_check_gnu_libtool=yes
  else
    ac_cv_check_gnu_libtool=no
  fi
])
  if test $ac_cv_check_gnu_libtool = yes ; then
    AC_MSG_RESULT(yes)
  else
    AC_MSG_RESULT(no)
  fi
])



dnl AC_CHECK_HEADER_WITH_INCLUDES works like AC_CHECK_HEADER but allows to specify
dnl additional code to be put into the test program before the #include statement
dnl generated by AC_CHECK_HEADER.
dnl Typically this additional code will be additional #include statements.
dnl For example, on Irix 6, <netinet/tcp.h> cannot be included if <netinet/in.h> is not
dnl included before (leads to parse error).
dnl
dnl AC_CHECK_HEADER_WITH_INCLUDES(HEADER-FILE, [INCLUDES, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
AC_DEFUN(AC_CHECK_HEADER_WITH_INCLUDES,
[dnl Do the transliteration at runtime so arg 1 can be a shell variable.
ac_safe=`echo "$1" | sed 'y%./+-%__p_%'`
AC_MSG_CHECKING([for $1])
AC_CACHE_VAL(ac_cv_header_$ac_safe,
[AC_TRY_CPP([$2
#include <$1>], eval "ac_cv_header_$ac_safe=yes",
  eval "ac_cv_header_$ac_safe=no")])dnl
if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
  AC_MSG_RESULT(yes)
  ifelse([$3], , :, [$3])
else
  AC_MSG_RESULT(no)
ifelse([$4], , , [$4
])dnl
fi
])

dnl AC_CHECK_HEADERS_WITH_INCLUDES works like AC_CHECK_HEADERS but allows to specify
dnl additional code to be put into the test program before the #include statement
dnl generated by AC_CHECK_HEADERS.
dnl Typically this additional code will be additional #include statements.
dnl For example, on Irix 6, <netinet/tcp.h> cannot be included if <netinet/in.h> is not
dnl included before (leads to parse error).
dnl
dnl AC_CHECK_HEADERS_WITH_INCLUDES(HEADER-FILE..., [INCLUDES, [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
AC_DEFUN(AC_CHECK_HEADERS_WITH_INCLUDES,
[for ac_hdr in $1
do
AC_CHECK_HEADER_WITH_INCLUDES($ac_hdr, $2,
[changequote(, )dnl
  ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
changequote([, ])dnl
  AC_DEFINE_UNQUOTED($ac_tr_hdr) $3], $4)dnl
done
])


dnl AC_CHECK_POLL_H checks if we have a usable <poll.h>.
dnl poll on macOS is unreliable, it first did not exist, then was broken until
dnl fixed in 10.9 only to break again in 10.12.
dnl
dnl AC_CHECK_POLL_H([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
AC_DEFUN(AC_CHECK_POLL_H,
[
AC_MSG_CHECKING([for usable poll.h])
AH_TEMPLATE(AS_TR_CPP(DCMTK_HAVE_POLL), [Define if your system has a usable <poll.h>.])
AC_CACHE_VAL(ac_cv_header_poll_h,
[
case "${host}" in
    *-*-darwin*)
      eval "ac_cv_header_poll_h=no"
      ;;
    *)
      AC_TRY_CPP([#include <poll.h>], eval "ac_cv_header_poll_h=yes", eval "ac_cv_header_poll_h=no")dnl
      ;;
esac
])
if eval "test \"`echo '$ac_cv_header_poll_h'`\" = yes"; then
  AC_MSG_RESULT(yes)
  AC_DEFINE_UNQUOTED(DCMTK_HAVE_POLL)
  ifelse([$1], , :, [$1])
else
  AC_MSG_RESULT(no)
  ifelse([$2], , , [$2])
fi
])


dnl AC_CHECK_TCP_H
dnl checks for the presence of three system include files:
dnl    <netinet/in_systm.h>
dnl    <netinet/in.h>
dnl    <netinet/tcp.h>
dnl On certain systems like Irix or NeXT these are interdependent, i.e.
dnl tcp.h can only be included if in.h is included before. This script
dnl accounts for these dependencies.
dnl
dnl Note: GNU autoheader recognizes the includes tested by this macro.
dnl   No manual intervention required.
dnl
AC_DEFUN(AC_CHECK_TCP_H,
[AC_CHECK_HEADERS(netinet/in_systm.h)

if eval "test \"`echo '$ac_cv_header_netinet_in_systm_h'`\" = yes"; then
  AC_CHECK_HEADERS_WITH_INCLUDES(netinet/in.h,
#include <netinet/in_systm.h>
)
  if eval "test \"`echo '$ac_cv_header_netinet_in_h'`\" = yes"; then
    AC_CHECK_HEADERS_WITH_INCLUDES(netinet/tcp.h,
#include <netinet/in_systm.h>
#include <netinet/in.h>
)
  else
    AC_CHECK_HEADERS_WITH_INCLUDES(netinet/tcp.h,
#include <netinet/in_systm.h>
)
  fi
else
  AC_CHECK_HEADERS(netinet/in.h)
  if eval "test \"`echo '$ac_cv_header_netinet_in_h'`\" = yes"; then
    AC_CHECK_HEADERS_WITH_INCLUDES(netinet/tcp.h,
#include <netinet/in.h>
)
  else
    AC_CHECK_HEADERS(netinet/tcp.h)
  fi
fi
])

dnl AC_CHECK_INTP_ACCEPT checks if the prototype for accept()
dnl   specifies arguments 2-4 to be int* instead of size_t *.

dnl AC_CHECK_INTP_ACCEPT(HEADER-FILE..., ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
AC_DEFUN(AC_CHECK_INTP_ACCEPT,
[AC_MSG_CHECKING([ifelse([$1], , [if accept() needs int* parameters],
[if accept() needs int* parameters (in $1)])])
AH_TEMPLATE([HAVE_INTP_ACCEPT], [Define if your system declares argument 3 of accept()
   as int * instead of size_t * or socklen_t *.])
ifelse([$1], , [ac_includes=""
],
[ac_includes=""
for ac_header in $1
do
  ac_includes="$ac_includes
#include<$ac_header>"
done])
AC_CACHE_VAL(ac_cv_prototype_intp_accept,
[AC_TRY_COMPILE(
[#ifdef __cplusplus
extern "C" {
#endif
$ac_includes
#ifdef __cplusplus
}
#endif
]
,
[
  int i;
  struct sockaddr *addr;
  size_t addrlen;

  addr = 0;
  addrlen = 0;
  i = accept(1, addr, &addrlen);
],
eval "ac_cv_prototype_intp_accept=no",
[AC_TRY_COMPILE(
[#ifdef __cplusplus
extern "C" {
#endif
$ac_includes
#ifdef __cplusplus
}
#endif
]
,
[
  int i;
  struct sockaddr *addr;
  int addrlen;

  addr = 0;
  addrlen = 0;
  i = accept(1, addr, &addrlen);
],
eval "ac_cv_prototype_intp_accept=yes", eval "ac_cv_prototype_intp_accept=no")])])
if eval "test \"`echo $ac_cv_prototype_intp_accept`\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_prototype=HAVE_INTP_ACCEPT
changequote([, ])dnl
  AC_DEFINE_UNQUOTED($ac_tr_prototype)
  ifelse([$2], , :, [$2])
else
  AC_MSG_RESULT(no)
  ifelse([$3], , , [$3])
fi
])




dnl AC_CHECK_PTHREAD_OPTION checks whether the compiler requires the
dnl -pthread option to correctly link code containing posix thread calls.
dnl This is true for example on FreeBSD.
dnl This test assumes that <pthread.h> is available.

dnl If the test is positive, -pthread is added to CFLAGS and CXXFLAGS.

dnl AC_CHECK_PTHREAD_OPTION
AC_DEFUN(AC_CHECK_PTHREAD_OPTION,
[AC_MSG_CHECKING(whether compiler requires -pthread option for posix threads)
REQUIRES_PTHREAD_OPTION="no"
AC_TRY_LINK(
[#ifdef __cplusplus
extern "C" {
#endif
]
#include <pthread.h>
[#ifdef __cplusplus
}
#endif
]
,
[
  (void) pthread_create(NULL, NULL, NULL, NULL);
], ,
SAVE_CXXFLAGS="$CXXFLAGS"
SAVE_CFLAGS="$CFLAGS"
CXXFLAGS="-pthread $CXXFLAGS"
CFLAGS="-pthread $CFLAGS"
AC_TRY_LINK(
[#ifdef __cplusplus
extern "C" {
#endif
]
#include <pthread.h>
[#ifdef __cplusplus
}
#endif
]
,
[
  (void) pthread_create(NULL, NULL, NULL, NULL);
],
REQUIRES_PTHREAD_OPTION="yes"
, )
CXXFLAGS="$SAVE_CXXFLAGS"
CFLAGS="$SAVE_CFLAGS"
)

if test $REQUIRES_PTHREAD_OPTION = yes ; then
  AC_MSG_RESULT([yes])
  CXXFLAGS="-pthread $CXXFLAGS"
  CFLAGS="-pthread $CFLAGS"
else
  AC_MSG_RESULT([no])
fi
])



dnl AC_MY_C_INLINE works like the standard script AC_C_INLINE
dnl but defines C_INLINE instead of redefining "inline" directly.

AC_DEFUN(AC_MY_C_INLINE,
[AH_TEMPLATE([C_INLINE], [Define to the inline keyword supported by the C compiler, if any, or to the empty string])
AC_CACHE_CHECK([for inline], ac_cv_my_c_inline,
[ac_cv_my_c_inline=no
for ac_kw in inline __inline__ __inline; do
  AC_TRY_COMPILE(, [} $ac_kw foo() {], [ac_cv_my_c_inline=$ac_kw; break])
done
])
case "$ac_cv_my_c_inline" in
  inline | yes) AC_DEFINE(C_INLINE, inline) ;;
  no) AC_DEFINE(C_INLINE, ) ;;
  *)  AC_DEFINE_UNQUOTED(C_INLINE, $ac_cv_my_c_inline) ;;
esac
])


dnl AC_MY_C_CONST works like the standard script AC_C_CONST
dnl but defines HAVE_C_CONST instead of redefining "const" directly.

AC_DEFUN(AC_MY_C_CONST,
[AH_TEMPLATE([HAVE_C_CONST], [Define if "const" is supported by the C compiler.])
dnl This message is consistent in form with the other checking messages,
dnl and with the result message.
AC_CACHE_CHECK([for working const], ac_cv_my_c_const,
[AC_TRY_COMPILE(,
changequote(<<, >>)dnl
<<
/* Ultrix mips cc rejects this.  */
typedef int charset[2]; const charset x;
/* SunOS 4.1.1 cc rejects this.  */
char const *const *ccp;
char **p;
/* NEC SVR4.0.2 mips cc rejects this.  */
struct point {int x, y;};
static struct point const zero = {0,0};
/* AIX XL C 1.02.0.0 rejects this.
   It does not let you subtract one const X* pointer from another in an arm
   of an if-expression whose if-part is not a constant expression */
const char *g = "string";
ccp = &g + (g ? g-g : 0);
/* HPUX 7.0 cc rejects these. */
++ccp;
p = (char**) ccp;
ccp = (char const *const *) p;
{ /* SCO 3.2v4 cc rejects this.  */
  char *t;
  char const *s = 0 ? (char *) 0 : (char const *) 0;

  *t++ = 0;
}
{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
  int x[] = {25, 17};
  const int *foo = &x[0];
  ++foo;
}
{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
  typedef const int *iptr;
  iptr p = 0;
  ++p;
}
{ /* AIX XL C 1.02.0.0 rejects this saying
     "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
  struct s { int j; const int *ap[3]; };
  struct s *b; b->j = 5;
}
{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
  const int foo = 10;
}
>>,
changequote([, ])dnl
ac_cv_my_c_const=yes, ac_cv_my_c_const=no)])
if test $ac_cv_my_c_const = yes; then
  AC_DEFINE_UNQUOTED(HAVE_C_CONST)
fi
])


dnl AC_MY_C_CHAR_UNSIGNED works like the standard script AC_C_CHAR_UNSIGNED
dnl but defines C_CHAR_UNSIGNED instead of __CHAR_UNSIGNED__.

AC_DEFUN(AC_MY_C_CHAR_UNSIGNED,
[AH_TEMPLATE([C_CHAR_UNSIGNED], [Define if char is unsigned on the C compiler.])
AC_CACHE_CHECK(whether char is unsigned, ac_cv_my_c_char_unsigned,
[if test "$GCC" = yes; then
  # GCC predefines this symbol on systems where it applies.
AC_EGREP_CPP(yes,
[#ifdef __CHAR_UNSIGNED__
  yes
#endif
], ac_cv_my_c_char_unsigned=yes, ac_cv_my_c_char_unsigned=no)
else
AC_TRY_RUN(
[/* volatile prevents gcc2 from optimizing the test away on sparcs.  */
#if !defined(__STDC__) || __STDC__ != 1
#define volatile
#endif
main() {
  volatile char c = 255; exit(c < 0);
}], ac_cv_my_c_char_unsigned=yes, ac_cv_my_c_char_unsigned=no)
fi])
if test $ac_cv_my_c_char_unsigned = yes ; then
  AC_DEFINE(C_CHAR_UNSIGNED)
fi
])


dnl AC_MY_C_RIGHTSHIFT_UNSIGNED checks whether the right shift operation
dnl is unsigned and, if yes, defines C_RIGHTSHIFT_UNSIGNED.

AC_DEFUN(AC_MY_C_RIGHTSHIFT_UNSIGNED,
[AH_TEMPLATE([C_RIGHTSHIFT_UNSIGNED], [Define if >> is unsigned on the C compiler])
AC_CACHE_CHECK(whether right shift is unsigned, ac_cv_my_c_rightshift_unsigned,
[
AC_TRY_RUN(
[/* See whether right-shift on a long is signed or not. */
int is_shifting_signed (long arg)
{
  long res = arg >> 4;

  if (res == -0x7F7E80CL) {	/* expected result for signed shift */
    return 1;			/* right shift is signed */
  }
  /* see if unsigned-shift hack will fix it. */
  /* we can't just test exact value since it depends on width of long... */
  res |= (~0L) << (32-4);
  if (res == -0x7F7E80CL) {	/* expected result now? */
    return 0;			/* right shift is unsigned */
  }
  /* Right shift isn't acting as I expect it to, try it with unsigned anyway */
  return 0;
}

int main()
{
  exit(is_shifting_signed(-0x7F7E80B1L));
}
], ac_cv_my_c_rightshift_unsigned=yes, ac_cv_my_c_rightshift_unsigned=no)
])
if test $ac_cv_my_c_rightshift_unsigned = yes ; then
  AC_DEFINE(C_CHAR_UNSIGNED)
fi
])


dnl AC_CHECK_IOS_NOCREATE checks if the flag ios::nocreate is defined.

dnl AC_CHECK_IOS_NOCREATE(IOS-Name, header [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
AC_DEFUN(AC_CHECK_IOS_NOCREATE,
[
AC_MSG_CHECKING([declaration of ios::nocreate (in $2)])
AH_TEMPLATE([HAVE_IOS_NOCREATE], [Define if your system defines ios::nocreate in iostream.h])
ac_cv_declaration=ac_cv_declaration_ios_nocreate
AC_CACHE_VAL($ac_cv_declaration,
[AC_TRY_COMPILE([
#include <$2>
], [namespace std { }
using namespace std;
ifstream file("name", $1::nocreate)] ,eval "$ac_cv_declaration=yes", eval "$ac_cv_declaration=no")])dnl
if eval "test \"\$$ac_cv_declaration\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_declaration=HAVE_IOS_NOCREATE
changequote([, ])dnl
  AC_DEFINE_UNQUOTED($ac_tr_declaration)
  ifelse([$3], , :, [$3])
else
  AC_MSG_RESULT(no)
ifelse([$4], , , [$4
])dnl
fi
unset ac_cv_declaration
])



dnl AC_CHECK_OLD_READDIR_R checks if there is a function readdir_r
dnl   conforming to the Posix 1.c Draft 6 interface, i.e.
dnl     struct dirent *readdir_r(DIR *dirp, struct dirent *entry);
dnl   instead of the Posix 1.c interface, i.e.
dnl     int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
dnl
dnl  The test macro AC_HEADER_DIRENT must be run before this test!
dnl
dnl AC_CHECK_OLD_READDIR_R([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
AC_DEFUN(AC_CHECK_OLD_READDIR_R,
[
AC_MSG_CHECKING([if declaration of readdir_r conforms to Posix 1.c draft 6])
AH_TEMPLATE([HAVE_OLD_READDIR_R], [Define if your system supports readdir_r with the obsolete
   Posix 1.c draft 6 declaration (2 arguments) instead of the
   Posix 1.c declaration with 3 arguments.])
ac_cv_result=ac_cv_old_readdir_r
AC_CACHE_VAL($ac_cv_result,
[AC_TRY_COMPILE([
#ifdef __cplusplus
extern "C" {
#endif
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#else
#define dirent direct
#ifdef HAVE_SYS_NDIR_H
#include <sys/ndir.h>
#endif
#ifdef HAVE_SYS_DIR_H
#include <sys/dir.h>
#endif
#ifdef HAVE_NDIR_H
#include <ndir.h>
#endif
#endif
#ifdef __cplusplus
}
#endif
], [
  DIR *dirp;
  struct dirent *dp;
  dp = readdir_r(dirp, dp);
], eval "$ac_cv_result=yes", eval "$ac_cv_result=no")])dnl
if eval "test \"\$$ac_cv_result\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_cv_result=HAVE_OLD_READDIR_R
changequote([, ])dnl
  AC_DEFINE_UNQUOTED($ac_cv_result)
  ifelse([$1], , , [$1
])dnl
else
  AC_MSG_RESULT(no)
  ifelse([$2], , , [$2
])dnl
fi
unset ac_cv_result
])


dnl AC_CHECK_INTP_GETSOCKOPT checks if the prototype for getsockopt()
dnl   specifies arguments 5 to be int* instead of size_t *.

dnl AC_CHECK_INTP_GETSOCKOPT(HEADER-FILE..., ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
AC_DEFUN(AC_CHECK_INTP_GETSOCKOPT,
[AC_MSG_CHECKING([ifelse([$1], , [if getsockopt() needs int* parameters],
[if getsockopt() needs int* parameters (in $1)])])
AH_TEMPLATE([HAVE_INTP_GETSOCKOPT], [Define if your system declares argument 5 of getsockopt()
   as int * instead of size_t * or socklen_t.])
ifelse([$1], , [ac_includes=""
],
[ac_includes=""
for ac_header in $1
do
  ac_includes="$ac_includes
#include<$ac_header>"
done])
AC_CACHE_VAL(ac_cv_prototype_intp_getsockopt,
[AC_TRY_COMPILE(
[#ifdef __cplusplus
extern "C" {
#endif
$ac_includes
#ifdef __cplusplus
}
#endif
]
,
[
  int i;
  size_t optlen;
  i = getsockopt(0, 0, 0, 0, &optlen);
],
eval "ac_cv_prototype_intp_getsockopt=no",
[AC_TRY_COMPILE(
[#ifdef __cplusplus
extern "C" {
#endif
$ac_includes
#ifdef __cplusplus
}
#endif
]
,
[
  int i;
  int optlen;
  i = getsockopt(0, 0, 0, 0, &optlen);
],
eval "ac_cv_prototype_intp_getsockopt=yes", eval "ac_cv_prototype_intp_getsockopt=no")])])
if eval "test \"`echo $ac_cv_prototype_intp_getsockopt`\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_prototype=HAVE_INTP_GETSOCKOPT
changequote([, ])dnl
  AC_DEFINE_UNQUOTED($ac_tr_prototype)
  ifelse([$2], , :, [$2])
else
  AC_MSG_RESULT(no)
  ifelse([$3], , , [$3])
fi
])


dnl AC_CHECK_ELLIPSE_SIGNAL_HANDLER checks if the prototype for the
dnl   callback function passed to signal() needs an ellipse (...)
dnl   as parameter.  Needed for example on Irix 5.
dnl   The header files for signal() have to be specified.

dnl AC_CHECK_ELLIPSE_SIGNAL_HANDLER(HEADER-FILE..., ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
AC_DEFUN(AC_CHECK_ELLIPSE_SIGNAL_HANDLER,
[AC_MSG_CHECKING([ifelse([$1], , [if signal() callback needs ellipse],
[if signal() callback needs ellipse (in $1)])])
AH_TEMPLATE([SIGNAL_HANDLER_WITH_ELLIPSE], [Define if signal handlers need ellipse (...) parameters.])
ifelse([$1], , [ac_includes=""
],
[ac_includes=""
for ac_header in $1
do
  ac_includes="$ac_includes
#include<$ac_header>"
done])
AC_CACHE_VAL(ac_cv_signal_handler_with_ellipse,
[AC_TRY_COMPILE(
[#ifdef __cplusplus
extern "C" {
#endif
$ac_includes

  void signal_handler(int)
  {
  }
#ifdef __cplusplus
}
#endif
]
,
[
 (void) signal(0, signal_handler);
],
eval "ac_cv_signal_handler_with_ellipse=no",
[AC_TRY_COMPILE(
[#ifdef __cplusplus
extern "C" {
#endif
$ac_includes

  void signal_handler(...)
  {
  }
#ifdef __cplusplus
}
#endif
]
,
[
 (void) signal(0, signal_handler);
],
eval "ac_cv_signal_handler_with_ellipse=yes", eval "ac_cv_signal_handler_with_ellipse=no")])])
if eval "test \"`echo $ac_cv_signal_handler_with_ellipse`\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_prototype=SIGNAL_HANDLER_WITH_ELLIPSE
changequote([, ])dnl
  AC_DEFINE_UNQUOTED($ac_tr_prototype)
  ifelse([$2], , :, [$2])
else
  AC_MSG_RESULT(no)
  ifelse([$3], , , [$3])
fi
])



dnl AC_INCLUDE_MATH_H_AS_CXX checks if <math.h> must be included as a C++
dnl   include file (i.e. without extern "C"). Some sytems (Win32, HP/UX 10)
dnl   use C++ language features in <math.h>.

dnl AC_INCLUDE_MATH_H_AS_CXX(HEADER-FILE..., ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
AC_DEFUN(AC_INCLUDE_MATH_H_AS_CXX,
[AC_MSG_CHECKING([if <math.h> fails if included extern "C"])
AH_TEMPLATE([INCLUDE_MATH_H_AS_CXX], [Define if <math.h> fails if included extern "C".])
AC_CACHE_VAL(ac_cv_include_math_h_as_cxx,
[AC_TRY_COMPILE([
extern "C"
{
#include<math.h>
}
],
[
],
eval "ac_cv_include_math_h_as_cxx=no",
[AC_TRY_COMPILE([
#include<math.h>
],
[
],
eval "ac_cv_include_math_h_as_cxx=yes", eval "ac_cv_include_math_h_as_cxx=no")])])
if eval "test \"`echo $ac_cv_include_math_h_as_cxx`\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_prototype=INCLUDE_MATH_H_AS_CXX
changequote([, ])dnl
  AC_DEFINE_UNQUOTED($ac_tr_prototype)
  ifelse([$2], , :, [$2])
else
  AC_MSG_RESULT(no)
  ifelse([$3], , , [$3])
fi
])


dnl AC_CHECK_CXX_BOOL checks if bool is a built-in C++ type
dnl   (which is not the case on older compilers).

dnl AC_CHECK_CXX_BOOL(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
AC_DEFUN(AC_CHECK_CXX_BOOL,
[AC_MSG_CHECKING([if bool is built-in type])
AH_TEMPLATE([HAVE_CXX_BOOL], [Define if bool is a built-in type.])
AC_CACHE_VAL(ac_cv_have_cxx_bool,
[AC_TRY_COMPILE([],[
bool b1 = true;
bool b2 = false;
],
eval "ac_cv_have_cxx_bool=yes",
eval "ac_cv_have_cxx_bool=no")])
if eval "test \"`echo $ac_cv_have_cxx_bool`\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_prototype=HAVE_CXX_BOOL
changequote([, ])dnl
  AC_DEFINE_UNQUOTED($ac_tr_prototype)
  ifelse([$1], , :, [$1])
else
  AC_MSG_RESULT(no)
  ifelse([$2], , , [$2])
fi
])


dnl AC_CHECK_CXX_VOLATILE checks if volatile is a built-in C++ keyword
dnl   (which is not the case on older compilers).

dnl AC_CHECK_CXX_VOLATILE(ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
AC_DEFUN(AC_CHECK_CXX_VOLATILE,
[AC_MSG_CHECKING([if volatile is known keyword])
AH_TEMPLATE([HAVE_CXX_VOLATILE], [Define if volatile is a known keyword])
AC_CACHE_VAL(ac_cv_have_cxx_volatile,
[AC_TRY_COMPILE([],[
volatile int i=0;
],
eval "ac_cv_have_cxx_volatile=yes",
eval "ac_cv_have_cxx_volatile=no")])
if eval "test \"`echo $ac_cv_have_cxx_volatile`\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_prototype=HAVE_CXX_VOLATILE
changequote([, ])dnl
  AC_DEFINE_UNQUOTED($ac_tr_prototype, ,[Define if volatile is a known keyword.])
  ifelse([$1], , :, [$1])
else
  AC_MSG_RESULT(no)
  ifelse([$2], , , [$2])
fi
])


dnl Available from the GNU Autoconf Macro Archive at:
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_typename.html
dnl
AC_DEFUN([AC_CXX_TYPENAME],
[AH_TEMPLATE([HAVE_TYPENAME], [Define if typename is a known keyword])
AC_CACHE_CHECK(whether the compiler recognizes typename,
ac_cv_cxx_typename,
[AC_LANG_SAVE
 AC_LANG_CPLUSPLUS
 AC_TRY_COMPILE([template<typename T>class X {public:X(){}};],
[X<float> z; return 0;],
 ac_cv_cxx_typename=yes, ac_cv_cxx_typename=no)
 AC_LANG_RESTORE
])
if test "$ac_cv_cxx_typename" = yes; then
  AC_DEFINE(HAVE_TYPENAME,,[Define if the compiler recognizes typename.])
fi
])


dnl Available from the GNU Autoconf Macro Archive at:
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_const_cast.html
dnl
AC_DEFUN([AC_CXX_CONST_CAST],
[AH_TEMPLATE([HAVE_CONST_CAST], [Define if the compiler supports const_cast<>])
AC_CACHE_CHECK(whether the compiler supports const_cast<>,
ac_cv_cxx_const_cast,
[AC_LANG_SAVE
 AC_LANG_CPLUSPLUS
 AC_TRY_COMPILE(,[int x = 0;const int& y = x;int& z = const_cast<int&>(y);return z;],
 ac_cv_cxx_const_cast=yes, ac_cv_cxx_const_cast=no)
 AC_LANG_RESTORE
])
if test "$ac_cv_cxx_const_cast" = yes; then
  AC_DEFINE(HAVE_CONST_CAST,,[Define if the compiler supports const_cast<>.])
fi
])


dnl Available from the GNU Autoconf Macro Archive at:
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_dynamic_cast.html
dnl
AC_DEFUN([AC_CXX_DYNAMIC_CAST],
[AH_TEMPLATE([HAVE_DYNAMIC_CAST], [Define if the compiler supports dynamic_cast<>])
AC_CACHE_CHECK(whether the compiler supports dynamic_cast<>,
ac_cv_cxx_dynamic_cast,
[AC_LANG_SAVE
 AC_LANG_CPLUSPLUS
 AC_TRY_COMPILE([#include <typeinfo>
class Base { public : Base () {} virtual void f () = 0;};
class Derived : public Base { public : Derived () {} virtual void f () {} };],[
Derived d; Base& b=d; return dynamic_cast<Derived*>(&b) ? 0 : 1;],
 ac_cv_cxx_dynamic_cast=yes, ac_cv_cxx_dynamic_cast=no)
 AC_LANG_RESTORE
])
if test "$ac_cv_cxx_dynamic_cast" = yes; then
  AC_DEFINE(HAVE_DYNAMIC_CAST,,[Define if the compiler supports dynamic_cast<>.])
fi
])


dnl Available from the GNU Autoconf Macro Archive at:
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_reinterpret_cast.html
dnl
AC_DEFUN([AC_CXX_REINTERPRET_CAST],
[AH_TEMPLATE([HAVE_REINTERPRET_CAST], [Define if the compiler supports reinterpret_cast<>])
AC_CACHE_CHECK(whether the compiler supports reinterpret_cast<>,
ac_cv_cxx_reinterpret_cast,
[AC_LANG_SAVE
 AC_LANG_CPLUSPLUS
 AC_TRY_COMPILE([#include <typeinfo>
class Base { public : Base () {} virtual void f () = 0;};
class Derived : public Base { public : Derived () {} virtual void f () {} };
class Unrelated { public : Unrelated () {} };
int g (Unrelated&) { return 0; }],[
Derived d;Base& b=d;Unrelated& e=reinterpret_cast<Unrelated&>(b);return g(e);],
 ac_cv_cxx_reinterpret_cast=yes, ac_cv_cxx_reinterpret_cast=no)
 AC_LANG_RESTORE
])
if test "$ac_cv_cxx_reinterpret_cast" = yes; then
  AC_DEFINE(HAVE_REINTERPRET_CAST,,
            [Define if the compiler supports reinterpret_cast<>.])
fi
])


dnl Available from the GNU Autoconf Macro Archive at:
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_static_cast.html
dnl
AC_DEFUN([AC_CXX_STATIC_CAST],
[AH_TEMPLATE([HAVE_STATIC_CAST], [Define if the compiler supports static_cast<>])
AC_CACHE_CHECK(whether the compiler supports static_cast<>,
ac_cv_cxx_static_cast,
[AC_LANG_SAVE
 AC_LANG_CPLUSPLUS
 AC_TRY_COMPILE([#include <typeinfo>
class Base { public : Base () {} virtual void f () = 0; };
class Derived : public Base { public : Derived () {} virtual void f () {} };
int g (Derived&) { return 0; }],[
Derived d; Base& b = d; Derived& s = static_cast<Derived&> (b); return g (s);],
 ac_cv_cxx_static_cast=yes, ac_cv_cxx_static_cast=no)
 AC_LANG_RESTORE
])
if test "$ac_cv_cxx_static_cast" = yes; then
  AC_DEFINE(HAVE_STATIC_CAST,,
            [Define if the compiler supports static_cast<>.])
fi
])


dnl AC_CXX_STD_NOTHROW checks if the compiler supports non-throwing new using
dnl std::nothrow.

AC_DEFUN([AC_CXX_STD_NOTHROW],
[AH_TEMPLATE([HAVE_STD__NOTHROW], [Define if the compiler supports std::nothrow])
AC_CACHE_CHECK(whether the compiler supports std::nothrow,
ac_cv_cxx_std_nothrow,
[AC_LANG_SAVE
 AC_LANG_CPLUSPLUS
 AC_TRY_COMPILE([#include <new>],[int *i = new (std::nothrow) int],
 ac_cv_cxx_std_nothrow=yes, ac_cv_cxx_std_nothrow=no)
 AC_LANG_RESTORE
])
if test "$ac_cv_cxx_std_nothrow" = yes; then
  AC_DEFINE(HAVE_STD__NOTHROW,, [Define if the compiler supports std::nothrow.])
fi
])


dnl AC_CXX_NOTHROW_DELETE checks if the compiler supports non-throwing delete using
dnl std::nothrow.

AC_DEFUN([AC_CXX_NOTHROW_DELETE],
[AH_TEMPLATE([HAVE_NOTHROW_DELETE], [Define if the compiler supports operator delete (std::nothrow.)])
AC_CACHE_CHECK(whether the compiler supports operator delete (std::nothrow),
ac_cv_cxx_nothrow_delete,
[AC_LANG_SAVE
 AC_LANG_CPLUSPLUS
 AC_TRY_COMPILE([#include <new>],[int *i = new (std::nothrow) int; operator delete (i,std::nothrow)],
 ac_cv_cxx_nothrow_delete=yes, ac_cv_cxx_nothrow_delete=no)
 AC_LANG_RESTORE
])
if test "$ac_cv_cxx_nothrow_delete" = yes; then
  AC_DEFINE(HAVE_NOTHROW_DELETE,, [Define if the compiler supports operator delete (std::nothrow.)])
fi
])


dnl AC_CXX_NOTHROW_DELETE checks if the compiler supports non-throwing delete using
dnl std::nothrow.

AC_DEFUN([AC_CXX_STATIC_ASSERT],
[AH_TEMPLATE([HAVE_STATIC_ASSERT], [Define if the compiler supports static_assert])
AC_CACHE_CHECK(whether the compiler supports static_assert,
ac_cv_cxx_static_assert,
[AC_LANG_SAVE
 AC_LANG_CPLUSPLUS
 AC_TRY_COMPILE([#include <cassert>],[static_assert(true, "good")],
 ac_cv_cxx_static_assert=yes, ac_cv_cxx_static_assert=no)
 AC_LANG_RESTORE
])
if test "$ac_cv_cxx_static_assert" = yes; then
  AC_DEFINE(HAVE_STATIC_ASSERT,, [Define if the compiler supports static_assert])
fi
])


dnl AC_CXX_LIBC_H_EXTERN_C checks if <libc.h> and <math.h> cause a problem if
dnl   libc.h is included extern "C" and math.h is not. This is the case on QNX
dnl   6.2.x and 6.5.x.

AC_DEFUN([AC_CXX_LIBC_H_EXTERN_C],
[AH_TEMPLATE([INCLUDE_LIBC_H_AS_CXX], [Define if libc.h should be treated as a C++ header])
AC_CACHE_CHECK(whether libc.h should be treated as a C++ header,
ac_cv_cxx_libc_h_is_cxx,
[AC_LANG_SAVE
 AC_LANG_CPLUSPLUS
 AC_TRY_COMPILE([extern "C" {
#include <libc.h>
}
#include <math.h>],[int i = 0],
 ac_cv_cxx_libc_h_is_cxx=no, ac_cv_cxx_libc_h_is_cxx=yes)
 AC_LANG_RESTORE
])
if test "$ac_cv_cxx_libc_h_is_cxx" = yes; then
  AC_DEFINE(INCLUDE_LIBC_H_AS_CXX,, [Define if libc.h should be treated as a C++ header])
fi
])


dnl AC_CHECK_POINTER_TYPE checks if a given type is a pointer type.
dnl   If header file(s) are given as argument 2, they
dnl   are #included in the search. The header files are only included in the search if they
dnl   have already been found using the AC_CHECK_HEADERS(header) macro.
dnl Examples:
dnl     AC_CHECK_POINTER_TYPE(pthread_d, pthread.h)
dnl     AC_CHECK_POINTER_TYPE(void *)

dnl AC_CHECK_POINTER_TYPE(FUNCTION, HEADER-FILE...)
AC_DEFUN(AC_CHECK_POINTER_TYPE,
[AC_MSG_CHECKING([ifelse([$2], , [if $1 is a pointer type], [if $1 is a pointer type (in $2)])])
AH_TEMPLATE(AS_TR_CPP(HAVE_POINTER_TYPE_$1), [Define if $1 is a pointer type on your system])
ifelse([$2], , [ac_includes=""
],
[ac_includes=""
cpp_code=""
if eval "test \"`echo '$ac_cv_cxx_static_cast'`\" = yes"; then
  cpp_code="unsigned long l = static_cast<unsigned long>(p)"
else
  cpp_code="unsigned long l = p"
fi
for ac_header in $2
do
  ac_safe=`echo "$ac_header" | sed 'y%./+-%__p_%'`
  if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'}'`\" = yes"; then
    ac_includes="$ac_includes
#include<$ac_header>"
  fi
done])
tmp_save_1=`echo $1 | tr ' :' '__'`
AC_CACHE_VAL(ac_cv_pointer_type_$tmp_save_1,
[AC_TRY_COMPILE(
[#ifdef __cplusplus
extern "C" {
#endif
$ac_includes
#ifdef __cplusplus
}
#endif
],[#ifdef __cplusplus
$1 p; $cpp_code
#else
$1 p; unsigned long l = p
#endif
],
eval "ac_cv_pointer_type_$tmp_save_1=no", eval "ac_cv_pointer_type_$tmp_save_1=yes")])dnl
if eval "test \"`echo '$''{'ac_cv_pointer_type_$tmp_save_1'}'`\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_prototype=HAVE_POINTER_TYPE_`echo $tmp_save_1 | tr '[a-z]' '[A-Z]'`
changequote([, ])dnl
  AC_DEFINE_UNQUOTED([$ac_tr_prototype])
  ifelse([$3], , :, [$3])
else
  AC_MSG_RESULT(no)
fi
])


dnl
dnl CHECK_VLA checks if the C Compiler supports variable-length arrays
dnl
AC_DEFUN(CHECK_VLA,
[AC_MSG_CHECKING([whether variable-length arrays are supported])
AH_TEMPLATE([HAVE_VLA], [Define if variable-length arrays are supported in C])
AC_LANG_SAVE
AC_LANG_C
AC_TRY_COMPILE([], [
 int n; int foo[n];
],
[AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VLA)],
AC_MSG_RESULT(no))
AC_LANG_RESTORE
])


#    AC_TYPEDEF_HELPER(TYPE,
#                  [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
#                  [INCLUDES])

m4_define([AC_TYPEDEF_HELPER],
[AS_VAR_PUSHDEF([ac_Type], [ac_cv_type_$1])dnl
AC_CACHE_CHECK([for $1], ac_Type,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT([$4])],
[if (($1 *) 0)
  return 0;
if (sizeof ($1))
  return 0;])],
                   [AS_VAR_SET(ac_Type, yes)],
                   [AS_VAR_SET(ac_Type, no)])])
AS_IF([test AS_VAR_GET(ac_Type) = yes], [$2], [$3])[]dnl
AS_VAR_POPDEF([ac_Type])dnl
])# AC_TYPEDEF_HELPER

AC_DEFUN(AC_TYPEDEF_HELPER2,[
AH_VERBATIM([$3[_TYPEDEF]], [#ifdef ]$3[
typedef $2 $1;
#endif])])# AC_TYPEDEF_HELPER2

#
#  AC_TYPEDEF(type, default)
#
#  This macro works similar to the old (deprecated, pre-2.13) AC_CHECK_TYPE
#  macro, but instead of creating a #define for the type if absent, it
#  creates a clean typedef.
#
AC_DEFUN(AC_TYPEDEF,[
m4_define(AC_TYPEDEF_TEMP,[AS_TR_CPP(HAVE_NO_TYPEDEF_$1)])
AC_TYPEDEF_HELPER2([$1],[$2],AC_TYPEDEF_TEMP)
AC_TYPEDEF_HELPER([$1],[],[AC_DEFINE_UNQUOTED(AC_TYPEDEF_TEMP, [1], [Define `$1' to `$2' if <sys/types.h> does not define.])])
])# AC_TYPEDEF


#
# AC_LFS64
#
# This macro checks with the C compiler whether fopen64 is declared in <stdio.h>
# when _LARGEFILE64_SOURCE is defined
#
AC_DEFUN([AC_LFS64],
[ AH_TEMPLATE([DCMTK_ENABLE_LFS], [Select LFS mode (defined above) that shall be used or don't define it])
  AH_TEMPLATE([_LARGEFILE64_SOURCE], [Define to enable LFS64 (explicit large file support) if available])
  AC_MSG_CHECKING([for explicit large file support])
  ac_cv_lfs64_support=no
  AC_LANG_SAVE
  AC_LANG_C
  AC_TRY_LINK([#define _LARGEFILE64_SOURCE
    #include <stdio.h>],[FILE *f = fopen64("name", "r");],
  ac_cv_lfs64_support=yes, ac_cv_lfs64_support=no)
  AC_LANG_RESTORE

  if test "$ac_cv_lfs64_support" = yes; then
    AC_MSG_RESULT([yes])
    AC_DEFINE(DCMTK_ENABLE_LFS, DCMTK_LFS64, [Select LFS mode (defined above) that shall be used or don't define it])
    AC_DEFINE(_LARGEFILE64_SOURCE, 1, [Define to enable LFS64 (explicit large file support) if available])
  else
    AC_MSG_RESULT([no])
  fi
])


# MY_AC_SYS_LARGEFILE_TEST_INCLUDES
# Copied from autoconf 2.60 repository of specific tests and renamed
# -------------------------------
m4_define([MY_AC_SYS_LARGEFILE_TEST_INCLUDES],
[@%:@include <sys/types.h>
 /* Check that off_t can represent 2**63 - 1 correctly.
    We can't simply define LARGE_OFF_T to be 9223372036854775807,
    since some C++ compilers masquerading as C compilers
    incorrectly reject 9223372036854775807.  */
@%:@define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
  int off_t_is_large[[(LARGE_OFF_T % 2147483629 == 721
		       && LARGE_OFF_T % 2147483647 == 1)
		      ? 1 : -1]];[]dnl
])


# MY_AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE,
#				CACHE-VAR,
#				DESCRIPTION,
#				PROLOGUE, [FUNCTION-BODY])
# Copied from autoconf 2.60 repository of specific tests and renamed
# ----------------------------------------------------------
m4_define([MY_AC_SYS_LARGEFILE_MACRO_VALUE],
[AC_CACHE_CHECK([for $1 value needed for large files], [$3],
[while :; do
  $3=no
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([$5], [$6])],
		    [ac_cv_lfs_support=yes; break])
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([@%:@define $1 $2
$5], [$6])],
		    [$3=$2; ac_cv_lfs_support=yes; break])
  break
done])
if test "$$3" != no; then
  AC_DEFINE_UNQUOTED([$1], [$$3], [$4])
fi
rm -f conftest*[]dnl
])# MY_AC_SYS_LARGEFILE_MACRO_VALUE


# MY_AC_SYS_LARGEFILE
# ----------------
# Copied from autoconf 2.60 repository of specific tests and modified
#
# By default, many hosts won't let programs access large files;
# one must use special compiler options to get large-file access to work.
# For more details about this brain damage please see:
# http://www.unix-systems.org/version2/whatsnew/lfs20mar.html
AC_DEFUN([MY_AC_SYS_LARGEFILE],
[AC_CACHE_CHECK([for special C compiler options needed for large files],
    ac_cv_sys_largefile_CC,
    [ac_cv_sys_largefile_CC=no
     if test "$GCC" != yes; then
       AC_LANG_SAVE
       AC_LANG_C
       ac_save_CC=$CC
       while :; do
	 # IRIX 6.2 and later do not support large files by default,
	 # so use the C compiler's -n32 option if that helps.
	 AC_LANG_CONFTEST([AC_LANG_PROGRAM([MY_AC_SYS_LARGEFILE_TEST_INCLUDES])])
	 AC_COMPILE_IFELSE([], [break])
	 CC="$CC -n32"
	 AC_COMPILE_IFELSE([], [ac_cv_sys_largefile_CC=' -n32'; break])
	 break
       done
       CC=$ac_save_CC
       rm -f conftest.$ac_ext
       AC_LANG_RESTORE
    fi])
  if test "$ac_cv_sys_largefile_CC" != no; then
    CC=$CC$ac_cv_sys_largefile_CC
    CXX=$CXX$ac_cv_sys_largefile_CC
  fi

  ac_cv_lfs64_support=no
  AH_TEMPLATE([DCMTK_ENABLE_LFS], [Select LFS mode (defined above) that shall be used or don't define it])
  MY_AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
    ac_cv_sys_file_offset_bits,
    [Number of bits in a file offset, on hosts where this is settable.],
    [MY_AC_SYS_LARGEFILE_TEST_INCLUDES])
  MY_AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
    ac_cv_sys_large_files,
    [Define for large files, on AIX-style hosts.],
    [MY_AC_SYS_LARGEFILE_TEST_INCLUDES])

  if test "$ac_cv_lfs_support" = yes; then
    AC_DEFINE(DCMTK_ENABLE_LFS, DCMTK_LFS, [Select LFS mode (defined above) that shall be used or don't define it])
  fi

])# MY_AC_SYS_LARGEFILE


#
# AC_STDIO_NAMESPACE
#
# This macro checks with the C++ compiler whether fopen() in <cstdio> is
# in namespace standard or in global namespace.
#
AC_DEFUN([AC_STDIO_NAMESPACE],
[ AH_TEMPLATE([STDIO_NAMESPACE], [Namespace for ANSI C functions in standard C++ headers])
  ac_cv_stdio_namespace_is_std=no
  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  AC_TRY_COMPILE([
#ifdef USE_STD_CXX_INCLUDES
#include <cstdio>
#else
#include <stdio.h>
#endif
],[FILE *f = ::fopen("name", "r");],
  ac_cv_stdio_namespace_is_std=no, ac_cv_stdio_namespace_is_std=yes)
  AC_LANG_RESTORE

  if test "$ac_cv_stdio_namespace_is_std" = yes; then
    AC_DEFINE(STDIO_NAMESPACE,[std::])
  else
    AC_DEFINE(STDIO_NAMESPACE,[::])
  fi
])


dnl AC_CHECK_CHARP_STRERROR_R checks if the prototype for strerror_r()
dnl specifies a return type of char * instead of int. This is the case
dnl for the GNU version, whereas the XOPEN (XSI-compliant) version returns int.

dnl AC_CHECK_CHARP_STRERROR_R(HEADER-FILE..., ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
AC_DEFUN(AC_CHECK_CHARP_STRERROR_R,
[AC_MSG_CHECKING([ifelse([$1], , [if strerror_r() returns a char *],
[if strerror_r() returns a char * (in $1)])])
AH_TEMPLATE([HAVE_CHARP_STRERROR_R], [Define if your system declares the return type of strerror_r
   as char * instead of int])
ifelse([$1], , [ac_includes=""
],
[ac_includes=""
for ac_header in $1
do
  ac_includes="$ac_includes
#include<$ac_header>"
done])
AC_CACHE_VAL(ac_cv_prototype_charp_strerror_r,
[AC_TRY_COMPILE(
[#ifdef __cplusplus
extern "C" {
#endif
$ac_includes
#ifdef __cplusplus
}
#endif
]
,
[
  char *buf = 0;
  int i = strerror_r(0, buf, 100)
],
eval "ac_cv_prototype_charp_strerror_r=no",
eval "ac_cv_prototype_charp_strerror_r=yes"
)])
if eval "test \"`echo $ac_cv_prototype_charp_strerror_r`\" = yes"; then
  AC_MSG_RESULT(yes)
changequote(, )dnl
  ac_tr_prototype=HAVE_CHARP_STRERROR_R
changequote([, ])dnl
  AC_DEFINE_UNQUOTED($ac_tr_prototype)
  ifelse([$2], , :, [$2])
else
  AC_MSG_RESULT(no)
  ifelse([$3], , , [$3])
fi
])

dnl
dnl This macro adds the --disable-rpath option to configure
dnl and sets the variable $dcmtk_cv_rpath_works to "no", if needed.
dnl If that option isn't given, the availability of the rpath option is tested
AC_DEFUN([AC_MY_LIB_PATH_RPATH],
[
  AC_CACHE_CHECK([whether -Wl,-rpath is supported], [dcmtk_cv_rpath_works],
                 [AC_ARG_ENABLE([rpath],
                                [AS_HELP_STRING([--disable-rpath], [do not hardcode runtime library paths])],
                                [dcmtk_cv_rpath_works=$enableval],
                                [old_LDFLAGS="$LDFLAGS"
                                 LDFLAGS="-Wl,-rpath,$srcdir $LDFLAGS"
                                 AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
                                                [dcmtk_cv_rpath_works=yes],
                                                [dcmtk_cv_rpath_works=no])
                                 LDFLAGS="$old_LDFLAGS"])
                 ])
])

dnl
dnl This macro adds the option --with-[OPTION_NAME]inc to configure. If this option
dnl is specified, include/ and lib/ are added to CPPFLAGS / LDFLAGS.
dnl
dnl AC_MY_LIB_PATH(OPTION_NAME, LIB_NAME)
AC_DEFUN([AC_MY_LIB_PATH],
[
  AC_REQUIRE([AC_MY_LIB_PATH_RPATH])dnl
  m4_pushdef([OPTION], [$1inc])dnl
  m4_pushdef([LONGOPTION], [--with-$1inc])dnl
  m4_pushdef([LIBNAME], [m4_default([$2], [$1])])dnl
  AC_ARG_WITH([OPTION], dnl
dnl The following line is underquoted on purpose, else the help line will be
dnl discarded because it is equal to an earlier help line.
AS_HELP_STRING([LONGOPTION=DIR], [location of LIBNAME includes and libraries]),
    [AS_CASE([$withval],
      [yes|no], [
        AC_MSG_WARN([LONGOPTION called without argument - will use default])
      ],
      [
        if test ! -d ${withval}; then
          AC_MSG_ERROR([called with LONGOPTION but LIBNAME base directory ${withval} does not exist or is not a directory.])
        fi

        CPPFLAGS="-I${withval}/include $CPPFLAGS"
        LDFLAGS="-L${withval}/lib $LDFLAGS"
        if test "x$dcmtk_cv_rpath_works" = "xyes"; then
          LDFLAGS="-Wl,-rpath,${withval}/lib $LDFLAGS"
        fi
      ])
    ])dnl
  m4_popdef([OPTION])dnl
  m4_popdef([LONGOPTION])dnl
  m4_popdef([LIBNAME])dnl
])

dnl
dnl This macro adds the option --with-openjpeginc to configure. If this option
dnl is specified, include/ and lib/ are added to CPPFLAGS / LDFLAGS.
dnl
dnl AC_MY_OPENJPEG_PATH()
AC_DEFUN([AC_MY_OPENJPEG_PATH],
[
  AC_REQUIRE([AC_MY_LIB_PATH_RPATH])dnl
  m4_pushdef([OPTION], [openjpeginc])dnl
  m4_pushdef([LONGOPTION], [--with-openjpeginc])dnl
  m4_pushdef([LIBNAME], [m4_default([OpenJPEG], [openjpeg])])dnl
  AC_ARG_WITH([OPTION], dnl
dnl The following line is underquoted on purpose, else the help line will be
dnl discarded because it is equal to an earlier help line.
AS_HELP_STRING([LONGOPTION=DIR], [location of LIBNAME includes and libraries (MUST be specified, otherwise OpenJPEG will not be found)]),
    [AS_CASE([$withval],
      [yes|no], [
        AC_MSG_WARN([LONGOPTION called without argument - will use default])
      ],
      [
        if test ! -d ${withval}; then
          AC_MSG_ERROR([called with LONGOPTION but LIBNAME base directory ${withval} does not exist or is not a directory.])
        fi

        dnl try to find openjpeg subdirectory within given include path
        OPENJPEGINCLUDEPATH=`(
          eval echo "${withval}/include/openjpeg*"
        )`

        dnl if not found, use include path following standard conventions
        if test ! -d "${OPENJPEGINCLUDEPATH}"; then
          OPENJPEGINCLUDEPATH="${withval}/include"
        fi

        CPPFLAGS="-I${OPENJPEGINCLUDEPATH} $CPPFLAGS"
        LDFLAGS="-L${withval}/lib $LDFLAGS"
        if test "x$dcmtk_cv_rpath_works" = "xyes"; then
          LDFLAGS="-Wl,-rpath,${withval}/lib $LDFLAGS"
        fi
      ])
    ])dnl
  m4_popdef([OPTION])dnl
  m4_popdef([LONGOPTION])dnl
  m4_popdef([LIBNAME])dnl
])

AC_DEFUN([AC_CHECK_SYNC_FN],
[
    AC_MSG_CHECKING([for $1])
    AC_LINK_IFELSE(
    [
        AC_LANG_SOURCE(
        [
            int main(){return $1((int *)0, 0);}
        ])
    ],
    [dcmtk_have_sync_fn=[yes]],
    [dcmtk_have_sync_fn=[no]]
    )
    if test "$dcmtk_have_sync_fn" = yes; then
        AC_MSG_RESULT([yes])
        AC_DEFINE($2,[1],[Define if $1 is available.])
    else
        AC_MSG_RESULT([no])
    fi
])

AC_DEFUN([AC_CHECK_ITERATOR_CATEGORY],
[
    AC_MSG_CHECKING([whether iterator category $1 is declared])
    AC_COMPILE_IFELSE(
    [
        AC_LANG_SOURCE(
        [
            #include <iterator>
            int main(){typedef std::$1_iterator_tag category;return 0;}
        ])
    ],
    [dcmtk_have_iter_cat=[yes]],
    [dcmtk_have_iter_cat=[no]]
    )
    if test "$dcmtk_have_iter_cat" = yes; then
        AC_MSG_RESULT([yes])
        AC_DEFINE($2,[1],[Define if the $1 iterator category is supported.])
    else
        AC_MSG_RESULT([no])
    fi
])

AC_DEFUN([AC_CHECK_ALIGNOF],
[
    AC_MSG_CHECKING([for __alignof__])
    AC_LINK_IFELSE(
    [
        AC_LANG_SOURCE(
        [
            int main(){char c[[__alignof__(int)]];return 0;}
        ])
    ],
    [dcmtk_have_alignof=[yes]],
    [dcmtk_have_alignof=[no]]
    )
    if test "$dcmtk_have_alignof" = yes; then
        AC_MSG_RESULT([yes])
        AC_DEFINE($1,[1],[Define if __alignof__ is available.])
    else
        AC_MSG_RESULT([no])
    fi
])

AC_DEFUN([AC_CHECK_ATTRIBUTE_ALIGNED],
[
    AC_MSG_CHECKING([for __attribute__((aligned))])
    AC_LINK_IFELSE(
    [
        AC_LANG_SOURCE(
        [
            int main(){__attribute__((aligned(4))) char c[[16]];return 0;}
        ])
    ],
    [dcmtk_have_attribute_aligned=[yes]],
    [dcmtk_have_attribute_aligned=[no]]
    )
    if test "$dcmtk_have_attribute_aligned" = yes; then
        AC_MSG_RESULT([yes])
        AC_DEFINE($1,[1],[Define if __attribute__((aligned)) is available.])
    else
        AC_MSG_RESULT([no])
    fi
])

AC_DEFUN([AC_CHECK_ATTRIBUTE_ALIGNED_SUPPORTS_TEMPLATES],
[
    AC_MSG_CHECKING([whether __attribute__((aligned)) supports templates])
    AC_LINK_IFELSE(
    [
        AC_LANG_SOURCE(
        [
            template<typename T>
            struct test { typedef T type __attribute__((aligned(4))); };
            int main()
            {
                test<char>::type i;
                return 0;
            }
        ])
    ],
    [dcmtk_attribute_aligned_supports_templates=[yes]],
    [dcmtk_attribute_aligned_supports_templates=[no]]
    )
    if test "$dcmtk_attribute_aligned_supports_templates" = yes; then
        AC_MSG_RESULT([yes])
        AC_DEFINE($1,[1],[Define if __attribute__((aligned)) supports templates.])
    else
        AC_MSG_RESULT([no])
    fi
])

AC_DEFUN([AC_CHECK_DEFAULT_CONSTRUCTOR_DETECTION_VIA_SFINAE],
[
    AC_MSG_CHECKING([whether the compiler supports default constructor detection via SFINAE])
    AC_LINK_IFELSE(
    [
        AC_LANG_SOURCE(
        [
            struct no_type {};
            struct yes_type {double d;};
            template<unsigned>
            struct consume{};
            template<typename X>
            static yes_type sfinae(consume<sizeof *new X>*);
            template<typename X>
            static no_type sfinae(...);
            struct test { test( int ); };
            int main()
            {
                return sizeof(sfinae<test>(0)) == sizeof(yes_type);
            }
        ])
    ],
    [dcmtk_default_constructor_detection_via_sfinae=[yes]],
    [dcmtk_default_constructor_detection_via_sfinae=[no]]
    )
    if test "$dcmtk_default_constructor_detection_via_sfinae" = yes; then
        AC_MSG_RESULT([yes])
        AC_DEFINE($1,[1],[Define if the compiler supports default constructor detection via SFINAE.])
    else
        AC_MSG_RESULT([no])
    fi
])

AC_DEFUN([AC_CHECK_ALIGNOF],
[
    AC_MSG_CHECKING([for __alignof__])
    AC_LINK_IFELSE(
    [
        AC_LANG_SOURCE(
        [
            int main(){char c[__alignof__(int)];return 0;}
        ])
    ],
    [dcmtk_have_alignof=[yes]],
    [dcmtk_have_alignof=[no]]
    )
    if test "$dcmtk_have_alignof" = yes; then
        AC_MSG_RESULT([yes])
        AC_DEFINE($1,[1],[Define if __alignof__ is available])
    else
        AC_MSG_RESULT([no])
    fi
])

AC_DEFUN([AC_CHECK_ATTRIBUTE_ALIGNED],
[
    AC_MSG_CHECKING([for __attribute__((aligned))])
    AC_LINK_IFELSE(
    [
        AC_LANG_SOURCE(
        [
            int main(){__attribute__((aligned(4))) char c[16];return 0;}
        ])
    ],
    [dcmtk_have_attribute_aligned=[yes]],
    [dcmtk_have_attribute_aligned=[no]]
    )
    if test "$dcmtk_have_attribute_aligned" = yes; then
        AC_MSG_RESULT([yes])
        AC_DEFINE($1,[1],[Define if __attribute__((aligned)) is available])
    else
        AC_MSG_RESULT([no])
    fi
])

dnl
dnl This macro checks if a given preprocessor symbol exists and is a string
dnl
dnl AC_MY_SYMBOL_EXISTS(SYMBOL)
AC_DEFUN([AC_MY_SYMBOL_EXISTS],
[
    AH_TEMPLATE([HAVE_$1_MACRO], [Define if the compiler supports $1.])dnl
    AC_CACHE_CHECK([for $1 macro], [ac_cv_have_$1_macro], [dnl
        AC_TRY_COMPILE([], [const char * func = $1;], [ac_cv_have_$1_macro=yes], [ac_cv_have_$1_macro=no])dnl
    ])
    if test "x$ac_cv_have_$1_macro" = "xyes"; then
        AC_DEFINE([HAVE_$1_MACRO])
    fi
])

dnl
dnl This macro checks if OpenSSL provides the SSL_CTX_get0_param function
dnl
dnl AC_CHECK_SSL_CTX_GET0_PARAM
AC_DEFUN([AC_CHECK_SSL_CTX_GET0_PARAM],
[
    AH_TEMPLATE([HAVE_SSL_CTX_GET0_PARAM], [Define if OpenSSL provides the SSL_CTX_get0_param function.])dnl
    SAVELIBS=$LIBS
    HAVE_SSL_CTX_GET0_PARAM=yes
    LIBS="$LIBS $OPENSSLLIBS"
    AC_MSG_CHECKING([whether OpenSSL provides the SSL_CTX_get0_param function])
    AC_COMPILE_IFELSE(
    [
        AC_LANG_PROGRAM([[#include <openssl/ssl.h>]],[[&SSL_CTX_get0_param;]])
    ],
    [
        AC_MSG_RESULT([yes])
        AC_DEFINE([HAVE_SSL_CTX_GET0_PARAM])
    ],
    [
        AC_MSG_RESULT([no])
    ])
    LIBS=$SAVELIBS
])

dnl
dnl This macro checks if OpenSSL provides the RAND_egd function
dnl
dnl AC_CHECK_RAND_EGD
AC_DEFUN([AC_CHECK_RAND_EGD],
[
    AH_TEMPLATE([HAVE_RAND_EGD], [Define if OpenSSL provides the RAND_egd function.])dnl
    SAVELIBS=$LIBS
    HAVE_RAND_EGD=yes
    LIBS="$LIBS $OPENSSLLIBS"
    AC_MSG_CHECKING([whether OpenSSL provides the RAND_egd function])
    AC_COMPILE_IFELSE(
    [
        AC_LANG_PROGRAM([[#include <openssl/rand.h>]],[[&RAND_egd;]])
    ],
    [
        AC_MSG_RESULT([yes])
        AC_DEFINE([HAVE_RAND_EGD])
    ],
    [
        AC_MSG_RESULT([no])
    ])
    LIBS=$SAVELIBS
])