File: configure.in

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 (1890 lines) | stat: -rw-r--r-- 57,822 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
dnl Process this file with autoconf to produce a configure script.
AC_INIT(dcmtk, 3.6.5, [bugs@dcmtk.org], [dcmtk-3.6.5], [http://www.dcmtk.org/])
AC_PREREQ(2.60)
AC_CONFIG_SRCDIR(Makefile.in)
AC_CONFIG_HEADERS(include/dcmtk/config/osconfig.h)

m4_include([stdcxx.m4])

dnl -------------------------------------------------------
dnl Additional Package Information
dnl -------------------------------------------------------

PACKAGE_VERSION_NUMBER=365
PACKAGE_VERSION_SUFFIX=""
PACKAGE_DATE="2019-10-28"
AC_DEFINE_UNQUOTED(PACKAGE_VERSION_NUMBER,${PACKAGE_VERSION_NUMBER},[Define to the version number of this package.])
AC_DEFINE_UNQUOTED(PACKAGE_VERSION_SUFFIX,"${PACKAGE_VERSION_SUFFIX}",[Define to the version suffix of this package.])
AC_DEFINE_UNQUOTED(PACKAGE_DATE,"${PACKAGE_DATE}",[Define to the release date of this package.])

AC_SUBST(PACKAGE_VERSION_NUMBER)
AC_SUBST(PACKAGE_VERSION_SUFFIX)
AC_SUBST(PACKAGE_DATE)

dnl -------------------------------------------------------
dnl Identify the host platform we're compiling for,
dnl using config.guess and config.sub.
dnl -------------------------------------------------------

AC_CANONICAL_HOST
AC_DEFINE_UNQUOTED(CANONICAL_HOST_TYPE, "${host}", [Define the canonical host system type as a string constant.])

case "${host}" in
	*-*-cygwin)
	  BINEXT=".exe"
	  ;;
	*-*-mingw32)
	  BINEXT=".exe"
	  ;;
	*)
	  BINEXT=""
	  ;;
esac

dnl -------------------------------------------------------
dnl Configuration Utilities
dnl -------------------------------------------------------

if test "x$prefix" = xNONE ; then
AC_DEFINE_UNQUOTED(DCMTK_PREFIX, "${ac_default_prefix}", [Define the DCMTK default path.])
else
AC_DEFINE_UNQUOTED(DCMTK_PREFIX, "${prefix}", [Define the DCMTK default path.])
fi

DATA_DIR="${datadir}"
DATA_DIR=`(
	test "$prefix" = NONE && prefix=${ac_default_prefix}
	test "$exec_prefix" = NONE && exec_prefix=${prefix}
	eval eval echo "$DATA_DIR"
)`
AC_DEFINE_UNQUOTED(DCM_DICT_DEFAULT_PATH, "${DATA_DIR}/dicom.dic", [Define the default data dictionary path for the dcmdata library package.])
AC_DEFINE_UNQUOTED(DEFAULT_SUPPORT_DATA_DIR, "${DATA_DIR}/", [Define the default directory where support data files reside.])

CONF_DIR="${sysconfdir}"
CONF_DIR=`(
	test "$prefix" = NONE && prefix=${ac_default_prefix}
	test "$exec_prefix" = NONE && exec_prefix=${prefix}
	eval echo "$CONF_DIR"
)`
AC_DEFINE_UNQUOTED(DEFAULT_CONFIGURATION_DIR, "${CONF_DIR}/", [Define the default directory where configuration files reside.])

AH_VERBATIM([PATH_SEPARATOR], [/* Define path separator. */
#define PATH_SEPARATOR '/'])

AH_VERBATIM([ENVIRONMENT_PATH_SEPARATOR], [/* Define the environment variable path separator. */
#ifndef ENVIRONMENT_PATH_SEPARATOR
#define ENVIRONMENT_PATH_SEPARATOR ':'
#endif])

AH_VERBATIM([HAVE_EMPTY_ARGC_ARGV], [/* Define if your system cannot pass command line arguments into main() (e.g. Macintosh). */
/* #undef HAVE_EMPTY_ARGC_ARGV */])

AH_TOP([#ifndef OSCONFIG_H
#define OSCONFIG_H

/*
** Define enclosures for include files with C linkage (mostly system headers)
*/
#ifdef __cplusplus
#define BEGIN_EXTERN_C extern "C" {
#define END_EXTERN_C }
#else
#define BEGIN_EXTERN_C
#define END_EXTERN_C
#endif

/* MinGW needs some special handling because it is a mixture of WIN32 and Posix.
 * The following settings are not tested by configure but need to be set for MinGW.
 */
#ifdef __MINGW32__
#define HAVE_WINDOWS_H 1
#define HAVE_WINSOCK_H 1
#define ENVIRONMENT_PATH_SEPARATOR ';'
#endif])

AH_BOTTOM([#if defined(HAVE_CXX11) && defined(__cplusplus) && __cplusplus < 201103L
#error\
DCMTK was configured to use C++11 features, but your compiler does not or was not configured to provide them.
#endif

#endif /* OSCONFIG_H */])


dnl Include general file
sinclude(general.m4)dnl

AC_CONFIG_AUX_DIR([.])

dnl Checks for programs.

AC_PROG_INSTALL
AC_PROG_CC
AC_PROG_CPP
AC_CHECK_PROGS(CXX, $CCC c++ cc++ g++ gcc CC cxx, gcc)

pedantic=""
if test -f /bin/uname ; then
	os=`uname -s`
	rev=`uname -r`
	if test \( "$os" = SunOS \) ; then
		case "$rev" in
			# only use the -pedantic compiler option on
			# Solaris 2 machines.
			5.*) pedantic="-pedantic" ;;
		esac
	fi
fi
if test "${CXXFLAGS}set" = set ; then
	case "$CXX" in
		c++|g++|gcc)
		  CXXFLAGS="-Wall $pedantic"
		  CFLAGS="-Wall $pedantic"
		  ;;
		cc++)
		  CXXFLAGS="-Wall"
		  CFLAGS="-Wall"
		  ;;
		*)
		  CXXFLAGS=""
		  CFLAGS=""
		  ;;
	esac
fi

AC_PROG_CXXCPP
dnl The next test is equivalent to AC_PROG_RANLIB
dnl Do not use AC_PROG_RANLIB because this produces
dnl an error on LINUX-systems in the configure script
AC_CHECK_PROGS(RANLIB, ranlib, :)

dnl Check for "ar" and "libtool". On certain systems, e.g. NeXTStep, we must
dnl prefer "libtool" over "ar" if both are present. However, we don't use
dnl GNU libtool at the moment which is something completely different
dnl (not an "ar" replacement).
AC_CHECK_PROGS(AR, ar, :)
AC_CHECK_PROGS(LIBTOOL, libtool, :)
if test "${LIBTOOL}set" = libtoolset ; then
  AC_CHECK_GNU_LIBTOOL
  if test $ac_cv_check_gnu_libtool = yes ; then
    :
  else
    AR=$LIBTOOL
  fi
fi

case "$AR" in
libtool) ARFLAGS=-o ;;
ar) ARFLAGS=cruv ;;
esac

if test "${LIBEXT}set" = set ; then
	LIBEXT="a"
fi

AC_SUBST(ARFLAGS)
AC_SUBST(LIBEXT)
AC_SUBST(BINEXT)

# Try to find a strip utility
AC_CHECK_PROGS(STRIP, strip, :)

dnl -------------------------------------------------------
dnl Check special systems
dnl -------------------------------------------------------

AC_AIX
AC_ISC_POSIX
AC_SYS_LONG_FILE_NAMES

dnl -------------------------------------------------------
dnl Perform some tests with the C compiler, needed for dcmjpeg
dnl -------------------------------------------------------

AC_MY_C_INLINE
AC_MY_C_CONST
AC_MY_C_CHAR_UNSIGNED
AC_MY_C_RIGHTSHIFT_UNSIGNED

dnl -------------------------------------------------------
dnl Check some typedefs versus definitions in <sys/types.h>,
dnl needed for JasPer support
dnl -------------------------------------------------------

AC_TYPEDEF(uchar, unsigned char)
AC_TYPEDEF(ushort, unsigned short)
AC_TYPEDEF(uint, unsigned int)
AC_TYPEDEF(ulong, unsigned long)
AC_CHECK_TYPES(longlong)
AC_CHECK_TYPES(ulonglong)
AC_CHECK_TYPES(long long)
AC_CHECK_TYPES(unsigned long long)
CHECK_VLA

dnl File access stuff
AC_CHECK_TYPES(fpos64_t)
AC_CHECK_TYPES(off64_t)

dnl stdbool.h and stdint.h are only defined in ANSI C, not in C++
AC_CHECK_HEADERS(stdbool.h)
AC_CHECK_HEADERS(stdint.h)
AC_CHECK_HEADERS(cstdint)

AC_CHECK_TYPES(int64_t)
AC_CHECK_TYPES(uint64_t)

AC_CHECK_TYPES(char16_t)

AC_CHECK_TYPES([sigjmp_buf], [], [], [[#include <setjmp.h>]])

dnl -------------------------------------------------------
dnl Checks for libc library functions.
dnl -------------------------------------------------------

AC_FUNC_MEMCMP
AC_FUNC_VPRINTF
AC_TYPE_SIGNAL
AC_FUNC_WAIT3
AC_CHECK_FUNCS(gethostname gethostid socket sysinfo)
AC_CHECK_FUNCS(strchr strstr strtoul itoa atoll)
AC_CHECK_FUNCS(memcpy memset memmove memcmp bcopy bcmp)
AC_CHECK_FUNCS(getpid mktemp tempnam tmpnam getenv mkstemp)
AC_CHECK_FUNCS(stat)
AC_CHECK_FUNCS(malloc_debug)
AC_CHECK_FUNCS(strerror strdup bzero index rindex access)
AC_CHECK_FUNCS(uname cuserid getlogin getlogin_r)
AC_CHECK_FUNCS(usleep)
AC_CHECK_FUNCS(flock lockf)
AC_CHECK_FUNCS(listen connect setsockopt getsockopt select)
AC_CHECK_FUNCS(gethostbyname gethostbyname_r)
AC_CHECK_FUNCS(gethostbyaddr_r getgrnam_r getpwnam_r)
AC_CHECK_FUNCS(bind accept getsockname getaddrinfo)
AC_CHECK_FUNCS(getrusage)
AC_CHECK_FUNCS(gettimeofday)
AC_CHECK_FUNCS(waitpid)
AC_CHECK_FUNCS(getuid geteuid setuid getpwnam getgrnam)
AC_CHECK_FUNCS(sleep fork)
AC_CHECK_FUNCS(_findfirst)
AC_CHECK_FUNCS(strlcpy strlcat)
AC_CHECK_FUNCS(vsnprintf)
AC_CHECK_FUNCS(mbstowcs wcstombs)
AC_CHECK_FUNCS(popen pclose)
AC_CHECK_FUNCS(readdir_r)
AC_FUNC_FSEEKO


dnl -------------------------------------------------------
dnl Checks for libcs library functions needed by oflog
dnl -------------------------------------------------------

AC_DEFUN([TYPE_SOCKLEN_T],
[
AH_TEMPLATE([socklen_t], [Define to int if undefined.])
AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t,
[
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
   #include <sys/socket.h>]], [[socklen_t len = 42; return 0;]])],[ac_cv_type_socklen_t=yes],[ac_cv_type_socklen_t=no])
])
  if test $ac_cv_type_socklen_t != yes; then
    AC_DEFINE(socklen_t, int)
  fi
])

AC_CHECK_FUNCS(ftime gmtime_r localtime_r lstat nanosleep fcntl)
AC_CHECK_FUNCS(htons htonl ntohs ntohl)
AC_CHECK_HEADERS(netinet/in.h)
AC_CHECK_HEADERS(syslog.h)
TYPE_SOCKLEN_T

AH_TEMPLATE([HAVE_ENAMETOOLONG])
AC_COMPILE_IFELSE(
  [AC_LANG_PROGRAM([#include <errno.h>], [int value = ENAMETOOLONG;])],
  [AC_DEFINE([HAVE_ENAMETOOLONG], , [Define if your system provides ENAMETOOLONG errno value.])])

dnl -------------------------------------------------------
dnl Checks for libm library functions.
dnl -------------------------------------------------------

SAVELIBS="$LIBS"
LIBS="$LIBS -lm"
AC_CHECK_FUNCS(finite isinf isnan)
LIBS="$SAVELIBS"

dnl -------------------------------------------------------
dnl Perform remaining tests with C++ compiler
dnl -------------------------------------------------------
AC_LANG(C++)

AC_CXX_CONST_CAST
AC_CXX_DYNAMIC_CAST
AC_CXX_REINTERPRET_CAST
AC_CXX_STATIC_CAST
AC_CXX_STD_NOTHROW
AC_CXX_NOTHROW_DELETE
AC_CXX_STATIC_ASSERT

dnl -------------------------------------------------------
dnl Check for Debug Mode
dnl -------------------------------------------------------

DEBUG="-DNDEBUG"
DEBUGCXXFLAGS=
DEBUGCFLAGS=
AC_MSG_CHECKING(whether to compile in debug mode)
AC_ARG_ENABLE(debug,
[  --enable-debug          compile with debug code, don't optimize
  --disable-debug         compile without debug code (default)],
[ case "$enableval" in
  yes)
    AC_MSG_RESULT(yes)
    DEBUGCXXFLAGS="-g"
    DEBUGCFLAGS="-g"
    DEBUG="-DDEBUG"
    ;;
  *)
    AC_MSG_RESULT(no)
    DEBUGCXXFLAGS="-O"
    DEBUGCFLAGS="-O"
    ;;
  esac ],
  AC_MSG_RESULT(no)
  DEBUGCXXFLAGS="-O"
  DEBUGCFLAGS="-O"
)

dnl -------------------------------------------------------
dnl Check for thread support
dnl -------------------------------------------------------

THREADSUPPORT="auto"
AC_MSG_CHECKING(whether to enable thread support)
AC_ARG_ENABLE(threads,
[  --enable-threads=TYPE   compile with MT support (posix/solaris/auto=default)
  --disable-threads       compile without MT support],
[ case "$enableval" in
  yes|auto)
    AC_MSG_RESULT(automatic detection)
    ;;
  posix)
    AC_MSG_RESULT([yes, type=posix])
    THREADSUPPORT="posix"
    ;;
  solaris)
    AC_MSG_RESULT([yes, type=solaris])
    THREADSUPPORT="solaris"
    ;;
  no)
    AC_MSG_RESULT(no)
    THREADSUPPORT="no"
    ;;
  *)
    AC_MSG_RESULT([yes - type $enableval is unknown - using automatic detection])
    ;;
  esac ],
  AC_MSG_RESULT(automatic detection)
)

