summaryrefslogtreecommitdiff
path: root/configure.ac
blob: 425fe27373bd1f66e2aa778bf076ddce927e5806 (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
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
##
## Configure template file for Quagga.
## autoconf will generate configure script.
##
##  Copyright (c) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro <kunihiro@zebra.org>
##  Portions Copyright (c) 2003 Paul Jakma <paul@dishone.st>
##
AC_PREREQ(2.53)

AC_INIT(Quagga, 0.99.21, [https://bugzilla.quagga.net])
AC_CONFIG_SRCDIR(lib/zebra.h)
AC_CONFIG_MACRO_DIR([m4])

dnl -----------------------------------
dnl Get hostname and other information.
dnl -----------------------------------
AC_CANONICAL_BUILD()
AC_CANONICAL_HOST()
AC_CANONICAL_TARGET()

AM_INIT_AUTOMAKE(1.6)
AM_CONFIG_HEADER(config.h)

AC_CHECK_PROG([GAWK],[gawk],[gawk],[not-in-PATH])
if test "x$GAWK" = "xnot-in-PATH" ; then
	AC_MSG_ERROR([GNU awk is required for lib/memtype.h made by memtypes.awk.
BSD awk complains: awk: gensub doesn't support backreferences (subst "\1") ])
fi
AC_ARG_VAR([GAWK],[GNU AWK])

dnl default is to match previous behavior
exampledir=${sysconfdir}
AC_ARG_ENABLE([exampledir],
	  AC_HELP_STRING([--enable-exampledir],
			 [specify alternate directory for examples]),
			 exampledir="$enableval",)
dnl XXX add --exampledir to autoconf standard directory list somehow
AC_SUBST(exampledir)

dnl default is to match previous behavior
pkgsrcrcdir=""
pkgsrcdir=""
AC_ARG_ENABLE([pkgsrcrcdir],
	  AC_HELP_STRING([--enable-pkgsrcrcdir],
			 [specify directory for rc.d scripts]),
			 pkgsrcrcdir="$enableval"; pkgsrcdir="pkgsrc",)
dnl XXX add --pkgsrcrcdir to autoconf standard directory list somehow
AC_SUBST(pkgsrcdir)
AC_SUBST(pkgsrcrcdir)

dnl ------------
dnl Check CFLAGS
dnl ------------
AC_ARG_WITH(cflags,
[  --with-cflags           Set CFLAGS for use in compilation.])
if test "x$with_cflags" != "x" ; then
  CFLAGS="$with_cflags" ; cflags_specified=yes ;
elif test -n "$CFLAGS" ; then
  cflags_specified=yes ;
fi

dnl --------------------
dnl Check CC and friends
dnl --------------------
AC_LANG([C])
AC_PROG_CC
AC_PROG_CPP
AM_PROG_CC_C_O
AC_PROG_EGREP

dnl autoconf 2.59 appears not to support AC_PROG_SED
dnl AC_PROG_SED
AC_CHECK_PROG([SED],[sed],[sed],[/bin/false])

dnl pdflatex and latexmk are needed to build HACKING.pdf
AC_CHECK_PROG([PDFLATEX],[pdflatex],[pdflatex],[/bin/false])
AC_CHECK_PROG([LATEXMK],[latexmk],[latexmk],[/bin/false])
if test "x$PDFLATEX" = "x/bin/false" -o "x$LATEXMK" = "x/bin/false"; then
	AC_MSG_WARN([Will not be able to make PDF versions of TeX documents])
else
	HAVE_LATEX=true
fi
AM_CONDITIONAL([HAVE_LATEX], [test "x$HAVE_LATEX" = "xtrue"])

dnl ------------------------------------------------------------------
dnl Intel compiler check. Although Intel tries really hard to make icc
dnl look like gcc, there are some differences. It's very verbose with
dnl -Wall and it doesn't support the individual -W options.
dnl ------------------------------------------------------------------
if test "x${GCC}" = "xyes" ; then
  COMPILER="GCC"
  AC_MSG_CHECKING([whether we are using the Intel compiler])
  AC_EGREP_CPP([^__INTEL_COMPILER], [__INTEL_COMPILER],
      [AC_MSG_RESULT([no])],
      [COMPILER="ICC"
       AC_MSG_RESULT([yes])]
  )
else
  AC_MSG_CHECKING([whether we are using SunPro compiler])
  AC_EGREP_CPP([^__SUNPRO_C.*0x5(7|8|9)], ["__SUNPRO_C" __SUNPRO_C],
      [AC_MSG_RESULT([no])],
      [COMPILER="SUNPRO"
       AC_MSG_RESULT([yes])]
  )
fi

dnl ---------------------------------------------
dnl If CLFAGS doesn\'t exist set default value
dnl AC_PROG_CC will have set minimal default
dnl already, eg "-O2 -g" for gcc, "-g" for others
dnl (Wall is gcc specific... have to make sure
dnl  gcc is being used before setting it)
dnl
dnl Intel icc 8.0 also sets __GNUC__, 
dnl but doesn't support all these fancy -W options.
dnl Intel compiler warnings we ignore:
dnl 279: controlling expression is constant.
dnl 869: parameter "xxx" was never referenced - to avoid massive warnings
dnl      about "self", "vty", "argc" and "argv" never referenced in DEFUN
dnl      macro.
dnl 981: operands are evaluated in unspecified order.
dnl
dnl Sun Studio 10 / SunPro 5.7 is also supported,
dnl so lets set some sane CFLAGS for it.
dnl ---------------------------------------------

AC_MSG_CHECKING([whether to set a default CFLAGS])
if test "x${cflags_specified}" = "x" ; then
  case ${COMPILER} in
    "ICC")
        CFLAGS="-Os -g -Wall -wd 279,869,981"
        AC_MSG_RESULT([Intel default])
        ;;
    "GCC")
  	CFLAGS="-Os -fno-omit-frame-pointer -g -std=gnu99 -Wall"
  	CFLAGS="${CFLAGS} -Wsign-compare -Wpointer-arith"
  	CFLAGS="${CFLAGS} -Wbad-function-cast -Wwrite-strings"
  	CFLAGS="${CFLAGS} -Wmissing-prototypes -Wmissing-declarations"
  	CFLAGS="${CFLAGS} -Wchar-subscripts -Wcast-qual"
  	# TODO: conditionally addd -Wpacked if handled
  	AC_MSG_RESULT([gcc default])
  	;;
    "SUNPRO")
  	CFLAGS="-xO4 -v -g -xspace -xcode=pic32 -xstrconst -xc99"
  	AC_MSG_RESULT([SunPro default])
  	;;
    *)
        AC_MSG_RESULT([unknown compiler])
        ;;
  esac
else
  AC_MSG_RESULT([CFLAGS supplied by user])
fi

dnl --------------
dnl Check programs
dnl --------------
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_CHECK_TOOL(AR, ar)

dnl ---------------------------
dnl We, perhaps unfortunately,
dnl depend on GNU Make specific
dnl constructs.
dnl Give the user a warning if
dnl not GNU Make.
dnl ---------------------------
AC_CACHE_CHECK([if ${MAKE-make} is GNU make], [quagga_cv_gnu_make],
	[quagga_cv_gnu_make=no
	 if ${MAKE-make} --version 2>/dev/null | \
	 	grep '^GNU Make ' >/dev/null ; then
	 	quagga_cv_gnu_make=yes;
	 fi
	]
)

dnl -----------------
dnl System extensions
dnl -----------------
AC_GNU_SOURCE

dnl -------
dnl libtool
dnl -------
AC_PROG_LIBTOOL

dnl ----------------------
dnl Packages configuration
dnl ----------------------
AC_ARG_WITH(pkg-extra-version,
	AS_HELP_STRING([--with-pkg-extra-version=VER], [add extra version field, for packagers/distributions]),
	[EXTRAVERSION=$withval],)
AC_ARG_ENABLE(vtysh,
[  --enable-vtysh          include integrated vty shell for Quagga])
AC_ARG_ENABLE(ipv6,
[  --disable-ipv6          turn off IPv6 related features and daemons])
AC_ARG_ENABLE(doc,
[  --disable-doc           do not build docs])
AC_ARG_ENABLE(tests,
[  --disable-tests         do not build tests])
AC_ARG_ENABLE(zebra,
[  --disable-zebra         do not build zebra daemon])
AC_ARG_ENABLE(bgpd,
[  --disable-bgpd          do not build bgpd])
AC_ARG_ENABLE(ripd,
[  --disable-ripd          do not build ripd])
AC_ARG_ENABLE(ripngd,
[  --disable-ripngd        do not build ripngd])
AC_ARG_ENABLE(ospfd,
[  --disable-ospfd         do not build ospfd])
AC_ARG_ENABLE(ospf6d,
[  --disable-ospf6d        do not build ospf6d])
AC_ARG_ENABLE(babeld,
[  --disable-babeld        do not build babeld])
AC_ARG_ENABLE(watchquagga,
[  --disable-watchquagga   do not build watchquagga])
AC_ARG_ENABLE(isisd,
[  --enable-isisd          build isisd])
AC_ARG_ENABLE(solaris,
[  --enable-solaris          build solaris])
AC_ARG_ENABLE(bgp-announce,
[  --disable-bgp-announce, turn off BGP route announcement])
AC_ARG_ENABLE(netlink,
[  --enable-netlink        force to use Linux netlink interface])
AC_ARG_ENABLE(broken-aliases,
[  --enable-broken-aliases enable aliases as distinct interfaces for Linux 2.2.X])
AC_ARG_ENABLE(snmp,
[  --enable-snmp=ARG       enable SNMP support (smux or agentx)])
AC_ARG_WITH(libpam,
[  --with-libpam           use libpam for PAM support in vtysh])
AC_ARG_ENABLE(tcp-zebra,
[  --enable-tcp-zebra      enable TCP/IP socket connection between zebra and protocol daemon])
AC_ARG_ENABLE(opaque-lsa,
  AC_HELP_STRING([--disable-opaque-lsa],[do not build OSPF Opaque-LSA with OSPFAPI support (RFC2370)]))
AC_ARG_ENABLE(ospfapi,
[  --disable-ospfapi       do not build OSPFAPI to access the OSPF LSA Database])
AC_ARG_ENABLE(ospfclient,
[  --disable-ospfclient    do not build OSPFAPI client for OSPFAPI, 
                          (this is the default if --disable-ospfapi is set)])
AC_ARG_ENABLE(ospf-te,
  AC_HELP_STRING([--disable-ospf-te],[disable Traffic Engineering Extension to OSPF]))
AC_ARG_ENABLE(multipath,
[  --enable-multipath=ARG  enable multipath function, ARG must be digit])
AC_ARG_ENABLE(user,
  AC_HELP_STRING([--enable-user=user], [user to run Quagga suite as (default quagga)]))
AC_ARG_ENABLE(group,
  AC_HELP_STRING([--enable-group=group], [group to run Quagga suite as (default quagga)]))
AC_ARG_ENABLE(vty_group,
[  --enable-vty-group=ARG  set vty sockets to have specified group as owner])
AC_ARG_ENABLE(configfile_mask,
[  --enable-configfile-mask=ARG  set mask for config files])
AC_ARG_ENABLE(logfile_mask,
[  --enable-logfile-mask=ARG     set mask for log files])

AC_ARG_ENABLE(rtadv,
[  --disable-rtadv               disable IPV6 router advertisement feature])
AC_ARG_ENABLE(irdp,
[  --enable-irdp                 enable IRDP server support in zebra])
AC_ARG_ENABLE(isis_topology,
[  --enable-isis-topology        enable IS-IS topology generator])
AC_ARG_ENABLE(capabilities,
[  --disable-capabilities        disable using POSIX capabilities])
AC_ARG_ENABLE(gcc_ultra_verbose,
[  --enable-gcc-ultra-verbose    enable ultra verbose GCC warnings])
AC_ARG_ENABLE(linux24_tcp_md5,
[  --enable-linux24-tcp-md5  enable support for old, Linux-2.4 RFC2385 patch])
AC_ARG_ENABLE(gcc-rdynamic,
[  --enable-gcc-rdynamic   enable gcc linking with -rdynamic for better backtraces])
AC_ARG_ENABLE(time-check,
[  --disable-time-check          disable slow thread warning messages])
AC_ARG_ENABLE(pcreposix,
[  --enable-pcreposix          enable using PCRE Posix libs for regex functions])

if test x"${enable_gcc_ultra_verbose}" = x"yes" ; then
  CFLAGS="${CFLAGS} -W -Wcast-qual -Wstrict-prototypes"
  CFLAGS="${CFLAGS} -Wmissing-declarations -Wmissing-noreturn"
  CFLAGS="${CFLAGS} -Wmissing-format-attribute -Wunreachable-code"
  CFLAGS="${CFLAGS} -Wpacked -Wpadded"
fi

if test x"${enable_gcc_rdynamic}" = x"yes" ; then
  LDFLAGS="${LDFLAGS} -rdynamic"
fi

if test x"${enable_time_check}" != x"no" ; then
  if test x"${enable_time_check}" = x"yes" -o x"${enable_time_check}" = x ; then
    AC_DEFINE(CONSUMED_TIME_CHECK,5000000,Consumed Time Check)
  else
    AC_DEFINE_UNQUOTED(CONSUMED_TIME_CHECK,$enable_time_check,Consumed Time Check)
  fi
fi

if test "${enable_broken_aliases}" = "yes"; then
  if test "${enable_netlink}" = "yes"
  then
    AC_MSG_FAILURE([Sorry you can not use netlink with broken aliases])
  fi
  AC_DEFINE(HAVE_BROKEN_ALIASES,,Broken Alias)
  enable_netlink=no
fi

if test "${enable_tcp_zebra}" = "yes"; then
  AC_DEFINE(HAVE_TCP_ZEBRA,,Use TCP for zebra communication)
fi

if test "${enable_opaque_lsa}" != "no"; then
  AC_DEFINE(HAVE_OPAQUE_LSA,,OSPF Opaque LSA)
fi

if test "${enable_ospf_te}" != "no"; then
  AC_DEFINE(HAVE_OPAQUE_LSA,,OSPF Opaque LSA)
  AC_DEFINE(HAVE_OSPF_TE,,OSPF TE)
fi

if test "${enable_linux24_tcp_md5}" = "yes"; then
  AC_DEFINE(HAVE_TCP_MD5_LINUX24,,Old Linux 2.4 TCP MD5 Signature Patch)
fi

AC_MSG_CHECKING(if zebra should be configurable to send Route Advertisements)
if test "${enable_rtadv}" != "no"; then
  AC_MSG_RESULT(yes)
  AC_DEFINE(HAVE_RTADV,,Enable IPv6 Routing Advertisement support)
else
  AC_MSG_RESULT(no)
fi

if test "${enable_irdp}" = "yes"; then
  AC_DEFINE(HAVE_IRDP,, IRDP )
fi

if test "${enable_isisd}" = "yes" && test "${enable_isis_topology}" = yes; then
  AC_DEFINE(TOPOLOGY_GENERATE,,Enable IS-IS topology generator code)
  ISIS_TOPOLOGY_INCLUDES="-I\$(srcdir)/topology"
  ISIS_TOPOLOGY_DIR="topology"
  ISIS_TOPOLOGY_LIB="./topology/libtopology.a"
fi

AC_SUBST(ISIS_TOPOLOGY_INCLUDES)
AC_SUBST(ISIS_TOPOLOGY_DIR)
AC_SUBST(ISIS_TOPOLOGY_LIB)

if test "${enable_user}" = "yes" || test x"${enable_user}" = x""; then
  enable_user="quagga"
elif test "${enable_user}" = "no"; then
  enable_user="root"
fi

if test "${enable_group}" = "yes" || test x"${enable_group}" = x""; then
  enable_group="quagga"
elif test "${enable_group}" = "no"; then
  enable_group="root"
fi

if test x"${enable_vty_group}" = x"yes" ; then
  AC_MSG_ERROR([--enable-vty-group requires a group as argument, not yes])
elif test x"${enable_vty_group}" != x""; then
  if test x"${enable_vty_group}" != x"no"; then
    AC_DEFINE_UNQUOTED(VTY_GROUP, "${enable_vty_group}", VTY Sockets Group)
  fi
fi
AC_SUBST([enable_user])
AC_SUBST([enable_group])
AC_SUBST([enable_vty_group])
AC_DEFINE_UNQUOTED(QUAGGA_USER, "${enable_user}", Quagga User)
AC_DEFINE_UNQUOTED(QUAGGA_GROUP, "${enable_group}", Quagga Group)

enable_configfile_mask=${enable_configfile_mask:-0600}
AC_DEFINE_UNQUOTED(CONFIGFILE_MASK, ${enable_configfile_mask}, Mask for config files)

enable_logfile_mask=${enable_logfile_mask:-0600}
AC_DEFINE_UNQUOTED(LOGFILE_MASK, ${enable_logfile_mask}, Mask for log files)

MULTIPATH_NUM=1

case "${enable_multipath}" in
  [[0-9]|[1-9][0-9]])
    MULTIPATH_NUM="${enable_multipath}"
    ;;
  "")
    ;;
  *)           
    AC_MSG_FAILURE([Please specify digit to enable multipath ARG])
    ;;
