summaryrefslogtreecommitdiffstats
path: root/configure.ac
blob: 384195925f19c35f89fcc0f848e56663f27971c9 (plain)
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
dnl  Copyright (c) 2006-2016 Red Hat, Inc. <http://www.redhat.com>
dnl  This file is part of GlusterFS.
dnl
dnl  This file is licensed to you under your choice of the GNU Lesser
dnl  General Public License, version 3 or any later version (LGPLv3 or
dnl  later), or the GNU General Public License, version 2 (GPLv2), in all
dnl  cases as published by the Free Software Foundation.

AC_INIT([glusterfs],
        [m4_esyscmd([build-aux/pkg-version --version])],
        [gluster-users@gluster.org],,[https://github.com/gluster/glusterfs.git])

AC_SUBST([PACKAGE_RELEASE],
         [m4_esyscmd([build-aux/pkg-version --release])])

AM_INIT_AUTOMAKE(tar-pax)

# Removes warnings when using automake 1.14 around (...but option 'subdir-objects' is disabled )
#but libglusterfs fails to build with contrib (Then are not set up that way?)
#AM_INIT_AUTOMAKE([subdir-objects])

m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])

if make --help 2>&1 | grep -q no-print-directory; then
   AM_MAKEFLAGS="$AM_MAKEFLAGS --no-print-directory";
fi

if make --help 2>&1 | grep -q quiet; then
   AM_MAKEFLAGS="$AM_MAKEFLAGS --quiet"
fi

if libtool --help 2>&1 | grep -q quiet; then
   AM_LIBTOOLFLAGS="--quiet";
fi

AC_CONFIG_HEADERS([config.h site.h])

AC_CONFIG_FILES([Makefile
                libglusterfs/Makefile
                libglusterfs/src/Makefile
                libglusterfs/src/gfdb/Makefile
                geo-replication/src/peer_gsec_create
                geo-replication/src/peer_mountbroker
                geo-replication/src/peer_mountbroker.py
                geo-replication/src/peer_georep-sshkey.py
                extras/peer_add_secret_pub
                geo-replication/syncdaemon/conf.py
                extras/snap_scheduler/conf.py
                glusterfsd/Makefile
                glusterfsd/src/Makefile
                rpc/Makefile
                rpc/rpc-lib/Makefile
                rpc/rpc-lib/src/Makefile
                rpc/rpc-transport/Makefile
                rpc/rpc-transport/socket/Makefile
                rpc/rpc-transport/socket/src/Makefile
                rpc/rpc-transport/rdma/Makefile
                rpc/rpc-transport/rdma/src/Makefile
                rpc/xdr/Makefile
                rpc/xdr/src/Makefile
                rpc/xdr/gen/Makefile
                xlators/Makefile
                xlators/meta/Makefile
                xlators/meta/src/Makefile
                xlators/mount/Makefile
                xlators/mount/fuse/Makefile
                xlators/mount/fuse/src/Makefile
                xlators/mount/fuse/utils/mount.glusterfs
                xlators/mount/fuse/utils/mount_glusterfs
                xlators/mount/fuse/utils/Makefile
                xlators/storage/Makefile
                xlators/storage/posix/Makefile
                xlators/storage/posix/src/Makefile
                xlators/storage/bd/Makefile
                xlators/storage/bd/src/Makefile
                xlators/cluster/Makefile
                xlators/cluster/afr/Makefile
                xlators/cluster/afr/src/Makefile
                xlators/cluster/stripe/Makefile
                xlators/cluster/stripe/src/Makefile
                xlators/cluster/dht/Makefile
                xlators/cluster/dht/src/Makefile
                xlators/cluster/ec/Makefile
                xlators/cluster/ec/src/Makefile
                xlators/performance/Makefile
                xlators/performance/write-behind/Makefile
                xlators/performance/write-behind/src/Makefile
                xlators/performance/read-ahead/Makefile
                xlators/performance/read-ahead/src/Makefile
                xlators/performance/readdir-ahead/Makefile
                xlators/performance/readdir-ahead/src/Makefile
                xlators/performance/io-threads/Makefile
                xlators/performance/io-threads/src/Makefile
                xlators/performance/io-cache/Makefile
                xlators/performance/io-cache/src/Makefile
                xlators/performance/symlink-cache/Makefile
                xlators/performance/symlink-cache/src/Makefile
                xlators/performance/quick-read/Makefile
                xlators/performance/quick-read/src/Makefile
                xlators/performance/open-behind/Makefile
                xlators/performance/open-behind/src/Makefile
                xlators/performance/md-cache/Makefile
                xlators/performance/md-cache/src/Makefile
                xlators/performance/decompounder/Makefile
                xlators/performance/decompounder/src/Makefile
                xlators/performance/nl-cache/Makefile
                xlators/performance/nl-cache/src/Makefile
                xlators/debug/Makefile
                xlators/debug/sink/Makefile
                xlators/debug/sink/src/Makefile
                xlators/debug/trace/Makefile
                xlators/debug/trace/src/Makefile
                xlators/debug/error-gen/Makefile
                xlators/debug/error-gen/src/Makefile
                xlators/debug/io-stats/Makefile
                xlators/debug/io-stats/src/Makefile
                xlators/protocol/Makefile
                xlators/protocol/auth/Makefile
                xlators/protocol/auth/addr/Makefile
                xlators/protocol/auth/addr/src/Makefile
                xlators/protocol/auth/login/Makefile
                xlators/protocol/auth/login/src/Makefile
                xlators/protocol/client/Makefile
                xlators/protocol/client/src/Makefile
                xlators/protocol/server/Makefile
                xlators/protocol/server/src/Makefile
                xlators/features/Makefile
                xlators/features/arbiter/Makefile
                xlators/features/arbiter/src/Makefile
                xlators/features/changelog/Makefile
                xlators/features/changelog/src/Makefile
                xlators/features/changelog/lib/Makefile
                xlators/features/changelog/lib/src/Makefile
                xlators/features/changetimerecorder/Makefile
                xlators/features/changetimerecorder/src/Makefile
                xlators/features/glupy/Makefile
                xlators/features/glupy/examples/Makefile
                xlators/features/glupy/src/Makefile
                xlators/features/glupy/src/setup.py
                xlators/features/glupy/src/__init__.py
                xlators/features/glupy/src/glupy/Makefile
                xlators/features/locks/Makefile
                xlators/features/locks/src/Makefile
                xlators/features/quota/Makefile
                xlators/features/quota/src/Makefile
                xlators/features/marker/Makefile
                xlators/features/marker/src/Makefile
                xlators/features/selinux/Makefile
                xlators/features/selinux/src/Makefile
                xlators/features/read-only/Makefile
                xlators/features/read-only/src/Makefile
                xlators/features/compress/Makefile
                xlators/features/compress/src/Makefile
                xlators/features/quiesce/Makefile
                xlators/features/quiesce/src/Makefile
                xlators/features/barrier/Makefile
                xlators/features/barrier/src/Makefile
                xlators/features/index/Makefile
                xlators/features/index/src/Makefile
                xlators/features/gfid-access/Makefile
                xlators/features/gfid-access/src/Makefile
                xlators/features/trash/Makefile
                xlators/features/trash/src/Makefile
                xlators/features/snapview-server/Makefile
                xlators/features/snapview-server/src/Makefile
                xlators/features/snapview-client/Makefile
                xlators/features/snapview-client/src/Makefile
                xlators/features/upcall/Makefile
                xlators/features/upcall/src/Makefile
                xlators/features/shard/Makefile
                xlators/features/shard/src/Makefile
                xlators/features/bit-rot/Makefile
                xlators/features/bit-rot/src/Makefile
                xlators/features/bit-rot/src/stub/Makefile
                xlators/features/bit-rot/src/bitd/Makefile
                xlators/features/leases/Makefile
                xlators/features/leases/src/Makefile
                xlators/playground/Makefile
                xlators/playground/template/Makefile
                xlators/playground/template/src/Makefile
                xlators/encryption/Makefile
                xlators/encryption/rot-13/Makefile
                xlators/encryption/rot-13/src/Makefile
                xlators/encryption/crypt/Makefile
                xlators/encryption/crypt/src/Makefile
                xlators/system/Makefile
                xlators/system/posix-acl/Makefile
                xlators/system/posix-acl/src/Makefile
                xlators/nfs/Makefile
                xlators/nfs/server/Makefile
                xlators/nfs/server/src/Makefile
                xlators/mgmt/Makefile
                xlators/mgmt/glusterd/Makefile
                xlators/mgmt/glusterd/src/Makefile
                cli/Makefile
                cli/src/Makefile
                doc/Makefile
                extras/Makefile
                extras/glusterd.vol
                extras/cliutils/Makefile
                extras/init.d/Makefile
                extras/init.d/glusterd.plist
                extras/init.d/glusterd-Debian
                extras/init.d/glusterd-Redhat
                extras/init.d/glusterd-FreeBSD
                extras/init.d/glusterd-SuSE
                extras/init.d/glustereventsd-Debian
                extras/init.d/glustereventsd-Redhat
                extras/init.d/glustereventsd-FreeBSD
                extras/systemd/Makefile
                extras/systemd/glusterd.service
                extras/systemd/glustereventsd.service
                extras/systemd/glusterfssharedstorage.service
                extras/run-gluster.tmpfiles
                extras/benchmarking/Makefile
                extras/hook-scripts/Makefile
                extras/ocf/Makefile
                extras/ocf/glusterd
                extras/ocf/volume
                extras/LinuxRPM/Makefile
                extras/geo-rep/Makefile
                extras/geo-rep/schedule_georep.py
                extras/firewalld/Makefile
                extras/hook-scripts/add-brick/Makefile
                extras/hook-scripts/add-brick/pre/Makefile
                extras/hook-scripts/add-brick/post/Makefile
                extras/hook-scripts/create/Makefile
                extras/hook-scripts/create/post/Makefile
                extras/hook-scripts/delete/Makefile
                extras/hook-scripts/delete/pre/Makefile
                extras/hook-scripts/start/Makefile
                extras/hook-scripts/start/post/Makefile
                extras/hook-scripts/set/Makefile
                extras/hook-scripts/set/post/Makefile
                extras/hook-scripts/stop/Makefile
                extras/hook-scripts/stop/pre/Makefile
                extras/hook-scripts/reset/Makefile
                extras/hook-scripts/reset/post/Makefile
                extras/hook-scripts/reset/pre/Makefile
                extras/snap_scheduler/Makefile
                events/Makefile
                events/src/Makefile
                events/src/eventsapiconf.py
                events/tools/Makefile
                contrib/fuse-util/Makefile
                contrib/umountd/Makefile
                contrib/uuid/uuid_types.h
                glusterfs-api.pc
                libgfchangelog.pc
                libgfdb.pc
                api/Makefile
                api/src/Makefile
                api/examples/Makefile
                geo-replication/Makefile
                geo-replication/src/Makefile
                geo-replication/syncdaemon/Makefile
                tools/Makefile
                tools/gfind_missing_files/Makefile
                heal/Makefile
                heal/src/Makefile
                glusterfs.spec
		tools/glusterfind/src/tool.conf
	        tools/glusterfind/glusterfind
	        tools/glusterfind/Makefile
                tools/glusterfind/src/Makefile
                tools/setgfid2path/Makefile
                tools/setgfid2path/src/Makefile
                tests/basic/fuse/Makefile
                tests/basic/gfapi/Makefile])

