File: configure.ac

package info (click to toggle)
syslog-ng 3.19.1-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 13,176 kB
  • sloc: ansic: 114,472; makefile: 4,697; sh: 4,391; python: 4,282; java: 4,047; xml: 2,435; yacc: 1,108; lex: 426; perl: 193; awk: 184
file content (1868 lines) | stat: -rw-r--r-- 70,572 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
#############################################################################
# Copyright (c) 2016 Balabit
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#
# As an additional exemption you are allowed to compile & link against the
# OpenSSL libraries as published by the OpenSSL project. See the file
# COPYING for details.
#
#############################################################################

dnl Process this file with autoconf to produce a configure script.
dnl
dnl There are a couple of environment defined variables which this script
dnl makes use of in addition to the standard CFLAGS/LDFLAGS/etc. These are:
dnl
dnl RELEASE_TAG        - Debian release tag which is put to debian/changelog
dnl SNAPSHOT_VERSION   - snapshot version to add to version number
dnl BINARY_BRANCH      - the value is added to all source/binary packages
dnl SOURCE_REVISION    - Revision of the source-tree, will added to the version string
dnl

AC_INIT([syslog-ng], m4_esyscmd([tr -d '\n' < VERSION]))
AC_CONFIG_SRCDIR([syslog-ng/main.c])
AC_CONFIG_MACRO_DIR([m4])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

dnl ***************************************************************************
dnl dependencies

GLIB_MIN_VERSION="2.26.1"
OPENSSL_MIN_VERSION="0.9.8"
LIBDBI_MIN_VERSION="0.9.0"
LIBRABBITMQ_MIN_VERSION="0.5.3"
IVYKIS_MIN_VERSION="0.36.1"
IVYKIS_UPDATED_VERSION="0.39"
JSON_C_MIN_VERSION="0.9"
PCRE_MIN_VERSION="6.1"
LMC_MIN_VERSION="1.0.0"
LRMQ_MIN_VERSION="0.0.1"
LRC_MIN_VERSION="1.6.0"
JOURNALD_MIN_VERSION="195"
LIBSYSTEMD_MIN_VERSION="209"
JAVA_MIN_VERSION="1.7"
GRADLE_MIN_VERSION="2.2"
HIREDIS_MIN_VERSION="0.11.0"
CRITERION_MIN_VERSION="2.2.1"

dnl ***************************************************************************
dnl Initial setup

ostype=`uname -s`

if test -r $srcdir/dist.conf; then
        # read defaults, dist.conf does not change
        # values for parameters that are already set
        . $srcdir/dist.conf
fi

if test -z "$RELEASE_TAG"; then
        RELEASE_TAG=unstable
fi


if test "`uname -s`" = "Linux";then
        CURRDATE=`date -R`
else
        CURRDATE=`date +"%a, %d %b %Y %H:%M:%S %Z"`
fi

AM_INIT_AUTOMAKE([foreign no-define subdir-objects])
_AM_PROG_TAR([ustar])
if test -n "$SNAPSHOT_VERSION"; then
	PACKAGE_VERSION=$PACKAGE_VERSION+$SNAPSHOT_VERSION
fi

dnl ***************************************************************************
dnl script snippet to generate user friendly version strings according to the
dnl new versioning policy. All needed code are here to allow easy moving
dnl between projects.
if test -z "$RELEASE_TYPE"; then
    RELEASE_TYPE=stable
fi

if test -z "$BROCHURE_VERSION"; then
    _MAJOR=`echo $VERSION | cut -f1 -d'.'`
    _MINOR=`echo $VERSION | cut -f2 -d'.'`
    case "$RELEASE_TYPE" in
        stable) BROCHURE_VERSION="$_MAJOR";;
        feature) BROCHURE_VERSION="$_MAJOR F$_MINOR";;
        *) BROCHURE_VERSION="$VERSION dogfood edition. Please contact your syslog-ng release manager to fix the configure scritpt";;
    esac
fi

if test -z "$COMBINED_VERSION"; then
    COMBINED_VERSION="$BROCHURE_VERSION ($VERSION)"
fi

TECHNICAL_VERSION=$VERSION

AC_DEFINE_UNQUOTED(RELEASE_TYPE, "$RELEASE_TYPE", [type of syslog-ng release. stable or feature])
AC_DEFINE_UNQUOTED(BROCHURE_VERSION, "$BROCHURE_VERSION", [pretty version for users depends on the release type])
AC_DEFINE_UNQUOTED(COMBINED_VERSION, "$COMBINED_VERSION", [normal and brochure version combined])
AC_DEFINE_UNQUOTED(SOURCE_REVISION, "$SOURCE_REVISION", [source revision])
AC_SUBST(RELEASE_TYPE)
AC_SUBST(BROCHURE_VERSION)
AC_SUBST(COMBINED_VERSION)
AC_SUBST(TECHNICAL_VERSION)
dnl ***************************************************************************


if test "x$prefix" = "xNONE"; then
        prefix=$ac_default_prefix
fi
if test "x$exec_prefix" = "xNONE"; then
        exec_prefix='${prefix}'
fi
pidfiledir='${localstatedir}'
moduledir='${exec_prefix}/lib/syslog-ng'
loggenplugindir='${moduledir}/loggen'
toolsdir='${datadir}/syslog-ng/tools'
xsddir='${datadir}/syslog-ng/xsd'

config_includedir='${datadir}/syslog-ng/include'
scldir="${config_includedir}/scl"
abs_topsrcdir=`(cd $srcdir && pwd)`

AC_CONFIG_HEADERS(config.h)

dnl ***************************************************************************
dnl Arguments

AC_ARG_WITH(libnet,
   [  --with-libnet=path      use path to libnet-config script],
   ,
   [with_libnet=""])

AC_ARG_WITH(pidfile-dir,
   [  --with-pidfile-dir=path   Use path as the directory for storing pidfiles],
   pidfiledir=$with_pidfile_dir)

AC_ARG_WITH(module-dir,
   [  --with-module-dir=path   Use path as the directory to install modules into],
   moduledir=$with_module_dir)

AC_ARG_WITH(module-path,
   [  --with-module-path=path   Use path as the list of ':' separated directories looked up when searching for modules],
   module_path=$with_module_path)

AC_ARG_WITH(timezone-dir,
   [  --with-timezone-dir=path   Use path as the directory to get the timezone files],
   timezonedir=$with_timezone_dir)

AC_ARG_WITH(ld-library-path,
   [  --with-ld-library-path=path  Set LD_LIBRARY_PATH during runtime to the value given],
   env_ld_library_path=$with_ld_library_path)

AC_ARG_WITH([systemdsystemunitdir],
   AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]))

AC_ARG_WITH(package_name,
   [  --with-package-name=package name Package name is printed out when syslog-ng started with --version],
   PACKAGE_NAME=$with_package_name)

AC_ARG_ENABLE(forced_server_mode,
              [  --enable-forced-server-mode   Enable forced server mode.],, enable_forced_server_mode="yes")

AC_ARG_ENABLE(debug,
              [  --enable-debug      Enable debugging code.],, enable_debug="no")

AC_ARG_ENABLE(extra-warnings,
              [  --enable-extra-warnings      Enable extra compiler warnings (recommended).],, enable_extra_warnings="no")

AC_ARG_ENABLE(env-wrapper,
              [  --enable-env-wrapper    Enable wrapper program to set up various environment variables],, enable_env_wrapper=auto)

AC_ARG_ENABLE(gprof,
              [  --enable-gprof      Enable gcc profiling.],, enable_gprof="no")

AC_ARG_ENABLE(memtrace,
              [  --enable-memtrace   Enable alternative leak debugging code.])

AC_ARG_ENABLE(dynamic-linking,
              [  --enable-dynamic-linking        Link everything dynamically.],,enable_dynamic_linking="auto")

AC_ARG_ENABLE(mixed-linking,
              [  --enable-mixed-linking          Link 3rd party libraries statically, system libraries dynamically],,enable_mixed_linking="auto")

AC_ARG_ENABLE(ipv6,
              [  --enable-ipv6           Enable support for IPv6.],,enable_ipv6="auto")

AC_ARG_ENABLE(tcp-wrapper,
              [  --enable-tcp-wrapper    Enable support for TCP wrappers.],,enable_tcp_wrapper="auto")

AC_ARG_ENABLE(spoof-source,
              [  --enable-spoof-source   Enable support for spoofed source addresses.]
              ,,enable_spoof_source="auto")

AC_ARG_ENABLE(sun-streams,
              [  --enable-sun-streams    Enable support for Solaris /dev/log STREAMS device.]
              ,,enable_sun_streams="auto")

AC_ARG_ENABLE(openbsd-system-source,
              [  --enable-openbsd-system-source    Enable support for OpenBSD /dev/klog device.]
              ,,enable_openbsd_system_source="auto")

AC_ARG_ENABLE(sql,
	      [  --enable-sql            Enable support for SQL destinations. (default: auto)]
	      ,,enable_sql="auto")

AC_ARG_ENABLE(pacct,
              [  --enable-pacct          Enable support for reading Process Accounting files (EXPERIMENTAL, Linux only).]
              ,,enable_pacct="no")

AC_ARG_ENABLE(linux-caps,
              [  --enable-linux-caps     Enable support for managing Linux capabilities (default: auto)]
              ,,enable_linux_caps="auto")

AC_ARG_ENABLE(gcov,
              [  --enable-gcov           Enable coverage profiling (default: no)]
              ,,enable_gcov="no")

AC_ARG_ENABLE(mongodb,
	      [  --enable-mongodb        Enable mongodb destination (default: auto)]
              ,,enable_mongodb="auto")

AC_ARG_ENABLE(legacy-mongodb-options,
              [  --enable-legacy-mongodb-options=[yes/no]
                                         Support libmongo-client non-URI MongoDB options. (default: yes)]
              ,,enable_legacy_mongodb_options="yes")

AC_ARG_WITH(jsonc,
              [  --with-jsonc=[system/internal/auto/no]
                                         Link against the system supplied or the built-in jsonc library or explicitly disable it. (default:auto)]
              ,,with_jsonc="internal")

AC_ARG_ENABLE(json,
             [ --enable-json=[yes/no]            Enable JSON support (default: yes)]
              ,[if test "x$enableval" != "xno"; then with_jsonc="system"; else with_jsonc="no"; fi],)

AC_ARG_ENABLE(amqp,
          [  --enable-amqp        Enable amqp destination (default: auto)]
              ,,enable_amqp="auto")

AC_ARG_ENABLE(stomp,
          [  --enable-stomp        Enable stomp destination (default: yes)]
              ,,enable_stomp="yes")

AC_ARG_WITH(ivykis,
              [  --with-ivykis=[system/internal]
                                         Link against the system supplied or the built-in ivykis library.]
              ,,with_ivykis="internal")