esac

AC_SUBST(MULTIPATH_NUM)

dnl -----------------------------------
dnl Add extra version string to package
dnl name, string and version fields.
dnl -----------------------------------
if test "x${EXTRAVERSION}" != "x" ; then
  VERSION=${VERSION}${EXTRAVERSION}
  PACKAGE_VERSION=${PACKAGE_VERSION}${EXTRAVERSION}
  PACKAGE_STRING=${PACKAGE_STRING}${EXTRAVERSION}
fi

dnl ------------------------------------
dnl Check C keywords and standard  types
dnl ------------------------------------
AC_C_CONST
AC_C_INLINE
AC_C_RESTRICT
AC_C_VOLATILE
AC_HEADER_STDC
AC_HEADER_TIME
AC_HEADER_SYS_WAIT
dnl AC_TYPE_PID_T
AC_TYPE_UID_T
AC_TYPE_MODE_T
AC_TYPE_SIZE_T
AC_TYPE_SIGNAL
AC_STRUCT_TM

dnl -------------------------
dnl Check other header files.
dnl -------------------------
AC_CHECK_HEADERS([stropts.h sys/ksym.h sys/times.h sys/select.h \
	sys/types.h linux/version.h netdb.h asm/types.h \
	sys/param.h limits.h signal.h \
	sys/socket.h netinet/in.h time.h sys/time.h])