AC_CANONICAL_HOST

AC_PROG_CC
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
AC_SUBST([shrext_cmds])

AC_CHECK_PROG([RPCGEN], [rpcgen], [yes], [no])

if test "x$RPCGEN" = "xno"; then
   AC_MSG_ERROR([`rpcgen` not found, glusterfs needs `rpcgen` exiting..])
fi

# Initialize CFLAGS before usage
AC_ARG_ENABLE([debug],
              AC_HELP_STRING([--enable-debug],
                             [Enable debug build options.]))
if test "x$enable_debug" = "xyes"; then
        BUILD_DEBUG=yes
        CFLAGS="${CFLAGS} -g -rdynamic -O0 -DDEBUG"
else
        BUILD_DEBUG=no
        CFLAGS="${CFLAGS} -g -rdynamic"
fi

AC_ARG_ENABLE([privport_tracking],
              AC_HELP_STRING([--disable-privport_tracking],
                             [Disable internal tracking of privileged ports.]))
TRACK_PRIVPORTS="yes"
if test x"$enable_privport_tracking" = x"no"; then
        TRACK_PRIVPORTS="no"
        AC_DEFINE(GF_DISABLE_PRIVPORT_TRACKING, 1,
                  [Disable internal tracking of privileged ports.])
fi

case $host_os in
  darwin*)
    if ! test "`/usr/bin/sw_vers | grep ProductVersion: | cut -f 2 | cut -d. -f2`" -ge 7; then
       AC_MSG_ERROR([You need at least OS X 10.7 (Lion) to build Glusterfs])
    fi
    # OSX version lesser than 9 has llvm/clang optimization issues which leads to various segfaults
    if test "`/usr/bin/sw_vers | grep ProductVersion: | cut -f 2 | cut -d. -f2`" -lt 9; then
       CFLAGS="${CFLAGS} -g -O0 -DDEBUG"
    fi
    ;;
esac

# --enable-valgrind prevents calling dlclose(), this leaks memory
AC_ARG_ENABLE([valgrind],
              AC_HELP_STRING([--enable-valgrind],
                             [Enable valgrind for resource leak debugging.]))
if test "x$enable_valgrind" = "xyes"; then
        AC_DEFINE(RUN_WITH_VALGRIND, 1, [define if all processes should run under valgrind])
fi


AC_ARG_WITH([previous-options],
        [AS_HELP_STRING([--with-previous-options],
                        [read config.status for configure options])
        ],
        [ if test -r ./config.status && \
             args=$(grep 'ac_cs_config=' config.status | \
                    sed -e 's/.*"\(.*\)".*/\1/'| sed -e "s/'//g") ; then
            echo "###"
            echo "### Rerunning as '$0 $args'"
            echo "###"
            exec $0 $args
          fi
        ])

AC_ARG_WITH(pkgconfigdir,
            [  --with-pkgconfigdir=DIR      pkgconfig file in DIR @<:@LIBDIR/pkgconfig@:>@],
            [pkgconfigdir=$withval],
            [pkgconfigdir='${libdir}/pkgconfig'])
AC_SUBST(pkgconfigdir)

AC_ARG_WITH(mountutildir,
            [  --with-mountutildir=DIR mount helper utility in DIR @<:@/sbin@:>@],
            [mountutildir=$withval],
            [mountutildir='/sbin'])
AC_SUBST(mountutildir)

AC_ARG_WITH(systemddir,
            [  --with-systemddir=DIR systemd service files in DIR @<:@PREFIX/lib/systemd/system@:>@],
            [systemddir=$withval],
            [systemddir='${prefix}/lib/systemd/system'])
AC_SUBST(systemddir)
AM_CONDITIONAL([USE_SYSTEMD], test [ -d '/usr/lib/systemd/system' ])

AC_ARG_WITH(initdir,
            [  --with-initdir=DIR init.d scripts in DIR @<:@/etc/init.d@:>@],
            [initdir=$withval],
            [initdir='/etc/init.d'])
AC_SUBST(initdir)

AC_ARG_WITH(launchddir,
            [  --with-launchddir=DIR launchd services in DIR @<:@/Library/LaunchDaemons@:>@],
            [launchddir=$withval],
            [launchddir='/Library/LaunchDaemons'])
AC_SUBST(launchddir)

AC_ARG_WITH(tmpfilesdir,
            AC_HELP_STRING([--with-tmpfilesdir=DIR],
                           [tmpfiles config in DIR, disabled by default]),
            [tmpfilesdir=$withval],
            [tmpfilesdir=''])
AC_SUBST(tmpfilesdir)

AC_ARG_WITH([ocf],
            [AS_HELP_STRING([--without-ocf], [build OCF-compliant cluster resource agents])],
            ,
            [OCF_SUBDIR='ocf'],
            )
AC_SUBST(OCF_SUBDIR)

# LEX needs a check
AC_PROG_LEX
if test  "x${LEX}" != "xflex" -a "x${FLEX}" != "xlex"; then
   AC_MSG_ERROR([Flex or lex required to build glusterfs.])
fi

dnl
dnl Word sizes...
dnl
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
SIZEOF_SHORT=$ac_cv_sizeof_short
SIZEOF_INT=$ac_cv_sizeof_int
SIZEOF_LONG=$ac_cv_sizeof_long
SIZEOF_LONG_LONG=$ac_cv_sizeof_long_long
AC_SUBST(SIZEOF_SHORT)
AC_SUBST(SIZEOF_INT)
AC_SUBST(SIZEOF_LONG)
AC_SUBST(SIZEOF_LONG_LONG)

# YACC needs a check
AC_PROG_YACC
if test "x${YACC}" = "xbyacc" -o "x${YACC}" = "xyacc" -o "x${YACC}" = "x"; then
   AC_MSG_ERROR([GNU Bison required to build glusterfs.])
fi

AC_CHECK_TOOL([LD],[ld])

AC_CHECK_LIB([crypto], [MD5], , AC_MSG_ERROR([OpenSSL crypto library is required to build glusterfs]))

AC_CHECK_LIB([pthread], [pthread_mutex_init], , AC_MSG_ERROR([Posix threads library is required to build glusterfs]))

AC_CHECK_FUNC([dlopen], [has_dlopen=yes], AC_CHECK_LIB([dl], [dlopen], , AC_MSG_ERROR([Dynamic linking library required to build glusterfs])))

AC_CHECK_LIB([readline], [rl_do_undo], [RL_UNDO="yes"], [RL_UNDO="no"])