dnl -------------------------------------------------------
dnl Check for large file support
dnl -------------------------------------------------------

LFSSUPPORT="auto"
AC_MSG_CHECKING(whether to enable large file support)
AC_ARG_ENABLE(lfs,
[  --enable-lfs=TYPE       compile with LFS support (lfs/lfs64/auto=default)
  --disable-lfs           compile without LFS support],
[ case "$enableval" in
  yes|auto)
    AC_MSG_RESULT(automatic detection)
    ;;
  lfs)
    AC_MSG_RESULT([yes, type=LFS])
    LFSSUPPORT="lfs"
    ;;
  lfs64)
    AC_MSG_RESULT([yes, type=LFS64])
    LFSSUPPORT="lfs64"
    ;;
  no)
    AC_MSG_RESULT(no)
    LFSSUPPORT="no"
    ;;
  *)
    AC_MSG_RESULT([yes - type $enableval is unknown - using automatic detection])
    ;;
  esac ],
  AC_MSG_RESULT(automatic detection)
)

dnl -------------------------------------------------------
dnl Checks for libraries.
dnl -------------------------------------------------------

AC_CHECK_GXXLIB
AC_CHECK_LIB(iostream, main)
dnl Some C++ compilers have problems with recursive main calls
dnl (e.g. Sun C++ 4.2). In this case we must test another function
dnl to link.
AC_CHECK_LIB(nsl, main)
if test $ac_cv_lib_nsl_main = no ; then
AC_CHECK_LIB(nsl, gethostbyname)
fi
AC_CHECK_LIB(socket, main)
if test $ac_cv_lib_socket_main = no ; then
AC_CHECK_LIB(socket, socket)
fi

dnl Some newer versions of OpenSSL must be linked against libdl.
dnl We just check whether libdl exists and in this case always
dnl add -ldl to OPENSSLLIBS. The same applies for OPENJPEG.
OPENSSLLIBS=""
OPENJPEGLIBS=""
AC_CHECK_LIB(dl, main,[
OPENSSLLIBS="-ldl"
OPENJPEGLIBS="-ldl"
])
if test $ac_cv_lib_dl_main = no ; then
AC_CHECK_LIB(dl, dlopen,[
OPENSSLLIBS="-ldl"
OPENJPEGLIBS="-ldl"
])
fi

MATHLIBS=""
AC_CHECK_LIB(m, main,[
MATHLIBS="-lm"
])
if test $ac_cv_lib_m_main = no ; then
AC_CHECK_LIB(m, sin,[
MATHLIBS="-lm"
])
fi

dnl On MinGW we have to link against the winsock32 library
dnl
AC_CHECK_LIB(wsock32, main,[
LIBS="$LIBS -lwsock32"
])

dnl On MinGW we have to link against the netapi32 library
dnl
AC_CHECK_LIB(netapi32, main,[
LIBS="$LIBS -lnetapi32"
])

dnl -------------------------------------------------------
dnl Checks for header files.
dnl -------------------------------------------------------

AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_HEADER_DIRENT
AC_CHECK_TCP_H
AC_CHECK_HEADERS(alloca.h)
AC_CHECK_HEADERS(arpa/inet.h)
AC_CHECK_HEADERS(assert.h)
AC_CHECK_HEADERS(ctype.h)
AC_CHECK_HEADERS(errno.h)
AC_CHECK_HEADERS(fcntl.h)
AC_CHECK_HEADERS(float.h)
AC_CHECK_HEADERS(fnmatch.h)
AC_CHECK_HEADERS(fstream)
AC_CHECK_HEADERS(fstream.h)
AC_CHECK_HEADERS(grp.h)
AC_CHECK_HEADERS(ieeefp.h)
AC_CHECK_HEADERS(io.h)
AC_CHECK_HEADERS(iomanip)
AC_CHECK_HEADERS(iomanip.h)
AC_CHECK_HEADERS(iostream)
AC_CHECK_HEADERS(iostream.h)
AC_CHECK_HEADERS(iso646.h)
AC_CHECK_HEADERS(libc.h)
AC_CHECK_HEADERS(limits.h)
AC_CHECK_HEADERS(climits)
AC_CHECK_HEADERS(locale.h)
AC_CHECK_HEADERS(malloc.h)
AC_CHECK_HEADERS(math.h)
AC_CHECK_HEADERS(cmath)
AC_CHECK_HEADERS(new)
AC_CHECK_HEADERS(new.h)
AC_CHECK_HEADERS(netdb.h)
AC_CHECK_HEADERS(pthread.h)
AC_CHECK_HEADERS(pwd.h)
AC_CHECK_HEADERS(semaphore.h)
AC_CHECK_HEADERS(setjmp.h)
AC_CHECK_HEADERS(signal.h)
AC_CHECK_HEADERS(sstream)
AC_CHECK_HEADERS(sstream.h)
AC_CHECK_HEADERS(stat.h)
AC_CHECK_HEADERS(cstdarg)
AC_CHECK_HEADERS(stdarg.h)
AC_CHECK_HEADERS(stddef.h)
AC_CHECK_HEADERS(cstddef)
AC_CHECK_HEADERS(cstdio)
AC_CHECK_HEADERS(stdio.h)
AC_CHECK_HEADERS(stdint.h)
AC_CHECK_HEADERS(stdlib.h)
AC_CHECK_HEADERS(streambuf.h)
AC_CHECK_HEADERS(string.h)
AC_CHECK_HEADERS(strings.h)
AC_CHECK_HEADERS(strstrea.h)
AC_CHECK_HEADERS(strstream)
AC_CHECK_HEADERS(strstream.h)
AC_CHECK_HEADERS(synch.h)
AC_CHECK_HEADERS(sys/errno.h)
AC_CHECK_HEADERS(sys/file.h)
AC_CHECK_HEADERS(sys/param.h)
AC_CHECK_HEADERS(sys/resource.h)
AC_CHECK_HEADERS(sys/select.h)
AC_CHECK_HEADERS(sys/socket.h)
AC_CHECK_HEADERS(sys/stat.h)
AC_CHECK_HEADERS(sys/syscall.h)
AC_CHECK_HEADERS(sys/systeminfo.h)
AC_CHECK_HEADERS(sys/time.h)
AC_CHECK_HEADERS(sys/timeb.h)
AC_CHECK_HEADERS(sys/types.h)
AC_CHECK_HEADERS(sys/utime.h)
AC_CHECK_HEADERS(sys/utsname.h)
AC_CHECK_HEADERS(thread.h)
AC_CHECK_HEADERS(time.h)
AC_CHECK_HEADERS(unistd.h)
AC_CHECK_HEADERS(unix.h)
AC_CHECK_HEADERS(utime.h)
AC_CHECK_HEADERS(wchar.h)
AC_CHECK_HEADERS(wctype.h)
AC_CHECK_HEADERS(fenv.h)
AC_CHECK_HEADER(iterator,
    [AC_DEFINE([HAVE_ITERATOR_HEADER], 1, [Define to 1 if you have the <iterator> header file.])]
)