dnl Utility macro to avoid retyping includes all the time
m4_define([QUAGGA_INCLUDES],
[#ifdef SUNOS_5
#define _XPG4_2
#define __EXTENSIONS__
#endif
#include <stdio.h>
#if STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
#else
# if HAVE_STDLIB_H
#  include <stdlib.h>
# endif
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
/* sys/conf.h depends on param.h on FBSD at least */
#if HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
/* Required for MAXSIG */
#if HAVE_SIGNAL_H
# include <signal.h>
#endif
#if HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#if HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# ifdef HAVE_SYS_TIME_H
#  include <sys/time.h>
# else
#  include <time.h>
# endif
#endif /* TIME_WITH_SYS_TIME */
])dnl

dnl HAVE_NET_IF_H must be discovered by the time the longer AC_CHECK_HEADERS
dnl round below execution begins, otherwise it doesn't properly detect
dnl HAVE_NETINET6_IN6_VAR_H, HAVE_NET_IF_VAR_H and HAVE_STRUCT_IN6_ALIASREQ
dnl on FreeBSD (BZ#408).

AC_CHECK_HEADERS([net/if.h], [], [], QUAGGA_INCLUDES)

m4_define([QUAGGA_INCLUDES],
QUAGGA_INCLUDES
[#if HAVE_NET_IF_H
# include <net/if.h>
#endif
])dnl

dnl Same applies for HAVE_NET_IF_VAR_H, which HAVE_NETINET6_ND6_H and
dnl HAVE_NETINET_IN_VAR_H depend upon. But if_var.h depends on if.h, hence
dnl an additional round for it.

AC_CHECK_HEADERS([net/if_var.h], [], [], QUAGGA_INCLUDES)

m4_define([QUAGGA_INCLUDES],
QUAGGA_INCLUDES
[#if HAVE_NET_IF_VAR_H
# include <net/if_var.h>
#endif
])dnl

AC_CHECK_HEADERS([sys/un.h netinet/in_systm.h netinet/in_var.h \
	net/if_dl.h net/netopt.h net/route.h \
	inet/nd.h arpa/inet.h netinet/ip_icmp.h \
	fcntl.h stddef.h sys/ioctl.h syslog.h wchar.h wctype.h \
	sys/sysctl.h sys/sockio.h kvm.h sys/conf.h],
	[], [], QUAGGA_INCLUDES)

AC_CHECK_HEADERS([ucontext.h], [], [],
[#ifndef __USE_GNU
#define __USE_GNU
#endif /* __USE_GNU */
QUAGGA_INCLUDES
])

m4_define([QUAGGA_INCLUDES],
QUAGGA_INCLUDES
[#if HAVE_SYS_UN_H
# include <sys/un.h>
#endif
#if HAVE_NETINET_IN_SYSTM_H
# include <netinet/in_systm.h>
#endif
#if HAVE_NETINET_IN_VAR_H
# include <netinet/in_var.h>
#endif
#if HAVE_NET_IF_DL_H
# include <net/if_dl.h>
#endif
#if HAVE_NET_NETOPT_H
# include <net/netopt.h>
#endif
#if HAVE_NET_ROUTE_H
# include <net/route.h>
#endif
#if HAVE_INET_ND_H
# include <inet/nd.h>
#endif
#if HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
/* Required for IDRP */
#if HAVE_NETINET_IP_ICMP_H
# include <netinet/ip_icmp.h>
#endif
])dnl

dnl V6 headers are checked below, after we check for v6

dnl Some systems (Solaris 2.x) require libnsl (Network Services Library)
case "$host" in
  [*-sunos5.[6-7]*] | [*-solaris2.[6-7]*])
      opsys=sol2-6
      AC_DEFINE(SUNOS_56, 1, SunOS 5.6 to 5.7)
      AC_DEFINE(SUNOS_5, 1, SunOS 5)
      AC_CHECK_LIB(xnet, main)
      CURSES=-lcurses
  ;;
  [*-sunos5.[8-9]] \
  | [*-sunos5.1[0-9]] \
  | [*-sunos5.1[0-9].[0-9]] \
  | [*-solaris2.[8-9]] \
  | [*-solaris2.1[0-9]] \
  | [*-solaris2.1[0-9].[0-9]])
      opsys=sol8
      AC_DEFINE(SUNOS_59, 1, [SunOS 5.8 up])
      AC_DEFINE(SUNOS_5, 1, [SunOS 5])
      AC_CHECK_LIB(socket, main)
      AC_CHECK_LIB(nsl, main)
      AC_CHECK_LIB(umem, main)
      AC_CHECK_FUNCS([printstack],
      	[AC_DEFINE([HAVE_PRINTSTACK],1,[Solaris printstack])
      	 AC_DEFINE([HAVE_STACK_TRACE],1,[Stack symbols decode functionality])
      	])
      CURSES=-lcurses
  ;;
  *-sunos5* | *-solaris2*)
      AC_DEFINE(SUNOS_5,,SunOS 5, Unknown SunOS)
      AC_CHECK_LIB(socket, main)
      AC_CHECK_LIB(nsl, main)
      CURSES=-lcurses
  ;;
  *-linux*)
      opsys=gnu-linux
      AC_DEFINE(GNU_LINUX,,GNU Linux)
  ;;
  *-nec-sysv4*)
      AC_CHECK_LIB(nsl, gethostbyname)
      AC_CHECK_LIB(socket, socket)
  ;;
  *-openbsd*)
      opsys=openbsd
      AC_DEFINE(OPEN_BSD,,OpenBSD)
  ;;
  *-bsdi*)
      opsys=bsdi
      OTHER_METHOD="mtu_kvm.o"
      AC_CHECK_LIB(kvm, main)
  ;;
  *-irix6.5)
      opsys=irix
      AC_DEFINE(IRIX_65,,IRIX 6.5)
  ;;
esac

AC_SYS_LARGEFILE

dnl ---------------------
dnl Integrated VTY option
dnl ---------------------
case "${enable_vtysh}" in
  "yes") VTYSH="vtysh";
         AC_DEFINE(VTYSH,,VTY shell)
	 AC_PATH_PROG(PERL, perl)
dnl	 Vtysh uses libreadline, which looks for termcap functions at
dnl	 configure time.  We follow readlines search order.
dnl	 The required procedures are in libtermcap on NetBSD, in
dnl	 [TODO] on Linux, and in [TODO] on Solaris.
	 AC_CHECK_LIB(termcap, tputs, LIBREADLINE="$LIBREADLINE -ltermcap",
	   [AC_CHECK_LIB(tinfo, tputs, LIBREADLINE="$LIBREADLINE -ltinfo",
	     [AC_CHECK_LIB(curses, tputs, LIBREADLINE="$LIBREADLINE -lcurses",
	       [AC_CHECK_LIB(ncurses, tputs, 
	                     LIBREADLINE="$LIBREADLINE -lncurses")]
	      )]
	    )]
	  )
         AC_CHECK_LIB(readline, main, LIBREADLINE="$LIBREADLINE -lreadline",,
                      "$LIBREADLINE")
         if test $ac_cv_lib_readline_main = no; then
           AC_MSG_ERROR([vtysh needs libreadline but was not found and usable on your system.])
         fi
	 AC_CHECK_HEADER(readline/history.h)
	 if test $ac_cv_header_readline_history_h = no;then
           AC_MSG_ERROR([readline is too old to have readline/history.h, please update to the latest readline library.])
	 fi
	 AC_CHECK_LIB(readline, rl_completion_matches, 
	              LIBREADLINE="$LIBREADLINE",, "$LIBREADLINE")
         if test $ac_cv_lib_readline_rl_completion_matches = no; then
           AC_DEFINE(rl_completion_matches,completion_matches,Old readline)
	 fi
	 ;;
  "no" ) VTYSH="";;
  *    ) ;;
esac
AC_SUBST(LIBREADLINE)
AM_CONDITIONAL(VTYSH, test "x$VTYSH" = "xvtysh")