AC_CHECK_LIB([intl], [gettext])

AC_CHECK_HEADERS([sys/xattr.h])

AC_CHECK_HEADERS([sys/ioctl.h], AC_DEFINE(HAVE_IOCTL_IN_SYS_IOCTL_H, 1, [have sys/ioctl.h]))

AC_CHECK_HEADERS([sys/extattr.h])

AC_CHECK_HEADERS([openssl/dh.h])

AC_CHECK_HEADERS([openssl/ecdh.h])

dnl Math library
AC_CHECK_LIB([m], [pow], [MATH_LIB='-lm'], [MATH_LIB=''])
AC_SUBST(MATH_LIB)

dnl use libuuid.so or fall-back to contrib/uuid
PKG_CHECK_MODULES([UUID], [uuid],
        [have_uuid=yes
         AC_DEFINE(HAVE_LIBUUID, 1, [have libuuid.so])
         PKGCONFIG_UUID=uuid],
        [have_uuid=no
         UUID_CFLAGS='-I$(CONTRIBDIR)/uuid'])
AM_CONDITIONAL([HAVE_LIBUUID], [test x$have_uuid = xyes])

dnl older version of libuuid (from e2fsprogs) require including uuid/uuid.h
saved_CFLAGS=${CFLAGS}
CFLAGS="${CFLAGS} ${UUID_CFLAGS}"
AC_CHECK_HEADER([uuid.h], [], [AC_CHECK_HEADER([uuid/uuid.h])],
                [[#if HAVE_UUID_H
                  #include <uuid.h>
                  #endif
                ]])
CFLAGS=${saved_CFLAGS}
if test "x$ac_cv_header_uuid_uuid_h" = "xyes"; then
    UUID_CFLAGS="${UUID_CFLAGS} -I$(pkg-config --variable=includedir uuid)/uuid"
fi

dnl libglusterfs needs uuid.h, practically everything depends on it
GF_CPPFLAGS="${GF_CPPFLAGS} ${UUID_CFLAGS}"
dnl PKGCONFIG_UUID is used for the dependency in *.pc.in files
AC_SUBST(PKGCONFIG_UUID)

dnl NetBSD does not support POSIX ACLs :-(
case $host_os in
     *netbsd* | darwin*)
        AC_MSG_WARN([platform does not support POSIX ACLs... disabling them])
        ACL_LIBS=''
        USE_POSIX_ACLS='0'
        BUILD_POSIX_ACLS='no'
        ;;
     *)
        AC_CHECK_HEADERS([sys/acl.h], ,
                         AC_MSG_ERROR([Support for POSIX ACLs is required]))
        USE_POSIX_ACLS='1'
        BUILD_POSIX_ACLS='yes'
        case $host_os in
             linux*)
                ACL_LIBS='-lacl'
                ;;
             solaris*)
                ACL_LIBS='-lsec'
                ;;
             *freebsd*)
                ACL_LIBS='-lc'
                ;;
             darwin*)
                ACL_LIBS='-lc'
                ;;
        esac
        if test "x${ACL_LIBS}" = "x-lacl"; then
          AC_CHECK_HEADERS([acl/libacl.h], , AC_MSG_ERROR([libacl is required for building on ${host_os}]))
        fi
        ;;
esac
AC_SUBST(ACL_LIBS)
AC_SUBST(USE_POSIX_ACLS)

# libglusterfs/checksum
AC_CHECK_HEADERS([openssl/md5.h])
AC_CHECK_LIB([z], [adler32], [ZLIB_LIBS="-lz"], AC_MSG_ERROR([zlib is required to build glusterfs]))
AC_SUBST(ZLIB_LIBS)

AC_CHECK_HEADERS([linux/falloc.h])

AC_CHECK_HEADERS([linux/oom.h], AC_DEFINE(HAVE_LINUX_OOM_H, 1, [have linux/oom.h]))

dnl Mac OS X does not have spinlocks
AC_CHECK_FUNC([pthread_spin_init], [have_spinlock=yes])
if test "x${have_spinlock}" = "xyes"; then
   AC_DEFINE(HAVE_SPINLOCK, 1, [define if found spinlock])
fi
AC_SUBST(HAVE_SPINLOCK)

dnl some os may not have GNU defined strnlen function
AC_CHECK_FUNC([strnlen], [have_strnlen=yes])
if test "x${have_strnlen}" = "xyes"; then
   AC_DEFINE(HAVE_STRNLEN, 1, [define if found strnlen])
fi
AC_SUBST(HAVE_STRNLEN)


AC_CHECK_FUNC([setfsuid], [have_setfsuid=yes])
AC_CHECK_FUNC([setfsgid], [have_setfsgid=yes])

if test "x${have_setfsuid}" = "xyes" -a "x${have_setfsgid}" = "xyes"; then
  AC_DEFINE(HAVE_SET_FSID, 1, [define if found setfsuid setfsgid])
fi

dnl test umount2 function
AC_CHECK_FUNC([umount2], [have_umount2=yes])

if test "x${have_umount2}" = "xyes"; then
   AC_DEFINE(HAVE_UMOUNT2, 1, [define if found umount2])
fi

dnl Check Python Availability
have_python=no
AM_PATH_PYTHON(,, [:])
if test "$PYTHON" != ":"; then
   have_python=yes
fi

dnl Check if version matches that we require
PYTHONDEV_CPPFLAGS=
PYTHONDEV_LDFLAGS=
BUILD_PYTHON_SITE_PACKAGES=
BUILD_PYTHON_INC=
BUILD_PYTHON_LIB=
have_python2=no
have_Python_h=no

if echo $PYTHON_VERSION | grep -q ^2; then
   have_python2=yes

   dnl Use pkg-config to get runtime search patch missing from ${PYTHON}-config
   dnl Just do "true" on failure so that configure does not bail out
   PKG_CHECK_MODULES([PYTHON], "python-$PYTHON_VERSION",,true)

   PYTHONDEV_CPPFLAGS="`${PYTHON}-config --cflags`"
   dnl Edit out the flags that are not required or are conflicting
   PYTHONDEV_CPPFLAGS=`echo ${PYTHONDEV_CPPFLAGS} | sed -e 's/-Wp,-D_FORTIFY_SOURCE=[[0-9]]//g'`

   dnl Find python libs at user configured libdir and also "lib" under prefix
   PYTHONDEV_LDFLAGS="${PYTHON_LIBS} -L`${PYTHON}-config --prefix`/lib -L`${PYTHON}-config --prefix`/$libdir `${PYTHON}-config --ldflags`"

   BUILD_PYTHON_SITE_PACKAGES=${pythondir}
   BUILD_PYTHON_INC=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_inc())" 2>/dev/null`
   BUILD_PYTHON_LIB=python$PYTHON_VERSION

   dnl Now check for python header using the include path obtained above
   AC_CHECK_HEADERS([${BUILD_PYTHON_INC}/Python.h],[have_Python_h=yes],[])
fi

AC_SUBST(PYTHONDEV_CPPFLAGS)
AC_SUBST(PYTHONDEV_LDFLAGS)
AC_SUBST(BUILD_PYTHON_SITE_PACKAGES)
AC_SUBST(BUILD_PYTHON_INC)
AC_SUBST(BUILD_PYTHON_LIB)


# FUSE section
AC_ARG_ENABLE([fuse-client],
              AC_HELP_STRING([--disable-fuse-client],
                             [Do not build the fuse client. NOTE: you cannot mount glusterfs without the client]))

BUILD_FUSE_CLIENT=no
if test "x$enable_fuse_client" != "xno"; then
   FUSE_CLIENT_SUBDIR=fuse
   BUILD_FUSE_CLIENT="yes"
fi

AC_ARG_ENABLE([bd-xlator],
              AC_HELP_STRING([--enable-bd-xlator], [Build BD xlator]))

if test "x$enable_bd_xlator" != "xno"; then
  AC_CHECK_LIB([lvm2app],
               [lvm_init,lvm_lv_from_name],
               [HAVE_BD_LIB="yes"],
               [HAVE_BD_LIB="no"])