AC_CHECK_POLL_H

if test $ac_cv_header_libc_h = yes ; then
  if test $ac_cv_header_math_h = yes ; then
    AC_CXX_LIBC_H_EXTERN_C
  fi
fi

dnl -------------------------------------------------------
dnl Tests for pointer vs. integer types
dnl These tests REQUIRE as a prerequisite AC_CXX_STATIC_CAST
dnl -------------------------------------------------------

if test $ac_cv_header_pthread_h = yes ; then
  AC_CHECK_POINTER_TYPE(pthread_t, pthread.h)
fi

dnl -------------------------------------------------------
dnl Check for thread support
dnl -------------------------------------------------------

dnl
dnl in auto mode, check whether we use solaris or posix threads
dnl
if test $THREADSUPPORT = auto ; then
  if test $ac_cv_header_synch_h = yes ; then
    THREADSUPPORT="solaris"
  fi
fi
if test $THREADSUPPORT = auto ; then
  if test $ac_cv_header_pthread_h = yes ; then
    THREADSUPPORT="posix"
  fi
fi
if test $THREADSUPPORT = auto ; then
  THREADSUPPORT="no"
fi

dnl
dnl in solaris mode, check for -lthread
dnl

if test $THREADSUPPORT = solaris ; then
  AC_CHECK_LIB(thread, sema_init, [
  ac_tr_lib=HAVE_LIBTHREAD
  AC_DEFINE_UNQUOTED($ac_tr_lib)
  LIBS="-lthread $LIBS"
  ])
fi

if test $THREADSUPPORT = posix ; then
  dnl
  dnl check Posix MT libraries -lrt and -lpthread
  dnl OSF/1 re-#defines most of the pthread function names.
  dnl This is why we use pthread_key_create for the test.
  dnl
  AC_CHECK_LIB(pthread, pthread_key_create, [
  ac_tr_lib=HAVE_LIBPTHREAD
  AC_DEFINE_UNQUOTED($ac_tr_lib)
  LIBS="-lpthread $LIBS"
  ])

  AC_CHECK_LIB(rt, sem_init, [
  ac_tr_lib=HAVE_LIBRT
  AC_DEFINE_UNQUOTED($ac_tr_lib)
  LIBS="-lrt $LIBS"
  ], , $LIBS )

  dnl
  dnl check whether the compiler required the -pthread option
  dnl to correctly link code containing posix thread calls.
  dnl This is true on FreeBSD.
  dnl
  AC_CHECK_PTHREAD_OPTION

  dnl
  dnl check whether Posix read/write locks are available
  dnl
  POSIXRWLOCKSAVAILABLE="no"
  AC_CHECK_LIB(pthread, pthread_rwlock_init, [
    AC_DEFINE(HAVE_PTHREAD_RWLOCK, , [Define if your system supports POSIX read/write locks.])
    dnl
    dnl we're going to use POSIX threads with read/write locks.
    dnl Linux 2.2.x only declares all prototypes if _XOPEN_SOURCE=500 and _BSD_SOURCE
    dnl OSF/1 requires _XOPEN_SOURCE=500, _XOPEN_SOURCE_EXTENDED, _OSF_SOURCE and _POSIX_C_SOURCE=199506L
    dnl Irix 6.x does not like _XOPEN_SOURCE=500 and _POSIX_C_SOURCE=199506L
    dnl
    POSIXRWLOCKSAVAILABLE="yes"
    case "${host}" in
	mips-sgi-irix6*)
	  CXXFLAGS="-D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE -D_BSD_COMPAT $CXXFLAGS"
	  CFLAGS="-D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE -D_BSD_COMPAT $CFLAGS"
	  ;;
	*-*-openbsd3*)
	  CXXFLAGS="-D_POSIX_C_SOURCE=199506L $CXXFLAGS"
	  CFLAGS="-D_POSIX_C_SOURCE=199506L $CFLAGS"
	  ;;
	*-*-openbsd4*)
	  ;;
	*-*-openbsd5*)
	  ;;
	*-*-freebsd*)
	  ;;
	*-*-netbsdelf2*)
	  ;;
	*-*-netbsd*)
	  CXXFLAGS="-D_XOPEN_SOURCE_EXTENDED -D_NETBSD_SOURCE -D_BSD_COMPAT $CXXFLAGS"
	  CFLAGS="-D_XOPEN_SOURCE_EXTENDED -D_NETBSD_SOURCE -D_BSD_COMPAT $CFLAGS"
	  ;;
	*-*-darwin*)
	  dnl On Mac OS X we need to have _DARWIN_C_SOURCE defined to enable UNIX standard API for system headers
	  CXXFLAGS="-D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_DARWIN_C_SOURCE $CXXFLAGS"
	  CFLAGS="-D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_DARWIN_C_SOURCE $CXXFLAGS"
	  ;;
	*)
	  CXXFLAGS="-D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_POSIX_C_SOURCE=199506L $CXXFLAGS"
	  CFLAGS="-D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_POSIX_C_SOURCE=199506L $CFLAGS"
	  ;;
    esac
  ],
  [
    dnl
    dnl We did not find pthread_rwlock_init in libpthread. Maybe it is somewhere else, e.g. in libc_r on FreeBSD.
    dnl We give it another try by just linking against the default libraries.
    dnl
    AC_MSG_CHECKING(for pthread_rwlock_init in default libraries)
    AC_TRY_LINK([extern "C" int pthread_rwlock_init(void *rwlock, void *attr);
      ] , [(void) pthread_rwlock_init(NULL, NULL);], [
    AC_MSG_RESULT(yes)
    AC_DEFINE(HAVE_PTHREAD_RWLOCK, , [Define if your system supports POSIX read/write locks.])
    dnl
    dnl we're going to use POSIX threads with read/write locks.
    dnl Linux 2.2.x only declares all prototypes if _XOPEN_SOURCE=500 and _BSD_SOURCE
    dnl OSF/1 requires _XOPEN_SOURCE=500, _XOPEN_SOURCE_EXTENDED, _OSF_SOURCE and _POSIX_C_SOURCE=199506L
    dnl Irix 6.x does not like _XOPEN_SOURCE=500 and _POSIX_C_SOURCE=199506L
    dnl
    POSIXRWLOCKSAVAILABLE="yes"
    case "${host}" in
	mips-sgi-irix6*)
	  CXXFLAGS="-D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE -D_BSD_COMPAT $CXXFLAGS"
	  CFLAGS="-D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE -D_BSD_COMPAT $CFLAGS"
	  ;;
	*-*-openbsd3*)
	  CXXFLAGS="-D_POSIX_C_SOURCE=199506L $CXXFLAGS"
	  CFLAGS="-D_POSIX_C_SOURCE=199506L $CFLAGS"
	  ;;
	*-*-openbsd4*)
	  ;;
	*-*-openbsd5*)
	  ;;
	*-*-freebsd*)
	  ;;
	*-*-netbsdelf2*)
	  ;;
	*-*-netbsd*)
	  CXXFLAGS="-D_XOPEN_SOURCE_EXTENDED -D_NETBSD_SOURCE -D_BSD_COMPAT $CXXFLAGS"
	  CFLAGS="-D_XOPEN_SOURCE_EXTENDED -D_NETBSD_SOURCE -D_BSD_COMPAT $CFLAGS"
	  ;;
	*-*-darwin*)
	  dnl On Mac OS X we need to have _DARWIN_C_SOURCE source defined to enable UNIX standard API for system headers
	  CXXFLAGS="-D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_DARWIN_C_SOURCE $CXXFLAGS"
	  CFLAGS="-D_XOPEN_SOURCE_EXTENDED -D_BSD_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_DARWIN_C_SOURCE $CXXFLAGS"
	  ;;
	*)
	  CXXFLAGS="-D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_POSIX_C_SOURCE=199506L $CXXFLAGS"
	  CFLAGS="-D_XOPEN_SOURCE_EXTENDED -D_XOPEN_SOURCE=500 -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_BSD_COMPAT -D_OSF_SOURCE -D_POSIX_C_SOURCE=199506L $CFLAGS"
	  ;;
    esac
    ], AC_MSG_RESULT(no))
  ]
  )
fi