dnl ----------
dnl PAM module
dnl
dnl Quagga detects the PAM library it is built against by checking for a
dnl functional pam_misc.h (Linux-PAM) or openpam.h (OpenPAM) header. pam_misc.h
dnl is known to #include pam_appl.h, the standard header of a PAM library, and
dnl openpam.h doesn't do that, although depends on the header too. Hence a
dnl little assistance to AC_CHECK_HEADER is necessary for the proper detection
dnl of OpenPAM.
dnl ----------
if test "$with_libpam" = "yes"; then
  AC_CHECK_HEADER([security/pam_misc.h],
    [AC_DEFINE(HAVE_PAM_MISC_H,,Have pam_misc.h)
     AC_DEFINE(PAM_CONV_FUNC,misc_conv,Have misc_conv)
     pam_conv_func="misc_conv"
    ],
    [], QUAGGA_INCLUDES)
  AC_CHECK_HEADER([security/openpam.h],
    [AC_DEFINE(HAVE_OPENPAM_H,,Have openpam.h)
     AC_DEFINE(PAM_CONV_FUNC,openpam_ttyconv,Have openpam_ttyconv)
     pam_conv_func="openpam_ttyconv"
    ],
    [], QUAGGA_INCLUDES[#include <security/pam_appl.h>])
  if test -z "$ac_cv_header_security_pam_misc_h$ac_cv_header_security_openpam_h" ; then
    AC_MSG_WARN([*** pam support will not be built ***])
    with_libpam="no"
  fi
fi

if test "$with_libpam" = "yes"; then
dnl took this test from proftpds configure.in and suited to our needs
dnl -------------------------------------------------------------------------
dnl
dnl This next check looks funky due to a linker problem with some versions
dnl of the PAM library.  Prior to 0.72 release, the Linux PAM shared library
dnl omitted requiring libdl linking information. PAM-0.72 or better ships
dnl with RedHat 6.2 and Debian 2.2 or better.
AC_CHECK_LIB(pam, pam_start,
  [AC_CHECK_LIB(pam, $pam_conv_func,
    [AC_DEFINE(USE_PAM,,Use PAM for authentication)
     LIBPAM="-lpam"],
    [AC_DEFINE(USE_PAM,,Use PAM for authentication)
     LIBPAM="-lpam -lpam_misc"]
    )
  ],

  [AC_CHECK_LIB(pam, pam_end,
    [AC_CHECK_LIB(pam, $pam_conv_func,
      [AC_DEFINE(USE_PAM,,Use PAM for authentication)
       LIBPAM="-lpam -ldl"],
      [AC_DEFINE(USE_PAM,,Use PAM for authentication)
       LIBPAM="-lpam -ldl -lpam_misc"]
     )
  ],AC_MSG_WARN([*** pam support will not be built ***]),
  [-ldl])
  ]
)
fi
AC_SUBST(LIBPAM)

dnl -------------------------------
dnl Endian-ness check
dnl -------------------------------
AC_WORDS_BIGENDIAN

dnl -------------------------------
dnl check the size in byte of the C
dnl -------------------------------
dnl AC_CHECK_SIZEOF(char)
dnl AC_CHECK_SIZEOF(int)
dnl AC_CHECK_SIZEOF(short)
dnl AC_CHECK_SIZEOF(long)

dnl ----------------------------
dnl check existance of functions
dnl ----------------------------
AC_FUNC_CHOWN
AC_FUNC_FNMATCH
AC_FUNC_FORK
AC_FUNC_MEMCMP
AC_FUNC_MKTIME
AC_FUNC_STRFTIME
AC_FUNC_STAT
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_STRFTIME
dnl Avoid AC_FUNC_STRNLEN because it pulls in AC_SYSTEM_EXTENSIONS which
dnl can lead to strange side effects.  So we just check for strnlen
dnl directly, see below.
dnl AC_FUNC_STRNLENdnl
AC_FUNC_VPRINTF

dnl -------------------------------
dnl bgpd needs pow() and hence libm
dnl -------------------------------
TMPLIBS="$LIBS"
AC_CHECK_HEADER([math.h],
  [AC_CHECK_LIB([m], [pow],
    [LIBM="-lm"
     LIBS="$LIBS $LIBM"
     AC_DEFINE(HAVE_LIBM,, Have libm)
     AC_CHECK_FUNCS(pow,[],[LIBM=""])
    ])
])
if test x"$LIBM" = x ; then
  AC_MSG_WARN([Unable to find working pow function - bgpd may not link])
fi
LIBS="$TMPLIBS"
AC_SUBST(LIBM)

dnl ---------------
dnl other functions
dnl ---------------
AC_CHECK_FUNCS([dup2 ftruncate getcwd gethostbyname getpagesize gettimeofday \
	inet_ntoa inet_aton strnlen \
	memchr memmove memset select socket \
	strcasecmp strchr strcspn strdup strerror \
	strncasecmp strndup strrchr strspn strstr \
	strtol strtoul strlcat strlcpy \
	daemon snprintf vsnprintf \
	if_nametoindex if_indextoname getifaddrs \
	uname fcntl])

AC_CHECK_FUNCS(setproctitle, ,
  [AC_CHECK_LIB(util, setproctitle, 
     [LIBS="$LIBS -lutil"
      AC_DEFINE(HAVE_SETPROCTITLE,, Have setproctitle)
     ]
   )
  ]
)

dnl ------------------------------------
dnl Determine routing get and set method
dnl ------------------------------------
AC_MSG_CHECKING(zebra between kernel interface method)
if test x"$opsys" = x"gnu-linux"; then
  if test "${enable_netlink}" = "yes";then
    AC_MSG_RESULT(netlink)
    RT_METHOD=rt_netlink.o
    AC_DEFINE(HAVE_NETLINK,,netlink)
    netlink=yes
  elif test "${enable_netlink}" = "no"; then
    AC_MSG_RESULT(ioctl)
    RT_METHOD=rt_ioctl.o
    netlink=no
  else
    AC_MSG_RESULT(netlink)
    RT_METHOD=rt_netlink.o
    AC_DEFINE(HAVE_NETLINK,,netlink)
    netlink=yes
  fi
elif test x"$opsys" = x"sol2-6";then
  AC_MSG_RESULT(Route socket)
  KERNEL_METHOD="kernel_socket.o"
  RT_METHOD="rt_socket.o"
elif test x"$opsys" = x"sol8";then
  AC_MSG_RESULT(Route socket)
  KERNEL_METHOD="kernel_socket.o"
  RT_METHOD="rt_socket.o"
elif test "$opsys" = "irix" ; then
  AC_MSG_RESULT(Route socket)
  KERNEL_METHOD="kernel_socket.o"
  RT_METHOD="rt_socket.o"
else
  AC_TRY_RUN([#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>

main ()
{
  int ac_sock;

  ac_sock = socket (AF_ROUTE, SOCK_RAW, 0);
  if (ac_sock < 0 && errno == EINVAL)
    exit (1);
  exit (0);
}],
  [KERNEL_METHOD=kernel_socket.o
   RT_METHOD=rt_socket.o
   AC_MSG_RESULT(socket)],
  [RT_METHOD=rt_ioctl.o
   AC_MSG_RESULT(ioctl)],
  [KERNEL_METHOD=kernel_socket.o
   RT_METHOD=rt_socket.o
   AC_MSG_RESULT(socket)])
fi
AC_SUBST(RT_METHOD)
AC_SUBST(KERNEL_METHOD)
AC_SUBST(OTHER_METHOD)

dnl --------------------------
dnl Determine IS-IS I/O method
dnl --------------------------
AC_DEFINE(ISIS_METHOD_PFPACKET,	1, [ constant value for isis method pfpacket ])
AC_DEFINE(ISIS_METHOD_DLPI,	2, [ constant value for isis method dlpi ])
AC_DEFINE(ISIS_METHOD_BPF,	3, [ constant value for isis method bpf ])
AC_CHECK_HEADER(net/bpf.h)
AC_CHECK_HEADER(sys/dlpi.h)
AC_MSG_CHECKING(zebra IS-IS I/O method)
if test x"$opsys" = x"gnu-linux"; then
  AC_MSG_RESULT(pfpacket)
  ISIS_METHOD_MACRO="ISIS_METHOD_PFPACKET"
elif test x"$opsys" = x"sol2-6" -o x"$opsys" = x"sol8"; then
  AC_MSG_RESULT(DLPI)
  ISIS_METHOD_MACRO="ISIS_METHOD_DLPI"
else
  if test $ac_cv_header_net_bpf_h = no; then
    if test $ac_cv_header_sys_dlpi_h = no; then
      AC_MSG_RESULT(none)
      AC_MSG_WARN([*** IS-IS support will not be built ***])
      ISISD=""
    else
      AC_MSG_RESULT(DLPI)
    fi
    ISIS_METHOD_MACRO="ISIS_METHOD_DLPI"
  else
    AC_MSG_RESULT(BPF)
    ISIS_METHOD_MACRO="ISIS_METHOD_BPF"
  fi
fi
AC_DEFINE_UNQUOTED(ISIS_METHOD, $ISIS_METHOD_MACRO, [ selected method for isis, == one of the constants ])

dnl ------------------------------------
dnl check for broken CMSG_FIRSTHDR macro
dnl ------------------------------------
AC_MSG_CHECKING(for broken CMSG_FIRSTHDR)
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#ifdef SUNOS_5
#define _XPG4_2
#define __EXTENSIONS__
#endif
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif

main()
{
  struct msghdr msg;
  char buf[4];

  msg.msg_control = buf;
  msg.msg_controllen = 0;

  if (CMSG_FIRSTHDR(&msg) != NULL)
    exit(0);
  exit (1);
}]])],[AC_MSG_RESULT(yes - using workaround) AC_DEFINE(HAVE_BROKEN_CMSG_FIRSTHDR,,Broken CMSG_FIRSTHDR)],
[AC_MSG_RESULT(no)],[AC_MSG_RESULT(no)])