if test "x$HAVE_BD_LIB" = "xyes"; then
    # lvm_lv_from_name() has been made public with lvm2-2.02.79
    AC_CHECK_DECLS(
                  [lvm_lv_from_name],
                  [NEED_LVM_LV_FROM_NAME_DECL="no"],
                  [NEED_LVM_LV_FROM_NAME_DECL="yes"],
                  [[#include <lvm2app.h>]])
  fi
fi

if test "x$enable_bd_xlator" = "xyes" -a "x$HAVE_BD_LIB" = "xno"; then
   echo "BD xlator requested but required lvm2 development library not found."
   exit 1
fi

BUILD_BD_XLATOR=no
if test "x${enable-bd-xlator}" != "xno" -a "x${HAVE_BD_LIB}" = "xyes"; then
  BUILD_BD_XLATOR=yes
  AC_DEFINE(HAVE_BD_XLATOR, 1, [define if lvm2app library found and bd xlator
                            enabled])
  if test "x$NEED_LVM_LV_FROM_NAME_DECL" = "xyes"; then
    AC_DEFINE(NEED_LVM_LV_FROM_NAME_DECL, 1, [defined if lvm_lv_from_name()
                  was not found in the lvm2app.h header, but can be linked])
  fi
fi

AM_CONDITIONAL([ENABLE_BD_XLATOR], [test x$BUILD_BD_XLATOR = xyes])

dnl check for old openssl
AC_CHECK_LIB([crypto], CRYPTO_THREADID_set_callback, [AC_DEFINE([HAVE_CRYPTO_THREADID], [1], [use new OpenSSL functions])])

AC_CHECK_LIB([ssl], TLS_method, [HAVE_OPENSSL_1_1="yes"], [HAVE_OPENSSL_1_1="no"])
if test "x$HAVE_OPENSSL_1_1" = "xyes"; then
    AC_DEFINE([HAVE_TLS_METHOD], [1], [Using OpenSSL-1.1 TLS_method])
else
    AC_CHECK_LIB([ssl], TLSv1_2_method, [AC_DEFINE([HAVE_TLSV1_2_METHOD], [1], [Using OpenSSL-1.0 TLSv1_2_method])])
fi

# start encryption/crypt section

AC_CHECK_HEADERS([openssl/cmac.h], [have_cmac_h=yes], [have_cmac_h=no])

AC_ARG_ENABLE([crypt-xlator],
        AC_HELP_STRING([--enable-crypt-xlator], [Build crypt encryption xlator]))

if test "x$enable_crypt_xlator" = "xyes" -a "x$have_cmac_h" = "xno"; then
   AC_MSG_ERROR([Encryption xlator requires OpenSSL with cmac.h])
fi

BUILD_CRYPT_XLATOR=no
if test "x$enable_crypt_xlator" != "xno" -a "x$have_cmac_h" = "xyes"; then
   BUILD_CRYPT_XLATOR=yes
   AC_DEFINE(HAVE_CRYPT_XLATOR, 1, [enable building crypt encryption xlator])
fi

AM_CONDITIONAL([ENABLE_CRYPT_XLATOR], [test x$BUILD_CRYPT_XLATOR = xyes])

AC_SUBST(FUSE_CLIENT_SUBDIR)
# end FUSE section


# FUSERMOUNT section
AC_ARG_ENABLE([fusermount],
              AC_HELP_STRING([--disable-fusermount],
                             [Use system's fusermount]))

BUILD_FUSERMOUNT="yes"
if test "x$enable_fusermount" = "xno"; then
   BUILD_FUSERMOUNT="no"
else
   AC_DEFINE(GF_FUSERMOUNT, 1, [Use our own fusermount])
   FUSERMOUNT_SUBDIR="contrib/fuse-util"
fi

AC_SUBST(FUSERMOUNT_SUBDIR)
#end FUSERMOUNT section

# EPOLL section
AC_ARG_ENABLE([epoll],
              AC_HELP_STRING([--disable-epoll],
                             [Use poll instead of epoll.]))

BUILD_EPOLL=no
if test "x$enable_epoll" != "xno"; then
   AC_CHECK_HEADERS([sys/epoll.h],
                    [BUILD_EPOLL=yes],
                    [BUILD_EPOLL=no])
fi
# end EPOLL section


# IBVERBS section
AC_ARG_ENABLE([ibverbs],
              AC_HELP_STRING([--disable-ibverbs],
                             [Do not build the ibverbs transport]))

if test "x$enable_ibverbs" != "xno"; then
  AC_CHECK_LIB([ibverbs],
               [ibv_get_device_list],
               [HAVE_LIBIBVERBS="yes"],
               [HAVE_LIBIBVERBS="no"])
  AC_CHECK_LIB([rdmacm], [rdma_create_id], [HAVE_RDMACM="yes"], [HAVE_RDMACM="no"])
  if test "x$HAVE_RDMACM" = "xyes" ; then
    AC_CHECK_DECLS(
                  [RDMA_OPTION_ID_REUSEADDR],
                  [],
                  [AC_ERROR([Need at least version 1.0.15 of librdmacm])],
                  [[#include <rdma/rdma_cma.h>]])
  fi
fi

if test "x$enable_ibverbs" = "xyes"; then
   if test "x$HAVE_LIBIBVERBS" = "xno"; then
      echo "ibverbs-transport requested, but libibverbs is not present."
      exit 1
   fi

   if test "x$HAVE_RDMACM" = "xno"; then
      echo "ibverbs-transport requested, but librdmacm is not present."
      exit 1
   fi
fi

BUILD_RDMA=no
BUILD_IBVERBS=no
if test "x$enable_ibverbs" != "xno" -a "x$HAVE_LIBIBVERBS" = "xyes" -a "x$HAVE_RDMACM" = "xyes"; then
  IBVERBS_SUBDIR=ib-verbs
  BUILD_IBVERBS=yes
  RDMA_SUBDIR=rdma
  BUILD_RDMA=yes
fi

AC_SUBST(IBVERBS_SUBDIR)
AC_SUBST(RDMA_SUBDIR)
# end IBVERBS section


# SYNCDAEMON section
AC_ARG_ENABLE([georeplication],
              AC_HELP_STRING([--disable-georeplication],
                             [Do not install georeplication components]))

BUILD_SYNCDAEMON=no
case $host_os in
     linux*)
#do nothing
       ;;
     netbsd*)
#do nothing
       ;;
     *)
#disabling geo replication for non-linux platforms
        enable_georeplication=no
        ;;
esac
SYNCDAEMON_COMPILE=0
if test "x$enable_georeplication" != "xno"; then
  SYNCDAEMON_SUBDIR=geo-replication
  SYNCDAEMON_COMPILE=1

  BUILD_SYNCDAEMON="yes"
  AM_PATH_PYTHON([2.4])
  echo -n "checking if python is python 2.x... "
  if echo $PYTHON_VERSION | grep ^2; then
    :
  else
    echo no
    AC_MSG_ERROR([only python 2.x is supported])
  fi
  echo -n "checking if python has ctypes support... "
  if "$PYTHON" -c 'import ctypes' 2>/dev/null; then
    echo yes
  else
    echo no
    AC_MSG_ERROR([python does not have ctypes support])
  fi
fi
AC_SUBST(SYNCDAEMON_COMPILE)
AC_SUBST(SYNCDAEMON_SUBDIR)
# end SYNCDAEMON section

# only install scripts from extras/geo-rep when enabled
if test "x$enable_georeplication" != "xno"; then
  GEOREP_EXTRAS_SUBDIR=geo-rep
fi
AC_SUBST(GEOREP_EXTRAS_SUBDIR)
AM_CONDITIONAL(USE_GEOREP, test "x$enable_georeplication" != "xno")

# Events section
AC_ARG_ENABLE([events],
              AC_HELP_STRING([--disable-events],
                             [Do not install Events components]))

BUILD_EVENTS=no
EVENTS_ENABLED=0
EVENTS_SUBDIR=
if test "x$enable_events" != "xno"; then
  EVENTS_SUBDIR=events
  EVENTS_ENABLED=1

  BUILD_EVENTS="yes"

  if test "x$have_python2" = "xno"; then
     if test "x$enable_events" = "xyes"; then
        AC_MSG_ERROR([python 2.x packages required. exiting..])
     fi
     AC_MSG_WARN([python 2.x not found, disabling events])
     EVENTS_SUBDIR=
     EVENTS_ENABLED=0
     BUILD_EVENTS="no"
  else
    AC_DEFINE(USE_EVENTS, 1, [define if events enabled])
  fi
fi
AC_SUBST(EVENTS_ENABLED)
AC_SUBST(EVENTS_SUBDIR)
AM_CONDITIONAL([BUILD_EVENTS], [test x$BUILD_EVENTS = xyes])
# end Events section

# CDC xlator - check if libz is present if so enable HAVE_LIB_Z
BUILD_CDC=yes
PKG_CHECK_MODULES([ZLIB], [zlib >= 1.2.0],,
                  [AC_CHECK_LIB([z], [deflate], [ZLIB_LIBS="-lz"],
                                [BUILD_CDC=no])])
echo -n "features requiring zlib enabled: "
if test "x$BUILD_CDC" = "xyes" ; then
  echo "yes"
  AC_DEFINE(HAVE_LIB_Z, 1, [define if zlib is present])
else
  echo "no"
fi
AC_SUBST(ZLIB_CFLAGS)
AC_SUBST(ZLIB_LIBS)
# end CDC xlator secion

#start firewalld section
BUILD_FIREWALLD="no"
AC_ARG_ENABLE([firewalld],
              AC_HELP_STRING([--enable-firewalld],
                             [enable installation configuration for firewalld]),
              [BUILD_FIREWALLD="${enableval}"], [BUILD_FIREWALLD="no"])

if test "x${BUILD_FIREWALLD}" = "xyes"; then
        if !(test -d /usr/lib/firewalld/services 1>/dev/null 2>&1) ; then
                BUILD_FIREWALLD="no (firewalld not installed)"
        fi
fi
AM_CONDITIONAL([USE_FIREWALLD],test ["x${BUILD_FIREWALLD}" =  "xyes"])

#endof firewald section

# Data tiering requires sqlite
AC_ARG_ENABLE([tiering],
               AC_HELP_STRING([--disable-tiering],
                             [Disable data classification/tiering]),
              [BUILD_GFDB="${enableval}"], [BUILD_GFDB="yes"])

case $host_os in
  darwin*)
    SQLITE_LIBS="-lsqlite3"
    AC_CHECK_HEADERS([sqlite3.h], AC_DEFINE(USE_GFDB, 1))
    ;;
  *)
    if test "x${BUILD_GFDB}" = "xyes"; then
      PKG_CHECK_MODULES([SQLITE], [sqlite3],
                        AC_DEFINE(USE_GFDB, 1),
                        AC_MSG_ERROR([pass --disable-tiering to build without sqlite]))
    else
      AC_DEFINE(USE_GFDB, 0, [no sqlite, gfdb is disabled])
    fi
    ;;
esac

AC_SUBST(SQLITE_CFLAGS)
AC_SUBST(SQLITE_LIBS)
AM_CONDITIONAL(BUILD_GFDB, test "x${BUILD_GFDB}" = "xyes")
AM_CONDITIONAL(USE_GFDB, test "x${BUILD_GFDB}" = "xyes")

# xml-output
AC_ARG_ENABLE([xml-output],
              AC_HELP_STRING([--disable-xml-output],
                             [Disable the xml output]))
BUILD_XML_OUTPUT="yes"
if test "x$enable_xml_output" != "xno"; then
    #check if libxml is present if so enable HAVE_LIB_XML
    m4_ifdef([AM_PATH_XML2],[AM_PATH_XML2([2.6.19])], [no_xml=yes])
    if test "x${no_xml}" = "x"; then
        AC_DEFINE([HAVE_LIB_XML], [1], [Define to 1 if using libxml2.])
    else
        if test "x$enable_georeplication" != "xno"; then
           AC_MSG_ERROR([libxml2 devel libraries not found])
        else
           AC_MSG_WARN([libxml2 devel libraries not found disabling XML support])
           BUILD_XML_OUTPUT="no"
        fi

    fi
else
    if test "x$enable_georeplication" != "xno"; then
       AC_MSG_ERROR([geo-replication requires xml output])
    fi
    BUILD_XML_OUTPUT="no"
fi
# end of xml-output

dnl SELinux feature enablement
case $host_os in
  linux*)
    AC_ARG_ENABLE([selinux],
                  AC_HELP_STRING([--disable-selinux],
                                 [Disable SELinux features]),
                  [USE_SELINUX="${enableval}"], [USE_SELINUX="yes"])
    ;;
  *)
    USE_SELINUX=no
    ;;
esac
AM_CONDITIONAL(USE_SELINUX, test "x${USE_SELINUX}" = "xyes")
dnl end of SELinux feature enablement

AC_CHECK_HEADERS([execinfo.h], [have_backtrace=yes])
if test "x${have_backtrace}" = "xyes"; then
   AC_DEFINE(HAVE_BACKTRACE, 1, [define if found backtrace])
fi
AC_SUBST(HAVE_BACKTRACE)

if test "x${have_backtrace}" != "xyes"; then
AC_TRY_COMPILE([#include <math.h>], [double x=0.0; x=ceil(0.0);],
   [],
   AC_MSG_ERROR([need math library for libexecinfo]))
fi

dnl glusterfs prints memory usage to stderr by sending it SIGUSR1
AC_CHECK_FUNC([malloc_stats], [have_malloc_stats=yes])
if test "x${have_malloc_stats}" = "xyes"; then
   AC_DEFINE(HAVE_MALLOC_STATS, 1, [define if found malloc_stats])
fi
AC_SUBST(HAVE_MALLOC_STATS)

dnl Linux, Solaris, Cygwin
AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec])
dnl FreeBSD, NetBSD
AC_CHECK_MEMBERS([struct stat.st_atimespec.tv_nsec])
case $host_os in
        *netbsd*)
        CFLAGS="${CFLAGS} -D_INCOMPLETE_XOPEN_C063 -DCONFIG_MACHINE_BSWAP_H"
        ;;