AC_ARG_ENABLE(smtp,
              [  --disable-smtp          Disable SMTP support (default: auto)]
              ,,enable_smtp="auto")

AC_ARG_WITH(libesmtp,
             AC_HELP_STRING([--with-libesmtp=DIR],
                            [use libesmtp library from (prefix) directory DIR]),,)

AC_ARG_ENABLE(http,
              [  --disable-http          Disable http support (default: auto)]
              ,,enable_http="auto")

AC_ARG_WITH(libcurl,
             AC_HELP_STRING([--with-libcurl=DIR],
                            [use libcurl library from (prefix) directory DIR]),,)

AC_ARG_ENABLE(redis,
              [  --disable-redis          Disable REDIS support (default: auto)]
              ,,enable_redis="auto")

AC_ARG_WITH(libhiredis,
             AC_HELP_STRING([--with-libhiredis=DIR],
                            [use libhiredis library from (prefix) directory DIR]),,)

AC_ARG_ENABLE(systemd,
              [  --enable-systemd        Enable systemd support (default: auto)]
              ,,enable_systemd="auto")

AC_ARG_ENABLE(geoip,
              [  --enable-geoip          Enable GeoIP support (default: auto)]
              ,,enable_geoip="auto")

AC_ARG_ENABLE(geoip2,
              [  --enable-geoip2          Enable GeoIP2 support (default: auto)]
              ,,enable_geoip2="auto")

AC_ARG_ENABLE(riemann,
              [  --disable-riemann       Disable riemann destination]
              ,,enable_riemann="auto")

AC_ARG_WITH(compile-date,
	      [  --without-compile-date  Do not include the compile date in the binary]
	      ,wcmp_date="${withval}", wcmp_date="yes")

AC_ARG_WITH(systemd-journal,
              [  --with-systemd-journal=[system/optional/auto]
                                         Link against the system supplied or the wrapper library. (default: auto)]
              ,,with_systemd_journal="auto")

AC_ARG_ENABLE(python,
              [  --disable-python       Disable python destination]
              ,,enable_python="auto")

AC_ARG_WITH(python,
              [  --with-python=VERSION    Build with a specific version of python]
              ,,with_python="auto")

AC_ARG_WITH(docbook-dir,
            AC_HELP_STRING([--with-docbook-dir=DIR],
                           [compiling manpages using docbook in the specified path, if not set online version will be used from http://docbook.sourceforge.net]),
            [ XSL_STYLESHEET=$with_docbook_dir ],
            [ XSL_STYLESHEET=http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl ]
            )

AC_ARG_ENABLE(manpages, AC_HELP_STRING([ --enable-manpages], [ Enable generation of manpages (default: no)]), , [enable_manpages="no"; XSL_STYLESHEET=""])

AC_ARG_ENABLE(java, [ --enable-java  Enable java destination (default: auto)],, enable_java="auto")

AC_ARG_ENABLE(java-modules, [ --enable-java-modules  Compile all Java modules (default: auto)],, enable_java_modules="auto")

AC_ARG_ENABLE(native,
              [  --enable-native        Enable native bindings (default: auto)]
              ,,enable_native="auto")

AC_ARG_ENABLE(all-modules,
              [  --enable-all-modules    Forcibly enable all modules. (default: auto)]
              ,,enable_all_modules="auto")

if test "x$enable_all_modules" != "xauto"; then
   state="$enable_all_modules"

   MODULES="spoof_source sun_streams sql pacct mongodb json amqp stomp \
            redis systemd geoip geoip2 riemann ipv6 smtp native python java java_modules \
            http"
   for mod in ${MODULES}; do
       modstate=$(eval echo \$enable_${mod})
       if test "x$modstate" = "xauto"; then
          eval enable_${mod}=${state}
       fi
   done
fi

if test "x$wcmp_date" != "xno"; then
  wcmp_date="1"
else
  wcmp_date="0"
fi

patheval()
{
        OLD=$1
        NEW=`eval echo $1`
        while test "x$OLD" != "x$NEW"
        do
                OLD=$NEW
                NEW=`eval echo $OLD`
        done
        echo $OLD
}

dnl ***************************************************************************
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CC_C99
AM_PROG_CC_C_O
if test "x$ac_cv_prog_cc_c99" = "xno"; then
	AC_MSG_ERROR("C99 standard compliant C compiler required. Try GCC 3.x or later.")
fi
AC_PROG_YACC
AM_PROG_LEX
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG
LT_INIT([dlopen disable-static])
if test "x$with_python" = "xauto"; then
  AM_PATH_PYTHON()
else
  AM_PATH_PYTHON([$with_python])
fi
if test "${PYTHON}" = ":"; then
	AC_MSG_ERROR([Python interpreter is required])
fi

dnl ***************************************************************************
dnl Validate yacc

yacc_ok=0
if echo "$YACC" | grep -q bison; then
	# NOTE: m4 removes [], that's why it needs to be escaped
	bison_version=`$YACC --version | head -n 1 | sed 's/@<:@^0-9.@:>@*//'`
	bison_version_major=`echo $bison_version | cut -d. -f1`
	bison_version_minor=`echo $bison_version | cut -d. -f2`
	if test "$bison_version_major" -ge 2 -a "$bison_version_minor" -ge 4; then
		yacc_ok=1
	fi
	if test "$bison_version_major" -gt 2; then
		yacc_ok=1
	fi
fi

if test $yacc_ok = 0; then
	if test -f $srcdir/lib/cfg-grammar.c || test -f lib/cfg-grammar.c; then
		AC_MSG_WARN([No proper bison found, you'll not be able to change lib/cfg-grammar.y])
	else
		AC_MSG_ERROR([syslog-ng requires bison 2.4 or later (traditional yacc is not enough). Your source tree seems to be from git, which doesn't have lib/cfg-grammar.c. Please install bison or use a distribution tarball.])
	fi
fi

dnl ***************************************************************************
dnl Validate flex

if $LEX --version | grep "flex" >/dev/null; then
	lex_ok=1
else
	lex_ok=0
fi

if test $lex_ok = 0 ; then
	if test -f $srcdir/lib/cfg-lex.c || test -f lib/cfg-lex.c; then
		AC_MSG_WARN([No flex found, you'll not be able to change lib/cfg-lex.l])
	else
		AC_MSG_ERROR([syslog-ng requires flex in order to generate its config lexer. Your source tree seems to be from git, which doesn't have lib/cfg-lex.c. Please install flex or use a distribution tarball.])
	fi
fi

dnl ***************************************************************************
dnl Set up NO_PIE_LDFLAG: -no-pie is compatible with $CC.

AX_COMPILER_VENDOR
AX_COMPILER_VERSION

if test $ostype = "Darwin"; then
  no_pie_ldflags="-Wl,-no_pie"
else
  if test x$ax_cv_c_compiler_vendor = "xgnu"; then
    AX_COMPARE_VERSION($ax_cv_c_compiler_version, gt, [4.5], [no_pie_ldflags="-no-pie"], [no_pie_ldflags=""])
  else
    no_pie_ldflags="-no-pie"
  fi;
fi

old_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $no_pie_ldflags"

AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])],
	[no_pie_option_available=yes],
	[no_pie_option_available=no])

LDFLAGS="$old_LDFLAGS"

if test "$no_pie_option_available" = "yes"; then
  NO_PIE_LDFLAG="$no_pie_ldflags"
fi
AC_SUBST([NO_PIE_LDFLAG])

dnl ***************************************************************************
dnl Set up CFLAGS



dnl The rest of CFLAGS. We produce
dnl -g/-O2/-pg/-fprofile-arcs/-ftest-coverage combinations, the rest is
dnl supplied by Makefile.am

if test "x$ac_compiler_gnu" = "xyes"; then
	# by ignoring the existing $CFLAGS setting we can override the
	# default supplied by autoconf (which defaults to -O2), which
	# we don't want to use with our debugging builds.

	CFLAGS_ADD=""
        if test "x$enable_debug" = "xyes"; then
                CFLAGS_ADD="${CFLAGS_ADD} -g"
        else
                CFLAGS_ADD="${CFLAGS_ADD} -O2 -g"
        fi
        if test "x$enable_gprof" = "xyes"; then
                CFLAGS_ADD="${CFLAGS_ADD} -pg"
        fi
        if test "x$enable_gcov" = "xyes"; then
                CFLAGS_ADD="${CFLAGS_ADD} -fprofile-arcs -ftest-coverage"
        fi
else
        enable_extra_warnings="no"
fi
CFLAGS_ADD="${CFLAGS_ADD} -pthread"

dnl We are checking for the postive warning flag, as gcc handles the
dnl -Wno-XXX version oddly, so if no other warnings are present, it is not
dnl reported at all, causing it to be unusable for detection purposes.

AX_CFLAGS_GCC_OPTION(-Winitializer-overrides,
		     CFLAGS_INITIALIZER_OVERRIDES,
		     CFLAGS_ADD="${CFLAGS_ADD} -Wno-initializer-overrides")

dnl User supplied CFLAGS come last
CFLAGS="${CFLAGS_ADD} ${ac_cv_env_CFLAGS_value}"

AC_SYS_LARGEFILE

# FIXME: skip tests on unsupported platforms/architectures...
case "$ostype" in
	HP-UX)
		if $CC -v 2>&1 | grep gcc > /dev/null; then
			CFLAGS="${CFLAGS} -U_XOPEN_SOURCE -U_XOPEN_SOURCE_EXTENDED -D_HPUX_SOURCE"
			LDFLAGS="${LDFLAGS} -lcl"
			AC_DEFINE(HAVE_BROKEN_PREAD, 1, [define if your platform has a broken pread/pwrite (e.g. HP-UX)])
			AC_MSG_WARN([NOTE: on HP-UX with gcc, you might need to edit sys/socket.h manually or you'll get compilation errors])
		fi
		;;
	AIX)
		if test "$ac_cv_sys_large_files" -ne 0; then
			CFLAGS="${CFLAGS} -D_LARGE_FILES=1"
		fi

                # NOTE: The -brtl option to the linker must be set before calling the
                # configure script, as otherwise the generated libtool will behave
                # differently. We need the runtime linker during execution (hence the
                # -brtl) to load external modules. Also, please note that with -brtl the
                # linker behaves similarly to what is expected on other UNIX systems,
                # without it, it refuses to link an .so in if there's no reference from
                # the main program, even if there is a proper -llibname option.
		LDFLAGS="$LDFLAGS -Wl,-brtl"
		MODULE_LDFLAGS="-avoid-version -module"
		;;
	Darwin)
		MODULE_LDFLAGS="-avoid-version -dylib"
    ;;
	OSF1)
		CFLAGS="${CFLAGS} -D_XOPEN_SOURCE=500 -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE -D_POSIX_C_SOURCE"
		;;
esac

if test "$enable_dynamic_linking" = "auto" -a "$enable_mixed_linking" = "auto"; then
	enable_dynamic_linking="yes"
	enable_mixed_linking="no"
fi

linkopts=0
if test "x$enable_dynamic_linking" = "xyes"; then
       linkopts=`expr $linkopts + 1`
fi
if test "x$enable_mixed_linking" = "xyes"; then
       linkopts=`expr $linkopts + 1`
fi

if test "$linkopts" -gt 1; then
       AC_MSG_ERROR([You cannot specify multiple linking options at the same time (--enable-dynamic-linking, --enable-mixed-linking).])
fi

if test "x$enable_dynamic_linking" = "xyes"; then
	enable_dynamic_linking="yes"
	enable_mixed_linking="no"
	linking_mode="dynamic"
elif test "x$enable_mixed_linking" = "xyes"; then
	enable_dynamic_linking="no"
	enable_mixed_linking="yes"
	linking_mode="mixed"
fi

dnl ***************************************************************************
dnl Check for --whole-archive flag
dnl ***************************************************************************

if test $ostype = "Darwin"; then
  WHOLE_ARCHIVE_OPT="-all_load"
  NO_WHOLE_ARCHIVE_OPT="-noall_load"
else
  WHOLE_ARCHIVE_OPT="--whole-archive"
  NO_WHOLE_ARCHIVE_OPT="--no-whole-archive"
fi

dnl ***************************************************************************
dnl Is the __thread keyword available?
dnl ***************************************************************************

AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <pthread.h>
__thread int a;
]],
[a=0;])],
[ac_cv_have_tls=yes; AC_DEFINE_UNQUOTED(HAVE_THREAD_KEYWORD, 1, "Whether Thread Local Storage is supported by the system")])