dnl ------------------------------
dnl check kernel route read method
dnl ------------------------------
AC_CACHE_CHECK([route read method], [quagga_cv_rtread_method],
[if test "x$netlink" = xyes; then
  quagga_cv_rtread_method="netlink"
else
for quagga_cv_rtread_method in /proc/net/route /dev/ip /dev/null;
do
  test x`ls $quagga_cv_rtread_method 2>/dev/null` = x"$quagga_cv_rtread_method" && break
done
case $quagga_cv_rtread_method in
  "/proc/net/route") quagga_cv_rtread_method="proc";;
  "/dev/ip")
                     case "$host" in
                       *-freebsd*)    quagga_cv_rtread_method="sysctl";;
                       *)             quagga_cv_rtread_method="getmsg";;
                     esac;;
	*)
                     quagga_cv_rtread_method="sysctl";;
esac
fi])
RTREAD_METHOD=rtread_${quagga_cv_rtread_method}.o
AC_SUBST(RTREAD_METHOD)

dnl -----------------------------
dnl check interface lookup method
dnl -----------------------------
IOCTL_METHOD=ioctl.o
AC_MSG_CHECKING(interface looking up method)
if test "$netlink" = yes; then
  AC_MSG_RESULT(netlink)
  IF_METHOD=if_netlink.o
elif test "$opsys" = "sol2-6";then
  AC_MSG_RESULT(Solaris GIF)
  IF_METHOD=if_ioctl.o
elif test "$opsys" = "sol8";then
  AC_MSG_RESULT(Solaris GLIF)
  IF_METHOD=if_ioctl_solaris.o
  IOCTL_METHOD=ioctl_solaris.o
elif test "$opsys" = "irix" ; then
  AC_MSG_RESULT(IRIX)
  IF_METHOD=if_ioctl.o
elif test "$opsys" = "openbsd";then
  AC_MSG_RESULT(openbsd)
  IF_METHOD=if_ioctl.o
elif grep NET_RT_IFLIST /usr/include/sys/socket.h >/dev/null 2>&1; then
  AC_MSG_RESULT(sysctl)
    IF_METHOD=if_sysctl.o
    AC_DEFINE(HAVE_NET_RT_IFLIST,,NET_RT_IFLIST)
else
    AC_MSG_RESULT(ioctl)
    IF_METHOD=if_ioctl.o
fi
AC_SUBST(IF_METHOD)
AC_SUBST(IOCTL_METHOD)

dnl ---------------------------------------------------------------
dnl figure out how to specify an interface in multicast sockets API
dnl ---------------------------------------------------------------
AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [], [], QUAGGA_INCLUDES)

AC_MSG_CHECKING([for BSD struct ip_mreq hack])
AC_TRY_COMPILE([#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif],[#if (defined(__FreeBSD__) && ((__FreeBSD_version >= 500022 && __FreeBSD_version < 700000) || (__FreeBSD_version < 500000 && __FreeBSD_version >= 440000))) || (defined(__NetBSD__) && defined(__NetBSD_Version__) && __NetBSD_Version__ >= 106010000) || defined(__OpenBSD__)
  return (0);
#else
  #error No support for BSD struct ip_mreq hack detected
#endif],[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BSD_STRUCT_IP_MREQ_HACK,,[Can pass ifindex in struct ip_mreq])],
AC_MSG_RESULT(no))

AC_MSG_CHECKING([for RFC3678 protocol-independed API])
AC_TRY_COMPILE([
#include <sys/types.h>
#include <netinet/in.h>
], [struct group_req gr; int sock; setsockopt(sock, IPPROTO_IP, MCAST_JOIN_GROUP, (void*)&gr, sizeof(gr));
], [AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_RFC3678,1,[Have RFC3678 protocol-independed API])],
AC_MSG_RESULT(no))

dnl ---------------------------------------------------------------
dnl figure out how to check link-state
dnl ---------------------------------------------------------------
AC_CHECK_HEADER([net/if.h],
  [AC_CHECK_HEADER( [net/if_media.h],
    [m4_define([LINK_DETECT_INCLUDES],
      QUAGGA_INCLUDES
      [#include <net/if_media.h>
    ])
    AC_CHECK_MEMBERS( [struct ifmediareq.ifm_status],
      AC_DEFINE(HAVE_BSD_LINK_DETECT,,[BSD link-detect]),
      [], LINK_DETECT_INCLUDES)], 
    [],
    QUAGGA_INCLUDES)], 
  [], QUAGGA_INCLUDES )

dnl ---------------------------------------------------------------
dnl Additional, newer way to check link-state using ifi_link_state.
dnl Not available in all BSD's when ifmediareq available
dnl ---------------------------------------------------------------
AC_CHECK_HEADER([net/if.h],
    AC_CHECK_MEMBERS([struct if_data.ifi_link_state],
      AC_DEFINE(HAVE_BSD_IFI_LINK_STATE,,[BSD ifi_link_state available]),
      [], QUAGGA_INCLUDES),
    ,)

dnl ------------------------
dnl TCP_MD5SIG socket option
dnl ------------------------

AC_CHECK_HEADER([netinet/tcp.h], 
   [m4_define([MD5_INCLUDES],
      QUAGGA_INCLUDES
      [#include <netinet/tcp.h>
    ])
    AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)],
   [],
   QUAGGA_INCLUDES)
if test $ac_cv_have_decl_TCP_MD5SIG = no; then
  AC_CHECK_HEADER([linux/tcp.h],
       [m4_define([MD5_INCLUDES],
          QUAGGA_INCLUDES
          [#include <linux/tcp.h>
        ])
       AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)])
fi

dnl -----------------------
dnl check proc file system.
dnl -----------------------
if test "$netlink" != yes; then
  if test -r /proc/net/dev; then
    AC_DEFINE(HAVE_PROC_NET_DEV,,/proc/net/dev)
    IF_PROC=if_proc.o
  fi
  if test -r /proc/net/if_inet6; then
    AC_DEFINE(HAVE_PROC_NET_IF_INET6,,/proc/net/if_inet6)
    IF_PROC=if_proc.o
  fi
fi
AC_SUBST(IF_PROC)

dnl -----------------------------
dnl check ipforward detect method
dnl -----------------------------
AC_CACHE_CHECK([ipforward method], [quagga_cv_ipforward_method],
[if test x$cross_compiling = xyes; then
  if test x"$opsys" = x"gnu-linux"; then
    quagga_cv_ipforward_method=/proc/net/snmp
  else
    quagga_cv_ipforward_method=/dev/ip
  fi
else
  for quagga_cv_ipforward_method in /proc/net/snmp /dev/ip /dev/null;
  do
    test x`ls $quagga_cv_ipforward_method 2>/dev/null` = x"$quagga_cv_ipforward_method" && break
  done
fi
case $quagga_cv_ipforward_method in
  "/proc/net/snmp")  quagga_cv_ipforward_method="proc";;
  "/dev/ip")         
                     case "$host" in
                       *-nec-sysv4*)  quagga_cv_ipforward_method="ews";;
                       *-freebsd*)    quagga_cv_ipforward_method="sysctl";;
                       *)             quagga_cv_ipforward_method="solaris";;
                     esac;;
  *)                 quagga_cv_ipforward_method="sysctl";;
esac])
IPFORWARD=ipforward_${quagga_cv_ipforward_method}.o
AC_SUBST(IPFORWARD)

AC_CHECK_FUNCS(getaddrinfo, [have_getaddrinfo=yes], [have_getaddrinfo=no])

dnl ----------
dnl IPv6 check
dnl ----------
AC_MSG_CHECKING(whether does this OS have IPv6 stack)
if test "${enable_ipv6}" = "no"; then
  AC_MSG_RESULT(disabled)
else
dnl ----------
dnl INRIA IPv6
dnl ----------
  if grep IPV6_INRIA_VERSION /usr/include/netinet/in.h >/dev/null 2>&1; then
    zebra_cv_ipv6=yes
    AC_DEFINE(HAVE_IPV6,1,INRIA IPv6)
    AC_DEFINE(INRIA_IPV6,1,INRIA IPv6)
    RIPNGD="ripngd"
    OSPF6D="ospf6d"
    LIB_IPV6=""
    AC_MSG_RESULT(INRIA IPv6)
