File: configure.ac

package info (click to toggle)
owfs 3.2p3+dfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 8,688 kB
  • sloc: ansic: 65,085; pascal: 5,957; tcl: 2,688; makefile: 1,357; python: 1,114; sh: 891; cs: 623; php: 600; perl: 587; java: 404; ruby: 289; cpp: 105; asm: 102; xml: 53
file content (1974 lines) | stat: -rw-r--r-- 50,151 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
dnl Process this file with autoconf to produce a configure script.

AC_PREREQ(2.57)

AC_INIT
AM_SILENT_RULES([yes])

# Making releases:
#   VERSION_PATCHLEVEL += 1;
#   OWFS_INTERFACE_AGE += 1;
#   OWFS_BINARY_AGE += 1;
# if any functions have been added, set OWFS_INTERFACE_AGE to 0.
# if backwards compatibility has been broken,
# set OWFS_BINARY_AGE _and_ OWFS_INTERFACE_AGE to 0.
# (In our case it's better to always keep AGE to 0, since nobody else will use our library)

VERSION_MAJOR=3
VERSION_MINOR=2
VERSION_PATCHLEVEL=3

OWFS_INTERFACE_AGE=0
OWFS_BINARY_AGE=0

AC_SUBST(VERSION_MAJOR)
AC_SUBST(VERSION_MINOR)
AC_SUBST(VERSION_PATCHLEVEL)
AC_SUBST(OWFS_INTERFACE_AGE)
AC_SUBST(OWFS_BINARY_AGE)

LT_CURRENT=`expr $VERSION_PATCHLEVEL - $OWFS_INTERFACE_AGE`
LT_REVISION=$OWFS_INTERFACE_AGE
LT_AGE=`expr $OWFS_BINARY_AGE - $OWFS_INTERFACE_AGE`

AC_SUBST(LT_CURRENT)dnl
AC_SUBST(LT_REVISION)dnl
AC_SUBST(LT_AGE)dnl

LT_RELEASE=$VERSION_MAJOR.$VERSION_MINOR
AC_SUBST(LT_RELEASE)dnl

VERSION="${VERSION_MAJOR}.${VERSION_MINOR}p${VERSION_PATCHLEVEL}"
AC_SUBST(VERSION)dnl

PACKAGE="owfs"
AC_SUBST(PACKAGE)dnl

AC_MSG_RESULT(Configuring ${PACKAGE}-${VERSION})

AC_CONFIG_AUX_DIR(src/scripts/install)dnl

AC_CONFIG_MACRO_DIR([src/scripts/m4])

AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE(${PACKAGE}, ${VERSION})dnl

PKG_PROG_PKG_CONFIG
PKG_INSTALLDIR

# Process config.h.in
AH_TOP([
#ifndef OWCONFIG_H
	#define OWCONFIG_H
])
AH_BOTTOM([#endif])
AM_CONFIG_HEADER(src/include/config.h)

AC_PREFIX_DEFAULT(/opt/owfs)dnl

AC_PATH_PROG(ECHO,echo,,$PATH)dnl
AC_PATH_PROG(TEST,test,,$PATH)dnl
AC_PATH_PROG(RM,rm,,$PATH)dnl
AC_PATH_PROG(RPM,rpm,,$PATH)dnl
AC_PATH_PROG(RPMBUILD,rpmbuild,,$PATH)dnl

# swig support
AC_ARG_VAR([SWIG], [path to SWIG utility])
AC_PATH_PROGS([SWIG],[swig swig3.0 swig2.0])

AC_PATH_PROG([SOELIM],[soelim])
AM_CONDITIONAL([SOELIM], [test -n "${SOELIM}"])
# This macro should appair before any other PKG_* macro
PKG_PROG_PKG_CONFIG

# Check for additional programs

# We don't need c++ right now.
#AC_PROG_CXX
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_LIBTOOL_WIN32_DLL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_AWK
AC_LIBTOOL_DLOPEN
AM_PROG_LIBTOOL
AC_SUBST(LIBTOOL_DEPS)

# Supposedly this helps OS X compiling
AC_DEFINE(_DARWIN_C_SOURCE, 1, [Define on Darwin to activate all library features])

HAVE_DEBIAN="false"
AC_MSG_CHECKING([if debian-system is used])
AC_ARG_ENABLE(debian,
[  --enable-debian         Enable debian-system (default false)],
[
	AC_MSG_RESULT([$enableval])
	if test "$enableval" = "yes" ; then
		HAVE_DEBIAN="true"
	fi
],
[
    AC_MSG_RESULT([no (default)])
])
AC_SUBST(HAVE_DEBIAN)
AM_CONDITIONAL(HAVE_DEBIAN, test "${HAVE_DEBIAN}" = "true")


HAVE_DARWIN="false"
HAVE_FREEBSD="false"
HAVE_CYGWIN="false"

AC_MSG_CHECKING([for special host])
case "$host" in
	*-*-cygwin*)
		HAVE_CYGWIN="true"
		CFLAGS="$CFLAGS -mwin32 -g"
		AC_MSG_RESULT([Cygwin])
		;;
	*-darwin*)
		HAVE_DARWIN="true"
		AC_MSG_RESULT([Darwin])
		;;
	*-freebsd*)
		HAVE_FREEBSD="true"
		AC_MSG_RESULT([FreeBSD])
		;;
	*)
		AC_MSG_RESULT([Other host])
		;;
esac
AC_SUBST(HAVE_DARWIN)
AM_CONDITIONAL(HAVE_DARWIN, test "${HAVE_DARWIN}" = "true")
AC_SUBST(HAVE_CYGWIN)
AM_CONDITIONAL(HAVE_CYGWIN, test "${HAVE_CYGWIN}" = "true")
AC_SUBST(HAVE_FREEBSD)
AM_CONDITIONAL(HAVE_FREEBSD, test "${HAVE_FREEBSD}" = "true")

# launchd using the new launch_activate_socket
AC_CHECK_FUNCS(launch_activate_socket)
# AC_CHECK_HEADERS(launch.h)

AM_CPPFLAGS=""
AC_SUBST([AM_CPPFLAGS])

PIC_FLAGS=""
if test "$lt_prog_compiler_pic_works" = yes; then
	PIC_FLAGS="$lt_prog_compiler_pic"
fi
AC_SUBST(PIC_FLAGS)

# Make sure tclConfig.sh is found under /usr/lib64/
# Should perhaps support cross-compiling to other cpu-type too?
LIBPOSTFIX=
case "${host_os}" in
	*linux* )
	case "${host_cpu}" in
		powerpc64 | s390x | x86_64 )
		LIBPOSTFIX="64"
		CFLAGS="$CFLAGS -m64"
		;;
	esac
	;;
esac
AC_SUBST(LIBPOSTFIX)



if test "$cross_compiling" != yes; then
	OW_CHECK_NESTED_FUNCTIONS
fi

OWFSROOT="`pwd`"
AC_SUBST(OWFSROOT)

m4_include([src/scripts/m4/acx_pthread.m4])

# Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_CHECK_HEADERS([asm/types.h arpa/inet.h sys/ioctl.h sys/socket.h sys/time.h sys/times.h sys/types.h sys/param.h sys/uio.h feature_tests.h fcntl.h netinet/in.h stdlib.h string.h strings.h sys/file.h syslog.h termios.h unistd.h limits.h stdint.h features.h getopt.h resolv.h semaphore.h])
AC_CHECK_HEADERS([linux/limits.h linux/types.h netdb.h dlfcn.h])
AC_CHECK_HEADERS(sys/event.h sys/inotify.h)
AC_HEADER_MAJOR

# Test if debugging out enabled
ENABLE_DEBUG="true"
AC_MSG_CHECKING([if debug-output is enabled])
AC_ARG_ENABLE(debug,
[  --enable-debug          Enable debug-output (default true)],
[
	AC_MSG_RESULT([$enableval])
	if ! test "$enableval" = "yes" ; then
		ENABLE_DEBUG="false"
	fi
],
[
	AC_MSG_RESULT([yes (default)])
])
AC_SUBST(ENABLE_DEBUG)
AM_CONDITIONAL(ENABLE_DEBUG, test "${ENABLE_DEBUG}" = "true")

# Test if mutex-debugging is enabled. Should not be enabled for smaller embedded systems
ENABLE_MUTEX_DEBUG="true"
AC_MSG_CHECKING([if mutexdebug is enabled])
AC_ARG_ENABLE(mutexdebug,
[  --enable-mutexdebug     Enable mutexdebug-output (default true)],
[
	AC_MSG_RESULT([$enableval])
	if ! test "$enableval" = "yes" ; then
		ENABLE_MUTEX_DEBUG="false"
	fi
],
[
	AC_MSG_RESULT([yes (default)])
])
AC_SUBST(ENABLE_MUTEX_DEBUG)
AM_CONDITIONAL(ENABLE_MUTEX_DEBUG, test "${ENABLE_MUTEX_DEBUG}" = "true")

# Test if OWSHELL should be supported
ENABLE_OWSHELL="true"
AC_MSG_CHECKING([if OWSHELL support is enabled])
AC_ARG_ENABLE(owshell,
[  --enable-owshell        Enable owshell support (default true)],
[
	AC_MSG_RESULT([$enableval])
	if ! test "$enableval" = "yes" ; then
		ENABLE_OWSHELL="false"
	fi
],
[
	AC_MSG_RESULT([yes (default)])
])
AC_SUBST(ENABLE_OWSHELL)
AM_CONDITIONAL(ENABLE_OWSHELL, test "${ENABLE_OWSHELL}" = "true")