AC_MSG_CHECKING(multi-thread support)
case "$THREADSUPPORT" in
  solaris)
    AC_MSG_RESULT([yes, solaris threads])
    CXXFLAGS="-D_REENTRANT $CXXFLAGS"
    CFLAGS="-D_REENTRANT $CFLAGS"
    AC_DEFINE(WITH_THREADS, , [Define if we are compiling with any type of multi-thread support.])
    ;;
  posix)
    if test $POSIXRWLOCKSAVAILABLE = yes ; then
      AC_MSG_RESULT([yes, posix threads with rwlock])
    else
      AC_MSG_RESULT([yes, posix threads without rwlock])
    fi
    CXXFLAGS="-D_REENTRANT $CXXFLAGS"
    CFLAGS="-D_REENTRANT $CFLAGS"
    AC_DEFINE(WITH_THREADS, , [Define if we are compiling with any type of multi-thread support.])
    ;;
  *)
    AC_MSG_RESULT(none)
    ;;
esac

dnl -------------------------------------------------------
dnl Check for LFS support
dnl -------------------------------------------------------

if test $LFSSUPPORT = auto -o $LFSSUPPORT = lfs64; then
  AC_LFS64
  if test $ac_cv_lfs64_support = yes ; then
    LFSSUPPORT="lfs64"
  fi
fi

if test $LFSSUPPORT = auto -o $LFSSUPPORT = lfs; then
  MY_AC_SYS_LARGEFILE
fi

dnl -------------------------------------------------------
dnl Checks for typedefs, structures, and compiler characteristics.
dnl -------------------------------------------------------

AC_TYPEDEF(size_t, unsigned)
AC_TYPEDEF(ssize_t, long)
AC_TYPEDEF(pid_t, int)
AC_C_CHAR_UNSIGNED
AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(float)
AC_CHECK_SIZEOF(double)
AC_CHECK_SIZEOF(void *)
AC_STRUCT_TM
AC_MY_SYMBOL_EXISTS([__FUNCTION__])
AC_MY_SYMBOL_EXISTS([__PRETTY_FUNCTION__])
AC_MY_SYMBOL_EXISTS([__func__])

dnl -------------------------------------------------------
dnl Checks for prototypes
dnl -------------------------------------------------------
dnl
dnl The following AC_CHECK_* macros _must_ have corresponding entries in
dnl the acconfig.h file.  This is because the macros are specific to the
dnl DCMTK project and are not supported by GNU autoheader.

AC_CHECK_PROTOTYPE(feenableexcept, fenv.h)
AC_CHECK_PROTOTYPE(_stricmp, string.h)
AC_CHECK_PROTOTYPE(accept, sys/types.h sys/socket.h)
if test $ac_cv_prototype_accept = yes ; then
AC_CHECK_INTP_ACCEPT(sys/types.h sys/socket.h)
fi
AC_CHECK_PROTOTYPE(bind, sys/types.h sys/socket.h)
AC_CHECK_PROTOTYPE(bzero, string.h strings.h libc.h unistd.h stdlib.h)
AC_CHECK_PROTOTYPE(connect, sys/types.h sys/socket.h)
AC_CHECK_PROTOTYPE(finite, math.h)
AC_CHECK_PROTOTYPE(isinf, math.h)
AC_CHECK_PROTOTYPE(isnan, math.h)
AC_CHECK_PROTOTYPE(std::finite, cmath)
AC_CHECK_PROTOTYPE(std::isinf, cmath)
AC_CHECK_PROTOTYPE(std::isnan, cmath)
AC_CHECK_PROTOTYPE(flock, sys/file.h)
AC_CHECK_PROTOTYPE(gethostbyname, libc.h unistd.h stdlib.h netdb.h)
AC_CHECK_PROTOTYPE(gethostbyname_r, libc.h unistd.h stdlib.h netdb.h)
AC_CHECK_PROTOTYPE(gethostbyaddr_r, libc.h unistd.h stdlib.h netdb.h)
AC_CHECK_PROTOTYPE(gethostid, libc.h unistd.h stdlib.h netdb.h)
AC_CHECK_PROTOTYPE(gethostname, unistd.h libc.h stdlib.h netdb.h)
AC_CHECK_PROTOTYPE(getsockname, sys/types.h sys/socket.h)
AC_CHECK_PROTOTYPE(getsockopt, sys/types.h sys/socket.h)
AC_CHECK_PROTOTYPE(strerror_r, string.h)
if test $ac_cv_prototype_strerror_r = yes ; then
AC_CHECK_CHARP_STRERROR_R(string.h)
fi
if test $ac_cv_prototype_getsockopt = yes ; then
AC_CHECK_INTP_GETSOCKOPT(sys/types.h sys/socket.h)
fi
AC_CHECK_PROTOTYPE(gettimeofday, sys/time.h unistd.h)
AC_CHECK_PROTOTYPE(listen, sys/types.h sys/socket.h)
AC_CHECK_PROTOTYPE(mktemp, libc.h unistd.h stdlib.h)
AC_CHECK_PROTOTYPE(mkstemp, libc.h unistd.h stdlib.h)
AC_CHECK_PROTOTYPE(select, sys/select.h sys/types.h sys/socket.h sys/time.h)
if test $ac_cv_prototype_select = yes ; then
AC_CHECK_INTP_SELECT(sys/select.h sys/types.h sys/socket.h sys/time.h)
fi
AC_CHECK_PROTOTYPE(setsockopt, sys/types.h sys/socket.h)
AC_CHECK_PROTOTYPE(socket, sys/types.h sys/socket.h)
AC_CHECK_PROTOTYPE(strcasecmp, string.h)
AC_CHECK_PROTOTYPE(strncasecmp, string.h)
AC_CHECK_PROTOTYPE(usleep, libc.h unistd.h stdlib.h)
AC_CHECK_PROTOTYPE(vsnprintf, stdio.h stdarg.h)
AC_CHECK_PROTOTYPE(wait3, libc.h sys/wait.h sys/time.h sys/resource.h)
AC_CHECK_PROTOTYPE(waitpid, sys/wait.h sys/time.h sys/resource.h)
AC_CHECK_DECLARATION(struct utimbuf, sys/types.h utime.h sys/utime.h)
AC_CHECK_DECLARATION(socklen_t, sys/types.h sys/socket.h)
AC_CHECK_OLD_READDIR_R
AC_CHECK_ELLIPSE_SIGNAL_HANDLER(signal.h)
if test $ac_cv_header_math_h = yes ; then
AC_INCLUDE_MATH_H_AS_CXX
fi


dnl -------------------------------------------------------
dnl Checks for the usage of standard C++ headers.
dnl -------------------------------------------------------

AC_MSG_CHECKING(whether to use C++ standard includes)
ac_use_std_includes="auto"
AC_ARG_ENABLE(std-includes,
[  --enable-std-includes   use C++ ANSI standard includes (default: auto)
  --disable-std-includes  use old C++ includes ],
[ case "$enableval" in
  yes)
   ac_use_std_includes="yes"
   ;;

  *)
    ac_use_std_includes="no"
    ;;
  esac ]
)

if test "$ac_cv_header_fstream" = "yes" -a "$ac_cv_header_iostream" = "yes" -a "$ac_cv_header_iomanip" = "yes"; then
   ac_have_std_includes="yes"
else
   ac_have_std_includes="no"
fi

if test "$ac_cv_header_fstream_h" = "yes" -a "$ac_cv_header_iostream_h" = "yes" -a "$ac_cv_header_iomanip_h" = "yes"; then
   ac_have_old_includes="yes"
else
   ac_have_old_includes="no"
fi

if test "$ac_use_std_includes" = "yes"; then
   AC_MSG_RESULT(yes)
   AC_DEFINE(USE_STD_CXX_INCLUDES, , [Define if ANSI standard C++ includes are used.])
elif test "$ac_use_std_includes" = "no"; then
   AC_MSG_RESULT(no)
elif test "$ac_have_std_includes" = "yes"; then
   AC_MSG_RESULT(yes)
   AC_DEFINE(USE_STD_CXX_INCLUDES, , [Define if ANSI standard C++ includes are used.])
   ac_use_std_includes="yes"
else
   AC_MSG_RESULT(no)
   ac_use_std_includes="no"
fi

if test "$ac_use_std_includes" = "yes"; then
   AC_CHECK_STD_NAMESPACE
   AC_CHECK_DECLARATION(std::ios_base::openmode, , iostream)
   AC_CHECK_IOS_NOCREATE(std::ios, fstream)
   AC_CHECK_COMPILES(std::vfprintf, cstdarg cstdio,
     [FILE *stream; va_list ap; std::vfprintf(stream, "", ap);])
   AC_CHECK_COMPILES(std::vsnprintf, cstdarg cstdio,
     [char buf[256]; va_list ap; std::vsnprintf(buf, 0, "", ap);])
else
   AC_CHECK_DECLARATION(std::ios_base::openmode, , iostream.h)
   AC_CHECK_IOS_NOCREATE(ios, fstream.h)
   AC_CHECK_COMPILES(std::vfprintf, stdarg.h stdio.h,
     [FILE *stream; va_list ap; std::vfprintf(stream, "", ap);])
   AC_CHECK_COMPILES(std::vsnprintf, stdarg.h stdio.h,
     [char buf[256]; va_list ap; std::vsnprintf(buf, 0, "", ap);])
fi

AC_CHECK_CLASS_TEMPLATE
AC_CHECK_STATIC_TEMPLATE_METHOD
AC_CHECK_FUNCTION_TEMPLATE
AC_CHECK_EXPLICIT_TEMPLATE_SPECIALIZATION
AC_CHECK_CXX_BOOL
AC_CHECK_CXX_VOLATILE
AC_CXX_TYPENAME
AC_STDIO_NAMESPACE

dnl -------------------------------------------------------
dnl Check for Private Tag support
dnl -------------------------------------------------------