dnl ---------
dnl KAME IPv6
dnl ---------
  elif grep WIDE /usr/include/netinet6/in6.h >/dev/null 2>&1; then
    zebra_cv_ipv6=yes
    AC_DEFINE(HAVE_IPV6,1,KAME IPv6)
    AC_DEFINE(KAME,1,KAME IPv6)
    RIPNGD="ripngd"
    OSPF6D="ospf6d"
    if test -d /usr/local/v6/lib -a -f /usr/local/v6/lib/libinet6.a; then
      LIB_IPV6="-L/usr/local/v6/lib -linet6"
    fi
    AC_MSG_RESULT(KAME)
dnl -------------------------
dnl MUSICA IPv6
dnl  default host check
dnl  It is not used by Kheops
dnl -------------------------
  elif grep MUSICA /usr/include6/netinet6/in6.h >/dev/null 2>&1; then
    zebra_cv_ipv6=yes
    AC_DEFINE(HAVE_IPV6,1,Musicia IPv6)
    AC_DEFINE(MUSICA,1,Musica IPv6 stack)
    AC_DEFINE(KAME,1,KAME IPv6 stack)
    RIPNGD="ripngd"
    OSPF6D="ospf6d"
    if test -d /usr/local/v6/lib -a -f /usr/local/v6/lib/libinet6.a; then
      LIB_IPV6="-L/usr/local/v6/lib -linet6"
    fi
    AC_MSG_RESULT(MUSICA)
dnl ---------
dnl NRL check
dnl ---------
  elif grep NRL /usr/include/netinet6/in6.h >/dev/null 2>&1; then
    zebra_cv_ipv6=yes
    AC_DEFINE(HAVE_IPV6,1,NRL IPv6)
    AC_DEFINE(NRL,1,NRL)
    RIPNGD="ripngd"
    OSPF6D="ospf6d"
    if test x"$opsys" = x"bsdi";then
      AC_DEFINE(BSDI_NRL,,BSDI)
      AC_MSG_RESULT(BSDI_NRL)
    else
      AC_MSG_RESULT(NRL)
    fi
dnl ------------------------------------
dnl Solaris 9, 10 and potentially higher
dnl ------------------------------------
  elif test x"$opsys" = x"sol8"; then
    zebra_cv_ipv6=yes;
    AC_DEFINE(HAVE_IPV6, 1, IPv6)
    AC_DEFINE(SOLARIS_IPV6, 1, Solaris IPv6)
    RIPNGD="ripngd"
    OSPF6D="ospf6d"
    AC_MSG_RESULT(Solaris IPv6)
dnl ----------
dnl Linux IPv6
dnl ----------
  elif test "${enable_ipv6}" = "yes"; then
    AC_EGREP_CPP(yes, [
      #include <linux/version.h>
      /* 2.1.128 or later */
      #if LINUX_VERSION_CODE >= 0x020180
      yes
      #endif],
      [zebra_cv_ipv6=yes
       zebra_cv_linux_ipv6=yes
       AC_MSG_RESULT(Linux IPv6)])
  else
    if test x`ls /proc/net/ipv6_route 2>/dev/null` = x"/proc/net/ipv6_route"
     then
      zebra_cv_ipv6=yes
      zebra_cv_linux_ipv6=yes
      AC_MSG_RESULT(Linux IPv6)
    fi
  fi

  if test "$zebra_cv_linux_ipv6" = "yes";then
    AC_MSG_CHECKING(whether libc has IPv6 support)
    AC_TRY_LINK([#include <netinet/in.h>
    ],[ int a; a = (int) in6addr_any.s6_addr[0]; if (a != 12345) return a; ],
    [AC_MSG_RESULT(yes)
      zebra_cv_ipv6=yes
      zebra_cv_linux_ipv6=yes],
    [AC_MSG_RESULT(no)
      zebra_cv_ipv6=no
      zebra_cv_linux_ipv6=no])
  fi

  if test "$zebra_cv_linux_ipv6" = "yes";then
    AC_MSG_CHECKING(for GNU libc >= 2.1)
    AC_DEFINE(HAVE_IPV6,1,Linux IPv6)
    AC_EGREP_CPP(yes, [
#include <features.h>
#if __GLIBC__ >= 2 && __GLIBC_MINOR__ >= 1
  yes
#endif], 
      [glibc=yes
       AC_DEFINE(LINUX_IPV6,1,Linux IPv6 stack)
       AC_MSG_RESULT(yes)], 
      AC_MSG_RESULT(no)
    )
    RIPNGD="ripngd"
    OSPF6D="ospf6d"
    if test "$glibc" != "yes"; then
      INCLUDES="-I/usr/inet6/include"
      if test x`ls /usr/inet6/lib/libinet6.a 2>/dev/null` != x;then
         LIB_IPV6="-L/usr/inet6/lib -linet6"
      fi
    fi
  fi

dnl -----------------------
dnl Set IPv6 related values
dnl -----------------------
  LIBS="$LIB_IPV6 $LIBS"
  AC_SUBST(LIB_IPV6)

  if test x"$RIPNGD" = x""; then
    AC_MSG_RESULT(IPv4 only)
  fi
fi

dnl ------------------
dnl IPv6 header checks
dnl ------------------
if test "x${zebra_cv_ipv6}" = "xyes"; then
AC_CHECK_HEADERS([netinet6/in6.h netinet/in6_var.h netinet/icmp6.h \
	netinet6/in6_var.h netinet6/nd6.h], [], [],
	QUAGGA_INCLUDES)
fi

m4_define([QUAGGA_INCLUDES],dnl
QUAGGA_INCLUDES
[#if HAVE_NETINET6_IN6_H
#include <netinet6/in6.h>
#endif
#if HAVE_NETINET_IN6_VAR_H
#include <netinet/in6_var.h>
#endif
#if HAVE_NETINET_ICMP6_H
# include <netinet/icmp6.h>
#endif
#if HAVE_NETINET6_IN6_VAR_H
# include <netinet6/in6_var.h>
#endif
#if HAVE_NETINET6_ND6_H
# include <netinet6/nd6.h>
#endif
])dnl

dnl disable doc check
if test "${enable_doc}" = "no";then
  DOC=""
else
  DOC="doc"
fi

dnl can't use TESTS as name, that's special with automake
if test "${enable_tests}" = "no";then
  BUILD_TESTS=""
else
  BUILD_TESTS="tests"
fi

dnl --------------------
dnl Daemon disable check
dnl --------------------
if test "${enable_zebra}" = "no";then
  ZEBRA=""
else
  ZEBRA="zebra"
fi
AM_CONDITIONAL(ZEBRA, test "x$ZEBRA" = "xzebra")

if test "${enable_bgpd}" = "no";then
  BGPD=""
else
  BGPD="bgpd"
fi
AM_CONDITIONAL(BGPD, test "x$BGPD" = "xbgpd")

if test "${enable_ripd}" = "no";then
  RIPD=""
else
  RIPD="ripd"
fi
AM_CONDITIONAL(RIPD, test "x$RIPD" = "xripd")

if test "${enable_ospfd}" = "no";then
  OSPFD=""
else
  OSPFD="ospfd"
fi
AM_CONDITIONAL(OSPFD, test "x$OSPFD" = "xospfd")

if test "${enable_babeld}" = "no";then
  BABELD=""
else
  BABELD="babeld"
fi
AM_CONDITIONAL(BABELD, test "x$BABELD" = "xbabeld")

if test "${enable_watchquagga}" = "no";then
  WATCHQUAGGA=""
else
  WATCHQUAGGA="watchquagga"
fi
AM_CONDITIONAL(WATCHQUAGGA, test "x$WATCHQUAGGA" = "xwatchquagga")

OSPFCLIENT=""
if test "${enable_opaque_lsa}" != "no"; then
  if test "${enable_ospfapi}" != "no";then
    AC_DEFINE(SUPPORT_OSPF_API,,OSPFAPI)

    if test "${enable_ospfclient}" != "no";then
      OSPFCLIENT="ospfclient"
    fi
  fi

fi
AM_CONDITIONAL(OSPFCLIENT, test "x$OSPFCLIENT" = "xospfclient")

case "${enable_ripngd}" in
  "yes") RIPNGD="ripngd";;
  "no" ) RIPNGD="";;
  *    ) ;;
esac
AM_CONDITIONAL(RIPNGD, test "x$RIPNGD" = "xripngd")

case "${enable_ospf6d}" in
  "yes") OSPF6D="ospf6d";;
  "no" ) OSPF6D="";;
  *    ) ;;
esac
AM_CONDITIONAL(OSPF6D, test "x$OSPF6D" = "xospf6d")

case "${enable_isisd}" in
  "yes") ISISD="isisd";;
  "no" ) ISISD="";;
  *    ) ;;
esac
AM_CONDITIONAL(ISISD, test "x$ISISD" = "xisisd")

# XXX Perhaps auto-enable on Solaris, but that's messy for cross builds.
case "${enable_solaris}" in
  "yes") SOLARIS="solaris";;
  "no" ) SOLARIS="";;
  *    ) ;;