# Test if OWLIB should be supported
ENABLE_OWLIB="true"
AC_MSG_CHECKING([if OWLIB support is enabled])
AC_ARG_ENABLE(owlib,
[  --enable-owlib          Enable owlib support (default true)],
[
	AC_MSG_RESULT([$enableval])
	if ! test "$enableval" = "yes" ; then
		ENABLE_OWLIB="false"
	fi
],
[
    AC_MSG_RESULT([yes (default)])
])
AC_SUBST(ENABLE_OWLIB)
AM_CONDITIONAL(ENABLE_OWLIB, test "${ENABLE_OWLIB}" = "true")

# Test if OWNETLIB should be supported
ENABLE_OWNETLIB="true"
AC_MSG_CHECKING([if OWNETLIB support is enabled])
AC_ARG_ENABLE(ownetlib,
[  --enable-ownetlib       Enable ownetlib support (default true)],
[
	AC_MSG_RESULT([$enableval])
	if ! test "$enableval" = "yes" ; then
		ENABLE_OWNETLIB="false"
	fi
],
[
	AC_MSG_RESULT([yes (default)])
])
AC_SUBST(ENABLE_OWNETLIB)
AM_CONDITIONAL(ENABLE_OWNETLIB, test "${ENABLE_OWNETLIB}" = "true")

# Check for threading
ACX_PTHREAD
if test "$acx_pthread_ok" = "yes"; then
	#CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
	# can't set pthread flags for all compilations, since owshell doesn't need it.
	if test "$cross_compiling" = yes; then
		# We need to link libow.so with -lpthread on some cross-platforms
		# since owtcl.so doesn't work otherwise. -pthread is not enough
		if test x"$PTHREAD_LIBS" = x -a "x$PTHREAD_CFLAGS" = "x-pthread"; then
			AC_MSG_RESULT([add -lpthread to PTHREAD_LIBS])
			PTHREAD_LIBS="-lpthread"
		fi
	fi

	ENABLE_MT="true"
else
	ENABLE_MT="false"
	PTHREAD_CFLAGS=""
	PTHREAD_LIBS=""
	PTHREAD_CC=""
fi

# Check for i2c support
ENABLE_I2C="true"
AC_MSG_CHECKING([if i2c(DS2482-x00) is enabled])
AC_ARG_ENABLE(i2c,
[  --enable-i2c            Enable i2c (DS2482-x00) support (default true)],
[
	AC_MSG_RESULT([$enableval])
	if ! test "$enableval" = "yes" ; then
		ENABLE_I2C="false"
	fi
],
[
	AC_MSG_RESULT([yes (default)])
])

AC_SUBST(ENABLE_I2C)
AM_CONDITIONAL(ENABLE_I2C, test "${ENABLE_I2C}" = "true")


# Check for W1 (linux kernel module)
ENABLE_W1="true"
AC_MSG_CHECKING([if W1 is enabled])
AC_ARG_ENABLE(w1,
[  --enable-w1             Enable w1 support (default true)],
[
	AC_MSG_RESULT([$enableval])
	if ! test "$enableval" = "yes" ; then
		ENABLE_W1="false"
	fi
],
[
	AC_MSG_RESULT([yes (default)])
])
AC_SUBST(ENABLE_W1)
AM_CONDITIONAL(ENABLE_W1, test "${ENABLE_W1}" = "true")


# Check if the modules are enabled

#Check owhttpd
ENABLE_OWHTTPD="true"
AC_MSG_CHECKING(if owhttpd is enabled)
AC_ARG_ENABLE(owhttpd,
[  --enable-owhttpd        Enable owhttpd module (default true)],
[
	AC_MSG_RESULT([$enableval])
	if test ! "$enableval" = "yes" ; then
		ENABLE_OWHTTPD="false"
	else
		ENABLE_OWLIB="true"
	fi
],
[
	ENABLE_OWLIB="true"
	AC_MSG_RESULT([yes (default)])
])
AC_SUBST(ENABLE_OWHTTPD)
AM_CONDITIONAL(ENABLE_OWHTTPD, test "${ENABLE_OWHTTPD}" = "true")

#Check owftpd
ENABLE_OWFTPD="true"
AC_MSG_CHECKING(if owftpd is enabled)
AC_ARG_ENABLE(owftpd,
[  --enable-owftpd         Enable owftpd module (default true)],
[
	AC_MSG_RESULT([$enableval])
	if test ! "$enableval" = "yes" ; then
		ENABLE_OWFTPD="false"
	else
#		if test ! "${ENABLE_MT}" = "true" ; then
#			AC_MSG_ERROR([owftpd needs multithreading])
#		fi
		ENABLE_OWLIB="true"
	fi
],
[
	if test "${ENABLE_MT}" = "true" ; then
		ENABLE_OWLIB="true"
		AC_MSG_RESULT([yes (default)])
	else
		ENABLE_OWFTPD="false"
		AC_MSG_RESULT([no (multithreading needed)])
	fi
])
AC_SUBST(ENABLE_OWFTPD)
AM_CONDITIONAL(ENABLE_OWFTPD, test "${ENABLE_OWFTPD}" = "true")


#Check owserver
AC_MSG_CHECKING(if owserver is enabled)
ENABLE_OWSERVER="true"
AC_ARG_ENABLE(owserver,
[  --enable-owserver       Enable owserver module (default true)],
[
	AC_MSG_RESULT([$enableval])
	if test ! "$enableval" = "yes" ; then
		ENABLE_OWSERVER="false"
	else
		ENABLE_OWLIB="true"
	fi
],
[
	ENABLE_OWLIB="true"
	AC_MSG_RESULT([yes (default)])
])
AC_SUBST(ENABLE_OWSERVER)
AM_CONDITIONAL(ENABLE_OWSERVER, test "${ENABLE_OWSERVER}" = "true")

#Check owexternal
AC_MSG_CHECKING(if owexternal is enabled)
ENABLE_OWEXTERNAL="true"
AC_ARG_ENABLE(owexternal,
[  --enable-owexternal     Enable owexternal module (default true)],
[
	AC_MSG_RESULT([$enableval])
	if test ! "$enableval" = "yes" ; then
		ENABLE_OWEXTERNAL="false"
	else
		ENABLE_OWLIB="true"
	fi
],
[
	ENABLE_OWLIB="true"
	AC_MSG_RESULT([yes (default)])
])
AC_SUBST(ENABLE_OWEXTERNAL)
AM_CONDITIONAL(ENABLE_OWEXTERNAL, test "${ENABLE_OWEXTERNAL}" = "true")

#Check ownet
ENABLE_OWNET="true"
AC_MSG_CHECKING(if ownet is enabled)
AC_ARG_ENABLE(ownet,
[  --enable-ownet          Enable ownet module (default true)],
[
	AC_MSG_RESULT([$enableval])
	if test ! "$enableval" = "yes" ; then
		ENABLE_OWNET="false"
	else
		ENABLE_OWLIB="true"
	fi
],
[
	ENABLE_OWLIB="true"
	AC_MSG_RESULT([yes (default)])
])
AC_SUBST(ENABLE_OWNET)
AM_CONDITIONAL(ENABLE_OWNET, test "${ENABLE_OWNET}" = "true")


#Check owtap
ENABLE_OWTAP="true"
AC_MSG_CHECKING(if owtap is enabled)
AC_ARG_ENABLE(owtap,
[  --enable-owtap          Enable owtap module (default true)],
[
	AC_MSG_RESULT([$enableval])
	if test ! "$enableval" = "yes" ; then
		ENABLE_OWTAP="false"
	fi
],
[
	AC_MSG_RESULT([yes (default)])
])
AC_SUBST(ENABLE_OWTAP)
AM_CONDITIONAL(ENABLE_OWTAP, test "${ENABLE_OWTAP}" = "true")


#Check owmalloc (special memory allocation routines)
ENABLE_OWMALLOC="false"
AC_MSG_CHECKING(if owmalloc is enabled)
AC_ARG_ENABLE(owmalloc,
[  --enable-owmalloc       Enable owmalloc checking (default false)],
[
	AC_MSG_RESULT([$enableval])
	if test "$enableval" = "yes" ; then
		ENABLE_OWMALLOC="true"
	fi
],
[
	AC_MSG_RESULT([no (default)])
])
AC_SUBST(ENABLE_OWMALLOC)
AM_CONDITIONAL(ENABLE_OWMALLOC, test "${ENABLE_OWMALLOC}" = "true")


#Check owmon
AC_MSG_CHECKING(if owmon is enabled)
ENABLE_OWMON="true"
AC_ARG_ENABLE(owmon,
[  --enable-owmon          Enable owmon module (default true)],
[
	AC_MSG_RESULT([$enableval])
	if test ! "$enableval" = "yes" ; then
		ENABLE_OWMON="false"
	fi
],
[
	AC_MSG_RESULT([yes (default)])
])
AC_SUBST(ENABLE_OWMON)
AM_CONDITIONAL(ENABLE_OWMON, test "${ENABLE_OWMON}" = "true")