AC_MSG_CHECKING(whether to enable private tag dictionary)
AC_ARG_ENABLE(private-tags,
[  --enable-private-tags   enable private tag dictionary
  --disable-private-tags  don't enable private tag dictionary (default)],
[ case "$enableval" in
  yes)
    AC_MSG_RESULT(yes)
    AC_DEFINE(ENABLE_PRIVATE_TAGS, , [Define if we are compiling for enabling external private tag dictionary.])
    AC_DEFINE_UNQUOTED(DCM_DICT_DEFAULT_PATH, "${DATA_DIR}/dicom.dic:${DATA_DIR}/private.dic", [Define the default data dictionary path for the dcmdata library package.])
    ;;
  *)
    AC_MSG_RESULT(no)
    ;;
  esac ],
  AC_MSG_RESULT(no)
)

dnl -------------------------------------------------------
dnl Check for External Dictionary support
dnl -------------------------------------------------------

AC_MSG_CHECKING(whether to enable loading external dictionary from default path)
AC_ARG_ENABLE(external-dict,
[  --enable-external-dict  enable loading of external dictionary (default)
  --disable-external-dict don't load external dictionary],
[ case "$enableval" in
  yes)
    AC_MSG_RESULT(yes)
    AC_DEFINE(ENABLE_EXTERNAL_DICTIONARY, , [Define if we are compiling for loading external dictionary from default path.])
    ;;
  *)
    AC_MSG_RESULT(no)
    dnl Reset default path so the dictionary is not loaded automatically on startup
    AC_DEFINE_UNQUOTED(DCM_DICT_DEFAULT_PATH, "", [Define the default data dictionary path for the dcmdata library package.])
    ;;
  esac ],
  AC_MSG_RESULT(yes)
  AC_DEFINE(ENABLE_EXTERNAL_DICTIONARY, , [Define if we are compiling for loading external dictionary from default path.])
)

dnl -------------------------------------------------------
dnl Check for Built-in (compiled-in) Dictionary support
dnl -------------------------------------------------------

AC_MSG_CHECKING(whether to enable built-in dictionary loading)
AC_ARG_ENABLE(builtin-dict,
[  --enable-builtin-dict   enable loading of built-in dictionary
  --disable-builtin-dict  don't load built-in dictionary (default)],
[ case "$enableval" in
  yes)
    AC_MSG_RESULT(yes)
    AC_DEFINE(ENABLE_BUILTIN_DICTIONARY, , [Define if we are compiling with built-in (compiled-in) dictionary enabled.])
    ;;
  *)
    AC_MSG_RESULT(no)
    ;;
  esac ],
  AC_MSG_RESULT(no)
)

dnl -------------------------------------------------------
dnl Check for OpenSSL support
dnl -------------------------------------------------------

AC_MY_LIB_PATH([openssl], [OpenSSL])