esac

if test "${enable_bgp_announce}" = "no";then
  AC_DEFINE(DISABLE_BGP_ANNOUNCE,1,Disable BGP installation to zebra)
else
  AC_DEFINE(DISABLE_BGP_ANNOUNCE,0,Disable BGP installation to zebra)
fi

AC_SUBST(DOC)
AC_SUBST(BUILD_TESTS)
AC_SUBST(ZEBRA)
AC_SUBST(BGPD)
AC_SUBST(RIPD)
AC_SUBST(RIPNGD)
AC_SUBST(OSPFD)
AC_SUBST(OSPF6D)
AC_SUBST(BABELD)
AC_SUBST(WATCHQUAGGA)
AC_SUBST(ISISD)
AC_SUBST(SOLARIS)
AC_SUBST(VTYSH)
AC_SUBST(INCLUDES)
AC_SUBST(CURSES)
AC_SUBST(OSPFCLIENT)
AC_SUBST(OSPFAPI)
AC_CHECK_LIB(c, inet_ntop, [AC_DEFINE(HAVE_INET_NTOP,,inet_ntop)])
AC_CHECK_LIB(c, inet_pton, [AC_DEFINE(HAVE_INET_PTON,,inet_pton)])
AC_CHECK_LIB(crypt, crypt)
AC_CHECK_LIB(resolv, res_init)

dnl ---------------------------------------------------
dnl BSD/OS 4.1 define inet_XtoY function as __inet_XtoY
dnl ---------------------------------------------------
AC_CHECK_FUNC(__inet_ntop, AC_DEFINE(HAVE_INET_NTOP,,__inet_ntop))
AC_CHECK_FUNC(__inet_pton, AC_DEFINE(HAVE_INET_PTON,,__inet_pton))
AC_CHECK_FUNC(__inet_aton, AC_DEFINE(HAVE_INET_ATON,,__inet_aton))

dnl ---------------------------
dnl check system has PCRE regexp
dnl ---------------------------
if test "x$enable_pcreposix" = "xyes"; then
  AC_CHECK_LIB(pcreposix, pcreposix_regexec, ,[enable_pcreposix=no
  AC_MSG_WARN([*** falling back to other regex library ***]) ])
fi

if test "x$enable_pcreposix" != "xyes"; then
dnl ---------------------------
dnl check system has GNU regexp
dnl ---------------------------
AC_MSG_CHECKING(whether system has GNU regex)
AC_CHECK_LIB(c, regexec,
[AC_DEFINE(HAVE_GNU_REGEX,,GNU regexp library)
 LIB_REGEX=""],
[LIB_REGEX="regex.o"])
fi
AC_SUBST(HAVE_LIBPCREPOSIX)
AC_SUBST(LIB_REGEX)

dnl ------------------
dnl check Net-SNMP library
dnl ------------------
if test "${enable_snmp}" != ""; then
   AC_PATH_TOOL([NETSNMP_CONFIG], [net-snmp-config], [no])
   if test x"$NETSNMP_CONFIG" = x"no"; then
      AC_MSG_ERROR([--enable-snmp given but unable to find net-snmp-config])
   fi
   LIBS="$LIBS `${NETSNMP_CONFIG} --agent-libs`"
   CFLAGS="`${NETSNMP_CONFIG} --base-cflags` $CFLAGS"
   AC_MSG_CHECKING([whether we can link to Net-SNMP])
   AC_LINK_IFELSE([AC_LANG_PROGRAM([
int main(void);
],
[
{
  return 0;
}
])],[AC_MSG_RESULT(yes)],[
     AC_MSG_RESULT(no)
     AC_MSG_ERROR([--enable-snmp given but not usable])])
   AC_DEFINE(HAVE_SNMP,,SNMP)
   case "${enable_snmp}" in
     yes)
      SNMP_METHOD=agentx
      ;;
     smux|agentx)
      SNMP_METHOD="${enable_snmp}"
      ;;
     *)
      AC_MSG_ERROR([--enable-snmp given with an unknown method (${enable_snmp}). Use smux or agentx])
      ;;
   esac
   AH_TEMPLATE([SNMP_SMUX], [Use SNMP SMUX to interface with snmpd])
   AH_TEMPLATE([SNMP_AGENTX], [Use SNMP AgentX to interface with snmpd])
   AC_DEFINE_UNQUOTED(AS_TR_CPP(SNMP_${SNMP_METHOD}),,SNMP method to interface with snmpd)
fi

dnl ---------------------------
dnl sockaddr and netinet checks
dnl ---------------------------
AC_CHECK_TYPES([struct sockaddr, struct sockaddr_in,
	struct sockaddr_in6, struct sockaddr_un, struct sockaddr_dl,
	socklen_t,
	struct ifaliasreq, struct if6_aliasreq, struct in6_aliasreq,
	struct nd_opt_adv_interval, struct rt_addrinfo,
	struct nd_opt_homeagent_info, struct nd_opt_adv_interval],
	[], [], QUAGGA_INCLUDES)

AC_CHECK_MEMBERS([struct sockaddr.sa_len,
	struct sockaddr_in.sin_len, struct sockaddr_un.sun_len,
	struct sockaddr_in6.sin6_scope_id,
	struct if6_aliasreq.ifra_lifetime,
	struct nd_opt_adv_interval.nd_opt_ai_type],
	[], [], QUAGGA_INCLUDES)

dnl ---------------------------
dnl IRDP/pktinfo/icmphdr checks
dnl ---------------------------
AC_CHECK_TYPES([struct in_pktinfo], 
 [AC_CHECK_TYPES([struct icmphdr],
   [if test "${enable_irdp}" != "no"; then
      AC_DEFINE(HAVE_IRDP,, IRDP)
    fi],
   [if test "${enable_irdp}" = "yes"; then
      AC_MSG_ERROR(['IRDP requires in_pktinfo at the moment!'])
    fi], [QUAGGA_INCLUDES])],
 [if test "${enable_irdp}" = "yes"; then
    AC_MSG_ERROR(['IRDP requires in_pktinfo at the moment!'])
  fi], [QUAGGA_INCLUDES])

dnl --------------------------------------
dnl checking for getrusage struct and call
dnl --------------------------------------
AC_MSG_CHECKING(whether getrusage is available)
AC_TRY_COMPILE([#include <sys/resource.h>
],[struct rusage ac_x; getrusage (RUSAGE_SELF, &ac_x);],
[AC_MSG_RESULT(yes)
 AC_DEFINE(HAVE_RUSAGE,,rusage)],
 AC_MSG_RESULT(no))

dnl --------------------------------------
dnl checking for clock_time monotonic struct and call
dnl --------------------------------------
AC_CHECK_DECL(CLOCK_MONOTONIC,
	[AC_CHECK_LIB(rt, clock_gettime, [LIBS="$LIBS -lrt"])
	 AC_DEFINE(HAVE_CLOCK_MONOTONIC,, Have monotonic clock)
], [AC_MSG_RESULT(no)], [QUAGGA_INCLUDES])

dnl -------------------
dnl capabilities checks
dnl -------------------
if test "${enable_capabilities}" != "no"; then
  AC_MSG_CHECKING(whether prctl PR_SET_KEEPCAPS is available)
  AC_TRY_COMPILE([#include <sys/prctl.h>],[prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);],
    [AC_MSG_RESULT(yes)
     AC_DEFINE(HAVE_PR_SET_KEEPCAPS,,prctl)
     quagga_ac_keepcaps="yes"],
     AC_MSG_RESULT(no)
  )
  if test x"${quagga_ac_keepcaps}" = x"yes"; then
    AC_CHECK_HEADERS(sys/capability.h)
  fi
  if test x"${ac_cv_header_sys_capability_h}" = x"yes"; then
    AC_CHECK_LIB(cap, cap_init, 
      [AC_DEFINE(HAVE_LCAPS,1,Capabilities)
       LIBCAP="-lcap"
       quagga_ac_lcaps="yes"]
    )
  else
    AC_CHECK_HEADERS(priv.h,
     [AC_MSG_CHECKING(Solaris style privileges are available)
      AC_TRY_COMPILE([#include <priv.h>],[getpflags(PRIV_AWARE);],
    	  [AC_MSG_RESULT(yes)
    	   AC_DEFINE(HAVE_SOLARIS_CAPABILITIES,1,getpflags)
    	   quagga_ac_scaps="yes"],
    	   AC_MSG_RESULT(no)
      )
     ]
   )
  fi
  if test x"${quagga_ac_scaps}" = x"yes" \
       -o x"${quagga_ac_lcaps}" = x"yes"; then
    AC_DEFINE(HAVE_CAPABILITIES,1,capabilities)
  fi
fi
AC_SUBST(LIBCAP)

dnl ---------------------------
dnl check for glibc 'backtrace'
dnl --------------------------- 
AC_CHECK_HEADER([execinfo.h],
  [AC_CHECK_FUNC([backtrace],
    [AC_DEFINE(HAVE_GLIBC_BACKTRACE,,[Glibc backtrace])
     AC_DEFINE(HAVE_STACK_TRACE,,[Stack symbol decoding])
  ])
])

dnl -----------------------------------------
dnl check for malloc mallinfo struct and call
dnl this must try and link using LIBS, in
dnl order to check no alternative allocator
dnl has been specified, which might not provide
dnl mallinfo, e.g. such as Umem on Solaris.
dnl -----------------------------------------
AC_CHECK_HEADER([malloc.h],
 [AC_MSG_CHECKING(whether mallinfo is available)
  AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <malloc.h>]],
                        [[struct mallinfo ac_x; ac_x = mallinfo ();]])],
      [AC_MSG_RESULT(yes)
       AC_DEFINE(HAVE_MALLINFO,,mallinfo)],
       AC_MSG_RESULT(no)
  )
 ], [], QUAGGA_INCLUDES)