#Check owcapi
AC_MSG_CHECKING(if owcapi is enabled)
ENABLE_OWCAPI="true"
AC_ARG_ENABLE(owcapi,
[  --enable-owcapi         Enable owcapi module (default true)],
[
	AC_MSG_RESULT([$enableval])
	if test ! "$enableval" = "yes" ; then
		ENABLE_OWCAPI="false"
	else
		ENABLE_OWLIB="true"
	fi
],
[
	ENABLE_OWLIB="true"
	AC_MSG_RESULT([yes (default)])
])
AC_SUBST(ENABLE_OWCAPI)
AM_CONDITIONAL(ENABLE_OWCAPI, test "${ENABLE_OWCAPI}" = "true")


#Check swig
AC_MSG_CHECKING(if swig is enabled)
if test -z "$SWIG"  ; then
	ENABLE_SWIG="false"
else
	ENABLE_SWIG="auto"
fi
AC_ARG_ENABLE(swig,
[  --enable-swig           Enable swig (default auto)],
[
	if test "$enableval" = "no"; then
		ENABLE_SWIG="false"
		SWIG=""
		AC_MSG_RESULT([no])
	else
		if test -z "$SWIG"; then
			AC_MSG_ERROR([Swig is not found and could not be enabled])
		fi
		ENABLE_OWLIB="true"
		ENABLE_SWIG="true"
		AC_MSG_RESULT([yes])
	fi
],
[
	AC_MSG_RESULT([auto (default)])
])
if test "${HAVE_CYGWIN}" = "true"; then
	if test ! "$ENABLE_SWIG" = "true"; then
		ENABLE_SWIG="false"
		SWIG=""
		AC_MSG_RESULT([(Disable swig by default in Cygwin)])
	fi
else
	if test "$ENABLE_SWIG" = "auto"; then
		ENABLE_SWIG="true"
	fi
fi
AC_SUBST(ENABLE_SWIG)
AM_CONDITIONAL(ENABLE_SWIG, test "${ENABLE_SWIG}" = "true")

#Check owperl
AC_MSG_CHECKING(if owperl is enabled)
ENABLE_OWPERL="true"
AC_ARG_ENABLE(owperl,
[  --enable-owperl         Enable owperl module (default true)],
[
	AC_MSG_RESULT([$enableval])
	if test ! "$enableval" = "yes" ; then
		ENABLE_OWPERL="false"
	else
		if test -z "$SWIG"  ; then
			AC_MSG_WARN([Cannot find swig program. Look for it at http://www.swig.org or use CPAN])
			AC_MSG_WARN([OWPERL is disabled because swig is not found])
			ENABLE_OWPERL="false"
		fi
	fi
],
[
	if test -z "$SWIG" ; then
		AC_MSG_RESULT([no (swig disabled)])
		ENABLE_OWPERL="false"
	else
		AC_MSG_RESULT([yes (default)])
	fi
])

PERL=""
if test "${ENABLE_OWPERL}" = "true"; then
	m4_include(module/swig/perl5/perl5.m4)
	AC_MSG_RESULT(Looking for location of Perl executable)
	SC_PATH_PERL5
	AC_SUBST(PERL5EXT)
	AC_SUBST(PERL5DYNAMICLINKING)
	AC_SUBST(PERL5LIB)
	AC_SUBST(PERL5DIR)
	AC_SUBST(PERL5NAME)
	AC_SUBST(PERL5CCFLAGS)
	if test -z "${PERL}" ; then
		AC_MSG_WARN([Cannot find perl binary.])
		AC_MSG_WARN([OWPERL is disabled because perl binary is not found])
		ENABLE_OWPERL="false"
	else
		if test -z "${PERL5NAME}" ; then
			AC_MSG_WARN([Cannot find perl library. Install perl-devel package.])
			AC_MSG_WARN([OWPERL is disabled because perl library is not found])
			ENABLE_OWPERL="false"
		fi
	fi
fi
AC_SUBST(PERL)
AC_SUBST(ENABLE_OWPERL)
AM_CONDITIONAL(ENABLE_OWPERL, test "${ENABLE_OWPERL}" = "true")
if test -z "$PERL" ; then
	ENABLE_PERL="false"
else
	ENABLE_PERL="true"
fi
AC_SUBST(ENABLE_PERL)
AM_CONDITIONAL(ENABLE_PERL, test "${ENABLE_PERL}" = "true")

#Check owphp
AC_MSG_CHECKING(if owphp is enabled)
ENABLE_OWPHP="true"
AC_ARG_ENABLE(owphp,
	[AS_HELP_STRING([--enable-owphp],
		[Enable owphp module (default true)])],
	[
	AC_MSG_RESULT([$enableval])
	if test "$enableval" = "no" ; then
		ENABLE_OWPHP="false"
	fi
	if test "$enableval" = "yes" ; then
		ENABLE_OWPHP="true"
	fi
	if test -z "$SWIG"  ; then
		AC_MSG_WARN([OWPHP is disabled because swig is not found])
		ENABLE_OWPHP="false"
	fi
	],
	[
	if test -z "$SWIG" ; then
		AC_MSG_RESULT([no (swig disabled)])
		ENABLE_OWPHP="false"
	else
		AC_MSG_RESULT([yes (default)])
	fi
	])

PHP=""
PHPVMAJOR=""
if test "${ENABLE_OWPHP}" = "true" ; then
	m4_include(module/swig/php/php.m4)
	AC_MSG_NOTICE([Looking for location of php executable])
	SC_PATH_PHP
	AC_SUBST(PHPCONFIG)
	AC_SUBST(PHPINC)
	AC_SUBST(PHPEXT)
	AC_SUBST(PHPLIBDIR)
	if test -z "${PHP}" ; then
		AC_MSG_WARN([Cannot find php binary. Install php or php5 package])
		AC_MSG_WARN([OWPHP is disabled because php binary is not found])
		ENABLE_OWPHP="false"
	else
		if test -z "${PHPCONFIG}" ; then
			AC_MSG_WARN([Cannot find php-config binary. Install php-devel or php5-dev package])
		fi
		if test -z "${PHPINC}" ; then
			AC_MSG_WARN([Cannot find php include-file. Install php-devel or php5-dev package])
			AC_MSG_WARN([OWPHP is disabled because php include-file is not found])
			ENABLE_OWPHP="false"
		else
			if test -z "${PHPLIBDIR}" ; then
				AC_MSG_WARN([Cannot find php extension-dir. Install php-devel or php5-dev package])
				AC_MSG_WARN([OWPHP is disabled because php extension-dir is not found])
				ENABLE_OWPHP="false"
			fi
		fi
	fi
fi
AC_SUBST(PHP)
AC_SUBST(ENABLE_OWPHP)
AM_CONDITIONAL(PHP7, test "${PHPVMAJOR}" = "7")
AM_CONDITIONAL(ENABLE_OWPHP, test "${ENABLE_OWPHP}" = "true")
if test -z "$PHP" ; then
	ENABLE_PHP="false"
else
	ENABLE_PHP="true"
fi
AC_SUBST(ENABLE_PHP)
AM_CONDITIONAL(ENABLE_PHP, test "${ENABLE_PHP}" = "true")


#Check owpython
AC_MSG_CHECKING(if owpython is enabled)
ENABLE_OWPYTHON="true"
AC_ARG_ENABLE(owpython,
[  --enable-owpython       Enable owpython module (default true)],
[
	AC_MSG_RESULT([$enableval])
	if test "$enableval" = "no" ; then
		ENABLE_OWPYTHON="false"
	fi
	if test "$enableval" = "yes" ; then
		ENABLE_OWPYTHON="true"
		if test -z "$SWIG"  ; then
			AC_MSG_WARN([Cannot find swig program. Look for it at http://www.swig.org or use CPAN])
			AC_MSG_WARN([OWPYTHON is disabled because swig is not found])
			ENABLE_OWPYTHON="false"
		fi
	fi
],
[
	if test -z "$SWIG" ; then
		AC_MSG_RESULT([no (swig disabled)])
		ENABLE_OWPYTHON="false"
	else
		AC_MSG_RESULT([yes (default)])
	fi
])

PYTHON=""
if test "${ENABLE_OWPYTHON}" = "true" ; then
	m4_include(module/swig/python/python.m4)
	AC_MSG_RESULT(Looking for location of Python executable)
	SC_PATH_PYTHON
	AC_SUBST(PYVERSION)
	AC_SUBST(PYSITEDIR)
	AC_SUBST(PYTHONDYNAMICLINKING)
	if test -z "${PYTHON}" ; then
		AC_MSG_WARN([Cannot find python binary. Install python package.])
		AC_MSG_WARN([OWPYTHON is disabled because python binary is not found])
		ENABLE_OWPYTHON="false"
	else
		if test -z "${PYLDFLAGS}" ; then
			AC_MSG_WARN([Cannot find python library. Install python-devel package.])
			AC_MSG_WARN([OWPYTHON is disabled because python library is not found])
			ENABLE_OWPYTHON="false"
		else
			if test -z "${PYCFLAGS}" ; then
				AC_MSG_WARN([Cannot find python include-file. Install python-devel package.])
				AC_MSG_WARN([OWPYTHON is disabled because python include-file is not found])
				ENABLE_OWPYTHON="false"
			fi
		fi
	fi
fi
AC_SUBST(ENABLE_OWPYTHON)
AM_CONDITIONAL(ENABLE_OWPYTHON, test "${ENABLE_OWPYTHON}" = "true")
AC_SUBST(PYTHON)
if test -z "$PYTHON" ; then
	ENABLE_PYTHON="false"
else
	ENABLE_PYTHON="true"
fi
AC_SUBST(ENABLE_PYTHON)
AM_CONDITIONAL(ENABLE_PYTHON, test "${ENABLE_PYTHON}" = "true")

#Check owtcl
AC_MSG_CHECKING(if owtcl is enabled)
ENABLE_OWTCL="true"
AC_ARG_ENABLE(owtcl,
[  --enable-owtcl          Enable owtcl module (default true)],
[
	AC_MSG_RESULT([$enableval])
	if test "$enableval" = "no" ; then
		ENABLE_OWTCL="false"
	fi
	if test "$enableval" = "yes" ; then
		ENABLE_OWTCL="true"
	fi
],
[
	AC_MSG_RESULT([yes (default)])
])

if test "${ENABLE_OWTCL}" = "true" ; then
	m4_include(module/owtcl/tcl.m4)
	AC_MSG_RESULT(Looking for tclConfig.sh)
	SC_PATH_TCLCONFIG
	if test -z "$TCL_BIN_DIR" -o ! -f "$TCL_BIN_DIR/tclConfig.sh" ; then
		AC_MSG_WARN([OWTCL is disabled because tclConfig.sh is not found])
		ENABLE_OWTCL="false"
	else
		SC_LOAD_TCLCONFIG
		AC_SUBST(TCL_BIN_DIR)
		AC_SUBST(TCL_SHLIB_CFLAGS)
		AC_SUBST(TCL_SHLIB_LD)
		AC_SUBST(TCL_SHLIB_LD_LIBS)
		AC_SUBST(TCL_SHLIB_SUFFIX)
		AC_SUBST(TCL_VERSION)
		AC_SUBST(TCL_PREFIX)
		AC_SUBST(TCL_EXEC_PREFIX)
		AC_SUBST(TCL_CFLAGS)
		AC_SUBST(TCL_DEFS)
		AC_SUBST(TCL_LIB_SPEC)
		AC_SUBST(TCL_LIBS)
		AC_SUBST(TCL_LD_FLAGS)
		AC_SUBST(TCL_COMPAT_OBJS)
		AC_SUBST(TCL_LD_SEARCH_FLAGS)
		AC_SUBST(TCL_SRC_DIR)
		AC_SUBST(TCL_LIB_SPEC)
		AC_SUBST(TCL_STUB_LIB_SPEC)
		AC_SUBST(TCL_BUILD_LIB_SPEC)
		AC_SUBST(TCL_BUILD_STUB_LIB_SPEC)
		AC_SUBST(TCL_INCLUDE_SPEC)
		AC_SUBST(TCL_PACKAGE_PATH)
		# guess that tcl will install the files under the first path in
		# TCL_PACKAGE_PATH. TCL_BIN_DIR is usually correct, but this
		# might contain staging_dir prefix when cross-compiling.
		OWTCL_INSTALL_PATH="`echo ${TCL_PACKAGE_PATH} | cut -d' ' -f1`"
		case "${host_cpu}-${host_os}" in
			*-darwin*)
				OWTCL_INSTALL_PATH="`echo ${TCL_BIN_DIR} | cut -d' ' -f1`"
				;;
			*)
				OWTCL_INSTALL_PATH="`echo ${TCL_PACKAGE_PATH} | cut -d' ' -f1`"
				;;
		esac
		# Debian Hack: do not install in /usr/local/lib/tcltk
		OWTCL_INSTALL_PATH="/usr/lib/tcltk"
		AC_SUBST(OWTCL_INSTALL_PATH)
	fi
fi
AC_SUBST(ENABLE_OWTCL)
AM_CONDITIONAL(ENABLE_OWTCL, test "${ENABLE_OWTCL}" = "true")


AC_DEFUN([ACX_EXPAND], [
	EXP_VAR=[$1]
	FROM_VAR=[$2]

	dnl first expand prefix and exec_prefix if necessary
	prefix_save=$prefix
	exec_prefix_save=$exec_prefix

	dnl if no prefix given, then use /usr/local, the default prefix
	if test "x$prefix" = "xNONE"; then
		prefix=$ac_default_prefix
	fi
	dnl if no exec_prefix given, then use prefix
	if test "x$exec_prefix" = "xNONE"; then
		exec_prefix=$prefix
	fi

	full_var="$FROM_VAR"
	dnl loop until it doesnt change anymore
	while true; do
		new_full_var="`eval echo $full_var`"
		if test "x$new_full_var"="x$full_var"; then break; fi
		full_var=$new_full_var
	done

	dnl clean up
	full_var=$new_full_var
	AC_SUBST([$1], "$full_var")

	dnl restore prefix and exec_prefix
	prefix=$prefix_save
	exec_prefix=$exec_prefix_save
]) dnl ACX_EXPAND

ACX_EXPAND(LIBDIR, $libdir)
ACX_EXPAND(BINDIR, $bindir)
ACX_EXPAND(DATADIR, $datadir)

EXTRACFLAGS="-D_FILE_OFFSET_BITS=64"
AC_MSG_CHECKING([if cflag _XOPEN_SOURCE is required])
case "${host_cpu}-${host_os}" in
	*-aix* | *solaris* | *-osf* | *-hpux*)
		CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500"
		EXTRACFLAGS="$EXTRACFLAGS -D_XOPEN_SOURCE=500"
		AC_MSG_RESULT([-D_XOPEN_SOURCE=500])
	;;
	*-darwin* | *-netbsd*)
		AC_MSG_RESULT([no])
	;;
	*-freebsd* | *)
		# have to add this to support pthread_rwlock_t
		CFLAGS="$CFLAGS -D_XOPEN_SOURCE=600"
		EXTRACFLAGS="$EXTRACFLAGS -D_XOPEN_SOURCE=600"
		AC_MSG_RESULT([-D_XOPEN_SOURCE=600])
	;;