dnl ***************************************************************************
dnl How to do static linking?
dnl ***************************************************************************

AC_MSG_CHECKING(how to enable static linking for certain libraries)
ldversion=`ld -V 2>&1 | head -n 1`
if echo $ldversion | egrep "GNU|Solaris" > /dev/null; then
        LD_START_STATIC="-Wl,-Bstatic"
        LD_END_STATIC="-Wl,-Bdynamic"
        AC_MSG_RESULT(GNU or Solaris)
elif test $ostype = "HP-UX" > /dev/null; then
        LD_START_STATIC="-Wl,-a,archive"
        LD_END_STATIC="-Wl,-a,shared_archive"
        AC_MSG_RESULT(HP-UX)
elif test "$ostype" = "AIX"; then
        LD_START_STATIC="-Wl,-bstatic"
        LD_END_STATIC="-Wl,-bdynamic"
        AC_MSG_RESULT(AIX)
else
        LD_START_STATIC=""
        LD_END_STATIC=""
        AC_MSG_RESULT([no clues, linking everything dynamically, please send appropriate ld arguments to syslog-ng@lists.balabit.hu])
fi

dnl ***************************************************************************
dnl Miscellanneous headers
dnl ***************************************************************************

AC_HEADER_STDC
AC_CHECK_HEADER(dmalloc.h)
AC_CHECK_HEADERS(strings.h	\
	getopt.h		\
	stropts.h		\
	sys/strlog.h		\
	door.h			\
	sys/capability.h	\
	sys/prctl.h		\
	utmp.h			\
	utmpx.h)
AC_CHECK_HEADERS(tcpd.h)