dnl ----------
dnl configure date
dnl ----------
CONFDATE=`date '+%Y%m%d'`
AC_SUBST(CONFDATE)

dnl Conditionally enable PIE support for GNU toolchains.
AC_ARG_ENABLE(pie, AS_HELP_STRING([--disable-pie], [Do not build tools as a Position Independent Executables]))
if test "$enable_pie" != "no"; then
  AC_CACHE_CHECK([whether $CC accepts PIE flags], [ap_cv_cc_pie], [
    save_CFLAGS=$CFLAGS
    save_LDFLAGS=$LDFLAGS
    CFLAGS="$CFLAGS -fPIE"
    LDFLAGS="$LDFLAGS -pie"
    AC_LINK_IFELSE([AC_LANG_SOURCE([[static int foo[30000]; int main () { return 0; }]])],
      [ap_cv_cc_pie=yes], [ap_cv_cc_pie=no]
    )
    CFLAGS=$save_CFLAGS
    LDFLAGS=$save_LDFLAGS
  ])
  if test "$ap_cv_cc_pie" = "yes"; then
    PICFLAGS="-fPIE"
    PILDFLAGS="-pie"
  fi
fi

AC_SUBST(PICFLAGS)
AC_SUBST(PILDFLAGS)

dnl ------------------------------
dnl set paths for state directory
dnl ------------------------------
AC_MSG_CHECKING(directory to use for state file)
if test "${prefix}" = "NONE"; then
  quagga_statedir_prefix="";
else
  quagga_statedir_prefix=${prefix}
fi
if test "${localstatedir}" = '${prefix}/var'; then
  for QUAGGA_STATE_DIR in ${quagga_statedir_prefix}/var/run dnl
			${quagga_statedir_prefix}/var/adm dnl
			${quagga_statedir_prefix}/etc dnl
			/var/run	dnl
                        /var/adm	dnl
                        /etc		dnl
                        /dev/null;
  do
    test -d $QUAGGA_STATE_DIR && break
  done
  quagga_statedir=$QUAGGA_STATE_DIR
else
  quagga_statedir=${localstatedir}
fi
if test $quagga_statedir = "/dev/null"; then
    AC_MSG_ERROR('STATE DIRECTORY NOT FOUND! FIX OR SPECIFY --localstatedir!')
fi
AC_MSG_RESULT(${quagga_statedir})
AC_SUBST(quagga_statedir)

AC_DEFINE_UNQUOTED(PATH_ZEBRA_PID, "$quagga_statedir/zebra.pid",zebra PID)
AC_DEFINE_UNQUOTED(PATH_RIPD_PID, "$quagga_statedir/ripd.pid",ripd PID)
AC_DEFINE_UNQUOTED(PATH_RIPNGD_PID, "$quagga_statedir/ripngd.pid",ripngd PID)
AC_DEFINE_UNQUOTED(PATH_BGPD_PID, "$quagga_statedir/bgpd.pid",bgpd PID)
AC_DEFINE_UNQUOTED(PATH_OSPFD_PID, "$quagga_statedir/ospfd.pid",ospfd PID)
AC_DEFINE_UNQUOTED(PATH_OSPF6D_PID, "$quagga_statedir/ospf6d.pid",ospf6d PID)
AC_DEFINE_UNQUOTED(PATH_BABELD_PID, "$quagga_statedir/babeld.pid",babeld PID)
AC_DEFINE_UNQUOTED(PATH_ISISD_PID, "$quagga_statedir/isisd.pid",isisd PID)
AC_DEFINE_UNQUOTED(PATH_WATCHQUAGGA_PID, "$quagga_statedir/watchquagga.pid",watchquagga PID)
AC_DEFINE_UNQUOTED(ZEBRA_SERV_PATH, "$quagga_statedir/zserv.api",zebra api socket)
AC_DEFINE_UNQUOTED(ZEBRA_VTYSH_PATH, "$quagga_statedir/zebra.vty",zebra vty socket)
AC_DEFINE_UNQUOTED(RIP_VTYSH_PATH, "$quagga_statedir/ripd.vty",rip vty socket)
AC_DEFINE_UNQUOTED(RIPNG_VTYSH_PATH, "$quagga_statedir/ripngd.vty",ripng vty socket)
AC_DEFINE_UNQUOTED(BGP_VTYSH_PATH, "$quagga_statedir/bgpd.vty",bgpd vty socket)
AC_DEFINE_UNQUOTED(OSPF_VTYSH_PATH, "$quagga_statedir/ospfd.vty",ospfd vty socket)
AC_DEFINE_UNQUOTED(OSPF6_VTYSH_PATH, "$quagga_statedir/ospf6d.vty",ospf6d vty socket)
AC_DEFINE_UNQUOTED(BABEL_VTYSH_PATH, "$quagga_statedir/babeld.vty",babeld vty socket)
AC_DEFINE_UNQUOTED(ISIS_VTYSH_PATH, "$quagga_statedir/isisd.vty",isisd vty socket)
AC_DEFINE_UNQUOTED(DAEMON_VTY_DIR, "$quagga_statedir",daemon vty directory)

dnl -------------------------------
dnl Quagga sources should always be 
dnl current wrt interfaces. Dont
dnl allow deprecated interfaces to
dnl be exposed.
dnl -------------------------------
AC_DEFINE(QUAGGA_NO_DEPRECATED_INTERFACES, 1, Hide deprecated interfaces)

dnl ---------------------------
dnl Check htonl works correctly
dnl ---------------------------
AC_MSG_CHECKING(for working htonl)
AC_CACHE_VAL(ac_cv_htonl_works,
 [AC_LINK_IFELSE([AC_LANG_PROGRAM([QUAGGA_INCLUDES],[htonl (0);])],
 		[ac_cv_htonl_works=yes], [ac_cv_htonl_works=no])
 ]
)
AC_MSG_RESULT($ac_cv_htonl_works)

AC_CONFIG_FILES([Makefile lib/Makefile zebra/Makefile ripd/Makefile 
	  ripngd/Makefile bgpd/Makefile ospfd/Makefile watchquagga/Makefile
	  ospf6d/Makefile isisd/Makefile babeld/Makefile vtysh/Makefile
          doc/Makefile ospfclient/Makefile tests/Makefile m4/Makefile
          redhat/Makefile
	  pkgsrc/Makefile
	  redhat/quagga.spec 
	  lib/version.h
	  doc/defines.texi
	  isisd/topology/Makefile
	  pkgsrc/bgpd.sh pkgsrc/ospf6d.sh pkgsrc/ospfd.sh
	  pkgsrc/ripd.sh pkgsrc/ripngd.sh pkgsrc/zebra.sh])
AC_CONFIG_FILES([solaris/Makefile])

AC_CONFIG_FILES([vtysh/extract.pl],[chmod +x vtysh/extract.pl])
## Hack, but working solution to avoid rebuilding of quagga.info.
## It's already in CVS until texinfo 4.7 is more common.
AC_OUTPUT

echo "
Quagga configuration
--------------------
quagga version          : ${PACKAGE_VERSION}
host operating system   : ${host_os}
source code location    : ${srcdir}
compiler                : ${CC}
compiler flags          : ${CFLAGS}
make                    : ${MAKE-make}
includes                : ${INCLUDES}
linker flags            : ${LDFLAGS} ${LIBS} ${LIBCAP} ${LIBREADLINE} ${LIBM}
state file directory    : ${quagga_statedir}
config file directory   : `eval echo \`echo ${sysconfdir}\``
example directory       : `eval echo \`echo ${exampledir}\``
user to run as		: ${enable_user}
group to run as		: ${enable_group}
group for vty sockets	: ${enable_vty_group}
config file mask        : ${enable_configfile_mask}
log file mask           : ${enable_logfile_mask}

The above user and group must have read/write access to the state file
directory and to the config files in the config file directory."

if test x"$quagga_cv_gnu_make" = x"no"; then echo "
Warning: The ${MAKE-make} programme detected, either in your path or
via the MAKE variable, is not GNU Make. GNU make may be installed as
gmake on some systems. and is required to complete a build of Quagga
" > /dev/stderr 
fi