esac

AC_MSG_CHECKING([if cflag _BSD_SOURCE is required])
case "${host_cpu}-${host_os}" in
 	*-netbsd*)
 		CFLAGS="$CFLAGS -D_NETBSD_SOURCE=1"
 		EXTRACFLAGS="$EXTRACFLAGS -D_NETBSD_SOURCE=1"
 		{ $as_echo "$as_me:${as_lineno-$LINENO}: result: -D_NETBSD_SOURCE=1" >&5 $as_echo "-D_NETBSD_SOURCE=1" >&6; }
 	;;
	*)
		# have to add -D_BSD_SOURCE=1 to support major() in sys/sysmacros.h
		# have to add -D_ISOC99_SOURCE=1 to support lrint() in bits/mathcalls.h
                # have to add -D_POSIX_C_SOURCE=200112L for sem_timedwait
                # have to add -D_POSIX_C_SOURCE=199309L for clock_gettime()
		CFLAGS="$CFLAGS -D_BSD_SOURCE=1 -D_ISOC99_SOURCE=1 -D_POSIX_C_SOURCE=200112L -D_DEFAULT_SOURCE"
		EXTRACFLAGS="$EXTRACFLAGS -D_BSD_SOURCE=1 -D_ISOC99_SOURCE=1 -D_POSIX_C_SOURCE=200112L -D_DEFAULT_SOURCE"
		AC_MSG_RESULT([-D_BSD_SOURCE=1 -D_ISOC99_SOURCE=1 -D_POSIX_C_SOURCE=200112L -D_DEFAULT_SOURCE])
	;;
esac

# should perhaps add _GNU_SOURCE=1 instead of the two defines above...
# That would define _BSD_SOURCE, _SVID_SOURCE, _LARGEFILE64_SOURCE,
# _XOPEN_SOURCE=600, _POSIX_C_SOURCE, _POSIX_SOURCE, _ISOC99_SOURCE


# Check if extra libs are needed. Should perhaps test if they are available too
# instead of hardcoding the libraries.
EXTRALIBS=""
AC_MSG_CHECKING([if extra libs are required])
case "${host_cpu}-${host_os}" in
	*-darwin*)
		# This will actually be duplicates if libusb is used.
		OSLIBS="-Wl,-framework -Wl,IOKit -Wl,-framework -Wl,CoreFoundation"
		EXTRALIBS=""
		AC_MSG_RESULT([${OSLIBS}])
		;;
	*-solaris*)
		OSLIBS=""
		EXTRALIBS=" -lsocket -lnsl "
		LIBS="$LIBS -lsocket -lnsl"
		AC_MSG_RESULT([${EXTRALIBS}])
		;;
	*)
		OSLIBS=""
		EXTRALIBS=""
		AC_MSG_RESULT([${EXTRALIBS}])
		;;
esac