esac
AC_CHECK_FUNC([linkat], [have_linkat=yes])
if test "x${have_linkat}" = "xyes"; then
   AC_DEFINE(HAVE_LINKAT, 1, [define if found linkat])
fi
AC_SUBST(HAVE_LINKAT)

dnl check for Monotonic clock
AC_CHECK_LIB([rt], [clock_gettime], ,
             AC_MSG_WARN([System doesn't have monotonic clock using contrib]))

dnl Check for argp
AC_CHECK_HEADER([argp.h], AC_DEFINE(HAVE_ARGP, 1, [have argp]))

BUILD_ARGP_STANDALONE=no
if test "x${ac_cv_header_argp_h}" = "xno"; then
   AC_CONFIG_SUBDIRS(contrib/argp-standalone)
   BUILD_ARGP_STANDALONE=yes
   ARGP_STANDALONE_CPPFLAGS='-I${top_srcdir}/contrib/argp-standalone'
   ARGP_STANDALONE_LDADD='${top_builddir}/contrib/argp-standalone/libargp.a'
   ARGP_STANDALONE_DIR='${top_builddir}/contrib/argp-standalone'
fi

dnl libglusterfs needs argp.h, practically everything depends on it
GF_CPPFLAGS="${GF_CPPFLAGS} ${ARGP_STANDALONE_CPPFLAGS}"

AC_SUBST(ARGP_STANDALONE_CPPFLAGS)
AC_SUBST(ARGP_STANDALONE_LDADD)
AC_SUBST(ARGP_STANDALONE_DIR)

dnl Check for atomic operation support
AC_CHECK_FUNC([__atomic_load], [have_atomic_builtins])
if test "x${have_atomic_builtins}" = "xyes"; then
   AC_DEFINE(HAVE_ATOMIC_BUILTINS, 1, [define if __atomic_*() builtins are available])
fi
AC_SUBST(HAVE_ATOMIC_BUILTINS)

dnl __sync_*() will not be needed if __atomic_*() is available
AC_CHECK_FUNC([__sync_fetch_and_add], [have_sync_builtins])
if test "x${have_sync_builtind}" = "xyes"; then
   AC_DEFINE(HAVE_SYNC_BUILTINS, 1, [define if __sync_*() builtins are available])
fi
AC_SUBST(HAVE_SYNC_BUILTINS)

AC_CHECK_HEADER([malloc.h], AC_DEFINE(HAVE_MALLOC_H, 1, [have malloc.h]))

AC_CHECK_FUNC([llistxattr], [have_llistxattr=yes])
if test "x${have_llistxattr}" = "xyes"; then
   AC_DEFINE(HAVE_LLISTXATTR, 1, [define if llistxattr exists])
fi

AC_CHECK_FUNC([fdatasync], [have_fdatasync=no])
if test "x${have_fdatasync}" = "xyes"; then
   AC_DEFINE(HAVE_FDATASYNC, 1, [define if fdatasync exists])
fi

AC_CHECK_FUNC([fallocate], [have_fallocate=yes])
if test "x${have_fallocate}" = "xyes"; then
   AC_DEFINE(HAVE_FALLOCATE, 1, [define if fallocate exists])
fi

AC_CHECK_FUNC([posix_fallocate], [have_posix_fallocate=yes])
if test "x${have_posix_fallocate}" = "xyes"; then
   AC_DEFINE(HAVE_POSIX_FALLOCATE, 1, [define if posix_fallocate exists])
fi

BUILD_NANOSECOND_TIMESTAMPS=no
AC_CHECK_FUNC([utimensat], [have_utimensat=yes])
if test "x${have_utimensat}" = "xyes"; then
   BUILD_NANOSECOND_TIMESTAMPS=yes
   AC_DEFINE(HAVE_UTIMENSAT, 1, [define if utimensat exists])
fi

OLD_CFLAGS=${CFLAGS}
CFLAGS="-D_GNU_SOURCE"
AC_CHECK_DECL([SEEK_HOLE], , , [#include <unistd.h>])
if test "x${ac_cv_have_decl_SEEK_HOLE}" = "xyes"; then
   AC_DEFINE(HAVE_SEEK_HOLE, 1, [define if SEEK_HOLE is available])
fi
CFLAGS=${OLD_CFLAGS}

# Check the distribution where you are compiling glusterfs on

GF_DISTRIBUTION=
AC_CHECK_FILE([/etc/debian_version])
AC_CHECK_FILE([/etc/SuSE-release])
AC_CHECK_FILE([/etc/redhat-release])

if test "x$ac_cv_file__etc_debian_version" = "xyes"; then
   GF_DISTRIBUTION=Debian
fi
if test "x$ac_cv_file__etc_SuSE_release" = "xyes"; then
   GF_DISTRIBUTION=SuSE
fi
if test "x$ac_cv_file__etc_redhat_release" = "xyes"; then
   GF_DISTRIBUTION=Redhat
fi

AC_SUBST(GF_DISTRIBUTION)

GF_HOST_OS=""
GF_LDFLAGS="-rdynamic"

dnl check for gcc -Werror=format-security
saved_CFLAGS=$CFLAGS
CFLAGS="-Wformat -Werror=format-security"
AC_MSG_CHECKING([whether $CC accepts -Werror=format-security])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_format_security=yes], [cc_werror_format_security=no])
echo $cc_werror_format_security
if test "x$cc_werror_format_security" = "xno"; then
    CFLAGS="$saved_CFLAGS"
else
    CFLAGS="$saved_CFLAGS $CFLAGS"
    GF_CFLAGS="$GF_CFLAGS $CFLAGS"
fi

dnl check for gcc -Werror=implicit-function-declaration
saved_CFLAGS=$CFLAGS
saved_GF_CFLAGS=$GF_CFLAGS
CFLAGS="-Werror=implicit-function-declaration"
GF_CFLAGS="-Werror=implicit-function-declaration"
AC_MSG_CHECKING([whether $CC accepts -Werror=implicit-function-declaration])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_implicit=yes], [cc_werror_implicit=no])
echo $cc_werror_implicit
if test "x$cc_werror_implicit" = "xno"; then
    CFLAGS="$saved_CFLAGS"
    GF_CFLAGS="$saved_GF_CFLAGS"
else
    CFLAGS="$saved_CFLAGS $CFLAGS"
    GF_CFLAGS="$saved_GF_CFLAGS $GF_CFLAGS"
fi

dnl clang is mostly GCC-compatible, but its version is much lower,
dnl so we have to check for it.
AC_MSG_CHECKING([if compiling with clang])

AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([], [[
#ifndef __clang__
       not clang
#endif
]])],
[CLANG=yes], [CLANG=no])