AC_CHECK_TYPES([struct ucred, struct cmsgcred], [], [], [#define _GNU_SOURCE 1
#define _DEFAULT_SOURCE 1
#include <sys/types.h>
#include <sys/socket.h>])

dnl ***************************************************************************
dnl Header checks
dnl ***************************************************************************

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

AC_CHECK_MEMBER(struct tm.tm_gmtoff,AC_DEFINE(HAVE_STRUCT_TM_TM_GMTOFF,1,[Whether you have tm_gmtoff field in struct tm]),,[
#if TM_IN_SYS_TIME
#include <sys/time.h>
#else
#include <time.h>
#endif])

AC_CHECK_MEMBER(struct msghdr.msg_control,AC_DEFINE(HAVE_CTRLBUF_IN_MSGHDR,1,[Whether you have msg_control field in msghdr in socket.h]),,[
#include <sys/socket.h>
])

AC_CACHE_CHECK(for I_CONSLOG, blb_cv_c_i_conslog,
  [AC_EGREP_CPP(I_CONSLOG,
[
#include <sys/strlog.h>
I_CONSLOG
],
  blb_cv_c_i_conslog=no, blb_cv_c_i_conslog=yes)])

old_CPPFLAGS=$CPPFLAGS
CPPFLAGS="-D_GNU_SOURCE -D_DEFAULT_SOURCE"
AC_CACHE_CHECK(for O_LARGEFILE, blb_cv_c_o_largefile,
  [AC_EGREP_CPP(O_LARGEFILE,
[
#include <fcntl.h>
O_LARGEFILE
],
  blb_cv_c_o_largefile=no, blb_cv_c_o_largefile=yes)])
CPPFLAGS=$old_CPPFLAGS

if test "x$blb_cv_c_o_largefile" = "xyes"; then
        AC_DEFINE(HAVE_O_LARGEFILE, 1, [O_LARGEFILE is present])
fi

AC_CACHE_CHECK(for struct sockaddr_storage, blb_cv_c_struct_sockaddr_storage,
  [AC_EGREP_HEADER([sockaddr_storage], sys/socket.h, blb_cv_c_struct_sockaddr_storage=yes,blb_cv_c_struct_sockaddr_storage=no)])

if test "$blb_cv_c_struct_sockaddr_storage" = "yes"; then
	AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE,[1],[struct sockaddr_storage is present on your system])
fi

AC_CACHE_CHECK(for struct sockaddr_in6, blb_cv_c_struct_sockaddr_in6,
  [AC_EGREP_HEADER([sockaddr_in6], netinet/in.h, blb_cv_c_struct_sockaddr_in6=yes,blb_cv_c_struct_sockaddr_in6=no)])

AC_CACHE_CHECK(for PR_SET_KEEPCAPS, blb_cv_keepcaps,
  [AC_EGREP_CPP(PR_SET_KEEPCAPS,
[
#include <sys/prctl.h>

PR_SET_KEEPCAPS
],
  blb_cv_keepcaps=no,
  blb_cv_keepcaps=yes)])

if test "x$blb_cv_keepcaps" = "xyes"; then
	AC_DEFINE(HAVE_PR_SET_KEEPCAPS, 1, [have PR_SET_KEEPCAPS])
fi

if test "$ostype" != "Darwin" ; then
	AC_DEFINE(HAVE_ENVIRON, [1], [Specifies whether the environ global variable exists])
fi

AC_CACHE_CHECK(for modern utmp,
               blb_cv_c_modern_utmp,
[AC_TRY_COMPILE([
#ifdef HAVE_UTMPX_H
#include <utmpx.h>
#else
#include <utmp.h>
#endif
],
[
#ifdef HAVE_UTMPX_H
        struct utmpx ut;
#else
        struct utmp ut;
#endif
  return sizeof(ut.ut_type) & sizeof(ut.ut_user);
],
blb_cv_c_modern_utmp=yes,
blb_cv_c_modern_utmp=no)])

if test "x$blb_cv_c_modern_utmp" = "xyes"; then
	AC_DEFINE(HAVE_MODERN_UTMP, 1, [have modern utmp/utmpx format])
fi

dnl ***************************************************************************
dnl Checks for libraries
AC_CHECK_LIB(door, door_create, BASE_LIBS="$BASE_LIBS -ldoor")
AC_CHECK_LIB(socket, socket, BASE_LIBS="$BASE_LIBS -lsocket")
AC_CHECK_LIB(rt, nanosleep, BASE_LIBS="$BASE_LIBS -lrt")
AC_CHECK_LIB(nsl, gethostbyname, BASE_LIBS="$BASE_LIBS -lnsl")
AC_CHECK_LIB(regex, regexec, REGEX_LIBS="-lregex")
AC_CHECK_LIB(resolv, res_init, RESOLV_LIBS="-lresolv")

AC_CHECK_FUNCS(strdup		\
	strtol			\
	strtoll			\
	strtoimax		\
	inet_aton		\
	inet_ntoa		\
	getopt_long		\
	getaddrinfo		\
	getnameinfo		\
	getutent		\
	getutxent		\
	pread			\
	pwrite			\
	strcasestr		\
	memrchr			\
	localtime_r		\
	getprotobynumber_r	\
	gmtime_r		\
	strnlen			\
	strtok_r)
old_LIBS=$LIBS
LIBS=$BASE_LIBS
AC_CHECK_FUNCS(clock_gettime)
LIBS=$old_LIBS

dnl ***************************************************************************
dnl check inotify
dnl ***************************************************************************
AC_CHECK_FUNCS([inotify_init])

dnl ***************************************************************************
dnl check getrandom
dnl ***************************************************************************
AC_CHECK_FUNCS([getrandom])

dnl ***************************************************************************
dnl libevtlog headers/libraries (remove after relicensing libevtlog)
dnl ***************************************************************************

EVTLOG_LIBS="\$(top_builddir)/lib/eventlog/src/libevtlog.la"
EVTLOG_NO_LIBTOOL_LIBS="\$(top_builddir)/lib/eventlog/src/.libs/libevtlog.so"
EVTLOG_CFLAGS="-I\$(top_srcdir)/lib/eventlog/src -I\$(top_builddir)/lib/eventlog/src"

dnl ***************************************************************************
dnl secret storage libraries
dnl ***************************************************************************

SECRETSTORAGE_LIBS="\$(top_builddir)/lib/secret-storage/libsecret-storage.la"
SECRETSTORAGE_NO_LIBTOOL_LIBS="\$(top_builddir)/lib/secret-storage/.libs/libsecret-storage.so"

dnl ***************************************************************************
dnl libwrap headers/libraries
dnl ***************************************************************************

old_LIBS=$LIBS
AC_CACHE_CHECK(for TCP wrapper library,
                blb_cv_c_lwrap,

for libwrap in "-lwrap" "/usr/local/lib/libwrap.a"; do
        LIBS="$old_LIBS $libwrap"

        [AC_TRY_LINK(,
        [
}

int allow_severity;
int deny_severity;
extern int hosts_access(void);

int foo(void)
{
        hosts_access();
],
        [blb_cv_c_lwrap=$libwrap
        break],
        blb_cv_c_lwrap="")
done

])
LIBS=$old_LIBS
LIBWRAP_LIBS=$blb_cv_c_lwrap

if test "x$enable_tcp_wrapper" = "xauto"; then
	AC_MSG_CHECKING(whether to enable TCP wrapper support)
        if test "x$ac_cv_header_tcpd_h" = "xyes" -a "x$blb_cv_c_lwrap" != "x"; then
                enable_tcp_wrapper=yes
                AC_MSG_RESULT(yes)
        else
                LIBWRAP_LIBS=""
                AC_MSG_RESULT(no)
                enable_tcp_wrapper=no
        fi
elif test "x$enable_tcp_wrapper" != "xyes"; then
        LIBWRAP_LIBS=""
fi

dnl ***************************************************************************
dnl -ldl
dnl ***************************************************************************

AC_CHECK_LIB(dl, dlsym, DL_LIBS="-ldl")

dnl ***************************************************************************
dnl libdbi headers/libraries
dnl ***************************************************************************
if test "x$enable_sql" = "xyes" || test "x$enable_sql" = "xauto"; then
	PKG_CHECK_MODULES(LIBDBI, dbi >= $LIBDBI_MIN_VERSION, with_libdbi="1", with_libdbi="0")
	if test "$with_libdbi" -eq 0; then
		dnl if libdbi has no .pc file (e.g., Ubuntu Precise), try it without one
		AC_CHECK_LIB(dbi, dbi_initialize_r, LIBDBI_LIBS="-ldbi"; LIBDBI_CFLAGS="-I/usr/include/dbi"; with_libdbi="1")
	fi

	AC_MSG_CHECKING(whether to enable SQL support)
	if test "$with_libdbi" -eq 1; then
		enable_sql="yes"
		AC_MSG_RESULT(yes)
	elif test "x$enable_sql" = "xyes"; then
		AC_MSG_RESULT(no)
		enable_sql="no"
                AC_MSG_ERROR([Could not find libdbi, and SQL support was explicitly enabled.])
        else
		AC_MSG_RESULT(no)
	fi
fi

dnl ***************************************************************************
dnl GLib headers/libraries
dnl ***************************************************************************

GLIB_ADDONS="gmodule-2.0 gthread-2.0"
PKG_CHECK_MODULES(GLIB, glib-2.0 >= $GLIB_MIN_VERSION $GLIB_ADDONS,,)

if test "$linking_mode" != "dynamic"; then
	# strip out -ldl & -lrt as it cannot be linked statically
	GLIB_LIBS=`echo $GLIB_LIBS | tr ' ' '\n' | egrep -v "^(-ldld?)|(-lrt)$" | tr '\n' ' '`

	old_LIBS=$LIBS
	LIBS="$LD_START_STATIC $GLIB_LIBS $LD_END_STATIC $BASE_LIBS"
	AC_CHECK_FUNC(g_hash_table_new, blb_cv_static_glib=yes, blb_cv_static_glib=no)
	LIBS=$old_LIBS
fi

old_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$GLIB_CFLAGS"
old_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS $GLIB_LIBS"

old_LIBS=$LIBS
LIBS="$LIBS $GLIB_LIBS"
AC_CHECK_FUNCS(g_list_copy_deep g_queue_free_full g_list_free_full)
LIBS=$old_LIBS

AC_CACHE_CHECK(sanity checking Glib headers,
               blb_cv_glib_sane,
[AC_TRY_RUN([
#include <glib.h>

int main()
{
  if (sizeof(long) != GLIB_SIZEOF_LONG)
    return 1;
  return 0;
}
],
blb_cv_glib_sane=yes,
blb_cv_glib_sane=no,
blb_cv_glib_sane=yes)])
CPPFLAGS=$old_CPPFLAGS
LDFLAGS=$old_LDFLAGS

if test "x$blb_cv_glib_sane" = "xno"; then
	AC_MSG_ERROR([Glib headers inconsistent with current compiler setting. You might be using 32 bit Glib with a 64 bit compiler, check PKG_CONFIG_PATH])
fi

if test "x$linking_mode" != "xdynamic" -a "x$blb_cv_static_glib" = "xno"; then
	AC_MSG_ERROR([static GLib libraries not found (a file named libglib-2.0.a), either link GLib dynamically using the --enable-dynamic-linking or install a static GLib])
fi

dnl ***************************************************************************
dnl geoip headers/libraries
dnl ***************************************************************************
if test "x$enable_geoip" = "xyes" || test "x$enable_geoip" = "xauto"; then
        if test "x$GEOIP_LIBS" != "x"; then
                AC_MSG_CHECKING([for GEOIP])
                AC_MSG_RESULT([yes (GEOIP_LIBS set, will use that.)])
                with_geoip="yes"
        else
                PKG_CHECK_MODULES(GEOIP, geoip, with_geoip="yes", with_geoip="no")
        fi

        if test "x$with_geoip" = "xno" && test "x$enable_geoip" = "xyes"; then
                AC_MSG_ERROR([Could not find libgeoip, and geoip support was explicitly enabled.])
        fi
        enable_geoip="$with_geoip"
fi

dnl ***************************************************************************
dnl geoip2 headers/libraries
dnl ***************************************************************************
if test "x$enable_geoip2" = "xyes" || test "x$enable_geoip2" = "xauto"; then
        if test "x$MAXMINDDB_LIBS" != "x"; then
                AC_MSG_CHECKING([for MAXMINDDB])
                AC_MSG_RESULT([yes (MAXMINDDB_LIBS set, will use that.)])
                with_maxminddb="yes"
        else
                AC_MSG_CHECKING([for MAXMINDDB])
                AC_CHECK_LIB(maxminddb, MMDB_open, MAXMINDDB_LIBS="-lmaxminddb"; with_maxminddb="yes", with_maxminddb="no")
                AC_SUBST(MAXMINDDB_LIBS)
        fi

        if test "x$with_maxminddb" = "xno" && test "x$enable_geoip2" = "xyes"; then
                AC_MSG_ERROR([Could not find libmaxminddb, and geoip2 support was explicitly enabled.])
        fi

        if test "x$with_maxminddb" = "xyes"; then
                AC_CONFIG_LINKS([modules/geoip2/tests/test.mmdb:modules/geoip2/tests/test.mmdb])
        fi

        enable_geoip2="$with_maxminddb"
fi

dnl ***************************************************************************
dnl pcre headers/libraries
dnl ***************************************************************************

if test "x$linking_mode" = "xmixed"; then

	# check if we have a pcre bundled in glib. In case glib is
        # dynamic it doesn't matter as glib doesn't export those
        # symbols.  But in case glib is static, linking it through
        # glib and through libpcre would clash.
        old_LIBS="$LIBS"
        LIBS="$LD_START_STATIC $GLIB_LIBS $LD_END_STATIC $LIBS"
        AC_CHECK_FUNC(pcre_compile2, AC_MSG_ERROR([You cannot use a GLib embedded PCRE in mixed linking mode]))
        LIBS="$old_LIBS"
fi

PKG_CHECK_MODULES(PCRE, libpcre >= $PCRE_MIN_VERSION,, PCRE_LIBS="")
if test -z "$PCRE_LIBS"; then
	AC_MSG_ERROR(Cannot find pcre version >= $PCRE_MIN_VERSION it is a hard dependency from syslog-ng 3.6 onwards)
fi

dnl ***************************************************************************
dnl OpenSSL headers/libraries
dnl ***************************************************************************

# openssl is needed for:
#  * TLS support

dnl check OpenSSL static linking
PKG_CHECK_MODULES(OPENSSL,
                  openssl >= $OPENSSL_MIN_VERSION,,
                  AC_MSG_ERROR(Cannot find OpenSSL libraries with version >= $OPENSSL_MIN_VERSION it is a hard dependency from syslog-ng 3.7 onwards))

if test -n "$OPENSSL_LIBS" -a "$linking_mode" != "dynamic"; then
        dnl required for openssl, but only when linking statically
        AC_CHECK_LIB(z, inflate, ZLIB_LIBS="-lz")

	dnl Remove -ldl as it cannot be linked statically on some platforms, it'll be present in DL_LIBS
	OPENSSL_LIBS=`echo $OPENSSL_LIBS | tr ' ' '\n' | egrep -v "^-ldld?$" | tr '\n' ' '`

	old_LIBS=$LIBS
	LIBS="$LD_START_STATIC $OPENSSL_LIBS $ZLIB_LIBS $LD_END_STATIC $DL_LIBS"
	AC_CHECK_FUNC(SSL_library_init, blb_cv_static_openssl=yes, blb_cv_static_openssl=no)
	LIBS=$old_LIBS
fi

CPPFLAGS_SAVE="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $OPENSSL_CFLAGS"

AC_CHECK_DECLS([SSL_CTX_get0_param],[], [], [[#include <openssl/ssl.h>]])
AC_CHECK_DECLS([X509_STORE_CTX_get0_cert],[], [], [[#include <openssl/ssl.h>]])
AC_CHECK_DECLS([X509_get_extension_flags], [], [], [[#include <openssl/x509v3.h>]])
AC_CHECK_DECLS([EVP_MD_CTX_reset], [], [], [[#include <openssl/evp.h>]])
AC_CHECK_DECLS([ASN1_STRING_get0_data], [], [], [[#include <openssl/asn1.h>]])
AC_CHECK_DECLS([DH_set0_pqg], [], [], [[#include <openssl/dh.h>]])
AC_CHECK_DECLS([BN_get_rfc3526_prime_2048], [], [], [[#include <openssl/bn.h>]])

CPPFLAGS="$CPPFLAGS_SAVE"

dnl
dnl Right now, openssl is never linked statically as it is only used by the
dnl TLS build of the afsocket plugin which is loaded dynamically anyway.
dnl
dnl The static check remains though, because the core may need openssl in the
dnl future, in which case it becomes relevant again.
dnl

dnl if test "x$linking_mode" != "xdynamic" -a "x$blb_cv_static_openssl" = "xno"; then
dnl	AC_MSG_ERROR([static OpenSSL libraries not found (libssl.a, libcrypto.a and their external dependencies like libz.a), either link OpenSSL statically using the --enable-dynamic-linking, or install a static OpenSSL])
dnl fi

dnl ***************************************************************************
dnl libnet headers/libraries
dnl ***************************************************************************
AC_MSG_CHECKING(for LIBNET)
if test "x$with_libnet" = "x"; then
        LIBNET_CONFIG="`which libnet-config`"
else
        LIBNET_CONFIG="$with_libnet/libnet-config"
fi

if test -n "$LIBNET_CONFIG" -a -x "$LIBNET_CONFIG"; then
        LIBNET_CFLAGS="`$LIBNET_CONFIG --defines`"
        LIBNET_LIBS="`$LIBNET_CONFIG --libs`"
        AC_MSG_RESULT(yes)
else
        LIBNET_LIBS=
        AC_MSG_RESULT(no)
fi


if test "x$enable_spoof_source" = "xauto"; then
	AC_MSG_CHECKING(whether to enable spoof source support)
        if test "x$LIBNET_LIBS" != "x"; then
                enable_spoof_source=yes
                AC_MSG_RESULT(yes)
	else
		enable_spoof_source=no
                LIBNET_LIBS=
		LIBNET_CFLAGS=
		AC_MSG_RESULT(no)
        fi
elif test "x$enable_spoof_source" = "xyes"; then
  if test "x$LIBNET_LIBS" = "x"; then
    AC_MSG_ERROR([Could not find libnet, and spoof source support was explicitly enabled.])
  fi
elif test "x$enable_spoof_source" = "xno"; then
	LIBNET_CFLAGS=""
	LIBNET_LIBS=""
	enable_spoof_source=no
else
  AC_MSG_ERROR([Invalid value ($enable_spoof_source) for enable-spoof-source])
fi

dnl ***************************************************************************
dnl Criterion headers/libraries
dnl ***************************************************************************

PKG_CHECK_MODULES(CRITERION, criterion >= $CRITERION_MIN_VERSION,
  [with_criterion="system"],
  [AC_MSG_WARN([pkg-config was not able to find Criterion >= $CRITERION_MIN_VERSION]); with_criterion="no"])

if test "$with_criterion" != "no"; then
   enable_tests=yes
else
  enable_tests=no
fi

dnl ***************************************************************************
dnl ivykis headers/libraries
dnl ***************************************************************************

IVYKIS_INTERNAL_SOURCE_EXISTS="test -f $srcdir/lib/ivykis/src/iv_main_posix.c"

if $IVYKIS_INTERNAL_SOURCE_EXISTS; then
	AC_CONFIG_SUBDIRS([lib/ivykis])
	IVYKIS_SUBDIRS=lib/ivykis
fi


INTERNAL_IVYKIS_CFLAGS=""
if test "x$with_ivykis" = "xinternal"; then
	if $IVYKIS_INTERNAL_SOURCE_EXISTS; then
		# these can only be used in lib as it assumes
		# the current directory just one below ivykis

		IVYKIS_LIBS="-Wl,${WHOLE_ARCHIVE_OPT} -L\$(top_builddir)/lib/ivykis/src -livykis -Wl,${NO_WHOLE_ARCHIVE_OPT}"
		IVYKIS_CFLAGS="-isystem \$(top_srcdir)/lib/ivykis/src/include -isystem \$(top_builddir)/lib/ivykis/src/include"
                INTERNAL_IVYKIS_CFLAGS="-isystem \${includedir}/syslog-ng/ivykis"

		IVYKIS_VERSION_UPDATED="yes"

		# LIBS to use when libtool is not applicable (when linking the main syslog-ng executable in mixed linking mode)
		IVYKIS_NO_LIBTOOL_LIBS="-Wl,${WHOLE_ARCHIVE_OPT} -L\$(top_builddir)/lib/ivykis/src/.libs -livykis -Wl,${NO_WHOLE_ARCHIVE_OPT}"
	else
		AC_MSG_ERROR([Internal ivykis sources not found in lib/ivykis. This is a hard dependency, unable to build syslog-ng without them.])
	fi
else
	with_ivykis="system"
	PKG_CHECK_MODULES(IVYKIS, ivykis >= $IVYKIS_MIN_VERSION,,)
	PKG_CHECK_MODULES(IVYKIS_VERSION_CHECK, ivykis >= $IVYKIS_UPDATED_VERSION, [IVYKIS_VERSION_UPDATED="yes"], [IVYKIS_VERSION_UPDATED="no"])

	# in case we're using a system installed ivykis, we can link against
	# it even without libtool and without extra linker arguments (as
	# we're linking dynamically)

	IVYKIS_NO_LIBTOOL_LIBS="$IVYKIS_LIBS"
fi

dnl ***************************************************************************
dnl json headers/libraries
dnl ***************************************************************************

enable_json="no"

if test "x$with_jsonc" = "xsystem" -o "x$with_jsonc" = "xauto"; then
   enable_json="yes"
   PKG_CHECK_EXISTS(json-c, json_module_name="json-c",
   PKG_CHECK_EXISTS(json, json_module_name="json"))
   PKG_CHECK_MODULES(JSON, $json_module_name >= $JSON_C_MIN_VERSION,[with_jsonc="system"], [JSON_LIBS=""; enable_json="no"])
   if test "x$with_jsonc" = "xsystem" -a "x$enable_json" = "xno"; then
     AC_MSG_ERROR([json-c library development files cannot be not found on system!])
   fi
fi
if test "x$with_jsonc" = "xinternal" -o "x$with_jsonc" = "xauto"; then
  AC_MSG_CHECKING(for JSON)
  if test -f "$srcdir/lib/jsonc/json.h"; then
      AC_CONFIG_SUBDIRS([lib/jsonc])
      JSON_LIBS="\$(top_builddir)/lib/jsonc/libjson-c.la"
      JSON_DEPENDENCY="$JSON_LIBS"
      JSON_CFLAGS="-I\$(top_srcdir)/lib/jsonc -I\$(top_builddir)/lib/jsonc"
      JSON_SUBDIRS="lib/jsonc"
      enable_json="yes"
      with_jsonc="internal"
  else
      AC_MSG_WARN([Internal jsonc sources not found in lib/jsonc])
      enable_json="no"
  fi
  AC_MSG_RESULT($enable_json)
fi

dnl ***************************************************************************
dnl mongo-c-driver headers/libraries
dnl ***************************************************************************

if test x"$enable_legacy_mongodb_options" = x"no"; then
	enable_legacy_mongodb_options_bit=0
else
	enable_legacy_mongodb_options_bit=1
fi
AC_DEFINE_UNQUOTED(ENABLE_LEGACY_MONGODB_OPTIONS, [$enable_legacy_mongodb_options_bit], [Support libmongo-client non-URI MongoDB options])

PKG_CHECK_MODULES(LIBMONGO, libmongoc-1.0 >= $LMC_MIN_VERSION, with_mongoc="yes", with_mongoc="no")

if test "x$with_mongoc" = "xno" && test "x$enable_mongodb" = "xyes"; then
   AC_MSG_ERROR([Could not find mongo-c-driver, and MongoDB support was explicitly enabled.])
fi

dnl ***************************************************************************
dnl libesmtp headers/libraries
dnl ***************************************************************************
if test "x$enable_smtp" != "xno" && test "x$with_libesmtp" != "xno"; then
	libesmtp="yes"
	if test "x$with_libesmtp" != "xyes" && test "x$with_libesmtp" != "x"; then
		CPPFLAGS_SAVE="$CPPFLAGS"
		LDFLAGS_SAVE="$LDFLAGS"
		CPPFLAGS="$CPPFLAGS -I$with_libesmtp/include"
		LDFLAGS="$LDFLAGS -L$with_libesmtp/lib"
		AC_CHECK_HEADER(libesmtp.h, [LIBESMTP_CFLAGS="-I$with_libesmtp/include"
					     LIBESMTP_LIBS="-L$with_libesmtp/lib -lesmtp"], [libesmtp=no])
		CPPFLAGS="$CPPFLAGS_SAVE"
		LDFLAGS="$LDFLAGS_SAVE"
	else
		AC_MSG_CHECKING(for libESMTP)
		if libesmtp-config --version >/dev/null 2>&1; then
			AC_MSG_RESULT(yes)
			LIBESMTP_CFLAGS="`libesmtp-config --cflags`"
			LIBESMTP_LIBS="`libesmtp-config --libs`"
		else
			AC_MSG_RESULT(no)
			libesmtp=no
		fi
	fi
	if test "x$enable_smtp" = "xyes" && test "x$libesmtp" = "xno"; then
		AC_MSG_ERROR(libESMTP not found)
	fi
	enable_smtp=$libesmtp
fi

dnl ***************************************************************************
dnl libcurl headers/libraries
dnl ***************************************************************************
if test "x$enable_http" != "xno" && test "x$with_libcurl" != "xno"; then
	libcurl="yes"
	if test "x$with_libcurl" != "xyes" && test "x$with_libcurl" != "x"; then
		CPPFLAGS_SAVE="$CPPFLAGS"
		LDFLAGS_SAVE="$LDFLAGS"
		CPPFLAGS="$CPPFLAGS -I$with_libcurl/include"
		LDFLAGS="$LDFLAGS -L$with_libcurl/lib"
		AC_CHECK_HEADER(curl/curl.h, [LIBCURL_CFLAGS="-I$with_libcurl/include"
					     LIBCURL_LIBS="-L$with_libcurl/lib -lcurl"], [libcurl=no])
		CPPFLAGS="$CPPFLAGS_SAVE"
		LDFLAGS="$LDFLAGS_SAVE"
	else
		AC_MSG_CHECKING(for libcurl)
		if curl-config --version >/dev/null 2>&1; then
			AC_MSG_RESULT(yes)
			LIBCURL_CFLAGS="`curl-config --cflags`"
			LIBCURL_LIBS="`curl-config --libs`"
		else
			AC_MSG_RESULT(no)
			libcurl=no
		fi
	fi
	if test "x$enable_http" = "xyes" && test "x$libcurl" = "xno"; then
		AC_MSG_ERROR(libcurl not found)
	fi
	enable_http=$libcurl
fi

dnl ***************************************************************************
dnl libhiredis headers/libraries
dnl ***************************************************************************
if test "x$enable_redis" != "xno" && test "x$with_redis" != "xno"; then
       hiredis="yes"
       if test "x$with_libhiredis" != "xyes" && test "x$with_libhiredis" != "x"; then
               CFLAGS_SAVE="$CFLAGS"
               LDFLAGS_SAVE="$LDFLAGS"
               CFLAGS="$CFLAGS -I$with_libhiredis/include"
               LDFLAGS="$LDFLAGS -L$with_libhiredis/lib"
               AC_CHECK_HEADER(hiredis/hiredis.h, [HIREDIS_CFLAGS="-I$with_libhiredis/include"
                                                   HIREDIS_LIBS="-L$with_libhiredis/lib -lhiredis"], [hiredis=no])
               CFLAGS="$CFLAGS_SAVE"
               LDFLAGS="$LDFLAGS_SAVE"
       else
               hiredis="yes"
               PKG_CHECK_MODULES(HIREDIS, hiredis >= $HIREDIS_MIN_VERSION, ,
                                 [AC_MSG_WARN([pkg-config was not able to find hiredis >= $HIREDIS_MIN_VERSION])
				  PKG_CHECK_MODULES(HIREDIS, libhiredis >= $HIREDIS_MIN_VERSION,,
				  [AC_MSG_WARN([pkg-config was not able to find libhiredis >= $HIREDIS_MIN_VERSION])
				   hiredis=no])])
       fi

       if test "x$enable_redis" = "xyes" && test "x$hiredis" = "xno"; then
               AC_MSG_ERROR(libHIREDIS not found)
       fi

       enable_redis=$hiredis
fi

dnl ***************************************************************************
dnl rabbitmq-c headers/libraries
dnl ***************************************************************************

PKG_CHECK_MODULES(LIBRABBITMQ, librabbitmq >= $LIBRABBITMQ_MIN_VERSION, with_librabbitmq_client="yes", with_librabbitmq_client="no")

if test "$enable_amqp" = "yes" && test "$with_librabbitmq_client" = "no"; then
       AC_MSG_ERROR([Could not find librabbitmq-c, and AMQP support was explicitly enabled.])
fi


if test "x$enable_native" = "xyes" -o "x$enable_native" = "xauto"; then
    AC_CONFIG_FILES([syslog-ng-native-connector.pc])
fi

dnl ***************************************************************************
dnl riemann-client headers/libraries
dnl ***************************************************************************
if test "$enable_riemann" != "no"; then
 PKG_CHECK_MODULES(RIEMANN_CLIENT, riemann-client >= $LRC_MIN_VERSION,,riemann_found="no")
 if test "$riemann_found" = "no" && test "$enable_riemann" = "yes"; then
   AC_MSG_ERROR([Dependency for Riemann not found!])
 fi
 if test "$riemann_found" = "no"; then
   enable_riemann="no";
 else
   enable_riemann="yes";
 fi

 if test "$enable_riemann" = "yes"; then

    old_CFLAGS=$CFLAGS
    CFLAGS=`pkg-config --cflags riemann-client`
    AC_CHECK_DECLS(RIEMANN_EVENT_FIELD_TIME_MICROS, [riemann_micros="yes"], [riemann_micros="no"], [[#include <riemann/event.h>]])
    CFLAGS=$old_CFLAGS
 fi
fi

dnl ***************************************************************************
dnl libsystemd headers/libraries
dnl ***************************************************************************

PKG_CHECK_MODULES(libsystemd, libsystemd >= ${LIBSYSTEMD_MIN_VERSION},
                  have_libsystemd="yes", have_libsystemd="no")

dnl ***************************************************************************
dnl python checks
dnl ***************************************************************************
if test "x$enable_python" != "xno"; then
  if test "x$with_python" = "xauto"; then
    PKG_CHECK_MODULES(PYTHON, python3, python_found="yes", python_found="no")
    if test "$python_found" = "no"; then
      PKG_CHECK_MODULES(PYTHON, python2, python_found="yes", python_found="no")
      if test "$python_found" = "no"; then
        PKG_CHECK_MODULES(PYTHON, python, python_found="yes", python_found="no")
      fi
    fi
  else
    case "$with_python" in
      [[0-9]])
          with_python="python${with_python}"
          ;;
      [[0-9]].[[0-9]])
          with_python="python-${with_python}"
          ;;
    esac

    PKG_CHECK_MODULES(PYTHON, $with_python, python_found="yes", python_found="no")
  fi

  if test "x$python_found" = "xyes"; then
    old_LIBS=$LIBS
    LIBS="$LIBS $PYTHON_LIBS"
    AC_CHECK_FUNCS(PyUnicode_AsUTF8, with_python=python3, with_python=python2)
    LIBS=$old_LIBS
  fi

  if test "x$enable_python" = "xyes" -a "x$python_found" = "xno"; then
    AC_MSG_ERROR([Could not find the requested Python development libraries])
  fi
  enable_python="$python_found"
else
  with_python=""
fi

dnl ***************************************************************************
dnl java headers/libraries
dnl ***************************************************************************

if test "x$enable_java" = "xauto" || test "x$enable_java" = "xyes"; then
    if test "x$enable_java" = "xauto"; then
      AC_CHECK_JAVA_VERSION([$JAVA_MIN_VERSION], [enable_java=yes], [enable_java=no])
    else
      AC_CHECK_JAVA_VERSION([$JAVA_MIN_VERSION], [enable_java=yes], [AC_MSG_ERROR([Java not found])])
    fi
fi

if test "x$enable_java" = "xyes"; then
    if test "x$enable_java_modules" = "xauto" || test "x$enable_java_modules" = "xyes"; then
        if test "x$enable_java_modules" = "xauto"; then
          AC_CHECK_GRADLE_VERSION([$GRADLE_MIN_VERSION], [enable_java_modules=yes], [enable_java_modules=no])
        else
          AC_CHECK_GRADLE_VERSION([$GRADLE_MIN_VERSION], [enable_java_modules=yes], [AC_MSG_ERROR([Gradle not found])])
        fi
    fi
else
    if test "x$enable_java_modules" = "xyes"; then
        AC_MSG_ERROR([Could not build Java modules without Java])
    elif test "x$enable_java_modules" = "xauto"; then
        AC_MSG_WARN([Could not build Java modules without Java])
	enable_java_modules=no
    fi
fi

dnl ***************************************************************************
dnl misc features to be enabled
dnl ***************************************************************************

if test "x$ac_cv_lib_door_door_create" = "xyes"; then
        AC_CHECK_HEADERS(pthread.h)
        AC_CHECK_LIB(pthread, pthread_create)
fi

AC_MSG_CHECKING(whether to enable Sun STREAMS support)
if test "x$ac_cv_header_stropts_h" = "xyes" -a \
        "x$ac_cv_header_sys_strlog_h" = "xyes" -a \
        "x$enable_sun_streams" != "xno" -a \
        "x$blb_cv_c_i_conslog" != "xno"; then
        enable_sun_streams=yes
        AC_MSG_RESULT(yes)
else
        enable_sun_streams=no
        AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING(whether to enable OpenBSD system source support)
if test "x$enable_openbsd_system_source" = "xyes"; then
        enable_openbsd_system_source="yes"
        AC_MSG_RESULT(yes)
elif test "x$enable_openbsd_system_source" = "xauto" -a \
        "$ostype" = "OpenBSD" ; then
        enable_openbsd_system_source="yes"
        AC_MSG_RESULT(yes)
else
        enable_openbsd_system_source="no"
        AC_MSG_RESULT(no)
fi

if test "x$enable_env_wrapper" = "xauto"; then
	if test "x$env_ld_library_path" != "x"; then
		enable_env_wrapper="yes"
	else
		enable_env_wrapper="no"
	fi
fi

if test "x$enable_ipv6" = "xauto"; then
	AC_MSG_CHECKING(whether to enable IPv6 support)
        if test "x$blb_cv_c_struct_sockaddr_in6" = "xyes"; then
                enable_ipv6=yes
                AC_MSG_RESULT(yes)
        else
                enable_ipv6=no
                AC_MSG_RESULT(no)
        fi
fi


if test "x$enable_linux_caps" = "xyes" -o "x$enable_linux_caps" = "xauto"; then
        PKG_CHECK_MODULES(LIBCAP, libcap, has_linux_caps="yes", has_linux_caps="no")

        if test "x$has_linux_caps" = "xno"; then
                if test "x$ac_cv_header_sys_capability_h" = "xyes"; then
                        AC_CHECK_LIB(cap, cap_set_proc, LIBCAP_LIBS="-lcap"; has_linux_caps="yes", has_linux_caps="no")
                else
                        has_linux_caps="no"
                fi
                AC_MSG_CHECKING(whether to enable Linux capability support)
                AC_MSG_RESULT([$has_linux_caps])
        fi

        if test "x$enable_linux_caps" = "xyes" -a "x$has_linux_caps" = "xno"; then
           AC_MSG_ERROR([Cannot enable Linux capability support.])
        fi

        enable_linux_caps="$has_linux_caps"
fi

if test "x$enable_mongodb" = "xauto"; then
	AC_MSG_CHECKING(whether to enable mongodb destination support)
	if test "x$with_mongoc" != "xno"; then
		enable_mongodb="yes"
	else
		enable_mongodb="no"
	fi
	AC_MSG_RESULT([$enable_mongodb])
fi

if test "x$enable_amqp" = "xauto"; then
    AC_MSG_CHECKING(whether to enable amqp destination support)
    if test "x$with_librabbitmq_client" != "xno"; then
        enable_amqp="yes"
    else
        enable_amqp="no"
    fi
    AC_MSG_RESULT([$enable_amqp])
fi


if test "x$enable_systemd" = "xauto"; then
	if test "$ostype" = "Linux" -a "$have_libsystemd" = "yes"; then
		enable_systemd=yes
	else
		enable_systemd=no
	fi

fi

if test "x$enable_systemd" != "xyes"; then
  if test "x$with_systemd_journal" = "xauto"; then
    with_systemd_journal=no
  fi
fi

if test "x$enable_systemd" = "xyes"; then

        if test "x$with_systemdsystemunitdir" = "xyes"; then
		# no arguments, just --with-systemdsystemunitdir
		systemdsystemunitdir=`$PKG_CONFIG --variable=systemdsystemunitdir systemd`
		if test "$systemdsystemunitdir" = ""; then
			AC_MSG_ERROR([Error autodetecting systemdsystemunitdir, systemd pkg-config file not found?])
		fi
	elif test "$systemdsystemunitdir" = "no"; then
		# --without-systemdsystemunitdir was specified
		systemdsystemunitdir=""
	else
		systemdsystemunitdir="$with_systemdsystemunitdir"
	fi

        if test "x$have_libsystemd" = "xno"; then
	    PKG_CHECK_MODULES(libsystemd_daemon, libsystemd-daemon >= 31,enable_systemd="yes",enable_systemd="no")
            if test "x$with_systemd_journal" = "xauto"; then
                PKG_CHECK_MODULES(LIBSYSTEMD_JOURNAL, libsystemd-journal >= $JOURNALD_MIN_VERSION,
                                  with_systemd_journal=system, with_systemd_journal=optional)
            elif test "x$with_systemd_journal" = "xsystem"; then
                PKG_CHECK_MODULES(LIBSYSTEMD_JOURNAL, libsystemd-journal >= $JOURNALD_MIN_VERSION,,
                                  AC_MSG_ERROR([Detecting system related systemd-journal library failed]))
            fi
            libsystemd_CFLAGS="${LIBSYSTEMD_JOURNAL_CFLAGS} ${libsystemd_daemon_CFLAGS}"
            libsystemd_LIBS="${LIBSYSTEMD_JOURNAL_LIBS} ${libsystemd_daemon_LIBS}"
            AC_SUBST(libsystemd_CFLAGS)
            AC_SUBST(libsystemd_LIBS)
        else
            if test "x$with_systemd_journal" = "xauto"; then
                with_systemd_journal="system"
            fi
        fi
fi

PKG_CHECK_MODULES(UUID, uuid, enable_libuuid="yes", enable_libuuid="no")

dnl ***************************************************************************
dnl check if we have timezone variable in <time.h>
dnl ***************************************************************************
AC_VAR_TIMEZONE_EXTERNALS

dnl ***************************************************************************
dnl check fmemopen
dnl ***************************************************************************
AC_CHECK_FUNCS([fmemopen])

dnl ***************************************************************************
dnl default modules to be loaded
dnl ***************************************************************************

### The default set of modules are those that provide functionality that
### were provided in syslog-ng 3.2 and prior, unless explicitly overridden
### by the user.
###
### New plugins can be loaded by explicit "@module foo" lines in the
### configuration file, or by the autoloading mechanism.

if test "x$module_path" = "x"; then
	module_path="$moduledir"
	java_module_path="$moduledir"/java-modules
fi

CPPFLAGS="$CPPFLAGS $GLIB_CFLAGS $EVTLOG_CFLAGS $PCRE_CFLAGS $OPENSSL_CFLAGS $LIBNET_CFLAGS $LIBDBI_CFLAGS $IVYKIS_CFLAGS $LIBCAP_CFLAGS -D_GNU_SOURCE -D_DEFAULT_SOURCE -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"

########################################################
## NOTES: on how syslog-ng is linked
#
# There are two major linking modes currently:
#   1) dynamic: all libraries are linked dynamically, and assumed to be available as dynamic libraries
#
#   2) mixed: typical system provided libraries are linked dynamicaly, the
#      rest is linked statically (Glib etc).  Please note that _only_ the
#      main syslog-ng executable is linked this way so that it can be
#      started early during startup, tools and unit tests are linked
#      dynamically the same way.
#
# The following variables are introduced and AC_SUBSTed to be used in Makefiles:
#
# SYSLOGNG_DEPS_LIBS:
#       includes all dependendent libraries used by binary that can be linked in mixed mode (e.g. only the syslog-ng binary).
#
# TOOL_DEPS_LIBS:
#       executables (e.g. tools & unit test programs) that link against
#       libsyslog-ng.so should be linked with this set of libraries.  other
#       tools that do not use libsyslog-ng.so can use the _LIBS variables
#       directly.
#
# CORE_DEPS_LIBS:
#	libsyslog-ng.so is linked with this set of libraries.
#
# MODULE_DEPS_LIBS:
#       The set of libraries that modules should be linked against. Only to
#       satisfy their "core" dependency, any other libs that the core doesn't
#       depend on must be linked explicitly.
#
# MODULE_LDFLAGS:
#       The LDFLAGS to be passed when linking modules (may not contain
#       library references -l and such, only linker flags)
#
# Modules should be linked against libsyslog-ng.la and libraries that are
# _NOT_ linked into libsyslog-ng.la no need to define a LIBS variable for
# that.


if test -z "$MODULE_LDFLAGS"; then
	MODULE_LDFLAGS="-avoid-version -module -no-undefined"
fi
MODULE_DEPS_LIBS="\$(top_builddir)/lib/libsyslog-ng.la"

if test "x$linking_mode" = "xdynamic"; then
	SYSLOGNG_DEPS_LIBS="$LIBS $BASE_LIBS $GLIB_LIBS $EVTLOG_LIBS $SECRETSTORAGE_LIBS $RESOLV_LIBS $LIBCAP_LIBS $PCRE_LIBS $REGEX_LIBS $DL_LIBS"

	if test "x$with_ivykis" = "xinternal"; then
		# when using the internal ivykis, we're linking it statically into libsyslog-ng.so

		TOOL_DEPS_LIBS="$SYSLOGNG_DEPS_LIBS"
		CORE_DEPS_LIBS="$SYSLOGNG_DEPS_LIBS $IVYKIS_LIBS"
	else
		# otherwise everything needs to link against libivykis.so

		SYSLOGNG_DEPS_LIBS="$SYSLOGNG_DEPS_LIBS $IVYKIS_LIBS"

		TOOL_DEPS_LIBS="$SYSLOGNG_DEPS_LIBS"
		CORE_DEPS_LIBS="$SYSLOGNG_DEPS_LIBS"
	fi

	# syslog-ng binary is linked with the default link command (e.g. libtool)
	SYSLOGNG_LINK='$(LINK)'
else
	SYSLOGNG_DEPS_LIBS="$LIBS $BASE_LIBS $RESOLV_LIBS $EVTLOG_NO_LIBTOOL_LIBS $SECRETSTORAGE_NO_LIBTOOL_LIBS $LD_START_STATIC -Wl,${WHOLE_ARCHIVE_OPT} $GLIB_LIBS $PCRE_LIBS $REGEX_LIBS  -Wl,${NO_WHOLE_ARCHIVE_OPT} $IVYKIS_NO_LIBTOOL_LIBS $LD_END_STATIC $LIBCAP_LIBS $DL_LIBS"
	TOOL_DEPS_LIBS="$LIBS $BASE_LIBS $GLIB_LIBS $EVTLOG_LIBS $SECRETSTORAGE_LIBS $RESOLV_LIBS $LIBCAP_LIBS $PCRE_LIBS $REGEX_LIBS $IVYKIS_LIBS $DL_LIBS"
	CORE_DEPS_LIBS=""

	# bypass libtool in case we want to do mixed linking because it
	# doesn't support -Wl,-Bstatic -Wl,-Bdynamic on a per-library basis.
	SYSLOGNG_LINK='$(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@'
fi
YFLAGS="-d"

enable_value()
{
        if test "x$1" = "xyes" ; then
                echo 1
        else
                echo 0
        fi
}

journald_mode()
{
  if test "x$with_systemd_journal" = "xno"; then
    echo SYSLOG_NG_JOURNALD_OFF
  elif test "x$with_systemd_journal" = "xsystem"; then
    echo SYSLOG_NG_JOURNALD_SYSTEM
  else
    echo SYSLOG_NG_JOURNALD_OPTIONAL
  fi
}

AC_DEFINE_UNQUOTED(JOURNALD_OFF, 0, ["Disable systemd-journal source"])
AC_DEFINE_UNQUOTED(JOURNALD_OPTIONAL, 1, ["Enable systemd-journal source if journald is available"])
AC_DEFINE_UNQUOTED(JOURNALD_SYSTEM, 2, ["Force systemd-journal source to use system's journald"])

AC_DEFINE_UNQUOTED(VERSION, "$PACKAGE_VERSION", [version number])
AC_DEFINE_UNQUOTED(SOURCE_REVISION, "$SOURCE_REVISION", [source revision])
AC_DEFINE_UNQUOTED(LICENSE_VERSION, "$LICENSE_VERSION", [Required license version])

AC_DEFINE_UNQUOTED(PATH_PREFIX, "$prefix", [prefix directory])
AC_DEFINE_UNQUOTED(PATH_EXECPREFIX, "$exec_prefix", [execprefix directory])

AC_DEFINE_UNQUOTED(PATH_SYSCONFDIR, "$sysconfdir", [sysconfdir])
AC_DEFINE_UNQUOTED(PATH_LOCALSTATEDIR, "$localstatedir", [local state directory])
AC_DEFINE_UNQUOTED(PATH_PIDFILEDIR, "$pidfiledir", [local state directory])
AC_DEFINE_UNQUOTED(PATH_DATAROOTDIR, "$datarootdir", [data root directory])
AC_DEFINE_UNQUOTED(PATH_DATADIR, "$datadir", [data directory])
AC_DEFINE_UNQUOTED(PATH_CONFIG_INCLUDEDIR, "$config_includedir", [include directory])
AC_DEFINE_UNQUOTED(PATH_SCLDIR, "$scldir", [SCL directory])
AC_DEFINE_UNQUOTED(PATH_XSDDIR, "$xsddir", [XSD directory])
AC_DEFINE_UNQUOTED(PATH_LIBEXECDIR, "$libexecdir", [libexec directory])
if test -n "$timezonedir"; then
        AC_DEFINE_UNQUOTED(PATH_TIMEZONEDIR, "$timezonedir", [timezone base directory])
fi
if test -n "$env_ld_library_path"; then
        AC_DEFINE_UNQUOTED(ENV_LD_LIBRARY_PATH, "$env_ld_library_path", [set LD_LIBRARY_PATH to this value])
fi
AC_DEFINE_UNQUOTED(PATH_MODULEDIR, "$moduledir", [module installation directory])
AC_DEFINE_UNQUOTED(PATH_LOGGENPLUGINDIR, "$loggenplugindir", [loggenplugin installation directory])
AC_DEFINE_UNQUOTED(MODULE_PATH, "$module_path", [module search path])
AC_DEFINE_UNQUOTED(JAVA_MODULE_PATH, "$java_module_path", [java module search path])
AC_DEFINE_UNQUOTED(PATH_TOPSRC_DIR, "$abs_topsrcdir", [self-defined top_srcdir path])
AC_DEFINE_UNQUOTED(PACKAGE_NAME, "$PACKAGE_NAME", [package name])


AC_DEFINE_UNQUOTED(WITH_COMPILE_DATE, $wcmp_date, [Include the compile date in the binary])
AC_DEFINE_UNQUOTED(ENABLE_FORCED_SERVER_MODE, `enable_value $enable_forced_server_mode`, [Enable forced server mode])
AC_DEFINE_UNQUOTED(ENABLE_DEBUG, `enable_value $enable_debug`, [Enable debugging])
AC_DEFINE_UNQUOTED(ENABLE_LIBUUID, `enable_value $enable_libuuid`, [Enable libuuid support])
AC_DEFINE_UNQUOTED(ENABLE_GPROF, `enable_value $enable_gprof`, [Enable gcc profiling])
AC_DEFINE_UNQUOTED(ENABLE_MEMTRACE, `enable_value $enable_memtrace`, [Enable memtrace])
AC_DEFINE_UNQUOTED(ENABLE_SPOOF_SOURCE, `enable_value $enable_spoof_source`, [Enable spoof source support])
AC_DEFINE_UNQUOTED(ENABLE_IPV6, `enable_value $enable_ipv6`, [Enable IPv6 support])
AC_DEFINE_UNQUOTED(ENABLE_TCP_WRAPPER, `enable_value $enable_tcp_wrapper`, [Enable TCP wrapper support])
AC_DEFINE_UNQUOTED(ENABLE_LINUX_CAPS, `enable_value $enable_linux_caps`, [Enable Linux capability management support])
AC_DEFINE_UNQUOTED(ENABLE_ENV_WRAPPER, `enable_value $enable_env_wrapper`, [Enable environment wrapper support])
AC_DEFINE_UNQUOTED(ENABLE_SYSTEMD, `enable_value $enable_systemd`, [Enable systemd support])
AC_DEFINE_UNQUOTED(SYSTEMD_JOURNAL_MODE, `journald_mode`, [Systemd-journal support mode])
AC_DEFINE_UNQUOTED(HAVE_INOTIFY, `enable_value $ac_cv_func_inotify_init`, [Have inotify])
AC_DEFINE_UNQUOTED(HAVE_GETRANDOM, `enable_value $ac_cv_func_getrandom`, [Have getrandom])
AC_DEFINE_UNQUOTED(ENABLE_PYTHONv2, `(echo "$with_python" | grep -Eq "python-?2.*") && echo 1 || echo 0`, [Python2 c api])
AC_DEFINE_UNQUOTED(ENABLE_PYTHONv3, `(echo "$with_python" | grep -Eq "python-?3.*") && echo 1 || echo 0`, [Python3 c api])
AC_DEFINE_UNQUOTED(HAVE_RIEMANN_MICROSECONDS, `enable_value $riemann_micros`, [Riemann microseconds support])
AC_DEFINE_UNQUOTED(USE_CONST_IVYKIS_MOCK, `enable_value $IVYKIS_VERSION_UPDATED`, [ivykis version is greater than $IVYKIS_UPDATED_VERSION])

AM_CONDITIONAL(ENABLE_ENV_WRAPPER, [test "$enable_env_wrapper" = "yes"])
AM_CONDITIONAL(ENABLE_SYSTEMD, [test "$enable_systemd" = "yes"])
AM_CONDITIONAL(ENABLE_SYSTEMD_UNIT_INSTALL, [test "$systemdsystemunitdir" != ""])
AM_CONDITIONAL(ENABLE_SQL, [test "$enable_sql" = "yes"])
AM_CONDITIONAL(ENABLE_SUN_STREAMS, [test "$enable_sun_streams" = "yes"])
AM_CONDITIONAL(ENABLE_OPENBSD_SYSTEM_SOURCE, [test "$enable_openbsd_system_source" = "yes"])
AM_CONDITIONAL(ENABLE_PACCT, [test "$enable_pacct" = "yes"])
AM_CONDITIONAL(ENABLE_MONGODB, [test "$enable_mongodb" = "yes"])
AM_CONDITIONAL(ENABLE_SMTP, [test "$enable_smtp" = "yes"])
AM_CONDITIONAL(ENABLE_HTTP, [test "$enable_http" = "yes"])
AM_CONDITIONAL(ENABLE_AMQP, [test "$enable_amqp" = "yes"])
AM_CONDITIONAL(ENABLE_STOMP, [test "$enable_stomp" = "yes"])
AM_CONDITIONAL(ENABLE_JSON, [test "$enable_json" = "yes"])
AM_CONDITIONAL(ENABLE_GEOIP, [test "$enable_geoip" = "yes"])
AM_CONDITIONAL(ENABLE_GEOIP2, [test "$enable_geoip2" = "yes"])
AM_CONDITIONAL(ENABLE_REDIS, [test "$enable_redis" = "yes"])
AM_CONDITIONAL(IVYKIS_INTERNAL, [test "x$with_ivykis" = "xinternal"])
AM_CONDITIONAL(JSON_INTERNAL, [test "x$JSON_SUBDIRS" != "x"])
AM_CONDITIONAL(LIBMONGO_INTERNAL, [test "x$LIBMONGO_SUBDIRS" != "x"])
AM_CONDITIONAL(LIBRABBITMQ_INTERNAL, [test "x$with_librabbitmq_client" = "xinternal"])
AM_CONDITIONAL(ENABLE_RIEMANN, [test "$enable_riemann" != "no"])
AM_CONDITIONAL(ENABLE_JOURNALD, [test "$with_systemd_journal" != "no"])
AM_CONDITIONAL(ENABLE_PYTHON, [test "$enable_python" != "no"])
AM_CONDITIONAL(ENABLE_JAVA, [test "$enable_java" = "yes"])
AM_CONDITIONAL(ENABLE_JAVA_MODULES, [test "$enable_java_modules" = "yes"])
AM_CONDITIONAL(ENABLE_MANPAGES, [test "$enable_manpages" != "no"])
AM_CONDITIONAL(ENABLE_NATIVE, [test "$enable_native" != "no"])
AM_CONDITIONAL(ENABLE_EXTRA_WARNINGS, [test "$enable_extra_warnings" = "yes"])
AM_CONDITIONAL(ENABLE_LEGACY_MONGODB_OPTIONS, [test x"$enable_legacy_mongodb_options" != x"no"])
AM_CONDITIONAL(ENABLE_TESTING, [test "$enable_tests" != "no"])
AM_CONDITIONAL([HAVE_INOTIFY], [test x$ac_cv_func_inotify_init = xyes])
AM_CONDITIONAL([HAVE_GETRANDOM], [test x$ac_cv_func_getrandom = xyes])
AM_CONDITIONAL([HAVE_FMEMOPEN], [test x$ac_cv_func_fmemopen = xyes])
AM_CONDITIONAL(ENABLE_IPV6, [test $enable_ipv6 = yes])

AC_SUBST(timezonedir)
AC_SUBST(pidfiledir)
AC_SUBST(moduledir)
AC_SUBST(loggenplugindir)
AC_SUBST(toolsdir)
AC_SUBST(config_includedir)
AC_SUBST(scldir)
AC_SUBST(abs_topsrcdir)
AC_SUBST(xsddir)
AC_SUBST(systemdsystemunitdir)
AC_SUBST(SYSLOGNG_LINK)
AC_SUBST(SYSLOGNG_DEPS_LIBS)
AC_SUBST(TOOL_DEPS_LIBS)
AC_SUBST(CORE_DEPS_LIBS)
AC_SUBST(MODULE_DEPS_LIBS)
AC_SUBST(MODULE_LDFLAGS)
AC_SUBST(BASE_LIBS)
AC_SUBST(YFLAGS)
AC_SUBST(LIBNET_LIBS)
AC_SUBST(LIBNET_CFLAGS)
AC_SUBST(LIBWRAP_LIBS)
AC_SUBST(LIBWRAP_CFLAGS)
AC_SUBST(ZLIB_LIBS)
AC_SUBST(ZLIB_CFLAGS)
AC_SUBST(LIBDBI_LIBS)
AC_SUBST(LIBDBI_CFLAGS)
AC_SUBST(LIBMONGO_LIBS)
AC_SUBST(LIBMONGO_CFLAGS)
AC_SUBST(LIBMONGO_SUBDIRS)
AC_SUBST(LIBESMTP_CFLAGS)
AC_SUBST(LIBESMTP_LIBS)
AC_SUBST(LIBCURL_CFLAGS)
AC_SUBST(LIBCURL_LIBS)
AC_SUBST(LIBRABBITMQ_LIBS)
AC_SUBST(LIBRABBITMQ_CFLAGS)
AC_SUBST(LIBRABBITMQ_SUBDIRS)
AC_SUBST(JSON_LIBS)
AC_SUBST(JSON_CFLAGS)
AC_SUBST(JSON_SUBDIRS)
AC_SUBST(JSON_DEPENDENCY)
AC_SUBST(IVYKIS_SUBDIRS)
AC_SUBST(RESOLV_LIBS)
AC_SUBST(UUID_CFLAGS)
AC_SUBST(UUID_LIBS)

AC_SUBST(CURRDATE)
AC_SUBST(RELEASE_TAG)
AC_SUBST(SNAPSHOT_VERSION)
AC_SUBST(SOURCE_REVISION)
AC_SUBST(with_ivykis)
AC_SUBST(INTERNAL_IVYKIS_CFLAGS)
AC_SUBST(LIBSYSTEMD_JOURNAL_CFLAGS)
AC_SUBST(LIBSYSTEMD_JOURNAL_LIBS)
AC_SUBST(XSL_STYLESHEET)

AX_PREFIX_CONFIG_H(syslog-ng-config.h, "SYSLOG_NG")
AX_VALGRIND_CHECK

AC_OUTPUT(dist.conf
          Makefile
	  syslog-ng.spec
	  syslog-ng.pc
          libtest/syslog-ng-test.pc
	  scripts/update-patterndb
          )

echo
echo "syslog-ng Open Source Edition $PACKAGE_VERSION configured"
echo " Edition settings:"
echo "  Release type                : $RELEASE_TYPE"
echo "  Pretty version              : $BROCHURE_VERSION"
echo "  Combined vers.              : $COMBINED_VERSION"
echo "  Package name                : $PACKAGE_NAME"
echo " Compiler options:"
echo "  compiler                    : $CC"
echo "  compiler options            : $CFLAGS $CPPFLAGS"
echo "  linker flags                : $LDFLAGS $LIBS"
echo "  prefix                      : $prefix"
echo "  linking mode                : $linking_mode"
echo "  embedded crypto             : ${with_embedded_crypto:=no}"
echo "  __thread keyword            : ${ac_cv_have_tls:=no}"
echo " Test dependencies:"
echo "  Criterion                   : ${with_criterion:=no}"
echo "  Unit tests                  : ${enable_tests:=no}"
echo " Submodules:"
echo "  ivykis                      : $with_ivykis"
echo "  jsonc                       : $with_jsonc"
echo " Features:"
echo "  Forced server mode          : ${enable_forced_server_mode:=yes}"
echo "  Debug symbols               : ${enable_debug:=no}"
echo "  GCC profiling               : ${enable_gprof:=no}"
echo "  Memtrace                    : ${enable_memtrace:=no}"
echo "  IPV6 support                : ${enable_ipv6:=no}"
echo "  spoof-source support        : ${enable_spoof_source:=no}"
echo "  tcp-wrapper support         : ${enable_tcp_wrapper:=no}"
echo "  Linux capability support    : ${has_linux_caps:=no}"
echo "  Env wrapper support         : ${enable_env_wrapper:=no}"
echo "  systemd support             : ${enable_systemd:=no} (unit dir: ${systemdsystemunitdir:=none})"
echo "  systemd-journal support     : ${with_systemd_journal:=no}"
echo "  libmongo-client options     : ${enable_legacy_mongodb_options}"
echo " Modules:"
echo "  Module search path          : ${module_path}"
echo "  Sun STREAMS support (module): ${enable_sun_streams:=no}"
echo "  OpenBSD syslog (module)     : ${enable_openbsd_system_source:=no}"
echo "  SQL support (module)        : ${enable_sql:=no}"
echo "  PACCT module (EXPERIMENTAL) : ${enable_pacct:=no}"
echo "  MongoDB destination (module): ${enable_mongodb:=no}"
echo "  JSON support (module)       : ${enable_json:=no}"
echo "  SMTP support (module)       : ${enable_smtp:=no}"
echo "  HTTP support (module)       : ${enable_http:=no}"
echo "  AMQP destination (module)   : ${enable_amqp:=no}"
echo "  STOMP destination (module)  : ${enable_stomp:=no}"
echo "  GEOIP support (module)      : ${enable_geoip:=no}"
echo "  GEOIP2 support (module)     : ${enable_geoip2:=no}"
echo "  Redis support (module)      : ${enable_redis:=no}"
echo "  Riemann destination (module): ${enable_riemann:=no}, microseconds: ${riemann_micros:=no}"
echo "  python                      : ${enable_python:=no} (pkg-config package: ${with_python:=none})"
echo "  java                        : ${enable_java:=no}"
echo "  java modules                : ${enable_java_modules:=no}"
echo "  native bindings             : ${enable_native:=no}"