#Check for profiling
AC_MSG_CHECKING(if profiling is enabled)
ENABLE_PROFILING="false"
AC_ARG_ENABLE(profiling,
[  --enable-profiling      Enable profiling (default false)],
[
	AC_MSG_RESULT([$enableval])
	if test "$enableval" = "yes" ; then
		ENABLE_PROFILING=true
		EXTRALIBS="$EXTRALIBS -pg"
		EXTRACFLAGS="$EXTRACFLAGS -pg"
	fi
],
[
	AC_MSG_RESULT([no (default)])
])
AC_SUBST(EXTRACFLAGS)
AC_SUBST(ENABLE_PROFILING)
AM_CONDITIONAL(ENABLE_PROFILING, test "${ENABLE_PROFILING}" = "true")
ACX_EXPAND(LD_EXTRALIBS, $EXTRALIBS)
AC_SUBST(LD_EXTRALIBS)
AC_SUBST(OSLIBS)
AC_MSG_WARN([LD_EXTRALIBS=${LD_EXTRALIBS} OSLIBS=${OSLIBS}])

AC_ARG_WITH(fuseinclude,
            [  --with-fuseinclude=DIR  FUSE-include from @<:@/usr/local/include@:>@],
            [fuse_include_path=$withval],
            [fuse_include_path='/usr/local/include'])
AC_SUBST(fuse_include_path)

AC_ARG_WITH(fuselib,
            [  --with-fuselib=DIR      FUSE-lib from @<:@/usr/local/lib@:>@],
            [fuse_lib_path=$withval],
            [fuse_lib_path='/usr/local/lib'])
AC_SUBST(fuse_lib_path)


#Check owfs
AC_MSG_CHECKING([if owfs is enabled])
ENABLE_OWFS="auto"
AC_ARG_ENABLE(owfs,
[  --enable-owfs           Enable owfs module (default auto)],
[
	AC_MSG_RESULT([$enableval])
	if test "$enableval" = "yes" ; then
		ENABLE_OWFS="true"
	fi
	if test "$enableval" = "no" ; then
		ENABLE_OWFS="false"
	fi
],
[
    AC_MSG_RESULT([auto (default)])
])