AC_MSG_RESULT([$CLANG])

if test "x$CLANG" = "xyes"; then
   GF_CFLAGS="${GF_CFLAGS} -Wno-gnu"
fi

if test "x$ac_cv_header_execinfo_h" = "xno"; then
   # The reason is that __builtin_frame_address(n) for n > 0 seems
   # to just crash on most platforms when -fomit-stack-pointer is
   # specified, which seems to be the default for many platforms on
   # -O2. The documentation says that __builtin_frame_address()
   # should return NULL in case it can't get the frame, but it
   # seems to crash instead.

   # execinfo.c in ./contrib/libexecinfo uses __builtin_frame_address(n)
   # for providing cross platform backtrace*() functions.
   if test "x$CLANG" = "xno"; then
      GF_CFLAGS="${GF_CFLAGS} -fno-omit-frame-pointer"
   fi
fi

old_prefix=$prefix
if test "x$prefix" = xNONE; then
	prefix=$ac_default_prefix
fi
old_exec_prefix=$exec_prefix
if test "x$exec_prefix" = xNONE; then
	exec_prefix="$(eval echo $prefix)"
fi
GLUSTERFS_LIBEXECDIR="$(eval echo $libexecdir)/glusterfs"
GLUSTERFSD_MISCDIR="$(eval echo $prefix)/var/lib/misc/glusterfsd"
prefix=$old_prefix
exec_prefix=$old_exec_prefix

### Dirty hacky stuff to make LOCALSTATEDIR work
if test "x$prefix" = xNONE; then
   test $localstatedir = '${prefix}/var' && localstatedir=$ac_default_prefix/var
   localstatedir=/var
fi
localstatedir="$(eval echo ${localstatedir})"
LOCALSTATEDIR=$localstatedir

old_prefix=$prefix
if test "x$prefix" = xNONE; then
    prefix=$ac_default_prefix
fi
GLUSTERD_VOLFILE="$(eval echo ${sysconfdir})/glusterfs/glusterd.vol"
prefix=$old_prefix


case $host_os in
     linux*)
        GF_HOST_OS="GF_LINUX_HOST_OS"
        GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(bindir)\\\""
        GLUSTERD_WORKDIR="${LOCALSTATEDIR}/lib/glusterd"
        ;;
     solaris*)
        GF_HOST_OS="GF_SOLARIS_HOST_OS"
        GF_CFLAGS="${GF_CFLAGS} -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS -m64"
        BUILD_FUSE_CLIENT=no
        FUSE_CLIENT_SUBDIR=""
        GLUSTERD_WORKDIR="${LOCALSTATEDIR}/lib/glusterd"
        ;;
     *netbsd*)
        GF_HOST_OS="GF_BSD_HOST_OS"
        GF_CFLAGS="${GF_CFLAGS} -D_INCOMPLETE_XOPEN_C063"
        GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
        GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
        GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(sbindir)\\\""
        GF_LDADD="${ARGP_STANDALONE_LDADD}"
        if test "x$ac_cv_header_execinfo_h" = "xyes"; then
           GF_LDFLAGS="-lexecinfo"
        fi
        GF_FUSE_LDADD="-lperfuse"
        BUILD_FUSE_CLIENT=yes
        LEXLIB=""
        BUILD_FUSERMOUNT=no
        FUSERMOUNT_SUBDIR=""
        GLUSTERD_WORKDIR="${LOCALSTATEDIR}/db/glusterd"
        ;;
     *freebsd*)
        GF_HOST_OS="GF_BSD_HOST_OS"
        GF_CFLAGS="${GF_CFLAGS} ${ARGP_STANDALONE_CPPFLAGS} -O0"
        GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
        GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
        GF_CFLAGS="${GF_CFLAGS} -D_LIBGEN_H_"
        GF_CFLAGS="${GF_CFLAGS} -DO_DSYNC=0"
        GF_CFLAGS="${GF_CFLAGS} -Dxdr_quad_t=xdr_longlong_t"
        GF_CFLAGS="${GF_CFLAGS} -Dxdr_u_quad_t=xdr_u_longlong_t"
        GF_FUSE_CFLAGS="-DFUSERMOUNT_DIR=\\\"\$(sbindir)\\\""
        GF_LDADD="${ARGP_STANDALONE_LDADD}"
        if test "x$ac_cv_header_execinfo_h" = "xyes"; then
           GF_LDFLAGS="-lexecinfo"
        fi
        BUILD_FUSE_CLIENT=yes
        BUILD_FUSERMOUNT=no
        FUSERMOUNT_SUBDIR=""
        GLUSTERD_WORKDIR="${LOCALSTATEDIR}/db/glusterd"
        ;;
     darwin*)
        GF_HOST_OS="GF_DARWIN_HOST_OS"
        LIBTOOL=glibtool
        GF_CFLAGS="${GF_CFLAGS} ${ARGP_STANDALONE_CPPFLAGS} "
        GF_CFLAGS="${GF_CFLAGS} -D_REENTRANT -D_XOPEN_SOURCE "
        GF_CFLAGS="${GF_CFLAGS} -D_DARWIN_USE_64_BIT_INODE "
        GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_BASENAME"
        GF_CFLAGS="${GF_CFLAGS} -DTHREAD_UNSAFE_DIRNAME"
        GF_LDADD="${ARGP_STANDALONE_LDADD}"
        GF_LDFLAGS=""
        GF_FUSE_CFLAGS="-I\$(CONTRIBDIR)/macfuse"
        BUILD_FUSERMOUNT="no"
        FUSERMOUNT_SUBDIR=""
        GLUSTERD_WORKDIR="${LOCALSTATEDIR}/db/glusterd"
        ;;
esac

case $host_os in
     darwin*)
        GFAPI_EXTRA_LDFLAGS='-Wl,-alias_list,$(top_srcdir)/api/src/gfapi.aliases'
        ;;
     *)
        GFAPI_EXTRA_LDFLAGS='-Wl,--version-script=$(top_srcdir)/api/src/gfapi.map'
        ;;
esac

# Default value for sbindir
prefix_temp=$prefix
exec_prefix_temp=$exec_prefix

test "${prefix}" = "NONE" && prefix="${ac_default_prefix}"
test "${exec_prefix}" = "NONE" && exec_prefix='${prefix}'
sbintemp="${sbindir}"
eval sbintemp=\"${sbintemp}\"
eval sbintemp=\"${sbintemp}\"
SBIN_DIR=${sbintemp}

sysconfdirtemp="${sysconfdir}"
eval sysconfdirtemp=\"${sysconfdirtemp}\"
SYSCONF_DIR=${sysconfdirtemp}