AC_MSG_CHECKING([whether to include OpenSSL support])
AC_ARG_WITH(openssl,
[AS_HELP_STRING([--with-openssl], [include OpenSSL support (default: auto)])
AS_HELP_STRING([--without-openssl], [don't include OpenSSL support])],
[ case "$withval" in
  yes)
      AC_TRY_COMPILE([#include <openssl/ssl.h>], [
#if OPENSSL_VERSION_NUMBER < 0x10001000L
#error OpenSSL too old
#endif
],
   [ AC_MSG_RESULT(yes)
    AC_DEFINE(WITH_OPENSSL, , [Define if we are compiling with OpenSSL support.])
    OPENSSLLIBS="-lssl -lcrypto $OPENSSLLIBS" ],
    [AC_MSG_RESULT(no - DCMTK requires OpenSSL version 1.0.1 or newer)] )
    ;;
  *)
    AC_MSG_RESULT(no)
    ;;
  esac ],
[ SAVELIBS="$LIBS"
  LIBS="$LIBS $OPENSSLLIBS -lssl -lcrypto"
  AC_TRY_LINK([#include <openssl/ssl.h>], [(void) TLSv1_method()],
    [
      AC_TRY_COMPILE([#include <openssl/ssl.h>], [
#if OPENSSL_VERSION_NUMBER < 0x10001000L
#error OpenSSL too old
#endif
],
      [ AC_MSG_RESULT(yes)
      AC_DEFINE(WITH_OPENSSL, , [Define if we are compiling with OpenSSL support.])
      OPENSSLLIBS="-lssl -lcrypto $OPENSSLLIBS" ],
     [AC_MSG_RESULT(no - DCMTK requires OpenSSL version 1.0.1 or newer)] )],
    [AC_MSG_RESULT(no)])
  LIBS="$SAVELIBS"] )

AC_CHECK_SSL_CTX_GET0_PARAM
AC_CHECK_RAND_EGD

dnl -------------------------------------------------------
dnl Check for libjpeg, which is needed by libtiff on some platforms
dnl -------------------------------------------------------

JPEGLIBS=""
AC_CHECK_LIB(jpeg, jpeg_set_defaults,[
JPEGLIBS="-ljpeg"
])
if test $ac_cv_lib_jpeg_jpeg_set_defaults = no ; then
AC_CHECK_LIB(jpeg, jSetDefaults,[
JPEGLIBS="-ljpeg"
])
fi

dnl -------------------------------------------------------
dnl Check for zlib support
dnl -------------------------------------------------------

AC_MY_LIB_PATH([zlib])

ZLIBLIBS=""
AC_MSG_CHECKING(whether to include zlib support)
AC_ARG_WITH(zlib,
[AS_HELP_STRING([--with-zlib], [include zlib support (default: auto)])
AS_HELP_STRING([--without-zlib], [don't include zlib support])],
[ case "$withval" in
  yes)
    AC_MSG_RESULT(yes)
    AC_DEFINE(WITH_ZLIB, , [Define if we are compiling with zlib support.])
    ZLIBLIBS="-lz"
    ;;
  *)
    AC_MSG_RESULT(no)
    ;;
  esac ],
[ SAVELIBS="$LIBS"
  LIBS="$LIBS -lz"
  AC_TRY_LINK([#include <zlib.h>], [(void) zlibVersion()],
    [ AC_MSG_RESULT(yes)
      AC_DEFINE(WITH_ZLIB, , [Define if we are compiling with zlib support.])
      ZLIBLIBS="-lz" ],
    [AC_MSG_RESULT(no)])
  LIBS="$SAVELIBS"] )

dnl -------------------------------------------------------
dnl Check for libtiff support
dnl -------------------------------------------------------

AC_MY_LIB_PATH([libtiff])

TIFFLIBS=""
AC_MSG_CHECKING(whether to include libtiff support)
AC_ARG_WITH(libtiff,
[AS_HELP_STRING([--with-libtiff], [include libtiff support (default: auto)])
AS_HELP_STRING([--without-libtiff], [don't include libtiff support])],
[ case "$withval" in
  yes)
    AC_MSG_RESULT(yes)
    AC_DEFINE(WITH_LIBTIFF, , [Define if we are compiling with libtiff support.])
    TIFFLIBS="-ltiff $JPEGLIBS $ZLIBLIBS"
    ;;
  *)
    AC_MSG_RESULT(no)
    ;;
  esac ],
[ SAVELIBS="$LIBS"
  LIBS="$LIBS -ltiff $JPEGLIBS $ZLIBLIBS"
  AC_TRY_LINK([#include <tiffio.h>], [(void) TIFFGetVersion()],
    [ AC_MSG_RESULT(yes)
      AC_DEFINE(WITH_LIBTIFF, , [Define if we are compiling with libtiff support.])
      TIFFLIBS="-ltiff $JPEGLIBS $ZLIBLIBS"
    ],
    [AC_MSG_RESULT(no)])
  LIBS="$SAVELIBS"] )


dnl -------------------------------------------------------
dnl Check for libpng support
dnl -------------------------------------------------------

AC_MY_LIB_PATH([libpng])

dnl perform check for <libpng/png.h> only after we have evaluated --with-libpnginc
AC_CHECK_HEADERS(libpng/png.h)

PNGLIBS=""
AC_MSG_CHECKING(whether to include libpng support)
AC_ARG_WITH(libpng,
[AS_HELP_STRING([--with-libpng], [include libpng support (default: auto)])
AS_HELP_STRING([--without-libpng], [don't include libpng support])],
[ case "$withval" in
  yes)
    if test "x$ZLIBLIBS" != x; then
        AC_MSG_RESULT(yes)
        AC_DEFINE(WITH_LIBPNG, , [Define if we are compiling with libpng support.])
        PNGLIBS="-lpng"
    else
        AC_MSG_RESULT(no because libpng requires zlib)
    fi
    ;;
  *)
    AC_MSG_RESULT(no)
    ;;
  esac ],
[ if test "x$ZLIBLIBS" != x; then
      SAVELIBS="$LIBS"
      LIBS="$LIBS -lpng $ZLIBLIBS"

      AC_TRY_LINK([#ifdef HAVE_LIBPNG_PNG_H
#include <libpng/png.h>
#else
#include <png.h>
#endif], [(void) png_access_version_number()],
        [ AC_MSG_RESULT(yes)
          AC_DEFINE(WITH_LIBPNG, , [Define if we are compiling with libpng support.])
          PNGLIBS="-lpng" ],
        [AC_MSG_RESULT(no)])

      LIBS="$SAVELIBS"
  else
      AC_MSG_RESULT(no because libpng requires zlib)
  fi
] )

dnl -------------------------------------------------------
dnl Check for libxml support
dnl -------------------------------------------------------

AC_MY_LIB_PATH([libxml])

LIBXMLCFLAGS=`xml2-config --cflags 2>/dev/null`
if test "${LIBXMLCFLAGS+set}" = set; then
  CXXFLAGS="$LIBXMLCFLAGS $CXXFLAGS"
  CFLAGS="$LIBXMLCFLAGS $CFLAGS"
fi
LIBXMLLIBS=`xml2-config --libs 2>/dev/null`

XMLLIBS=""
AC_MSG_CHECKING(whether to include libxml support)
AC_ARG_WITH(libxml,
[AS_HELP_STRING([--with-libxml], [include libxml support (default: auto)])
AS_HELP_STRING([--without-libxml], [don't include libxml support])],
[ case "$withval" in
  yes)
    AC_MSG_RESULT(yes)
    AC_DEFINE(WITH_LIBXML, , [Define if we are compiling with libxml support.])
    XMLLIBS=$LIBXMLLIBS
    ;;
  *)
    AC_MSG_RESULT(no)
    ;;
  esac ],
[ SAVELIBS="$LIBS"
  LIBS="$LIBS $LIBXMLLIBS"
  AC_TRY_LINK([#include <libxml/parser.h>], [(void) xmlInitParser()],
    [ AC_MSG_RESULT(yes)
      AC_DEFINE(WITH_LIBXML, , [Define if we are compiling with libxml support.])
      XMLLIBS=$LIBXMLLIBS ],
    [AC_MSG_RESULT(no)])
  LIBS="$SAVELIBS"] )

dnl -------------------------------------------------------
dnl Check for libwrap (TCP wrapper) support
dnl -------------------------------------------------------

AC_MY_LIB_PATH([libwrap])

TCPWRAPPERLIBS=""
AC_MSG_CHECKING(whether to include libwrap support)
AC_ARG_WITH(libwrap,
[AS_HELP_STRING([--with-libwrap], [include libwrap support (default: auto)])
AS_HELP_STRING([--without-libwrap], [don't include libwrap support])],
[ case "$withval" in
  yes)
    AC_MSG_RESULT(yes)
    AC_DEFINE(WITH_TCPWRAPPER, , [Define if we are compiling with libwrap (TCP wrapper) support.])
    TCPWRAPPERLIBS="-lwrap"
    ;;
  *)
    AC_MSG_RESULT(no)
    ;;
  esac ],
[ SAVELIBS="$LIBS"
  LIBS="-lwrap $LIBS"
  AC_TRY_LINK(
    [#ifdef __cplusplus
    extern "C" {
    #endif
    #ifdef HAVE_STDIO_H
    /* on some platforms, tcpd.h needs stdio.h */
    #include <stdio.h>
    #endif
    #ifdef HAVE_SYS_TYPES_H
    /* on some platforms, tcpd.h needs sys/types.h */
    #include <sys/types.h>
    #endif
    #include <tcpd.h>
    #ifdef __cplusplus
    }
    #endif
    int deny_severity = 0;
    int allow_severity = 0;], [struct request_info r; (void) hosts_access(&r)],
    [ AC_MSG_RESULT(yes)
      AC_DEFINE(WITH_TCPWRAPPER, , [Define if we are compiling with libwrap (TCP wrapper) support.])
    TCPWRAPPERLIBS="-lwrap" ],
    [AC_MSG_RESULT(no)])
  LIBS="$SAVELIBS"] )


dnl -------------------------------------------------------
dnl Check for OpenJPEG support
dnl -------------------------------------------------------

AC_MY_OPENJPEG_PATH()

AC_MSG_CHECKING(whether to include OpenJPEG support)
AC_ARG_WITH(libwrap,
[AS_HELP_STRING([--with-openjpeg], [include OpenJPEG support (default: auto)])
AS_HELP_STRING([--without-openjpeg], [don't include OpenJPEG support])],
[ case "$withval" in
  yes)
    AC_MSG_RESULT(yes)
    AC_DEFINE(WITH_OPENJPEG, , [Define if we are compiling with OpenJPEG support.])
    OPENJPEGLIBS="-lopenjp2 $OPENJPEGLIBS"
    ;;
  *)
    AC_MSG_RESULT(no)
    ;;
  esac ],
[ SAVELIBS="$LIBS"
  LIBS="-lopenjp2 $OPENJPEGLIBS $LIBS"
  AC_TRY_LINK([#include <openjpeg.h>], [(void) opj_version()],
    [ AC_MSG_RESULT(yes)
      AC_DEFINE(WITH_OPENJPEG, , [Define if we are compiling with OpenJPEG support.])
    OPENJPEGLIBS="-lopenjp2 $OPENJPEGLIBS" ],
    [AC_MSG_RESULT(no)])
  LIBS="$SAVELIBS"] )


dnl -------------------------------------------------------
dnl Check for libsndfile support
dnl -------------------------------------------------------

AC_MY_LIB_PATH([libsndfile])

SNDFILELIBS=""
AC_MSG_CHECKING(whether to include libsndfile support)
AC_ARG_WITH(libsndfile,
  [AS_HELP_STRING([--with-libsndfile], [include libsndfile support (default: auto)])
AS_HELP_STRING([--without-libsndfile], [don't include libsndfile support])],
  [ case "$withval" in
    yes)
      AC_MSG_RESULT(yes)
      AC_DEFINE(WITH_SNDFILE, , [Define if we are compiling with libsndfile support.])
      SNDFILELIBS="-lsndfile"
      ;;
    *)
      AC_MSG_RESULT(no)
      ;;
    esac ],
  [ SAVELIBS="$LIBS"
    LIBS="$LIBS -lsndfile"
    AC_TRY_LINK([#include <sndfile.h>], [char buffer [128]; sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer));],
      [ AC_MSG_RESULT(yes)
        AC_DEFINE(WITH_SNDFILE, , [Define if we are compiling with libsndfile support.])
        SNDFILELIBS="-lsndfile" ],
      [AC_MSG_RESULT(no)])
    LIBS="$SAVELIBS"]
)

dnl -------------------------------------------------------
dnl Check for libiconv support
dnl -------------------------------------------------------

AC_MY_LIB_PATH([libiconv])
AH_TEMPLATE(WITH_LIBICONV, [Define if we are compiling with libiconv support.])
WITH_LIBICONV=no
ICONVLIBS=""
AC_MSG_CHECKING(whether to include libiconv support)
AC_ARG_WITH(libiconv,
[AS_HELP_STRING([--with-libiconv], [include libiconv support (default: auto)])
AS_HELP_STRING([--without-libiconv], [don't include libiconv support])],
[ case "$withval" in
  yes)
    WITH_LIBICONV=yes
    AC_DEFINE(WITH_LIBICONV)
    ICONVLIBS="-liconv -lcharset"
    ;;
  *)
    ;;
  esac ],
[ SAVELIBS="$LIBS"
  LIBS="$LIBS -liconv -lcharset"
  AC_TRY_LINK([#include <iconv.h>], [iconv_t cd = iconv_open("", ""); iconv(cd, 0, 0, 0, 0); iconv_close(cd);],
    [ WITH_LIBICONV=yes
      AC_DEFINE(WITH_LIBICONV)
      ICONVLIBS="-liconv -lcharset" ])
  LIBS="$SAVELIBS"] )
AC_MSG_RESULT($WITH_LIBICONV)

AC_MSG_CHECKING(whether the second argument to iconv() is const)
SAVELIBS="$LIBS"
LIBS="$LIBS $ICONVLIBS"
AC_TRY_COMPILE([#include <iconv.h>], [iconv_t cd = iconv_open("", ""); const char *in = 0; iconv(cd, &in, 0, 0, 0); iconv_close(cd);],
  [ AC_MSG_RESULT(yes)
    AC_DEFINE(LIBICONV_SECOND_ARGUMENT_CONST, , [Define if the second argument to iconv() is const.]) ],
  [AC_MSG_RESULT(no)])
LIBS="$SAVELIBS"

dnl -------------------------------------------------------
dnl Check for iconv inside C standard library
dnl -------------------------------------------------------

AH_TEMPLATE([WITH_STDLIBC_ICONV], [Define if the C standard library has iconv builtin.])dnl
WITH_STDLIBC_ICONV=no
AC_MSG_CHECKING([whether the C standard library provides iconv functionality])
SAVELIBS="$LIBS"
LIBS=""
AC_TRY_LINK([#include <iconv.h>], [iconv_t cd=iconv_open("","");iconv(cd,0,0,0,0);iconv_close(cd);],
    [WITH_STDLIBC_ICONV=yes
     AC_DEFINE(WITH_STDLIBC_ICONV)])
AC_MSG_RESULT($WITH_STDLIBC_ICONV)
LIBS="$SAVELIBS"

dnl -------------------------------------------------------
dnl Check for libicu support
dnl -------------------------------------------------------

AC_MY_LIB_PATH([libicu])
AH_TEMPLATE([WITH_LIBICU], [Define if we are compiling with ICU support.])
WITH_LIBICU=no
AC_ARG_WITH(libicu,
[AS_HELP_STRING([--with-libicu], [include libicu support (default: auto)])
AS_HELP_STRING([--without-libicu], [don't include libicu support])],
[ AC_MSG_CHECKING(whether to include ICU support)
  case "$withval" in
  yes)
    WITH_LIBICU=yes
    AC_DEFINE(WITH_LIBICU)
    ICULIBS="-licui18n -licuuc -licudata"
    ;;
  *)
    ;;
  esac ],
[
  if test -z "$ICU_CONFIG"; then
    AC_PATH_PROG(ICU_CONFIG, icu-config, no)
    AC_MSG_CHECKING(whether to include ICU support)
  fi
  if [[ ! "$ICU_CONFIG" = "no" ]]; then
    ICU_VERSION=`$ICU_CONFIG --version`
        VERSION_CHECK=`expr $ICU_VERSION \>\= 3.4.1`
        if test VERSION_CHECK=1; then
            WITH_LIBICU=yes
            AC_DEFINE(WITH_LIBICU)
            ICUINCLUDES=`$ICU_CONFIG --cppflags`
            ICULIBS=`$ICU_CONFIG --ldflags`
        fi
  fi
])
AC_MSG_RESULT($WITH_LIBICU)

dnl -------------------------------------------------------
dnl character set conversion support
dnl -------------------------------------------------------

AH_VERBATIM([DCMTK_CHARSET_CONVERSION_CONSTANTS], [/* character set conversion constants. */
#define DCMTK_CHARSET_CONVERSION_ICU 1
#define DCMTK_CHARSET_CONVERSION_ICONV 2
#define DCMTK_CHARSET_CONVERSION_STDLIBC_ICONV 3

/* LFS mode constants. */
#define DCMTK_LFS 1
#define DCMTK_LFS64 2])

CHARCONVINCLUDES=""
CHARCONVLIBS=""

AC_DEFUN([AC_CHOOSE_CHARSET_LIBICONV],
[
    AC_MSG_RESULT([yes, type=libiconv])
    CHARCONVLIBS="$ICONVLIBS"
    DCMTK_ENABLE_CHARSET_CONVERSION="DCMTK_CHARSET_CONVERSION_ICONV"
])

AC_DEFUN([AC_CHOOSE_CHARSET_LIBICU],
[
    AC_MSG_RESULT([yes, type=libicu])
    CHARCONVINCLUDES="$ICUINCLUDES"
    CHARCONVLIBS="$ICULIBS"
    DCMTK_ENABLE_CHARSET_CONVERSION="DCMTK_CHARSET_CONVERSION_ICU"
])

AC_DEFUN([AC_CHOOSE_CHARSET_STDLIBC_ICONV],
[
    AC_MSG_RESULT([yes, type=stdlibc])
    DCMTK_ENABLE_CHARSET_CONVERSION="DCMTK_CHARSET_CONVERSION_STDLIBC_ICONV"
])

AC_DEFUN([AC_CHOOSE_CHARSET_IMPL],
[
if test "$WITH_LIBICONV" = "yes"; then
    AC_CHOOSE_CHARSET_LIBICONV()
elif test "$WITH_LIBICU" = "yes"; then
    AC_CHOOSE_CHARSET_LIBICU()
elif test "$WITH_STDLIBC_ICONV" = "yes"; then
    AC_CHOOSE_CHARSET_STDLIBC_ICONV()
else
    AC_MSG_RESULT(no)
fi
])

AC_MSG_CHECKING(fixed iconv conversion flags)
if test "$WITH_STDLIBC_ICONV" != "yes"; then
    SAVELIBS="$LIBS"
    LIBS="$LIBS $ICONVLIBS"
fi
AC_RUN_IFELSE(
    [AC_LANG_SOURCE([[#include "tests/iconv.cc"]])],
    [
        AC_DEFINE_UNQUOTED(DCMTK_FIXED_ICONV_CONVERSION_FLAGS, [`./conftest$EXEEXT`], [Try to define the iconv behavior as conversion flags])
        AC_MSG_RESULT()
    ],
    [AC_MSG_RESULT([unknown])]
)
if test "$WITH_STDLIBC_ICONV" != "yes"; then
    LIBS="$SAVELIBS"
fi

if test "$WITH_STDLIBC_ICONV" == "yes"; then
    AC_MSG_CHECKING([whether iconv_open() accepts "" as an argument])
    AC_RUN_IFELSE(
        [AC_LANG_SOURCE([[#include "tests/lciconv.cc"]])],
        [
            AC_DEFINE(DCMTK_STDLIBC_ICONV_HAS_DEFAULT_ENCODING, 1, [Define if iconv_open() accepts "" as an argument])
            AC_MSG_RESULT(yes)
        ],
        [AC_MSG_RESULT(no)]
    )
fi

AC_MSG_CHECKING(whether to enable character set conversion support)
AC_ARG_ENABLE(charconv,
[  --enable-charconv=TYPE  enable character set conversion support
                          (libiconv/libicu/stdlibc/auto=default)
  --disable-charconv      disable character set conversion support],
[ case "$enableval" in
  yes|auto)
    AC_CHOOSE_CHARSET_IMPL()
    ;;
  libiconv)
    AC_CHOOSE_CHARSET_LIBICONV()
    ;;
  libicu)
    AC_CHOOSE_CHARSET_LIBICU()
    ;;
  stdlibc)
    AC_CHOOSE_CHARSET_STDLIBC_ICONV()
    ;;
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_CHOOSE_CHARSET_IMPL()
    ;;
  esac ],
  [AC_CHOOSE_CHARSET_IMPL()]
)

AC_SUBST(CHARCONVINCLUDES)
AC_SUBST(CHARCONVLIBS)

if [[ ! -z "$DCMTK_ENABLE_CHARSET_CONVERSION" ]]; then
  AC_DEFINE_UNQUOTED(DCMTK_ENABLE_CHARSET_CONVERSION,
    [$DCMTK_ENABLE_CHARSET_CONVERSION],
    [Define to select character set conversion implementation.])
fi


dnl -------------------------------------------------------
dnl include config test code from config/tests
dnl -------------------------------------------------------

ac_enable_cxx11="no"
AC_MSG_CHECKING(whether to enable C++11 support)
AC_ARG_ENABLE(cxx11,
[  --enable-cxx11          use C++11
  --disable-cxx11         do not use C++11 (default)],
[ case "$enableval" in
  yes)
   AC_MSG_RESULT()
   AX_CXX_COMPILE_STDCXX([11], [noext], [optional])
   if test "$HAVE_CXX11 == 1"; then
     ac_enable_cxx11="yes"
   fi
   AC_MSG_CHECKING(whether to enable C++11 support)
   ;;

  *)
   ac_enable_cxx11="no"
   ;;
  esac ]
)
AC_MSG_RESULT($ac_enable_cxx11)


dnl -------------------------------------------------------
dnl Enable/disable STL support.
dnl -------------------------------------------------------

ac_enable_stl="no"
AC_MSG_CHECKING(whether to enable STL support)
AC_ARG_ENABLE(stl,
[  --enable-stl            use C++ STL
  --disable-stl           do not use C++ STL (default)],
[ case "$enableval" in
  yes)
   ac_enable_stl="yes"
   ;;

  *)
    ac_enable_stl="no"
    ;;
  esac ]
)
AC_MSG_RESULT($ac_enable_stl)


ac_enable_stl_vector="auto"
AC_MSG_CHECKING(whether to enable STL vector support)
AC_ARG_ENABLE(stl-vector,
[  --enable-stl-vector     use C++ STL vector
  --disable-stl-vector    do not use C++ STL vector],
[ case "$enableval" in
  yes)
   ac_enable_stl_vector="yes"
   ;;

  *)
    ac_enable_stl_vector="no"
    ;;
  esac]
)
if test "$ac_enable_stl_vector" = "auto"; then
  ac_enable_stl_vector="$ac_enable_stl"
fi
if test "$ac_enable_stl_vector" = "yes"; then
  AC_RUN_IFELSE([AC_LANG_SOURCE([[#include "tests/vector.cc"]])], [AC_DEFINE(HAVE_STL_VECTOR, , [Define if STL's vector should be used.])], [ac_enable_stl_vector="unsupported -> no"])
fi
AC_MSG_RESULT($ac_enable_stl_vector)

ac_enable_stl_algorithm="auto"
AC_MSG_CHECKING(whether to enable STL algorithm support)
AC_ARG_ENABLE(stl-algorithm,
[  --enable-stl-algorithm  use C++ STL algorithm
  --disable-stl-algorithm do not use C++ STL algorithm],
[ case "$enableval" in
  yes)
   ac_enable_stl_algorithm="yes"
   ;;

  *)
    ac_enable_stl_algorithm="no"
    ;;
  esac ]
)
if test "$ac_enable_stl_algorithm" = "auto"; then
  ac_enable_stl_algorithm="$ac_enable_stl"
fi
if test "$ac_enable_stl_algorithm" = "yes"; then
  AC_RUN_IFELSE([AC_LANG_SOURCE([[#include "tests/algo.cc"]])], [AC_DEFINE(HAVE_STL_ALGORITHM, , [Define if STL's algorithm should be used.])], [ac_enable_stl_algorithm="unsupported -> no"])
fi
AC_MSG_RESULT($ac_enable_stl_algorithm)

ac_enable_stl_limits="auto"
AC_MSG_CHECKING(whether to enable STL limits support)
AC_ARG_ENABLE(stl-limits,
[  --enable-stl-limits     use C++ STL limits
  --disable-stl-limits    do not use C++ STL limits],
[ case "$enableval" in
  yes)
   ac_enable_stl_limits="yes"
   ;;

  *)
    ac_enable_stl_limits="no"
    ;;
  esac ]
)
if test "$ac_enable_stl_limits" = "auto"; then
  ac_enable_stl_limits="$ac_enable_stl"
fi
if test "$ac_enable_stl_limits" = "yes"; then
  AC_RUN_IFELSE([AC_LANG_SOURCE([[#include "tests/limits.cc"]])], [AC_DEFINE(HAVE_STL_LIMITS, , [Define if STL's limits should be used.])], [ac_enable_stl_limits="unsupported -> no"])
fi
AC_MSG_RESULT($ac_enable_stl_limits)

ac_enable_stl_list="auto"
AC_MSG_CHECKING(whether to enable STL list support)
AC_ARG_ENABLE(stl-list,
[  --enable-stl-list       use C++ STL list
  --disable-stl-list      do not use C++ STL list],
[ case "$enableval" in
  yes)
   ac_enable_stl_list="yes"
   ;;

  *)
    ac_enable_stl_list="no"
    ;;
  esac ]
)
if test "$ac_enable_stl_list" = "auto"; then
  ac_enable_stl_list="$ac_enable_stl"
fi
if test "$ac_enable_stl_list" = "yes"; then
  AC_RUN_IFELSE([AC_LANG_SOURCE([[#include "tests/list.cc"]])], [AC_DEFINE(HAVE_STL_LIST, , [Define if STL's list should be used.])], [ac_enable_stl_list="unsupported -> no"])
fi
AC_MSG_RESULT($ac_enable_stl_list)

ac_enable_stl_map="auto"
AC_MSG_CHECKING(whether to enable STL map support)
AC_ARG_ENABLE(stl-map,
[  --enable-stl-map        use C++ STL map
  --disable-stl-map       do not use C++ STL map],
[ case "$enableval" in
  yes)
   ac_enable_stl_map="yes"
   ;;

  *)
    ac_enable_stl_map="no"
    ;;
  esac ]
)
if test "$ac_enable_stl_map" = "auto"; then
  ac_enable_stl_map="$ac_enable_stl"
fi
if test "$ac_enable_stl_map" = "yes"; then
  AC_RUN_IFELSE([AC_LANG_SOURCE([[#include "tests/map.cc"]])], [AC_DEFINE(HAVE_STL_MAP, , [Define if STL's map should be used.])], [ac_enable_stl_map="unsupported -> no"])
fi
AC_MSG_RESULT($ac_enable_stl_map)

ac_enable_stl_memory="auto"
AC_MSG_CHECKING(whether to enable STL memory support)
AC_ARG_ENABLE(stl-memory,
[  --enable-stl-memory     use C++ STL memory
  --disable-stl-memory    do not use C++ STL memory],
[ case "$enableval" in
  yes)
   ac_enable_stl_memory="yes"
   ;;

  *)
    ac_enable_stl_memory="no"
    ;;
  esac ]
)
if test "$ac_enable_stl_memory" = "auto"; then
  ac_enable_stl_memory="$ac_enable_stl"
fi
if test "$ac_enable_stl_memory" = "yes"; then
  AC_RUN_IFELSE([AC_LANG_SOURCE([[#include "tests/memory.cc"]])], [AC_DEFINE(HAVE_STL_MEMORY, , [Define if STL's memory should be used.])], [ac_enable_stl_memory="unsupported -> no"])
fi
AC_MSG_RESULT($ac_enable_stl_memory)

ac_enable_stl_stack="auto"
AC_MSG_CHECKING(whether to enable STL stack support)
AC_ARG_ENABLE(stl-stack,
[  --enable-stl-stack      use C++ STL stack
  --disable-stl-stack     do not use C++ STL stack],
[ case "$enableval" in
  yes)
   ac_enable_stl_stack="yes"
   ;;

  *)
    ac_enable_stl_stack="no"
    ;;
  esac ]
)
if test "$ac_enable_stl_stack" = "auto"; then
  ac_enable_stl_stack="$ac_enable_stl"
fi
if test "$ac_enable_stl_stack" = "yes"; then
  AC_RUN_IFELSE([AC_LANG_SOURCE([[#include "tests/stack.cc"]])], [AC_DEFINE(HAVE_STL_STACK, , [Define if STL's stack should be used.])], []ac_enable_stl_stack="unsupported -> no")
fi
AC_MSG_RESULT($ac_enable_stl_stack)

ac_enable_stl_string="auto"
AC_MSG_CHECKING(whether to enable STL string support)
AC_ARG_ENABLE(stl-string,
[  --enable-stl-string     use C++ STL string
  --disable-stl-string    do not use C++ STL string],
[ case "$enableval" in
  yes)
   ac_enable_stl_string="yes"
   ;;

  *)
    ac_enable_stl_string="no"
    ;;
  esac ]
)
if test "$ac_enable_stl_string" = "auto"; then
  ac_enable_stl_string="$ac_enable_stl"
fi
if test "$ac_enable_stl_string" = "yes"; then
  AC_RUN_IFELSE([AC_LANG_SOURCE([[#include "tests/string.cc"]])], [AC_DEFINE(HAVE_STL_STRING, , [Define if STL's string should be used.])], [ac_enable_stl_string="unsupported -> no"])
fi
AC_MSG_RESULT($ac_enable_stl_string)

ac_enable_stl_type_traits="auto"
AC_MSG_CHECKING(whether to enable STL type-traits support)
AC_ARG_ENABLE(stl-type-traits,
[  --enable-stl-type-traits
                          use C++ STL type-traits
  --disable-stl-type-traits
                          do not use C++ STL type-traits],
[ case "$enableval" in
  yes)
   ac_enable_stl_type_traits="yes"
   ;;

  *)
    ac_enable_stl_type_traits="no"
    ;;
  esac ]
)
if test "$ac_enable_stl_type_traits" = "auto"; then
  ac_enable_stl_type_traits="$ac_enable_stl"
fi
if test "$ac_enable_stl_type_traits" = "yes"; then
  AC_RUN_IFELSE([AC_LANG_SOURCE([[#include "tests/ttraits.cc"]])], [AC_DEFINE(HAVE_STL_TYPE_TRAITS, , [Define if STL's type traits should be used.])], [ac_enable_stl_type_traits="unsupported -> no"])
fi
AC_MSG_RESULT($ac_enable_stl_type_traits)

ac_enable_stl_tuple="auto"
AC_MSG_CHECKING(whether to enable STL tuple support)
AC_ARG_ENABLE(stl-tuple,
[  --enable-stl-tuple      use C++ STL tuple
  --disable-stl-tuple     do not use C++ STL tuple],
[ case "$enableval" in
  yes)
   ac_enable_stl_tuple="yes"
   ;;

  *)
    ac_enable_stl_tuple="no"
    ;;
  esac ]
)
if test "$ac_enable_stl_tuple" = "auto"; then
  ac_enable_stl_tuple="$ac_enable_stl"
fi
if test "$ac_enable_stl_tuple" = "yes"; then
  AC_RUN_IFELSE([AC_LANG_SOURCE([[#include "tests/tuple.cc"]])], [AC_DEFINE(HAVE_STL_TUPLE, , [Define if STL's tuple should be used.])], [ac_enable_stl_tuple="unsupported -> no"])
fi
AC_MSG_RESULT($ac_enable_stl_tuple)

ac_enable_stl_system_error="auto"
AC_MSG_CHECKING(whether to enable STL system_error support)
AC_ARG_ENABLE(stl-system-error,
[  --enable-stl-system-error
                          use C++ STL system_error
  --disable-stl-system_error
                          do not use C++ STL system_error],
[ case "$enableval" in
  yes)
   ac_enable_stl_system_error="yes"
   ;;

  *)
    ac_enable_stl_system_error="no"
    ;;
  esac ]
)
if test "$ac_enable_stl_system_error" = "auto"; then
  ac_enable_stl_system_error="$ac_enable_stl"
fi
if test "$ac_enable_stl_system_error" = "yes"; then
  AC_RUN_IFELSE([AC_LANG_SOURCE([[#include "tests/syserr.cc"]])], [AC_DEFINE(HAVE_STL_SYSTEM_ERROR, , [Define if STL's system_error should be used.])], [ac_enable_stl_system_error="unsupported -> no"])
fi
AC_MSG_RESULT($ac_enable_stl_system_error)


dnl -------------------------------------------------------
dnl Test for some additional functions and keywords
dnl -------------------------------------------------------

AC_CHECK_SYNC_FN([__sync_add_and_fetch],[HAVE_SYNC_ADD_AND_FETCH])
AC_CHECK_SYNC_FN([__sync_sub_and_fetch],[HAVE_SYNC_SUB_AND_FETCH])
AC_CHECK_ALIGNOF([HAVE_GNU_ALIGNOF])
AC_CHECK_ATTRIBUTE_ALIGNED([HAVE_ATTRIBUTE_ALIGNED])
AC_CHECK_ATTRIBUTE_ALIGNED_SUPPORTS_TEMPLATES([ATTRIBUTE_ALIGNED_SUPPORTS_TEMPLATES])
AC_CHECK_DEFAULT_CONSTRUCTOR_DETECTION_VIA_SFINAE([HAVE_DEFAULT_CONSTRUCTOR_DETECTION_VIA_SFINAE])

dnl -------------------------------------------------------
dnl Test if passwd has the pw_gecos field
dnl -------------------------------------------------------

AC_MSG_CHECKING(whether struct pwd contains the field pw_gecos)
AC_TRY_COMPILE([#include <pwd.h>],
  [&passwd::pw_gecos;],
  [ AC_MSG_RESULT(yes)
    AC_DEFINE(HAVE_PASSWD_GECOS, , [Define if passwd::pw_gecos is available.]) ],
  [AC_MSG_RESULT(no)])

dnl -------------------------------------------------------
dnl Test if SYS_gettid is available
dnl -------------------------------------------------------

AC_MSG_CHECKING(for SYS_gettid in sys/syscall.h)
AC_TRY_COMPILE([#include <sys/syscall.h>],
  [SYS_gettid;],
  [ AC_MSG_RESULT(yes)
    AC_DEFINE(HAVE_SYS_GETTID, , [Define if your system has a prototype for gettid.]) ],
  [AC_MSG_RESULT(no)])


dnl -------------------------------------------------------
dnl Test for defined iterator categories
dnl -------------------------------------------------------

AC_CHECK_ITERATOR_CATEGORY([input],[HAVE_INPUT_ITERATOR_CATEGORY])
AC_CHECK_ITERATOR_CATEGORY([output],[HAVE_OUTPUT_ITERATOR_CATEGORY])
AC_CHECK_ITERATOR_CATEGORY([forward],[HAVE_FORWARD_ITERATOR_CATEGORY])
AC_CHECK_ITERATOR_CATEGORY([bidirectional],[HAVE_BIDIRECTIONAL_ITERATOR_CATEGORY])
AC_CHECK_ITERATOR_CATEGORY([random_access],[HAVE_RANDOM_ACCESS_ITERATOR_CATEGORY])
AC_CHECK_ITERATOR_CATEGORY([contiguous],[HAVE_CONTIGUOUS_ITERATOR_CATEGORY])


dnl -------------------------------------------------------
dnl Set optimizer and debug compiler flags
dnl -------------------------------------------------------
CFLAGS="$DEBUGCFLAGS $CFLAGS"
CXXFLAGS="$DEBUGCXXFLAGS $CXXFLAGS"

dnl -------------------------------------------------------
dnl Special Definitions for output
dnl -------------------------------------------------------
AC_SUBST(CXXFLAGS)
AC_SUBST(OPENSSLLIBS)
AC_SUBST(TIFFLIBS)
AC_SUBST(PNGLIBS)
AC_SUBST(MATHLIBS)
AC_SUBST(ZLIBLIBS)
AC_SUBST(XMLLIBS)
AC_SUBST(TCPWRAPPERLIBS)
AC_SUBST(SNDFILELIBS)
AC_SUBST(ICONVLIBS)
AC_SUBST(OPENJPEGLIBS)
AC_SUBST(DEBUG)

AC_OUTPUT(Makefile.def Makefile)

dnl disabled: AC_ARG_PROGRAM