# We need fuse only if OWFS is enabled
if test "${ENABLE_OWFS}" != "false" ; then

	save_LD_EXTRALIBS="$LD_EXTRALIBS"
	save_CPPFLAGS="$CPPFLAGS"
	save_LDFLAGS="$LDFLAGS"
	FUSE_FLAGS="-DFUSE_USE_VERSION=26"
	FUSE_INCLUDES="-I${fuse_include_path}"
	FUSE_LIBS="-L${fuse_lib_path}"
	LD_EXTRALIBS="$save_LD_EXTRALIBS "
	CPPFLAGS="$save_CPPFLAGS -D_FILE_OFFSET_BITS=64 $FUSE_FLAGS $FUSE_INCLUDES"
	LDFLAGS="$save_LDFLAGS $FUSE_LIBS"

	AC_CHECK_HEADER(fuse.h,,[
	AC_MSG_WARN([
	Cannot find fuse.h - Add the search path with --with-fuseinclude])

	FUSE_FLAGS=""
	FUSE_INCLUDES=""
	FUSE_LIBS=""
	LD_EXTRALIBS="$save_LD_EXTRALIBS"
	CPPFLAGS="$save_CPPFLAGS -D_FILE_OFFSET_BITS=64"
	LDFLAGS="$save_LDFLAGS"

	AC_MSG_WARN([Install FUSE-2.2 or later to enable owfs - download it from http://fuse.sourceforge.net/])

	if test "${ENABLE_OWFS}" = "auto"; then
		AC_MSG_WARN([OWFS is disabled because fuse.h is not found.])
		ENABLE_OWFS="false"
	else
		AC_MSG_ERROR([Configure without --enable-owfs to detect fuse automatically.])
	fi
	])

	if test "${ENABLE_OWFS}" != "false"; then
	save_CFLAGS="$CFLAGS"
	save_LIBS="$LIBS"
	CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
	LIBS="$LIBS $PTHREAD_LIBS"
	AC_CHECK_LIB(fuse,fuse_main, [FUSE_LIBS="$FUSE_LIBS -lfuse"],[
		AC_MSG_WARN([
	Cannot find libfuse.a - add the search path with --with-fuselib])
		AC_MSG_WARN([Running ldconfig or adding "/usr/local/lib" to /etc/ld.so.conf might also solve the problem, otherwise re-install fuse.])
		if test "${ENABLE_OWFS}" = "auto"; then
			AC_MSG_WARN([OWFS is disabled because libfuse.a is not found.])
			ENABLE_OWFS="false"
		else
			AC_MSG_ERROR([Cannot enable OWFS])
		fi
		],)
	CFLAGS="$save_CFLAGS"
	LIBS="$save_LIBS"
	fi


	if test "${ENABLE_OWFS}" != "false"; then
		# check for a supported FUSE_MAJOR_VERSION.
		AC_MSG_CHECKING([For supported FUSE API version])
		AC_COMPILE_IFELSE([
		AC_LANG_PROGRAM([[#include <fuse.h>]],
		[[
		#ifndef FUSE_MAJOR_VERSION
		#error "FUSE_MAJOR_VERSION not defined"
		#endif
		]])],
		[AC_MSG_RESULT([yes])],
		[AC_MSG_RESULT([no])
		AC_MSG_WARN([OWFS is disabled since fuse.h is too old])
		if test "${ENABLE_OWFS}" = "true"; then
			AC_MSG_ERROR([You have to install fuse first (fuse-2.2 or later recommended) - download it from http://fuse.sourceforge.net/])
		else
			ENABLE_OWFS="false"
		fi
		])
	fi


	# Use newest FUSE API if version is newer than 2.2
	if test "${ENABLE_OWFS}" != "false"; then
		# check for a supported FUSE_MAJOR_VERSION.
		AC_MSG_CHECKING([For FUSE version ])
		AC_COMPILE_IFELSE([
		AC_LANG_PROGRAM([[#include <fuse.h>]],
		[[
		#ifndef FUSE_VERSION
			#ifndef FUSE_MAJOR_VERSION
				#define FUSE_VERSION 11
			#else /* FUSE_MAJOR_VERSION */
				#undef FUSE_MAKE_VERSION
				#define FUSE_MAKE_VERSION(maj,min)  ((maj) * 10 + (min))
				#define FUSE_VERSION FUSE_MAKE_VERSION(FUSE_MAJOR_VERSION,FUSE_MINOR_VERSION)
			#endif /* FUSE_MAJOR_VERSION */
		#endif /* FUSE_VERSION */
		#if (FUSE_VERSION >= 22)
			/* Fuse > 2.2 is ok */
		#else
			#error "Fuse < 2.2"
		#endif
		]])],
		[AC_MSG_RESULT([2.2 or later])
		],
		[AC_MSG_RESULT([<2.2])
		FUSE_FLAGS=""
		])
	fi

	CPPFLAGS="$save_CPPFLAGS"
	LDFLAGS="$save_LDFLAGS"
	LD_EXTRALIBS="$save_LD_EXTRALIBS"

	if test "${ENABLE_OWFS}" != "false"; then
		ENABLE_OWLIB="true"
		ENABLE_OWFS="true"
	fi
else
    ENABLE_OWFS="false"
fi
AC_SUBST(FUSE_LIBS)
AC_SUBST(FUSE_FLAGS)
AC_SUBST(FUSE_INCLUDES)
AC_SUBST(ENABLE_OWFS)
AM_CONDITIONAL(ENABLE_OWFS, test "${ENABLE_OWFS}" = "true")

# Check if the zeroconf/bonjour is enabled.
AC_MSG_CHECKING(if zeroconf/bonjour is enabled)
ENABLE_ZERO="true"
AC_ARG_ENABLE(zero,
[  --enable-zero           Enable zeroconf/bonjour (default true)],
[
	AC_MSG_RESULT([$enableval])

	if test ! "$enableval" = "yes" ; then
		ENABLE_ZERO=false
	fi
],
[
	AC_MSG_RESULT([yes (default)])
])
AC_SUBST(ENABLE_ZERO)
AM_CONDITIONAL(ENABLE_ZERO, test "${ENABLE_ZERO}" = "true")


LIBUSB_CFLAGS=""
LIBUSB_LIBS=""


# Check for USB enabled
ENABLE_USB=auto
AC_MSG_CHECKING([if usb support is enabled])

AC_ARG_ENABLE(usb,
[  --enable-usb            Enable 1-Wire usb DS2490 support (default auto)],
[
	AC_MSG_RESULT([$enableval])

	if ! test "$enableval" = "yes" ; then
		ENABLE_USB=false
	fi
],
[
	AC_MSG_RESULT([auto (default)])
])

if test "${ENABLE_USB}" != "false"; then
	#LIBUSB_CONFIG
	PKG_CHECK_MODULES([LIBUSB], [libusb-1.0 >= 0.9.1], [ENABLE_USB=true],[ENABLE_USB=false])
fi

AC_SUBST(LIBUSB_CFLAGS)
AC_SUBST(LIBUSB_LIBS)
AC_SUBST(ENABLE_USB)
AM_CONDITIONAL(ENABLE_USB, test "${ENABLE_USB}" = "true")

AM_CPPFLAGS="$AM_CPPFLAGS $LIBUSB_CFLAGS"

# Check for Avahi enabled
ENABLE_AVAHI=auto
AC_MSG_CHECKING([if Avahi support is enabled])

AC_ARG_ENABLE(avahi,
[  --enable-avahi          Enable zero-config autodiscovery (default auto)],
[
	AC_MSG_RESULT([$enableval])

	if ! test "$enableval" = "yes" ; then
		ENABLE_AVAHI=false
	fi
],
[
	AC_MSG_RESULT([auto (default)])
])

if test "${ENABLE_AVAHI}" != "false"; then

	# Include libavahi if the avahi is enabled
	if test "X${LIBAVAHI_CONFIG}" != "X" ; then

		LIBAVAHI_CFLAGS=`$LIBAVAHI_CONFIG --cflags`
		LIBAVAHI_LIBS=`$LIBAVAHI_CONFIG --libs`

		save_CPPFLAGS="$CPPFLAGS"
		save_LDFLAGS="$LDFLAGS"
		CPPFLAGS="$save_CPPFLAGS $LIBAVAHI_CFLAGS"
		LDFLAGS="$save_LDFLAGS $LIBAVAHI_LIBS"

		AC_MSG_CHECKING([if libavahi compiles with includes+lib ])
		AC_COMPILE_IFELSE([
		AC_LANG_PROGRAM([[#include <avahi-chient/client.h>]],
		[[
			avahi_client_new(NULL,0,NULL);
		]])],
		[AC_MSG_RESULT([ok])],
		[AC_MSG_RESULT([compilation error])
		LIBAVAHI_CFLAGS=""
		LIBAVAHI_LDFLAGS=""
		LIBAVAHI_CONFIG=""
		])

		CPPFLAGS="$save_CPPFLAGS"
		LDFLAGS="$save_LDFLAGS"

		#LIBAVAHI_CONFIG
	fi

	# ultimate test to see if libavahi is found after AC_CHECK_LIB
	if test "X${LIBAVAHI_CONFIG}" == "X"; then

	    PKG_CHECK_MODULES([LIBAVAHI], [avahi-client], [ dnl ok, avahi found with pkg-config
	    ],[ dnl else trying basic detection
		AC_CHECK_LIB(avahi-common,avahi_threaded_poll_new,[
			AC_CHECK_LIB(avahi-client,avahi_client_new,[
				LIBAVAHI_LIBS="-lavahi-client -lavahi-common"],[
				AC_MSG_WARN([Cannot find libavahi-client])
				if test "${ENABLE_AVAHI}" = "true" ; then
					AC_MSG_ERROR([libavahi must be installed to use a Avahi zero-configuration])
				else
					AC_MSG_WARN([libavahi not found, avahi will be disabled])
					ENABLE_AVAHI=false
				fi
			],)],[
			AC_MSG_WARN([Cannot find libavahi-common])
			if test "${ENABLE_AVAHI}" = "true" ; then
				AC_MSG_ERROR([libavahi must be installed to use a Avahi zero-configuration])
			else
				AC_MSG_WARN([libavahi not found, avahi will be disabled])
				ENABLE_AVAHI=false
			fi
		],)
	    ])

	fi

	if test "${ENABLE_AVAHI}" != "false" ; then
	ENABLE_AVAHI=true
	fi

	# ENABLE_AVAHI
fi

AC_SUBST(LIBAVAHI_CFLAGS)
AC_SUBST(LIBAVAHI_LIBS)
AC_SUBST(ENABLE_AVAHI)
AM_CONDITIONAL(ENABLE_AVAHI, test "${ENABLE_AVAHI}" = "true")

# Check for Parallel port enabled
ENABLE_PARPORT=auto
AC_MSG_CHECKING([if parallel port support is enabled])

AC_ARG_ENABLE(parport,
[  --enable-parport        Enable 1-Wire parallel port DS1410E support (default auto)],
[
	AC_MSG_RESULT([$enableval])

	if ! test "$enableval" = "yes" ; then
		ENABLE_PARPORT=false
	fi
],
[
	AC_MSG_RESULT([yes (default)])
])

# Include linux/ppdev.h if the parallel port is enabled
if test "${ENABLE_PARPORT}" != "false" ; then

	AC_CHECK_HEADER(linux/ppdev.h,,[
		if test "${ENABLE_PARPORT}" = "true" ; then
			AC_MSG_ERROR([ppdev.h must be installed to use parallel port adapter])
		else
			AC_MSG_WARN([ppdev.h not found, parallel port will be disabled])
			ENABLE_PARPORT=false
		fi
	])
	if test "${ENABLE_PARPORT}" != "false" ; then
		ENABLE_PARPORT=true
	fi
fi

AC_SUBST(ENABLE_PARPORT)
AM_CONDITIONAL(ENABLE_PARPORT, test "${ENABLE_PARPORT}" = "true")


dnl We support both libftdi 1.x and libftdi 0.x
if test "$cross_compiling" != yes; then
AC_CHECK_PROGS(LIBFTDI_CONFIG, libftdi1-config libftdi-config)
else
LIBFTDI_CONFIG=""
fi
AC_SUBST(LIBFTDI_CONFIG)

AC_ARG_WITH(libftdi-config,
            [  --with-libftdi-config=PATH Specify full path to libftdi-config or libftdi1-config])
dnl Check if user passed a specific libftdi-config program.
if test "X$with_libftdi_config" != "X" ; then
	LIBFTDI_CONFIG=$with_libftdi_config
fi

if test "$cross_compiling" != yes; then
	if test "X$LIBFTDI_CONFIG" == "X" ; then
		dirs="/usr/bin /usr/local/bin /opt/local/bin"
		for i in $dirs; do
			for prog in libftdi1-config libftdi-config; do
				echo "Testing $i/$prog"
				if test -x $i/$prog; then
					AC_MSG_RESULT($i/$prog is found)
					LIBFTDI_CONFIG="$i/$prog"
					break 2;
				fi
			done
		done
	fi
fi

# Check if FTDI should be enabled
ENABLE_FTDI=auto
AC_MSG_CHECKING([if libftdi is available])

AC_ARG_ENABLE(ftdi,
[  --enable-ftdi          Enable LinkUSB support via libftdi (default auto)],
[
	AC_MSG_RESULT([$enableval])

	if ! test "$enableval" = "yes" ; then
		ENABLE_FTDI=false
	fi
],
[
	AC_MSG_RESULT([auto (default)])
])

# Include ftdi.h if enabled
if test "${ENABLE_FTDI}" != "false" ; then

	LIBFTDI_FOUND=false
	if test "X${LIBFTDI_CONFIG}" != "X" ; then
		LIBFTDI_CFLAGS=`$LIBFTDI_CONFIG --cflags`
		LIBFTDI_LIBS=`$LIBFTDI_CONFIG --libs`

		save_CPPFLAGS="$CPPFLAGS"
		save_LDFLAGS="$LDFLAGS"
		CPPFLAGS="$save_CPPFLAGS $LIBFTDI_CFLAGS"
		LDFLAGS="$save_LDFLAGS $LIBFTDI_LIBS"

		AC_MSG_CHECKING([if libftdi compiles with includes+lib ])
		AC_COMPILE_IFELSE([
		AC_LANG_PROGRAM([[#include <ftdi.h>]],
		[[
			struct ftdi_context ftdic;
			ftdi_init(&ftdic);
		]])],
		[AC_MSG_RESULT([ok])
		FTDI_FOUND=true
		],
		[AC_MSG_RESULT([compilation error])
		LIBFTDI_CFLAGS=""
		LIBFTDI_LDFLAGS=""
		LIBFTDI_CONFIG=""
		])

		CPPFLAGS="$save_CPPFLAGS"
		LDFLAGS="$save_LDFLAGS"
	fi

	if test "${FTDI_FOUND}" = "true"; then
		ENABLE_FTDI=true
	else
		if test "${ENABLE_FTDI}" = "true" ; then
			AC_MSG_ERROR([libftdi must be installed to use LinkUSB natively])
		else
			AC_MSG_WARN([libftdi not found, LinkUSB native will be disabled])
			ENABLE_FTDI=false
		fi
	fi
fi
AC_SUBST(LIBFTDI_CFLAGS)
AC_SUBST(LIBFTDI_LIBS)
AC_SUBST(ENABLE_FTDI)
AM_CONDITIONAL(ENABLE_FTDI, test "${ENABLE_FTDI}" = "true")

if test "${HAVE_CYGWIN}" = "true" ; then
	OW_CYGWIN=1
else
	OW_CYGWIN=0
fi
AC_SUBST(OW_CYGWIN)

if test "${HAVE_DARWIN}" = "true" ; then
	OW_DARWIN=1
else
	OW_DARWIN=0
fi
AC_SUBST(OW_DARWIN)


AC_CHECK_TYPES([struct sockaddr_storage], , ,
[[
	#ifdef HAVE_SYS_TYPES_H
		#include <sys/types.h>
	#endif
	#ifdef HAVE_SYS_SOCKET_H
		#include <sys/socket.h>
	#endif
	#ifdef HAVE_NETINET_IN_H
		#include <netinet/in.h>
	#endif
	#ifdef HAVE_ARPA_INET_H
		#include <arpa/inet.h>
	#endif
]]
)

if test "$ac_cv_type_struct_sockaddr_storage" = no; then
	AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
	[AC_DEFINE(SOCKADDR_IN_HAS_LEN, 1, [Define to 1 if sockaddr_in has a 'sin_len' member.])])
fi
AC_CHECK_TYPES([struct addrinfo], , , [[#include <netdb.h>]])
AC_CHECK_TYPE(socklen_t, ,
[AC_DEFINE([socklen_t], [unsigned int],
[If we do not have a real socklen_t, unsigned int is good enough.])],
[
	#ifdef HAVE_SYS_TYPES_H
		#include <sys/types.h>
	#endif
	#ifdef HAVE_SYS_SOCKET_H
		#include <sys/socket.h>
	#endif
])


AC_MSG_CHECKING(for AF_NETLINK)
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[
	#ifdef HAVE_SYS_TYPES_H
		#include <sys/types.h>
	#endif
	#ifdef HAVE_SYS_SOCKET_H
		#include <sys/socket.h>
	#endif
],
[int ss_family = AF_NETLINK;])],
[
	AC_MSG_RESULT(yes)
	have_af_netlink="yes"
	AC_DEFINE(HAVE_AF_NETLINK, 1, [Have AF_NETLINK in socket.h])
],
[AC_MSG_RESULT(no)
have_af_netlink="no"])

if test "${have_af_netlink}" != "yes" ; then
   if test "${ENABLE_W1}" != "false" ; then
      AC_MSG_WARN([Disable w1 since AF_NETLINK not found])
      ENABLE_W1="false"
   fi
fi


AC_MSG_CHECKING(for broken glibc with __ss_family)
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[
	#ifdef HAVE_SYS_TYPES_H
		#include <sys/types.h>
	#endif
	#ifdef HAVE_SYS_SOCKET_H
		#include <sys/socket.h>
	#endif
],
[struct sockaddr_storage s; s.__ss_family = AF_INET;])],
[
	AC_MSG_RESULT(yes)
	AC_DEFINE(HAVE_BROKEN_SS_FAMILY, 1, [Broken glibc implementations use __ss_family instead of ss_family.])
],
[AC_MSG_RESULT(no)])


AC_MSG_CHECKING([for core ipv6 support])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
	[[#define IN_AUTOCONF
	#include "include/stdinc.h"]],
	[[struct sockaddr_in6 s;
	  struct sockaddr_storage t;
	    s.sin6_family = 0;]]
	    )],
[
	if test "${HAVE_CYGWIN}" = "true" ; then
		AC_MSG_RESULT([no, Cygwins ipv6 is incomplete])
		AC_DEFINE(__HAS_IPV6__, 0, [No ipv6 support available.])
		have_v6=no
	else
		have_v6=yes
		AC_DEFINE(IPV6, 1, [Define if ipv6 support is present and available.])
		AC_DEFINE(__HAS_IPV6__, 1, [Define if ipv6 support is present and available.])
		AC_MSG_RESULT(yes)
		AC_MSG_CHECKING([for struct in6addr_any])
		AC_COMPILE_IFELSE(
			[AC_LANG_PROGRAM(
				[[#define IN_AUTOCONF
				  #include "include/stdinc.h"]],
				  [[struct in6_addr a = in6addr_any;]]
			)],
			[AC_MSG_RESULT(yes)],
			[
				AC_MSG_RESULT(no)
				AC_DEFINE(NO_IN6ADDR_ANY, 1, [Define to 1 if your system has no in6addr_any.])
				inet_misc=1
			]
		)
	fi
],
[
	AC_MSG_RESULT(no)
	have_v6=no
	AC_DEFINE(__HAS_IPV6__, 0, [No ipv6 support available.])
])


AC_CACHE_CHECK(if sem_timedwait exists,ac_cv_sem_timedwait, [
   save_LIBS="$LIBS"; LIBS="$LIBS $PTHREAD_LIBS" ; save_CFLAGS="$CFLAGS"; CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
AC_TRY_LINK([
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif
#if HAVE_SEMAPHORE_H
#include <semaphore.h>
#endif
],
    [sem_timedwait(NULL, NULL)],[
    ac_cv_sem_timedwait="yes"],[
    AC_MSG_WARN([Cannot find sem_timedwait])
    ac_cv_sem_timedwait="no"
])
LIBS="$save_LIBS"
CFLAGS="$save_CFLAGS"
])

if test "$ac_cv_sem_timedwait" = "yes"; then
    AC_DEFINE(HAVE_SEM_TIMEDWAIT, 1, [Define to 1 if you have the sem_timedwait function.])
fi


AC_CACHE_CHECK([whether string.h and strings.h may both be included],
gcc_cv_header_string,
[
	AC_COMPILE_IFELSE(
		[AC_LANG_SOURCE(
			[[#include <string.h>
			 #include <strings.h>]]
		)],
		[gcc_cv_header_string=yes],
		[gcc_cv_header_string=no]
	)
])

if test "$gcc_cv_header_string" = "yes"; then
	AC_DEFINE(STRING_WITH_STRINGS, 1, [Define to 1 if string.h may be included along with strings.h])
fi

if test "${ENABLE_I2C}" = "true" ; then
	OW_I2C=1
else
	OW_I2C=0
fi
AC_SUBST(OW_I2C)

if test "${ENABLE_W1}" = "true" ; then
	OW_W1=1
else
	OW_W1=0
fi
AC_SUBST(OW_W1)

if test "${ENABLE_USB}" = "true" ; then
	OW_USB=1
else
	OW_USB=0
fi
AC_SUBST(OW_USB)

if test "${ENABLE_AVAHI}" = "true" ; then
	OW_AVAHI=1
else
	OW_AVAHI=0
fi
AC_SUBST(OW_AVAHI)

if test "${ENABLE_ZERO}" = "true" ; then
	OW_ZERO=1
else
	OW_ZERO=0
fi
AC_SUBST(OW_ZERO)

if test "${ENABLE_PARPORT}" = "true" ; then
	OW_PARPORT=1
else
	OW_PARPORT=0
fi
AC_SUBST(OW_PARPORT)

if test "${ENABLE_FTDI}" = "true" ; then
	OW_FTDI=1
else
	OW_FTDI=0
fi
AC_SUBST(OW_FTDI)

if test "${ENABLE_DEBUG}" = "true" ; then
	OW_DEBUG=1
else
	OW_DEBUG=0
fi
AC_SUBST(OW_DEBUG)

if test "${ENABLE_MUTEX_DEBUG}" = "true" ; then
	OW_MUTEX_DEBUG=1
else
	OW_MUTEX_DEBUG=0
fi
AC_SUBST(OW_MUTEX_DEBUG)

if test "${ENABLE_OWMALLOC}" = "true" ; then
	OW_ALLOC_DEBUG=1
else
	OW_ALLOC_DEBUG=0
fi
AC_SUBST(OW_ALLOC_DEBUG)

# Checks for typedefs, structures, and compiler characteristics.

AC_C_CONST
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_HEADER_STDBOOL
AC_STRUCT_TM

# Checks for library functions.
AC_FUNC_FORK
#AC_FUNC_MALLOC
#AC_FUNC_MKTIME
#AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_STRFTIME
AC_FUNC_STRTOD
AC_TYPE_SIGNAL
AC_CHECK_FUNCS([accept daemon getaddrinfo freeaddrinfo gethostbyname2_r gethostbyaddr_r gethostbyname_r getservbyname_r getopt getopt_long gmtime_r gettimeofday localtime_r inet_ntop inet_pton memchr memset select socket strcasecmp strchr strdup strncasecmp strtol strtoul twalk tsearch tfind tdelete tdestroy vasprintf strsep vsprintf vsnprintf writev getline])

save_LIBS="$LIBS"
LIBS=""
DL_LIBS=""
if test "${ENABLE_ZERO}" = "true" ; then
	AC_SEARCH_LIBS(dlopen, dl,
		AC_DEFINE(HAVE_DLOPEN, 1, [Define if you have dlopen]))
	DL_LIBS="$LIBS"
fi
AC_SUBST([DL_LIBS])
LIBS="$save_LIBS"

save_LIBS="$LIBS"
M_LIBS=""
LIBS=""
AC_SEARCH_LIBS(lrint, m,
       AC_DEFINE(HAVE_LRINT, 1, [Define if you have lrint]))
M_LIBS="$LIBS"
AC_SUBST([M_LIBS])
LIBS="$save_LIBS"

AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP, 1, [Define if you have nanosleep]))
# clock_gettime needed if real-time wait is needed for sem_timedwait. gettimeofday is enough.
#AC_SEARCH_LIBS(clock_gettime, rt posix4, AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if you have clock_gettime]))

# systemd support (see man 7 daemon)
AC_ARG_WITH([systemdsystemunitdir],
       [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
       [with_systemdsystemunitdir=auto])
AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
       def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)

AS_IF([test "x$def_systemdsystemunitdir" = "x"],
       [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
               [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
        with_systemdsystemunitdir=no],
       [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
       [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
save_LIBS="$LIBS"
MQ_LIBS=""
LIBS=""
AC_SEARCH_LIBS([mq_getattr], [rt])
MQ_LIBS="$LIBS"
AC_SUBST([MQ_LIBS])
LIBS="$save_LIBS"

HAVE_CHECK="false"
PKG_CHECK_MODULES([libcheck],[check >= 0.10.0],[HAVE_CHECK="true"],
	AC_MSG_WARN(["Check unit testing framework not found. "]))
AM_CONDITIONAL(HAVE_CHECK, test "${HAVE_CHECK}" = "true")
CHECK_CFLAGS="$libcheck_CFLAGS"
CHECK_LIBS="$libcheck_LIBS"
AC_SUBST([CHECK_CFLAGS])
AC_SUBST([CHECK_LIBS])


AC_CONFIG_FILES([
	Makefile
	module/Makefile

	module/owlib/Makefile
	module/owlib/src/Makefile
	module/owlib/src/include/Makefile
	module/owlib/src/c/Makefile
	module/owlib/tests/Makefile

	module/owfs/Makefile
	module/owfs/src/Makefile
	module/owfs/src/include/Makefile
	module/owfs/src/c/Makefile

	module/owhttpd/Makefile
	module/owhttpd/src/Makefile
	module/owhttpd/src/include/Makefile
	module/owhttpd/src/c/Makefile

	module/owserver/Makefile
	module/owserver/src/Makefile
	module/owserver/src/include/Makefile
	module/owserver/src/c/Makefile

	module/owftpd/Makefile
	module/owftpd/src/Makefile
	module/owftpd/src/include/Makefile
	module/owftpd/src/c/Makefile

	module/ownet/Makefile
	module/ownet/php/Makefile
	module/ownet/php/examples/ownet_example.php
	module/ownet/python/Makefile
	module/ownet/perl5/Makefile
	module/ownet/c/Makefile
	module/ownet/c/src/Makefile
	module/ownet/c/src/include/Makefile
	module/ownet/c/src/c/Makefile
	module/ownet/c/src/example/Makefile

	module/owshell/Makefile
	module/owshell/src/Makefile
	module/owshell/src/include/Makefile
	module/owshell/src/c/Makefile

	module/owcapi/Makefile
	module/owcapi/src/Makefile
	module/owcapi/src/include/Makefile
	module/owcapi/src/c/Makefile
	module/owcapi/src/example/Makefile
	module/owcapi/src/example++/Makefile
	module/owcapi/owcapi.pc

	module/owtap/Makefile

	module/owmon/Makefile

	module/swig/Makefile
	module/swig/perl5/Makefile
	module/swig/perl5/OW/Makefile.linux
	module/swig/perl5/OW/Makefile.osx
	module/swig/php/Makefile
	module/swig/php/example/load_php_OW.php
	module/swig/python/Makefile
	module/swig/python/ow/Makefile
	module/swig/python/setup.py

	module/owtcl/Makefile

	src/Makefile
	src/include/Makefile

	src/man/Makefile
	src/man/man1/Makefile
	src/man/man3/Makefile
	src/man/man5/Makefile
	src/man/mann/Makefile

	src/rpm/Makefile
	src/rpm/owfs.spec
	src/scripts/Makefile
	src/scripts/windows/Makefile
	src/scripts/windows/owfs.nsi
	src/scripts/usb/Makefile
	src/scripts/usb/cygwin/Makefile
	src/scripts/usb/windows/Makefile
	src/scripts/systemd/Makefile
	src/include/owfs_config.h
])
AC_OUTPUT

# Now, let's tell them what is the current configuration. Only the items
# that are funny (like current default prefix) or configurable (like the
# cache) should be included.

AC_MSG_RESULT()
AC_MSG_RESULT([Current configuration:])
AC_MSG_RESULT()

AC_MSG_RESULT([    Deployment location: ${prefix}])

AC_MSG_RESULT()
AC_MSG_RESULT([Compile-time options:])

if test "${ENABLE_USB}" = "true"; then
	AC_MSG_RESULT([                      USB is enabled])
else
	AC_MSG_RESULT([                      USB is DISABLED])
fi
if test "${ENABLE_AVAHI}" = "true"; then
	AC_MSG_RESULT([                    AVAHI is enabled])
else
	AC_MSG_RESULT([                    AVAHI is DISABLED])
fi
if test "${ENABLE_I2C}" = "true"; then
	AC_MSG_RESULT([                      I2C is enabled])
else
	AC_MSG_RESULT([                      I2C is DISABLED])
fi
if test "${ENABLE_W1}" = "true"; then
	AC_MSG_RESULT([                       W1 is enabled])
else
	AC_MSG_RESULT([                       W1 is DISABLED])
fi
if test "${ENABLE_PARPORT}" = "true"; then
	AC_MSG_RESULT([    Parallel port DS1410E is enabled])
else
	AC_MSG_RESULT([    Parallel port DS1410E is DISABLED])
fi
if test "${ENABLE_FTDI}" = "true"; then
	AC_MSG_RESULT([           FTDI (LinkUSB) is enabled])
else
	AC_MSG_RESULT([           FTDI (LinkUSB) is DISABLED])
fi
if test "${ENABLE_ZERO}" = "true"; then
	AC_MSG_RESULT([         Zeroconf/Bonjour is enabled])
else
	AC_MSG_RESULT([         Zeroconf/Bonjour is DISABLED])
fi
if test "${ENABLE_DEBUG}" = "true"; then
	AC_MSG_RESULT([             Debug-output is enabled])
else
	AC_MSG_RESULT([             Debug-output is DISABLED])
fi
if test "${ENABLE_MUTEX_DEBUG}" = "true"; then
	AC_MSG_RESULT([               Mutexdebug is enabled])
else
	AC_MSG_RESULT([               Mutexdebug is DISABLED])
fi
if test "${ENABLE_PROFILING}" = "true"; then
	AC_MSG_RESULT([                Profiling is enabled])
else
	AC_MSG_RESULT([                Profiling is DISABLED])
fi
if test "${ENABLE_OWMALLOC}" = "true"; then
	AC_MSG_RESULT([Tracing memory allocation is enabled])
else
	AC_MSG_RESULT([Tracing memory allocation is DISABLED])
fi

AC_MSG_RESULT()
AC_MSG_RESULT([Module configuration:])

if test "${ENABLE_OWLIB}" = "true"; then
	AC_MSG_RESULT([                    owlib is enabled])
else
	AC_MSG_RESULT([                    owlib is DISABLED])
fi
if test "${ENABLE_OWSHELL}" = "true"; then
	AC_MSG_RESULT([                  owshell is enabled])
else
	AC_MSG_RESULT([                  owshell is DISABLED])
fi
if test "${ENABLE_OWFS}" = "true"; then
	AC_MSG_RESULT([                     owfs is enabled])
else
	AC_MSG_RESULT([                     owfs is DISABLED])
fi
if test "${ENABLE_OWHTTPD}" = "true"; then
	AC_MSG_RESULT([                  owhttpd is enabled])
else
	AC_MSG_RESULT([                  owhttpd is DISABLED])
fi
if test "${ENABLE_OWFTPD}" = "true"; then
	AC_MSG_RESULT([                   owftpd is enabled])
else
	AC_MSG_RESULT([                   owftpd is DISABLED])
fi
if test "${ENABLE_OWSERVER}" = "true"; then
	AC_MSG_RESULT([                 owserver is enabled])
else
	AC_MSG_RESULT([                 owserver is DISABLED])
fi
if test "${ENABLE_OWEXTERNAL}" = "true"; then
	AC_MSG_RESULT([               owexternal is enabled])
else
	AC_MSG_RESULT([               owexternal is DISABLED])
fi
if test "${ENABLE_OWNET}" = "true"; then
	AC_MSG_RESULT([                    ownet is enabled])
else
	AC_MSG_RESULT([                    ownet is DISABLED])
fi
if test "${ENABLE_OWNETLIB}" = "true"; then
	AC_MSG_RESULT([                 ownetlib is enabled])
else
	AC_MSG_RESULT([                 ownetlib is DISABLED])
fi
if test "${ENABLE_OWTAP}" = "true"; then
	AC_MSG_RESULT([                    owtap is enabled])
else
	AC_MSG_RESULT([                    owtap is DISABLED])
fi
if test "${ENABLE_OWMON}" = "true"; then
	AC_MSG_RESULT([                    owmon is enabled])
else
	AC_MSG_RESULT([                    owmon is DISABLED])
fi
if test "${ENABLE_OWCAPI}" = "true"; then
	AC_MSG_RESULT([                   owcapi is enabled])
else
	AC_MSG_RESULT([                   owcapi is DISABLED])
fi
if test "${ENABLE_SWIG}" = "true"; then
	AC_MSG_RESULT([                     swig is enabled])
else
	AC_MSG_RESULT([                     swig is DISABLED])
fi
if test "${ENABLE_OWPERL}" = "true" -a "${ENABLE_SWIG}" = "true"; then
	AC_MSG_RESULT([                   owperl is enabled])
else
	AC_MSG_RESULT([                   owperl is DISABLED])
fi
if test "${ENABLE_OWPHP}" = "true" -a "${ENABLE_SWIG}" = "true"; then
	AC_MSG_RESULT([                    owphp is enabled])
else
	AC_MSG_RESULT([                    owphp is DISABLED])
fi
if test "${ENABLE_OWPYTHON}" = "true" -a "${ENABLE_SWIG}" = "true"; then
	AC_MSG_RESULT([                 owpython is enabled])
else
	AC_MSG_RESULT([                 owpython is DISABLED])
fi
if test "${ENABLE_OWTCL}" = "true"; then
	AC_MSG_RESULT([                    owtcl is enabled])
else
	AC_MSG_RESULT([                    owtcl is DISABLED])
fi

AC_MSG_RESULT()
if test "${HAVE_CHECK}" = "true"; then
	AC_MSG_RESULT([              unit tests are enabled (run with 'make check')])
else
	AC_MSG_RESULT([              unit tests are DISABLED])
fi
AC_MSG_RESULT()