# Eval two times to expand fully. First eval replaces $exec_prefix into $prefix
# Second eval will expand $prefix
build_python_site_packages_temp="${BUILD_PYTHON_SITE_PACKAGES}"
eval build_python_site_packages_temp=\"${build_python_site_packages_temp}\"
eval build_python_site_packages_temp=\"${build_python_site_packages_temp}\"
BUILD_PYTHON_SITE_PACKAGES_EXPANDED=${build_python_site_packages_temp}

prefix=$prefix_temp
exec_prefix=$exec_prefix_temp

AC_SUBST(SBIN_DIR)
AC_SUBST(SYSCONF_DIR)
AC_SUBST(BUILD_PYTHON_SITE_PACKAGES_EXPANDED)

# lazy umount emulation
UMOUNTD_SUBDIR=""
if test "x${GF_HOST_OS}" != "xGF_LINUX_HOST_OS" ; then
        UMOUNTD_SUBDIR="contrib/umountd"
fi
AC_SUBST(UMOUNTD_SUBDIR)


# enable debug section
AC_ARG_ENABLE([debug],
              AC_HELP_STRING([--enable-debug],
                             [Enable debug build options.]))

AC_ARG_ENABLE([mempool],
              AC_HELP_STRING([--disable-mempool],
                             [Disable the Gluster memory pooler.]))

USE_MEMPOOL="yes"
if test "x$enable_mempool" = "xno"; then
        USE_MEMPOOL="no"
        AC_DEFINE(GF_DISABLE_MEMPOOL, 1, [Disable the Gluster memory pooler.])
fi

# syslog section
AC_ARG_ENABLE([syslog],
              AC_HELP_STRING([--disable-syslog],
                             [Disable syslog for logging]))

USE_SYSLOG="yes"
if test "x$enable_syslog" != "xno"; then
  AC_DEFINE(GF_USE_SYSLOG, 1, [Use syslog for logging])
else
  USE_SYSLOG="no"
fi
AM_CONDITIONAL([ENABLE_SYSLOG], [test x$USE_SYSLOG = xyes])
#end syslog section

BUILD_READLINE=no
AC_CHECK_LIB([readline -lcurses],[readline],[RLLIBS="-lreadline -lcurses"])
AC_CHECK_LIB([readline -ltermcap],[readline],[RLLIBS="-lreadline -ltermcap"])
AC_CHECK_LIB([readline -lncurses],[readline],[RLLIBS="-lreadline -lncurses"])

if test "x$RLLIBS" != "x"; then
   if test "x$RL_UNDO" = "xyes"; then
      AC_DEFINE(HAVE_READLINE, 1, [readline enabled CLI])
      BUILD_READLINE=yes
   else
      BUILD_READLINE="no (present but missing undo)"
   fi

fi

BUILD_LIBAIO=no
AC_CHECK_LIB([aio],[io_setup],[LIBAIO="-laio"])

if test "x$LIBAIO" != "x"; then
   AC_DEFINE(HAVE_LIBAIO, 1, [libaio based POSIX enabled])
   BUILD_LIBAIO=yes
fi

dnl glupy section
BUILD_GLUPY=no

AC_ARG_ENABLE([glupy], AS_HELP_STRING([--enable-glupy], [build glupy]))
if test "x$enable_glupy" != "xno"; then enable_glupy=yes; fi

if test "x$enable_glupy" = "xyes"; then
    GLUPY_SUBDIR=glupy
    GLUPY_SUBDIR_MAKEFILE=xlators/features/glupy/Makefile
    GLUPY_SUBDIR_SRC_MAKEFILE=xlators/features/glupy/src/Makefile

    if test "x$have_python2" = "xyes" -a "x$have_Python_h" = "xyes"; then
        case $host_os in
            darwin*)
                BUILD_GLUPY=no
                ;;
            *)
                BUILD_GLUPY=yes
                ;;
        esac
    else
        AC_MSG_WARN([
        ---------------------------------------------------------------------------------
        cannot build glupy. python 2.x and python-devel/python-dev package are required.
        ---------------------------------------------------------------------------------])
    fi

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

        echo "building glupy with -isystem $BUILD_PYTHON_INC -l $BUILD_PYTHON_LIB"

        AC_SUBST(GLUPY_SUBDIR)
        AC_SUBST(GLUPY_SUBDIR_MAKEFILE)
        AC_SUBST(GLUPY_SUBDIR_SRC_MAKEFILE)
    fi
fi
dnl end glupy section

dnl gnfs section
BUILD_GNFS="no"
AC_ARG_ENABLE([gnfs],
              AC_HELP_STRING([--enable-gnfs],
                             [Enable legacy gnfs server xlator.]))
if test "x$enable_gnfs" = "xyes"; then
    BUILD_GNFS="yes"
fi
AM_CONDITIONAL([BUILD_GNFS], [test x$BUILD_GNFS = xyes])
dnl end gnfs section

dnl Check for userspace-rcu
PKG_CHECK_MODULES([URCU], [liburcu-bp], [],
  [AC_CHECK_HEADERS([urcu-bp.h],
     [URCU_LIBS='-lurcu-bp'],
     AC_MSG_ERROR([liburcu-bp not found]))])
PKG_CHECK_MODULES([URCU_CDS], [liburcu-cds >= 0.8], [],
  [PKG_CHECK_MODULES([URCU_CDS], [liburcu-cds >= 0.7],
    [AC_DEFINE(URCU_OLD, 1, [Define if liburcu 0.6 or 0.7 is found])],
    [AC_CHECK_HEADERS([urcu/cds.h],
      [AC_DEFINE(URCU_OLD, 1, [Define if liburcu 0.6 or 0.7 is found])
       URCU_CDS_LIBS='-lurcu-cds'],
      [AC_MSG_ERROR([liburcu-cds not found])])])])

BUILD_UNITTEST="no"
AC_ARG_ENABLE([cmocka],
              AC_HELP_STRING([--enable-cmocka],
                             [Enable cmocka build options.]))
if test "x$enable_cmocka" = "xyes"; then
    BUILD_UNITTEST="yes"
    PKG_CHECK_MODULES([UNITTEST], [cmocka >= 1.0.1], [BUILD_UNITTEST="yes"],
        [AC_MSG_ERROR([cmocka library is required to build glusterfs])]
    )
fi
AM_CONDITIONAL([UNITTEST], [test x$BUILD_UNITTEST = xyes])

dnl Define UNIT_TESTING only for building cmocka binaries.
UNITTEST_CFLAGS="${UNITTEST_CFLAGS} -DUNIT_TESTING=1"

dnl Add cmocka for unit tests
case $host_os in
  freebsd*)
    dnl remove --coverage on FreeBSD due to a known llvm packaging bug
    UNITTEST_CFLAGS="${UNITTEST_CPPFLAGS} ${UNITTEST_CFLAGS} -g -DDEBUG -O0"
    UNITTEST_LDFLAGS="${UNITTEST_LIBS} ${UNITTEST_LDFLAGS}"
    ;;
  *)
    UNITTEST_CFLAGS="${UNITTEST_CPPFLAGS} ${UNITTEST_CFLAGS} -g -DDEBUG -O0 --coverage"
    UNITTEST_LDFLAGS="${UNITTEST_LIBS} ${UNITTEST_LDFLAGS}"
    ;;
esac

AC_SUBST(UNITTEST_CFLAGS)
AC_SUBST(UNITTEST_LDFLAGS)

AC_SUBST(CFLAGS)
# end enable debug section

# EC dynamic code generation section

EC_DYNAMIC_SUPPORT="none"
EC_DYNAMIC_ARCH="none"

AC_ARG_ENABLE([ec-dynamic],
              AC_HELP_STRING([--disable-ec-dynamic],
                             [Disable all dynamic code generation extensions for EC module]))

AC_ARG_ENABLE([ec-dynamic-intel],
              AC_HELP_STRING([--disable-ec-dynamic-intel],
                             [Disable all INTEL dynamic code generation extensions for EC module]))

AC_ARG_ENABLE([ec-dynamic-arm],
              AC_HELP_STRING([--disable-ec-dynamic-arm],
                             [Disable all ARM dynamic code generation extensions for EC module]))

AC_ARG_ENABLE([ec-dynamic-x64],
              AC_HELP_STRING([--disable-ec-dynamic-x64],
                             [Disable dynamic INTEL x64 code generation for EC module]))

AC_ARG_ENABLE([ec-dynamic-sse],
              AC_HELP_STRING([--disable-ec-dynamic-sse],
                             [Disable dynamic INTEL SSE code generation for EC module]))

AC_ARG_ENABLE([ec-dynamic-avx],
              AC_HELP_STRING([--disable-ec-dynamic-avx],
                             [Disable dynamic INTEL AVX code generation for EC module]))

AC_ARG_ENABLE([ec-dynamic-neon],
              AC_HELP_STRING([--disable-ec-dynamic-neon],
                             [Disable dynamic ARM NEON code generation for EC module]))

if test "x$enable_ec_dynamic" != "xno"; then
  case $host in
    x86_64*)
      if test "x$enable_ec_dynamic_intel" != "xno"; then
        if test "x$enable_ec_dynamic_x64" != "xno"; then
          EC_DYNAMIC_SUPPORT="$EC_DYNAMIC_SUPPORT x64"
          AC_DEFINE(USE_EC_DYNAMIC_X64, 1, [Defined if using dynamic INTEL x64 code])
        fi
        if test "x$enable_ec_dynamic_sse" != "xno"; then
          EC_DYNAMIC_SUPPORT="$EC_DYNAMIC_SUPPORT sse"
          AC_DEFINE(USE_EC_DYNAMIC_SSE, 1, [Defined if using dynamic INTEL SSE code])
        fi
        if test "x$enable_ec_dynamic_avx" != "xno"; then
          EC_DYNAMIC_SUPPORT="$EC_DYNAMIC_SUPPORT avx"
          AC_DEFINE(USE_EC_DYNAMIC_AVX, 1, [Defined if using dynamic INTEL AVX code])
        fi

        if test "x$EC_DYNAMIC_SUPPORT" != "xnone"; then
          EC_DYNAMIC_ARCH="intel"
        fi
      fi
      ;;
    arm*)
      if test "x$enable_ec_dynamic_arm" != "xno"; then
        if test "x$enable_ec_dynamic_neon" != "xno"; then
          EC_DYNAMIC_SUPPORT="$EC_DYNAMIC_SUPPORT neon"
          AC_DEFINE(USE_EC_DYNAMIC_NEON, 1, [Defined if using dynamic ARM NEON code])
        fi

        if test "x$EC_DYNAMIC_SUPPORT" != "xnone"; then
          EC_DYNAMIC_ARCH="arm"
        fi
      fi
      ;;
  esac

  EC_DYNAMIC_SUPPORT="${EC_DYNAMIC_SUPPORT#none }"
fi

AM_CONDITIONAL([ENABLE_EC_DYNAMIC_INTEL], [test "x$EC_DYNAMIC_ARCH" = "xintel"])
AM_CONDITIONAL([ENABLE_EC_DYNAMIC_ARM], [test "x$EC_DYNAMIC_ARCH" = "xarm"])

AM_CONDITIONAL([ENABLE_EC_DYNAMIC_X64], [test "x${EC_DYNAMIC_SUPPORT##*x64*}" = "x"])
AM_CONDITIONAL([ENABLE_EC_DYNAMIC_SSE], [test "x${EC_DYNAMIC_SUPPORT##*sse*}" = "x"])
AM_CONDITIONAL([ENABLE_EC_DYNAMIC_AVX], [test "x${EC_DYNAMIC_SUPPORT##*avx*}" = "x"])
AM_CONDITIONAL([ENABLE_EC_DYNAMIC_NEON], [test "x${EC_DYNAMIC_SUPPORT##*neon*}" = "x"])

AC_SUBST(USE_EC_DYNAMIC_X64)
AC_SUBST(USE_EC_DYNAMIC_SSE)
AC_SUBST(USE_EC_DYNAMIC_AVX)
AC_SUBST(USE_EC_DYNAMIC_NEON)

# end EC dynamic code generation section

dnl libglusterfs.so uses math functions
GF_LDADD="${GF_LDADD} ${MATH_LIB}"

GF_XLATOR_DEFAULT_LDFLAGS='-avoid-version -export-symbols $(top_srcdir)/xlators/xlator.sym'

AC_SUBST(GF_HOST_OS)
AC_SUBST(GF_CFLAGS)
AC_SUBST(GF_LDFLAGS)
AC_SUBST(GF_LDADD)
AC_SUBST(GF_FUSE_LDADD)
AC_SUBST(GF_FUSE_CFLAGS)
AC_SUBST(RLLIBS)
AC_SUBST(LIBAIO)
AC_SUBST(AM_MAKEFLAGS)
AC_SUBST(AM_LIBTOOLFLAGS)
AC_SUBST(GF_XLATOR_DEFAULT_LDFLAGS)

CONTRIBDIR='$(top_srcdir)/contrib'
AC_SUBST(CONTRIBDIR)

GF_CPPDEFINES='-D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -D$(GF_HOST_OS)'
GF_CPPINCLUDES='-include $(top_builddir)/config.h -include $(top_builddir)/site.h -I$(top_srcdir)/libglusterfs/src -I$(top_builddir)/libglusterfs/src'
GF_CPPFLAGS="$GF_CPPFLAGS $GF_CPPDEFINES $GF_CPPINCLUDES"
AC_SUBST([GF_CPPFLAGS])

AM_CONDITIONAL([GF_LINUX_HOST_OS], test "${GF_HOST_OS}" = "GF_LINUX_HOST_OS")
AM_CONDITIONAL([GF_DARWIN_HOST_OS], test "${GF_HOST_OS}" = "GF_DARWIN_HOST_OS")
AM_CONDITIONAL([GF_BSD_HOST_OS], test "${GF_HOST_OS}" = "GF_BSD_HOST_OS")

AC_SUBST(GLUSTERD_WORKDIR)
AM_CONDITIONAL([GF_INSTALL_GLUSTERD_WORKDIR], test ! -d ${GLUSTERD_WORKDIR} && test -d ${sysconfdir}/glusterd )
AC_SUBST(GLUSTERD_VOLFILE)
AC_SUBST(GLUSTERFS_LIBEXECDIR)
AC_SUBST(GLUSTERFSD_MISCDIR)

dnl pkg-config versioning
dnl
dnl Once we released gluster-api.pc with version=7. Since then we undid the
dnl library versioning and replaced it with symbol-versioning. The current
dnl libgfapi.so has version 0, but the symbols have the version from the main
dnl package at the time they were added.
dnl
dnl Because other packages (like samba) use the pkg-config version, we can not
dnl drop it, or decrease the version easily. The simplest solution is to keep
dnl the version=7 and add sub-digits for the actual package/symbol versions.
GFAPI_VERSION="7."${PACKAGE_VERSION}
LIBGFCHANGELOG_VERSION="0.0.1"
AC_SUBST(GFAPI_VERSION)
AC_SUBST(LIBGFCHANGELOG_VERSION)
LIBGFDB_VERSION="0.0.1"
AC_SUBST(LIBGFDB_VERSION)

dnl libtool versioning
LIBGFXDR_LT_VERSION="0:1:0"
LIBGFRPC_LT_VERSION="0:1:0"
LIBGLUSTERFS_LT_VERSION="0:1:0"
LIBGFCHANGELOG_LT_VERSION="0:1:0"
GFAPI_LT_VERSION="0:0:0"
AC_SUBST(LIBGFXDR_LT_VERSION)
AC_SUBST(LIBGFRPC_LT_VERSION)
AC_SUBST(LIBGLUSTERFS_LT_VERSION)
AC_SUBST(LIBGFCHANGELOG_LT_VERSION)
AC_SUBST(GFAPI_LT_VERSION)
AC_SUBST(GFAPI_EXTRA_LDFLAGS)

GFAPI_LIBS="${ACL_LIBS}"
AC_SUBST(GFAPI_LIBS)

dnl this change necessary for run-tests.sh
AC_CONFIG_FILES([tests/env.rc],[ln -s ${ac_abs_builddir}/env.rc ${ac_abs_srcdir}/env.rc 2>/dev/null])

AC_OUTPUT

echo
echo "GlusterFS configure summary"
echo "==========================="
echo "FUSE client          : $BUILD_FUSE_CLIENT"
echo "Infiniband verbs     : $BUILD_IBVERBS"
echo "epoll IO multiplex   : $BUILD_EPOLL"
echo "argp-standalone      : $BUILD_ARGP_STANDALONE"
echo "fusermount           : $BUILD_FUSERMOUNT"
echo "readline             : $BUILD_READLINE"
echo "georeplication       : $BUILD_SYNCDAEMON"
echo "Linux-AIO            : $BUILD_LIBAIO"
echo "Enable Debug         : $BUILD_DEBUG"
echo "Block Device xlator  : $BUILD_BD_XLATOR"
echo "glupy                : $BUILD_GLUPY"
echo "Use syslog           : $USE_SYSLOG"
echo "XML output           : $BUILD_XML_OUTPUT"
echo "Encryption xlator    : $BUILD_CRYPT_XLATOR"
echo "Unit Tests           : $BUILD_UNITTEST"
echo "Track priv ports     : $TRACK_PRIVPORTS"
echo "POSIX ACLs           : $BUILD_POSIX_ACLS"
echo "Data Classification  : $BUILD_GFDB"
echo "SELinux features     : $USE_SELINUX"
echo "firewalld-config     : $BUILD_FIREWALLD"
echo "Events               : $BUILD_EVENTS"
echo "EC dynamic support   : $EC_DYNAMIC_SUPPORT"
echo "Use memory pools     : $USE_MEMPOOL"
echo "Nanosecond m/atimes  : $BUILD_NANOSECOND_TIMESTAMPS"
echo "Legacy gNFS server   : $BUILD_GNFS"
echo