summaryrefslogtreecommitdiff
path: root/polux/devkit/rtai-3.1-2.6/configure.in
blob: 7c52d607094677cc097f933c5b8a8dbf6979ce3a (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
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)

AC_INIT(rtai,3.1,rtai@rtai.org)

CONFIG_RTAI_VERSION_MAJOR=3
CONFIG_RTAI_VERSION_MINOR=1
CONFIG_RTAI_REVISION_LEVEL=0

AC_CONFIG_HEADERS(rtai_config.h)
AC_CONFIG_AUX_DIR(rtai-core/config/autoconf)
AC_CONFIG_SRCDIR(rtai-core/sched/rtai/sched_up.c)
AC_PREFIX_DEFAULT(/usr/realtime)
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_PROG_INSTALL

AC_ARG_WITH(CC,
    [  --with-cc=compiler      use specific C compiler],
    [
	case "$withval" in
	"" | y | ye | yes | n | no)
	    AC_MSG_ERROR([You must supply an argument to --with-cc.])
	  ;;
	esac
	CC="$withval"
    ])
AC_PROG_CC
CFLAGS=""

AC_ARG_WITH(CXX,
    [  --with-cxx=compiler      use specific C++ compiler],
    [ case "$withval" in
	"" | y | ye | yes | n | no)
	    AC_MSG_ERROR([You must supply an argument to --with-cxx.])
	  ;;
	esac
	CXX="$withval" ])
AC_PROG_CXX
CXXFLAGS=""

AC_DEFINE_UNQUOTED(CONFIG_RTAI_BUILD_STRING,"$build",[Build system alias])
RTAI_BUILD_STRING="$build"
AC_DEFINE_UNQUOTED(CONFIG_RTAI_HOST_STRING,"$host",[Host system alias])
RTAI_HOST_STRING="$host"
AC_DEFINE_UNQUOTED(CONFIG_RTAI_COMPILER,"`$CC -v 2>&1 | tail -n 1`",[Compiler])

AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2])
AM_MAINTAINER_MODE
AC_PROG_LIBTOOL
AM_PROG_AS
AM_PROG_LEX

dnl Find arch-specific requirements and supports. Features which
dnl are not supported by all archs must be listed here, so that a
dnl an Autoconf flag can later be defined/undefined in rtai_config.h.

arch_supports_lxrt=
arch_supports_leds=
arch_supports_sim=
arch_supports_rtailab=

case "$host" in
 i*86*-*)
	RTAI_TARGET_ARCH=i386
	arch_supports_lxrt=y
	arch_supports_leds=y
	arch_supports_sim=y
	arch_supports_rtailab=y
	wanted_kernel_arch=CONFIG_X86
        ;;
 arm-*)
	RTAI_TARGET_ARCH=arm
	wanted_kernel_arch=CONFIG_ARM
        ;;
 powerpc-*|ppc-*)
	RTAI_TARGET_ARCH=ppc
	wanted_kernel_arch=CONFIG_PPC
        ;;
 mips-*|mipsel-*)
	RTAI_TARGET_ARCH=mips
	wanted_kernel_arch=CONFIG_MIPS
        ;;
 cris-*)
	RTAI_TARGET_ARCH=cris
	dnl There is no non-ambiguous CONFIG_ETRAX|CRIS symbol
	dnl so use the root device definition.
	wanted_kernel_arch=CONFIG_ETRAX_ROOT_DEVICE
        ;;
 *) echo ""
   echo "*******************************************"
   echo "Still unsupported host: $host -- Sorry."
   echo "*******************************************"
   echo ""
   exit 1;;
esac

dnl
dnl Load the RTAI configuration.
dnl

RTAI_KCONFIG_FILE=$srcdir/rtai-core/arch/$RTAI_TARGET_ARCH/defconfig
kconfig_type=default

AC_ARG_WITH(kconfig-file,
    [  --with-kconfig-file=<kconfig-file>      KConfig parameter file],
    [
	case "$withval" in
	"" | y | ye | yes | n | no)
	    AC_MSG_ERROR([You must supply an argument to --with-kconfig-file.])
	  ;;
	esac
	RTAI_KCONFIG_FILE="$withval"
	kconfig_type=supplied
    ])

AC_MSG_CHECKING([for RTAI Kconfig file])
if test \! -f $RTAI_KCONFIG_FILE; then
    AC_MSG_ERROR([Kconfig-file $RTAI_KCONFIG_FILE not found -- --with-kconfig-file sets Kconfig file])
fi
. $RTAI_KCONFIG_FILE
AC_MSG_RESULT([$RTAI_KCONFIG_FILE ($kconfig_type)])

dnl
dnl Installation directory for modules
dnl

AC_MSG_CHECKING([for module installation directory])

AC_ARG_WITH(module-dir,
    [  --with-module-dir=<module-dir>      Installation directory for modules],
    [
	case "$withval" in
	"" | y | ye | yes | n | no)
	    AC_MSG_ERROR([You must supply an argument to --with-module-dir.])
	  ;;
	esac
	RTAI_MODULE_DIR="$withval"
    ])

dnl Are we building into the source tree?
if test "$srcdir" = `pwd`; then
   CONFIG_RTAI_OLD_FASHIONED_BUILD=y
else
   CONFIG_RTAI_OLD_FASHIONED_BUILD=
fi

dnl Set a default module dir if unspecified
if test "x" = "x$RTAI_MODULE_DIR"
then
   RTAI_MODULE_DIR='${exec_prefix}/modules'
fi

AC_MSG_RESULT([$RTAI_MODULE_DIR])
CONFIG_RTAI_MODULE_DIR=$RTAI_MODULE_DIR

dnl
dnl Process the Linux kernel configuration
dnl

AC_MSG_CHECKING([for Linux source tree])

dnl CONFIG_MODULES has been forcibly set in RTAI's configuration
dnl file, therefore we must unset it before later checking if the kernel
dnl actually defined it as required too.
unset CONFIG_MODULES

RTAI_LINUX_DIR=$CONFIG_RTAI_LINUXDIR

AC_ARG_WITH(linux-dir,
    [  --with-linux-dir=<linux-dir>      RTAI-enabled Linux kernel tree],
    [
	case "$withval" in
	"" )
	    if test x${CONFIG_RTAI_LINUXDIR} = x; then
		AC_MSG_ERROR([You must supply an argument to --with-linux-dir.])
	    else
		withval=${CONFIG_RTAI_LINUXDIR}
	    fi
	  ;;
	y | ye | yes | n | no)
	    AC_MSG_ERROR([You must supply an argument to --with-linux-dir.])
	  ;;
	esac
	RTAI_LINUX_DIR="$withval"
    ])

if test x${RTAI_LINUX_DIR} = x; then
   echo
   AC_MSG_ERROR([Linux kernel tree not specified -- use --with-linux-dir])
fi

if test \! -r ${RTAI_LINUX_DIR}/Makefile; then
   echo
   AC_MSG_ERROR([No Linux kernel tree in ${RTAI_LINUX_DIR}])
fi

eval linux_`grep '^EXTRAVERSION =' $RTAI_LINUX_DIR/Makefile | sed -e 's, ,,g'`
eval linux_`grep '^PATCHLEVEL =' $RTAI_LINUX_DIR/Makefile | sed -e 's, ,,g'`
eval linux_`grep '^SUBLEVEL =' $RTAI_LINUX_DIR/Makefile | sed -e 's, ,,g'`
eval linux_`grep '^VERSION =' $RTAI_LINUX_DIR/Makefile | sed -e 's, ,,g'`

dnl Load Linux kernel configuration now, before config symbols are tested.
if test \! -r ${RTAI_LINUX_DIR}/.config; then
   AC_MSG_RESULT([invalid])
   AC_MSG_ERROR([$RTAI_LINUX_DIR is not configured -- --with-linux-dir sets linux-dir])
fi

. $RTAI_LINUX_DIR/.config

RTAI_LINUX_VERSION="$linux_VERSION.$linux_PATCHLEVEL.$linux_SUBLEVEL"
AC_MSG_RESULT([$RTAI_LINUX_DIR (kernel ${RTAI_LINUX_VERSION}${CONFIG_SMP:+-SMP})])
if test x${CONFIG_RTAI_LINUXDIR} = x; then
   CONFIG_RTAI_LINUXDIR=$RTAI_LINUX_DIR
fi

dnl
dnl Identify the base technology used.
dnl

unset CONFIG_RTAI_ADEOS

AC_MSG_CHECKING([for RTAI base technology])

if test -r $RTAI_LINUX_DIR/include/linux/adeos.h; then
   AC_DEFINE(CONFIG_RTAI_ADEOS,1,[Use Adeos-based HAL])
   AC_MSG_RESULT([Adeos])
   CONFIG_RTAI_ADEOS=y
elif test x${CONFIG_RTHAL} = xy; then
    dnl This test has a flaw. CONFIG_RTHAL could be undefined even for
    dnl a patched kernel if the RTAI support has been configured out.
    dnl This is the reason why the error message remains ambiguous.
    dnl We should definitely have _one_ common way of identifying the
    dnl RTHAL signature inside a kernel tree, that does not rely on
    dnl the Makefile's EXTRAVERSION variable, because it happened that
    dnl some people change its value manually to suit their needs...
    if test "$CONFIG_X86" = y; then
       echo
       AC_MSG_ERROR([The legacy RTHAL/x86 has been obsoleted - Please use Adeos instead])
    else
       AC_MSG_RESULT([RTHAL])
    fi
    dnl Need Adeos to run Xenomai in native mode.
    unset CONFIG_RTAI_XENOMAI
else
    echo
    AC_MSG_ERROR([HAL patch not applied/enabled in $RTAI_LINUX_DIR])
fi

case "$RTAI_LINUX_VERSION" in
  2.4.*)
	unset CONFIG_KBUILD
    ;;
  2.6.*)
	CONFIG_KBUILD=y
    ;;
  *) 
    AC_MSG_ERROR([Unsupported kernel version $RTAI_LINUX_VERSION])
esac

dnl
dnl Perform a few sanity checks.
dnl

arch_select=`eval echo \\$$wanted_kernel_arch`
if test x$arch_select = x; then
   echo
   echo "************************************************************"
   echo " The target RTAI architecture ($RTAI_TARGET_ARCH) does not match"
   echo " the kernel architecture selected in $RTAI_LINUX_DIR"
   echo " (i.e. $wanted_kernel_arch is undefined)"
   echo "************************************************************"
   exit 1
fi

if test x${CONFIG_MODULES} = x ; then
  AC_MSG_ERROR([Please set CONFIG_MODULES for $RTAI_LINUX_DIR and rebuild your kernel])
fi

if test x${CONFIG_MODVERSIONS} = xy ; then
  AC_MSG_ERROR([Please unset CONFIG_MODVERSIONS for $RTAI_LINUX_DIR and rebuild your kernel])
fi

if test x${CONFIG_RTAI_ADEOS} = xy -a x${CONFIG_ADEOS_CORE} = x; then
   AC_MSG_ERROR([Please activate the Adeos support in $RTAI_LINUX_DIR and rebuild your kernel])
fi

dnl
dnl Process the build options, possibly overriding the loaded
dnl configuration.
dnl

RTAI_BUILTIN_MODLIST=""

AC_MSG_CHECKING(for trace support)
AC_ARG_ENABLE(trace,
	[ --enable-trace		Enable trace support],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_TRACE=y ;;
	*) unset CONFIG_RTAI_TRACE ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_TRACE:-no})

if test x${CONFIG_RTAI_MATH} = xy; then
   dnl Override Kconfig settings for now
   CONFIG_RTAI_MATH=m
fi

AC_MSG_CHECKING(for math support)
AC_ARG_ENABLE(math,
	[ --enable-math		Enable math support],
	[case "$enableval" in
	y | yes | b | builtin | built-in) CONFIG_RTAI_MATH=y ;;
	m | mod | module) CONFIG_RTAI_MATH=m ;;
	*) unset CONFIG_RTAI_MATH ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_MATH:-no})

if test x$CONFIG_RTAI_MATH = xy ; then
  RTAI_BUILTIN_MODLIST="$RTAI_BUILTIN_MODLIST math"
fi

AC_MSG_CHECKING(for bits IPC support)
AC_ARG_ENABLE(bits,
	[ --enable-bits		Enable bits IPC support],
	[case "$enableval" in
	y | yes | b | builtin | built-in) CONFIG_RTAI_BITS=y ;;
	m | mod | module) CONFIG_RTAI_BITS=m ;;
	*) unset CONFIG_RTAI_BITS ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_BITS:-no})

if test x$CONFIG_RTAI_BITS = xy ; then
  RTAI_BUILTIN_MODLIST="$RTAI_BUILTIN_MODLIST ipc/bits"
fi

AC_MSG_CHECKING(for real-time fifos support)
AC_ARG_ENABLE(fifos,
	[ --enable-fifos		Enable fifo IPC support],
	[case "$enableval" in
	y | yes | b | builtin | built-in) CONFIG_RTAI_FIFOS=y ;;
	m | mod | module) CONFIG_RTAI_FIFOS=m ;;
	*) unset CONFIG_RTAI_FIFOS ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_FIFOS:-no})

if test x$CONFIG_RTAI_FIFOS = xy ; then
  RTAI_BUILTIN_MODLIST="$RTAI_BUILTIN_MODLIST ipc/fifos"
fi

AC_MSG_CHECKING(for netrpc support)
AC_ARG_ENABLE(netrpc,
	[ --enable-netrpc	Enable netrpc support],
	[case "$enableval" in
	y | yes | b | builtin | built-in) CONFIG_RTAI_NETRPC=y ;;
	m | mod | module) CONFIG_RTAI_NETRPC=m ;;
	*) unset CONFIG_RTAI_NETRPC ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_NETRPC:-no})

if test x$CONFIG_RTAI_NETRPC = xy ; then
  RTAI_BUILTIN_MODLIST="$RTAI_BUILTIN_MODLIST ipc/netrpc"
fi

AC_MSG_CHECKING(for netrpc emulation of RTNet)
AC_ARG_ENABLE(netrpc-rtnet,
	[ --enable-netrpc-rtnet	Enable netrpc emulation of RTNet],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_NETRPC_RTNET=y ;;
	*) unset CONFIG_RTAI_NETRPC_RTNET ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_NETRPC_RTNET:-no})

AC_MSG_CHECKING(for semaphore support)
AC_ARG_ENABLE(sem,
	[ --enable-sem		Enable semaphore support],
	[case "$enableval" in
	y | yes | b | builtin | built-in) CONFIG_RTAI_SEM=y ;;
	m | mod | module) CONFIG_RTAI_SEM=m ;;
	*) unset CONFIG_RTAI_SEM ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_SEM:-no})

if test x$CONFIG_RTAI_SEM = xy ; then
  RTAI_BUILTIN_MODLIST="$RTAI_BUILTIN_MODLIST ipc/sem"
fi

AC_MSG_CHECKING(for messaging support)
AC_ARG_ENABLE(mbx,
	[ --enable-msg		Enable messaging support],
	[case "$enableval" in
	y | yes | b | builtin | built-in) CONFIG_RTAI_MSG=y ;;
	m | mod | module) CONFIG_RTAI_MSG=m ;;
	*) unset CONFIG_RTAI_MSG ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_MSG:-no})

if test x$CONFIG_RTAI_MSG = xy ; then
  RTAI_BUILTIN_MODLIST="$RTAI_BUILTIN_MODLIST ipc/msg"
fi

AC_MSG_CHECKING(for mailbox support)
AC_ARG_ENABLE(mbx,
	[ --enable-mbx		Enable mailbox support],
	[case "$enableval" in
	y | yes | b | builtin | built-in) CONFIG_RTAI_MBX=y ;;
	m | mod | module) CONFIG_RTAI_MBX=m ;;
	*) unset CONFIG_RTAI_MBX ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_MBX:-no})

if test x$CONFIG_RTAI_MBX = xy ; then
  RTAI_BUILTIN_MODLIST="$RTAI_BUILTIN_MODLIST ipc/mbx"
fi

AC_MSG_CHECKING(for typed mailbox support)
AC_ARG_ENABLE(tbx,
	[ --enable-tbx		Enable typed mailbox support],
	[case "$enableval" in
	y | yes | b | builtin | built-in) CONFIG_RTAI_TBX=y ;;
	m | mod | module) CONFIG_RTAI_TBX=m ;;
	*) unset CONFIG_RTAI_TBX ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_TBX:-no})

if test x$CONFIG_RTAI_TBX = xy ; then
  RTAI_BUILTIN_MODLIST="$RTAI_BUILTIN_MODLIST ipc/tbx"
fi

AC_MSG_CHECKING(for POSIX-like message queue support)
AC_ARG_ENABLE(mq,
	[ --enable-mq		Enable POSIX-like message queue support],
	[case "$enableval" in
	y | yes | b | builtin | built-in) CONFIG_RTAI_MQ=y ;;
	m | mod | module) CONFIG_RTAI_MQ=m ;;
	*) unset CONFIG_RTAI_MQ ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_MQ:-no})

if test x$CONFIG_RTAI_MQ = xy ; then
  RTAI_BUILTIN_MODLIST="$RTAI_BUILTIN_MODLIST ipc/mq"
fi

AC_MSG_CHECKING(for shared memory support)
AC_ARG_ENABLE(shm,
	[ --enable-shm		Enable shared memory support],
	[case "$enableval" in
	y | yes | b | builtin | built-in) CONFIG_RTAI_SHM=y ;;
	m | mod | module) CONFIG_RTAI_SHM=m ;;
	*) unset CONFIG_RTAI_SHM ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_SHM:-no})

if test x$CONFIG_RTAI_SHM = xy ; then
  RTAI_BUILTIN_MODLIST="$RTAI_BUILTIN_MODLIST ipc/shm"
fi

AC_MSG_CHECKING(for real-time malloc support)
AC_ARG_ENABLE(malloc,
	[ --enable-malloc		Enable real-time malloc support],
	[case "$enableval" in
	y | yes | b | builtin | built-in) CONFIG_RTAI_MALLOC=y ;;
	m | mod | module) CONFIG_RTAI_MALLOC=m ;;
	*) unset CONFIG_RTAI_MALLOC ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_MALLOC:-no})

if test x$CONFIG_RTAI_MALLOC = xy ; then
  RTAI_BUILTIN_MODLIST="$RTAI_BUILTIN_MODLIST malloc"
fi

AC_MSG_CHECKING(for tasklets support)
AC_ARG_ENABLE(tasklets,
	[ --enable-tasklets	Enable tasklets support],
	[case "$enableval" in
	y | yes | b | builtin | built-in) CONFIG_RTAI_TASKLETS=y ;;
	m | mod | module) CONFIG_RTAI_TASKLETS=m ;;
	*) unset CONFIG_RTAI_TASKLETS ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_TASKLETS:-no})

if test x$CONFIG_RTAI_TASKLETS = xy ; then
  RTAI_BUILTIN_MODLIST="$RTAI_BUILTIN_MODLIST tasklets"
fi

AC_MSG_CHECKING(for user-space interrupt support)
AC_ARG_ENABLE(usi,
	[ --enable-usi		Enable user-space interrupt support],
	[case "$enableval" in
	y | yes | b | builtin | built-in) CONFIG_RTAI_USI=y ;;
	m | mod | module) CONFIG_RTAI_USI=m ;;
	*) unset CONFIG_RTAI_USI ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_USI:-no})

if test x$CONFIG_RTAI_USI = xy ; then
  RTAI_BUILTIN_MODLIST="$RTAI_BUILTIN_MODLIST usi"
fi

AC_MSG_CHECKING(for watchdog support)
AC_ARG_ENABLE(watchdog,
	[ --enable-watchdog	Enable watchdog support],
	[case "$enableval" in
	y | yes | m | mod | module) CONFIG_RTAI_WD=m ;;
	*) unset CONFIG_RTAI_WD ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_WD:-no})

AC_MSG_CHECKING(for leds-based debugging support)
AC_ARG_ENABLE(leds,
	[ --enable-leds		Enable leds-based debugging support],
	[case "$enableval" in
	y | yes | b | builtin | built-in) CONFIG_RTAI_LEDS=y ;;
	m | mod | module) CONFIG_RTAI_LEDS=m ;;
	*) unset CONFIG_RTAI_LEDS ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_LEDS:-no})

if test x$CONFIG_RTAI_LEDS = xy ; then
  RTAI_BUILTIN_MODLIST="$RTAI_BUILTIN_MODLIST leds"
fi

AC_ARG_ENABLE(sched-up,
	[ --enable-sched-up	Enable UP scheduler support],
	[case "$enableval" in
	y | yes | m | mod | module) CONFIG_RTAI_SCHED_UP=y ;;
	*) unset CONFIG_RTAI_SCHED_UP ;;
	esac])

AC_ARG_ENABLE(sched-smp,
	[ --enable-sched-smp	Enable SMP scheduler support],
	[case "$enableval" in
	y | yes | m | mod | module) CONFIG_RTAI_SCHED_SMP=y ;;
	*) unset CONFIG_RTAI_SCHED_SMP ;;
	esac])

AC_ARG_ENABLE(sched-mup,
	[ --enable-sched-mup	Enable MUP scheduler support],
	[case "$enableval" in
	y | yes | m | mod | module) CONFIG_RTAI_SCHED_MUP=y ;;
	*) unset CONFIG_RTAI_SCHED_MUP ;;
	esac])

AC_ARG_ENABLE(sched-lxrt,
	[ --enable-sched-lxrt	Enable LXRT scheduler support],
	[case "$enableval" in
	y | yes | m | mod | module) CONFIG_RTAI_SCHED_LXRT=y ;;
	*) unset CONFIG_RTAI_SCHED_LXRT ;;
	esac])

AC_ARG_ENABLE(xenomai,
	[ --enable-xenomai	Build Xenomai sub-system],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_XENOMAI=y ;;
	*) unset CONFIG_RTAI_XENOMAI ;;
	esac])

dnl Some sanity checks for scheduler settings. We are only rearranging
dnl defaults and discarding preposterous settings here, previous user
dnl selection is kept as long as it is sane.

if test "$CONFIG_X86" = y; then
  if test "$CONFIG_SMP" = y; then
    # x86 with SMP kernel
    test x$CONFIG_RTAI_SCHED_SMP = x && smp_forced="(forced)"
    CONFIG_RTAI_SCHED_SMP=y
    test x$CONFIG_RTAI_SCHED_UP = xy && up_forced="(forced)"
    unset CONFIG_RTAI_SCHED_UP
  else
    # x86 with UP kernel
    if test "$CONFIG_RTAI_SCHED_MUP" = y -o "$CONFIG_RTAI_SCHED_SMP" = y; then
       test x$CONFIG_RTAI_SCHED_SMP = xy && smp_forced="(forced)"
       unset CONFIG_RTAI_SCHED_SMP
       test x$CONFIG_RTAI_SCHED_MUP = xy && mup_forced="(forced)"
       unset CONFIG_RTAI_SCHED_MUP
    fi
    test x$CONFIG_RTAI_SCHED_UP = x && up_forced="(forced)"
    CONFIG_RTAI_SCHED_UP=y
    CONFIG_RTAI_CPUS=1
  fi
  if test x$CONFIG_X86_CMPXCHG = x; then
     AC_MSG_ERROR([RTAI won't work on legacy i386 platforms (cmpxchg() is missing, need >= CONFIG_M486)])
  fi
  if test x$CONFIG_RTAI_XENOMAI = xy -a x$CONFIG_X86_WP_WORKS_OK = x; then
     AC_MSG_ERROR([RTAI/Xenomai won't work on legacy i386 platforms (cannot rely on WP bit, need >= CONFIG_M486)])
  fi
else
  # non-x86
  test x$CONFIG_RTAI_SCHED_UP = x && up_forced="(forced)"
  CONFIG_RTAI_SCHED_UP=y
  test x$CONFIG_RTAI_SCHED_SMP = xy && smp_forced="(forced)"
  unset CONFIG_RTAI_SCHED_SMP
  test x$CONFIG_RTAI_SCHED_MUP = xy && mup_forced="(forced)"
  unset CONFIG_RTAI_SCHED_MUP
  test x$CONFIG_RTAI_SCHED_LXRT = xy && lxrt_forced="(forced)"
  unset CONFIG_RTAI_SCHED_LXRT
  CONFIG_RTAI_CPUS=1
fi

dnl Xenomai unsupported on SMP.
if test x$CONFIG_RTAI_XENOMAI = xy -a x$CONFIG_SMP = xy; then
   xenomai_forced="(forced)"
   unset CONFIG_RTAI_XENOMAI
fi

AC_MSG_CHECKING(for UP scheduler support)
AC_MSG_RESULT([${CONFIG_RTAI_SCHED_UP:-no} $up_forced])
AC_MSG_CHECKING(for SMP scheduler support)
AC_MSG_RESULT([${CONFIG_RTAI_SCHED_SMP:-no} $smp_forced])
AC_MSG_CHECKING(for MUP scheduler support)
AC_MSG_RESULT([${CONFIG_RTAI_SCHED_MUP:-no} $mup_forced])
AC_MSG_CHECKING(for LXRT scheduler support)
AC_MSG_RESULT([${CONFIG_RTAI_SCHED_LXRT:-no} $lxrt_forced])
AC_MSG_CHECKING(for Xenomai sub-system)
AC_MSG_RESULT(${CONFIG_RTAI_XENOMAI:-no} $xenomai_forced)

AC_MSG_CHECKING(for scheduler lock in ISRs)
AC_ARG_ENABLE(sched-lock-isr,
	[ --enable-sched-lock-isr	Enable scheduler lock in ISRs],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_SCHED_ISR_LOCK=y ;;
	*) unset CONFIG_RTAI_SCHED_ISR_LOCK ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_SCHED_ISR_LOCK:-no})

AC_MSG_CHECKING(for 8254 tuning latency)
AC_ARG_ENABLE(sched-8254-latency,
	[ --enable-sched-8254-latency	Set 8254 tuning latency],
	[case "$enableval" in
 changequote(,)dnl
	[0-9]*) CONFIG_RTAI_SCHED_8254_LATENCY=$enableval ;;
 changequote([,])dnl
	*) AC_MSG_ERROR([Bad argument to option: --enable-8254-latency=<nanoseconds>]) ;;
	esac])
if test x$CONFIG_RTAI_SCHED_8254_LATENCY = x ; then
  # Use a reasonable default if unset
  CONFIG_RTAI_SCHED_8254_LATENCY=4700
fi
AC_MSG_RESULT($CONFIG_RTAI_SCHED_8254_LATENCY)

AC_MSG_CHECKING(for APIC tuning latency)
AC_ARG_ENABLE(sched-apic-latency,
	[ --enable-sched-apic-latency	Set APIC tuning latency],
	[case "$enableval" in
 changequote(,)dnl
	[0-9]*) CONFIG_RTAI_SCHED_APIC_LATENCY=$enableval ;;
 changequote([,])dnl
	*) AC_MSG_ERROR([Bad argument to option: --enable-sched-apic-latency=<nanoseconds>]) ;;
	esac])
if test x$CONFIG_RTAI_SCHED_APIC_LATENCY = x ; then
  # Use a reasonable default if unset
  CONFIG_RTAI_SCHED_APIC_LATENCY=3944
fi
AC_MSG_RESULT($CONFIG_RTAI_SCHED_APIC_LATENCY)

AC_MSG_CHECKING(for maximum number of LXRT slots)
AC_ARG_ENABLE(sched-lxrt-numslots,
	[ --enable-sched-lxrt-numslots	Set maximum number of LXRT slots],
	[case "$enableval" in
 changequote(,)dnl
	[0-9]*) CONFIG_RTAI_SCHED_LXRT_NUMSLOTS=$enableval ;;
 changequote([,])dnl
	*) AC_MSG_ERROR([Bad argument to option: --enable-sched-lxrt-numslots=<number>]) ;;
	esac])
if test x$CONFIG_RTAI_SCHED_LXRT_NUMSLOTS = x ; then
  # Use a reasonable default if unset
  CONFIG_RTAI_SCHED_LXRT_NUMSLOTS=100
fi
AC_MSG_RESULT($CONFIG_RTAI_SCHED_LXRT_NUMSLOTS)

AC_MSG_CHECKING(for in-kernel C++ support)
AC_ARG_ENABLE(cplusplus,
	[ --enable-cplusplus	Build in-kernel C++ support],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_CPLUSPLUS=y ;;
	*) unset CONFIG_RTAI_CPLUSPLUS ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_CPLUSPLUS:-no})

AC_MSG_CHECKING([if gcc accepts -fno-use-cxa-atexit])
save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="-fno-use-cxa-atexit -Werror"
AC_CACHE_VAL(ac_cv_accepts_cxa_atexit,
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
[AC_TRY_COMPILE([],
[int i = 0; return i; ],
[ac_cv_accepts_cxa_atexit=yes],
[ac_cv_accepts_cxa_atexit=no])]
AC_LANG_RESTORE)
AC_MSG_RESULT($ac_cv_accepts_cxa_atexit)
CXXFLAGS="$save_CXXFLAGS"

AC_MSG_CHECKING(for comedi support over LXRT)
AC_ARG_ENABLE(comedi-lxrt,
	[ --enable-comedi-lxrt	Enable comedi/LXRT support],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_COMEDI_LXRT=y ;;
	*) unset CONFIG_RTAI_COMEDI_LXRT ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_COMEDI_LXRT:-no})

#if test x$CONFIG_RTAI_COMEDI_LXRT = xy; then
#   SC_PATH_COMEDI($COMEDI_DIR)
#fi

AC_MSG_CHECKING(for real-time serial driver)
AC_ARG_ENABLE(serial,
	[ --enable-serial	Build real-time serial driver],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_SERIAL=y ;;
	*) unset CONFIG_RTAI_SERIAL ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_SERIAL:-no})

AC_MSG_CHECKING(for testsuite)
AC_ARG_ENABLE(testsuite,
	[ --enable-testsuite	Build RTAI testsuite],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_TESTSUITE=y ;;
	*) unset CONFIG_RTAI_TESTSUITE ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_TESTSUITE:-no})

AC_MSG_CHECKING(for Xenomai debug support)
AC_ARG_ENABLE(xenomai-debug,
	[ --enable-xenomai-debug	Enable Xenomai debug],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_XENOMAI_DEBUG=y ;;
	*) unset CONFIG_RTAI_XENOMAI_DEBUG ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_XENOMAI_DEBUG:-no})

AC_MSG_CHECKING(for pSOS+ skin)
AC_ARG_ENABLE(psos-skin,
	[ --enable-psos-skin	Build Xenomai-based pSOS+ emulator],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_XENOMAI_SKIN_PSOS=y ;;
	*) unset CONFIG_RTAI_XENOMAI_SKIN_PSOS ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_XENOMAI_SKIN_PSOS:-no})

AC_MSG_CHECKING(for VxWorks skin)
AC_ARG_ENABLE(vxworks-skin,
	[ --enable-vxworks-skin	Build Xenomai-based VxWorks emulator],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_XENOMAI_SKIN_VXWORKS=y ;;
	*) unset CONFIG_RTAI_XENOMAI_SKIN_VXWORKS ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_XENOMAI_SKIN_VXWORKS:-no})

AC_MSG_CHECKING(for VRTX skin)
AC_ARG_ENABLE(vrtx-skin,
	[ --enable-vrtx-skin	Build Xenomai-based VRTX emulator],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_XENOMAI_SKIN_VRTX=y ;;
	*) unset CONFIG_RTAI_XENOMAI_SKIN_VRTX ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_XENOMAI_SKIN_VRTX:-no})

AC_MSG_CHECKING(for uITRON skin)
AC_ARG_ENABLE(uitron-skin,
	[ --enable-uitron-skin	Build Xenomai-based uITRON API skin],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_XENOMAI_SKIN_UITRON=y ;;
	*) unset CONFIG_RTAI_XENOMAI_SKIN_UITRON ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_XENOMAI_SKIN_UITRON:-no})

AC_MSG_CHECKING(for pse51 skin)
AC_ARG_ENABLE(pse51-skin,
	[ --enable-pse51-skin	Build Xenomai-based PSE51 API skin],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_XENOMAI_SKIN_PSE51=y ;;
	*) unset CONFIG_RTAI_XENOMAI_SKIN_PSE51 ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_XENOMAI_SKIN_PSE51:-no})

AC_MSG_CHECKING(for Xenomai user-space VMs)
AC_ARG_ENABLE(xenomai-vm,
	[ --enable-xenomai-vm	Build Xenomai user-space VMs],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_XENOMAI_VMLIB=y ;;
	*) unset CONFIG_RTAI_XENOMAI_VMLIB ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_XENOMAI_VMLIB:-no})

AC_MSG_CHECKING(for RTAI-Lab)
AC_ARG_ENABLE(rtailab,
	[ --enable-rtailab	Build RTAI-Lab],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_LAB=y ;;
	*) unset CONFIG_RTAI_LAB ;;
	esac])
if test x$arch_supports_rtailab = x; then
  unset CONFIG_RTAI_LAB
fi
AC_MSG_RESULT(${CONFIG_RTAI_LAB:-no})

if test x$CONFIG_RTAI_LAB = xy; then
AC_MSG_CHECKING(for gcc version)
AC_CACHE_VAL(ac_cv_mingcc,
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
[AC_TRY_COMPILE(
[#if !( __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0))
#error GCC too old
#endif],
[return 0;],
[ac_cv_mingcc=yes],
[ac_cv_mingcc=no])]
AC_LANG_RESTORE)
if [[ $ac_cv_mingcc = no ]]; then
  AC_MSG_ERROR([Building RTAI-Lab requires GCC version >= 3.1])
else
  AC_MSG_RESULT([ok])
fi
MDL_HAVE_OPENGL
#SC_PATH_EFLTK($CONFIG_RTAI_EFLTK_DIR)
fi

AC_MSG_CHECKING(for FPU support)
AC_ARG_ENABLE(fpu,
	[ --enable-fpu		Enable FPU support],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_FPU_SUPPORT=y ;;
	*) unset CONFIG_RTAI_FPU_SUPPORT ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_FPU_SUPPORT:-no})

AC_MSG_CHECKING(for math C99 support)
AC_ARG_ENABLE(math-c99,
	[ --enable-math-c99	Enable math C99 support],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_MATH_C99=y ;;
	*) unset CONFIG_RTAI_MATH_C99 ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_MATH_C99:-no})

AC_MSG_CHECKING(for vmalloc use in real-time malloc support)
AC_ARG_ENABLE(malloc-vmalloc,
	[ --enable-malloc-vmalloc	Enable vmalloc support in malloc],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_MALLOC_VMALLOC=y ;;
	*) unset CONFIG_RTAI_MALLOC_VMALLOC ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_MALLOC_VMALLOC:-no})

AC_MSG_CHECKING(for size of real-time malloc heap)
AC_ARG_ENABLE(malloc-heap-size,
	[ --enable-malloc-heap-size	Set size of real-time malloc heap],
	[case "$enableval" in
 changequote(,)dnl
	[0-9]*) CONFIG_RTAI_MALLOC_HEAPSZ=$enableval ;;
 changequote([,])dnl
	*) AC_MSG_ERROR([Bad argument to option: --enable-malloc-heap-size=<Kbytes>]) ;;
	esac])
if test x$CONFIG_RTAI_MALLOC_HEAPSZ = x ; then
  # Use a reasonable default if unset (in Kbytes)
  CONFIG_RTAI_MALLOC_HEAPSZ=128
fi
AC_MSG_RESULT($CONFIG_RTAI_MALLOC_HEAPSZ)

AC_MSG_CHECKING(for number of CPUs (SMP-only))
AC_ARG_ENABLE(cpus,
	[ --enable-cpus		Enable CPUs],
	[case "$enableval" in
 changequote(,)dnl
	[1-8]) CONFIG_RTAI_CPUS=$enableval ;;
 changequote([,])dnl
	*) AC_MSG_ERROR([Bad argument to option: --enable-cpus=<number-of-CPUs>]) ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_CPUS:-1})

dnl
dnl Check for additional build options.
dnl

if test \! -d $srcdir/rtai-doc; then 
    unset RTAI_MAYBE_DOCDIR
else
    RTAI_MAYBE_DOCDIR=rtai-doc
fi
AC_SUBST(RTAI_MAYBE_DOCDIR)

AC_MSG_CHECKING(for Doxygen documentation)
AC_ARG_ENABLE(doc,
	[ --enable-dox-doc	Build Doxygen documentation],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_DOX_DOC=y ;;
	*) unset CONFIG_RTAI_DOX_DOC ;;
	esac])

if test \! -d $srcdir/rtai-doc; then
    if test x$CONFIG_RTAI_DOX_DOC = xy ; 
    then
        AC_MSG_ERROR([documentation tree is missing.])
    fi
    AC_MSG_RESULT([not present])
else
    AC_MSG_RESULT(${CONFIG_RTAI_DOX_DOC:-no})
fi

AC_CHECK_PROG(DOXYGEN, doxygen, doxygen)

if test x${CONFIG_RTAI_DOX_DOC} = xy -a x"$DOXYGEN" = x; then
   AC_MSG_ERROR([Missing the Doxygen tools to generate the RTAI documentation.])
fi

AC_MSG_CHECKING(doxygen version)
if test x"$DOXYGEN" != x; then
   dox_version=`"$DOXYGEN" --version`
fi
AC_MSG_RESULT(${dox_version:-not installed})

if test x${CONFIG_RTAI_DOX_DOC} = xy
then
   dox_version_number=`echo $dox_version | sed 'y,., ,' | {
        read dox_major dox_minor dox_patch
        expr $dox_major \* 10000 + $dox_minor \* 100 + $dox_patch
   }`
   if test $dox_version_number \< 10304
   then
        AC_MSG_ERROR([Doxygen version 1.3.4 or higher is needed.])
   fi
fi

AC_CHECK_PROG(DOXYGEN_HAVE_DOT, dot, YES, NO)
if test x"$DOXYGEN_HAVE_DOT" = xYES; then
   DOXYGEN_SHOW_INCLUDE_FILES=NO
else
   DOXYGEN_SHOW_INCLUDE_FILES=YES
fi

case "$CONFIG_RTAI_DBX_DOC" in
y | ye | yes)
    DBX_DOC=yes;;
*)
    DBX_DOC="";;
esac
DBX_NET="$CONFIG_RTAI_DBX_NET"
DBX_ROOT="$CONFIG_RTAI_DBX_ROOT"
DBX_XSL_ROOT="$CONFIG_RTAI_DBX_XSL_ROOT"
#DBX_DOC_INIT(rtai-doc/docbook, rtai-doc/generated, 4.2)

AC_MSG_CHECKING(whether using LaTeX non-stop mode)
AC_ARG_ENABLE(verbose-latex,
        [ --enable-verbose-latex Uses LaTeX non-stop mode],
        [case "$enableval" in
        y | yes) CONFIG_RTAI_DOC_LATEX_NONSTOP=y ;;
        *) unset CONFIG_RTAI_DOC_LATEX_NONSTOP ;;
        esac])
AC_MSG_RESULT(${CONFIG_RTAI_DOC_LATEX_NONSTOP:-no})

if test x${CONFIG_RTAI_DOC_LATEX_NONSTOP} = xy; then
   LATEX_BATCHMODE=NO
   LATEX_MODE=nonstopmode
else
   LATEX_BATCHMODE=YES
   LATEX_MODE=batchmode
fi

AC_MSG_CHECKING(for compatibility mode)
AC_ARG_ENABLE(compat,
	[ --enable-compat	Enable compatibility mode],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_COMPAT=y ;;
	*) unset CONFIG_RTAI_COMPAT ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_COMPAT:-no})

if test x${CONFIG_RTAI_COMPAT} = xy ; then
  RTAI_COMPAT_CPPFLAGS='-I${staging}${includedir}/compat'
else
  RTAI_COMPAT_CPPFLAGS=""
fi

dnl Set default inline mode for LXRT as specified from
dnl Kconfig. Defaults to conditional inlining.

if test x$CONFIG_RTAI_LXRT_STATIC_INLINE = xy; then
   CONFIG_RTAI_LXRT_INLINE=1
elif test x$CONFIG_RTAI_LXRT_NO_INLINE = xy; then
   CONFIG_RTAI_LXRT_INLINE=3
else
   CONFIG_RTAI_LXRT_INLINE=2
fi

AC_MSG_CHECKING(for LXRT inlining)
AC_ARG_WITH(lxrt-inline,
	[ --with-lxrt-inline	Set LXRT inlining mode (static|extern|none)],
	[case "$withval" in
	static) CONFIG_RTAI_LXRT_INLINE=1 ;;
	extern) CONFIG_RTAI_LXRT_INLINE=2 ;;
	none) CONFIG_RTAI_LXRT_INLINE=3 ;;
	*) AC_MSG_ERROR([Bad argument to option: --with-lxrt-inline=<static|extern|none>]) ;;
	esac])
case "$CONFIG_RTAI_LXRT_INLINE" in
  1) inline_type=static ;;
  2) inline_type=extern ;;
  3) inline_type=none ;;
esac
AC_MSG_RESULT([$inline_type])

AC_MSG_CHECKING(for debug symbols in kernel modules)
AC_ARG_ENABLE(module-debug,
	[ --enable-module-debug	Enable debug information in kernel modules],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_KMOD_DEBUG=y ;;
	*) unset CONFIG_RTAI_KMOD_DEBUG ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_KMOD_DEBUG:-no})

AC_MSG_CHECKING(for debug symbols in user-space programs)
AC_ARG_ENABLE(user-debug,
	[ --enable-user-debug	Enable debug information in user-space programs],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_USER_DEBUG=y ;;
	*) unset CONFIG_RTAI_USER_DEBUG ;;
	esac])
AC_MSG_RESULT(${CONFIG_RTAI_USER_DEBUG:-no})

dnl Catch sub-package flags

AC_MSG_CHECKING(for RTAI simulator)
AC_ARG_ENABLE(sim,
	[ --enable-sim		Build RTAI simulator (MVM) ],
	[case "$enableval" in
	y | yes) CONFIG_RTAI_MVM=y ;;
	*) unset CONFIG_RTAI_MVM ;;
	esac])

unset RTAI_MAYBE_SIMDIR
if test \! -d $srcdir/rtai-sim; then
    if test x$CONFIG_RTAI_MVM = xy; then
        AC_MSG_ERROR([simulator is missing.])
    fi
    AC_MSG_RESULT([not present])
else
    if test x$CONFIG_RTAI_MVM = xy; then
	export CONFIG_RTAI_XENOMAI_DEBUG
	export CONFIG_RTAI_MVM_DEBUG
    	export CONFIG_RTAI_MVM_GCC_TARBALL
    else
	RTAI_MAYBE_SIMDIR=rtai-sim
    fi
    AC_MSG_RESULT(${CONFIG_RTAI_MVM:-no})
fi
if test x$arch_supports_sim = x -a x$CONFIG_RTAI_MVM = xy; then
   AC_MSG_ERROR([simulator is not available on this architecture.])
fi
AC_SUBST(RTAI_MAYBE_SIMDIR)

dnl We need to know this before building the APIC support
dnl into the SMP scheduler for the x86 platform. Autoconf imposes
dnl us to define all Automake conditionals...unconditionally. e.g.
dnl regardless of the current architecture setup.
AM_CONDITIONAL(CONFIG_X86_LOCAL_APIC,[test -n "$CONFIG_X86_LOCAL_APIC"])

if test -n "$CONFIG_RTAI_TRACE" -a x$CONFIG_TRACE = x; then
   AC_MSG_ERROR([Missing LTT support in kernel to enable trace support.])
fi

dnl Check for invalid combinations

if test x$CONFIG_RTAI_NETRPC = xy -o x$CONFIG_RTAI_NETRPC = xm ; then
   if test x$CONFIG_RTAI_MSG = x ; then
      AC_MSG_ERROR([--enable-netrpc requires --enable-msg])
   fi
fi

if test x$CONFIG_RTAI_NETRPC = xy ; then
   if test x$CONFIG_RTAI_MSG = xm ; then
      AC_MSG_ERROR([--enable-netrpc=y requires --enable-msg=y])
   fi
fi

if test x$CONFIG_RTAI_MBX = xy -o x$CONFIG_RTAI_MBX = xm ; then
   if test x$CONFIG_RTAI_SEM = x ; then
      AC_MSG_ERROR([--enable-mbx requires --enable-sem])
   fi
fi

if test x$CONFIG_RTAI_MBX = xy ; then
   if test x$CONFIG_RTAI_SEM = xm ; then
      AC_MSG_ERROR([--enable-mbx=y requires --enable-sem=y])
   fi
fi

if test x$CONFIG_RTAI_TBX = xy -o x$CONFIG_RTAI_TBX = xm ; then
   if test x$CONFIG_RTAI_SEM = x ; then
      AC_MSG_ERROR([--enable-tbx requires --enable-sem])
   fi
fi

if test x$CONFIG_RTAI_TBX = xy ; then
   if test x$CONFIG_RTAI_SEM = xm ; then
      AC_MSG_ERROR([--enable-tbx=y requires --enable-sem=y])
   fi
fi

if test x$CONFIG_RTAI_MQ = xy -o x$CONFIG_RTAI_MQ = xm ; then
   if test x$CONFIG_RTAI_SEM = x ; then
      AC_MSG_ERROR([--enable-mq requires --enable-sem])
   fi
fi

if test x$CONFIG_RTAI_MQ = xy ; then
   if test x$CONFIG_RTAI_SEM = xm ; then
      AC_MSG_ERROR([--enable-mq=y requires --enable-sem=y])
   fi
fi

if test x$CONFIG_RTAI_USI = xy -o x$CONFIG_RTAI_USI = xm ; then
   if test x$CONFIG_RTAI_SEM = x -o x$CONFIG_RTAI_TASKLETS = x; then
      AC_MSG_ERROR([--enable-usi requires --enable-sem and --enable-tasklets])
   fi
fi

if test x$CONFIG_RTAI_USI = xy ; then
   if test x$CONFIG_RTAI_SEM = xm -o x$CONFIG_RTAI_TASKLETS = xm; then
      AC_MSG_ERROR([--enable-usi=y requires --enable-sem=y and --enable-tasklets=y])
   fi
fi

if test x$CONFIG_RTAI_COMEDI_LXRT = xy -a x$CONFIG_RTAI_SCHED_LXRT = x ; then
   AC_MSG_ERROR([--enable-comedi-lxrt requires --enable-sched-lxrt])
fi

dnl Built-in math support is not currently available with Kbuild-built
dnl kernels due to bad dependencies on user-space headers we really
dnl need to fix first. So we leave in place all the config machinery
dnl for having built-in/modular math support, but will complain here
dnl until those dependencies are properly cleared.
if test x$CONFIG_KBUILD = xy -a x$CONFIG_RTAI_MATH = xy ; then
   AC_MSG_ERROR([Built-in math support is not currently available with Linux >= 2.6.x])
fi

dnl Kbuild is not quite C++ friendly these days.
if test x$CONFIG_KBUILD = xy -a x$CONFIG_RTAI_CPLUSPLUS = xy ; then
   AC_MSG_ERROR([In-kernel C++ support is not available with Linux >= 2.6.x])
fi

dnl
dnl Build a Kconfig file corresponding to the current configuration
dnl if none exists.
dnl

if test \! -r .rtai_config; then
   set | grep -e '^CONFIG_RTAI' -e '^CONFIG_MODULES' | \
   sed -e 's,\(.*\)=\(.*\)$,\1=\"\2\",' > .rtai_config
fi

dnl
dnl Produce the info needed to build rtai_config.h
dnl

AC_DEFINE_UNQUOTED(CONFIG_RTAI_VERSION_MAJOR,$CONFIG_RTAI_VERSION_MAJOR,[Kconfig])
AC_DEFINE_UNQUOTED(CONFIG_RTAI_VERSION_MINOR,$CONFIG_RTAI_VERSION_MINOR,[Kconfig])
AC_DEFINE_UNQUOTED(CONFIG_RTAI_REVISION_LEVEL,$CONFIG_RTAI_REVISION_LEVEL,[Kconfig])

AC_DEFINE(CONFIG_RTAI,1,[Legacy])
AC_DEFINE(CONFIG_RTAI_MOUNT_ON_LOAD,1,[Legacy])
test \! x$CONFIG_KBUILD = x && AC_DEFINE(CONFIG_KBUILD,1,[Kconfig])
test \! x$CONFIG_RTAI_ADEOS = x && AC_DEFINE(CONFIG_RTAI_ADEOS,1,[Kconfig])
test \! x$CONFIG_RTAI_HAL_PREEMPT = x && AC_DEFINE(CONFIG_RTAI_HAL_PREEMPT,1,[Kconfig])
test \! x$CONFIG_RTAI_CPUS = x && AC_DEFINE_UNQUOTED(CONFIG_RTAI_CPUS,$CONFIG_RTAI_CPUS,[Kconfig])
test \! x$CONFIG_RTAI_FPU_SUPPORT = x && AC_DEFINE(CONFIG_RTAI_FPU_SUPPORT,1,[Kconfig])
test \! x$CONFIG_RTAI_MATH_C99 = x && AC_DEFINE(CONFIG_RTAI_MATH_C99,1,[Kconfig])
test \! x$CONFIG_RTAI_TRACE = x && AC_DEFINE(CONFIG_RTAI_TRACE,1,[Kconfig])
test \! x$CONFIG_RTAI_MATH = x && AC_DEFINE(CONFIG_RTAI_MATH,1,[Kconfig])
test \! x$CONFIG_RTAI_BITS = x && AC_DEFINE(CONFIG_RTAI_BITS,1,[Kconfig])
test \! x$CONFIG_RTAI_FIFOS = x && AC_DEFINE(CONFIG_RTAI_FIFOS,1,[Kconfig])
test \! x$CONFIG_RTAI_NETRPC = x && AC_DEFINE(CONFIG_RTAI_NETRPC,1,[Kconfig])
test \! x$CONFIG_RTAI_NETRPC_RTNET = x && AC_DEFINE(CONFIG_RTAI_NETRPC_RTNET,1,[Kconfig])
test \! x$CONFIG_RTAI_SEM = x && AC_DEFINE(CONFIG_RTAI_SEM,1,[Kconfig])
test \! x$CONFIG_RTAI_MSG = x && AC_DEFINE(CONFIG_RTAI_MSG,1,[Kconfig])
test \! x$CONFIG_RTAI_MBX = x && AC_DEFINE(CONFIG_RTAI_MBX,1,[Kconfig])
test \! x$CONFIG_RTAI_TBX = x && AC_DEFINE(CONFIG_RTAI_TBX,1,[Kconfig])
test \! x$CONFIG_RTAI_MQ = x && AC_DEFINE(CONFIG_RTAI_MQ,1,[Kconfig])
test \! x$CONFIG_RTAI_SHM = x && AC_DEFINE(CONFIG_RTAI_SHM,1,[Kconfig])
test \! x$CONFIG_RTAI_MALLOC = x && AC_DEFINE(CONFIG_RTAI_MALLOC,1,[Kconfig])
test \! x$CONFIG_RTAI_MALLOC_VMALLOC = x && AC_DEFINE(CONFIG_RTAI_MALLOC_VMALLOC,1,[Kconfig])
test \! x$CONFIG_RTAI_TASKLETS = x && AC_DEFINE(CONFIG_RTAI_TASKLETS,1,[Kconfig])
test \! x$CONFIG_RTAI_USI = x && AC_DEFINE(CONFIG_RTAI_USI,1,[Kconfig])
test \! x$CONFIG_RTAI_WD = x && AC_DEFINE(CONFIG_RTAI_WD,1,[Kconfig])
test \! x$CONFIG_RTAI_LEDS = x && AC_DEFINE(CONFIG_RTAI_LEDS,1,[Kconfig])
test \! x$CONFIG_RTAI_SERIAL = x && AC_DEFINE(CONFIG_RTAI_SERIAL,1,[Kconfig])

test x$CONFIG_RTAI_MATH = xy && AC_DEFINE(CONFIG_RTAI_MATH_BUILTIN,1,[Kconfig])
test x$CONFIG_RTAI_BITS = xy && AC_DEFINE(CONFIG_RTAI_BITS_BUILTIN,1,[Kconfig])
test x$CONFIG_RTAI_FIFOS = xy && AC_DEFINE(CONFIG_RTAI_FIFOS_BUILTIN,1,[Kconfig])
test x$CONFIG_RTAI_NETRPC = xy && AC_DEFINE(CONFIG_RTAI_NETRPC_BUILTIN,1,[Kconfig])
test x$CONFIG_RTAI_SEM = xy && AC_DEFINE(CONFIG_RTAI_SEM_BUILTIN,1,[Kconfig])
test x$CONFIG_RTAI_MSG = xy && AC_DEFINE(CONFIG_RTAI_MSG_BUILTIN,1,[Kconfig])
test x$CONFIG_RTAI_MBX = xy && AC_DEFINE(CONFIG_RTAI_MBX_BUILTIN,1,[Kconfig])
test x$CONFIG_RTAI_TBX = xy && AC_DEFINE(CONFIG_RTAI_TBX_BUILTIN,1,[Kconfig])
test x$CONFIG_RTAI_MQ = xy && AC_DEFINE(CONFIG_RTAI_MQ_BUILTIN,1,[Kconfig])
test x$CONFIG_RTAI_SHM = xy && AC_DEFINE(CONFIG_RTAI_SHM_BUILTIN,1,[Kconfig])
test x$CONFIG_RTAI_MALLOC = xy && AC_DEFINE(CONFIG_RTAI_MALLOC_BUILTIN,1,[Kconfig])
test x$CONFIG_RTAI_TASKLETS = xy && AC_DEFINE(CONFIG_RTAI_TASKLETS_BUILTIN,1,[Kconfig])
test x$CONFIG_RTAI_USI = xy && AC_DEFINE(CONFIG_RTAI_USI_BUILTIN,1,[Kconfig])
test x$CONFIG_RTAI_LEDS = xy && AC_DEFINE(CONFIG_RTAI_LEDS_BUILTIN,1,[Kconfig])

test x$CONFIG_RTAI_SCHED_ISR_LOCK = xy && AC_DEFINE(CONFIG_RTAI_SCHED_ISR_LOCK,1,[Kconfig])
test x$CONFIG_RTAI_XENOMAI_DEBUG = xy && AC_DEFINE(CONFIG_RTAI_XENOMAI_DEBUG,1,[Kconfig])
AC_DEFINE_UNQUOTED(CONFIG_RTAI_SCHED_8254_LATENCY,$CONFIG_RTAI_SCHED_8254_LATENCY,[Kconfig])
AC_DEFINE_UNQUOTED(CONFIG_RTAI_SCHED_APIC_LATENCY,$CONFIG_RTAI_SCHED_APIC_LATENCY,[Kconfig])
AC_DEFINE_UNQUOTED(CONFIG_RTAI_SCHED_LXRT_NUMSLOTS,$CONFIG_RTAI_SCHED_LXRT_NUMSLOTS,[Kconfig])
AC_DEFINE_UNQUOTED(CONFIG_RTAI_MALLOC_HEAPSZ,$CONFIG_RTAI_MALLOC_HEAPSZ,[Kconfig])
if test x$CONFIG_DEVFS_FS = xy; then
   fifos_template="/dev/rtf/%d"
else
   fifos_template="/dev/rtf%d"
fi
AC_DEFINE_UNQUOTED(CONFIG_RTAI_FIFOS_TEMPLATE,"$fifos_template",[Kconfig])

test x$CONFIG_RTAI_MAINTAINER = xy && AC_DEFINE(CONFIG_RTAI_MAINTAINER,1,[Kconfig])
test x$CONFIG_RTAI_MAINTAINER_PMA = xy && AC_DEFINE(CONFIG_RTAI_MAINTAINER_PMA,1,[Kconfig])
test x$CONFIG_RTAI_MAINTAINER_PGM = xy && AC_DEFINE(CONFIG_RTAI_MAINTAINER_PGM,1,[Kconfig])

test x$arch_supports_lxrt = xy && AC_DEFINE(CONFIG_RTAI_INTERNAL_LXRT_SUPPORT,1,[Kconfig])
test x$arch_supports_leds = xy && AC_DEFINE(CONFIG_RTAI_INTERNAL_LEDS_SUPPORT,1,[Kconfig])
AC_DEFINE_UNQUOTED(CONFIG_RTAI_INTERNAL_LXRT_INLINE,$CONFIG_RTAI_LXRT_INLINE,[Kconfig])
test x$CONFIG_RTAI_COMPAT = xy && AC_DEFINE(CONFIG_RTAI_COMPAT,1,[Kconfig])

AH_VERBATIM(CONFIG_RTAI_LXRT_INLINE,[
#ifndef CONFIG_RTAI_LXRT_INLINE
#define CONFIG_RTAI_LXRT_INLINE CONFIG_RTAI_INTERNAL_LXRT_INLINE
#endif /* !CONFIG_RTAI_LXRT_INLINE */
#define __hidefun(name) name ## _hidden_inline
#if CONFIG_RTAI_LXRT_INLINE == 1
#define RTAI_PROTO(type,name,arglist) static inline type name arglist
#elif CONFIG_RTAI_LXRT_INLINE == 2
#define RTAI_PROTO(type,name,arglist) extern inline type name arglist
#elif CONFIG_RTAI_LXRT_INLINE == 3
#define RTAI_PROTO(type,name,arglist) type name arglist; static inline type __hidefun(name) arglist
#else
#define RTAI_PROTO(type,name,arglist) type name arglist
#endif /* CONFIG_RTAI_LXRT_INLINE */
#define RTAI_PROTO_ALWAYS_INLINE(type,name,arglist) static inline type name arglist
#define RTAI_PROTO_NEVER_INLINE(type,name,arglist) type name arglist; static inline type __hidefun(name) arglist
])

dnl CAUTION: We need to have the CONFIG_RTAI_XX symbols always defined when
dnl the configuration header is read, but we want the Autoconf-produced
dnl symbols to be defined only when compiling RTAI. This way, we won't
dnl pollute the namespace with the latter when our configuration header is
dnl indirectly included by a client application. To achieve this, we ask
dnl autoheader to produce the following header structure:
dnl #define CONFIG_XX
dnl #define CONFIG_XX ...
dnl #ifdef __IN_RTAI__
dnl <Autoconf-defined symbols>
dnl #endif /* __IN_RTAI__ */
dnl This is quite a hack since we have to rely on the fact that
dnl all Autoconf-generated symbols are lexicographically sorted
dnl after CONFIG_RTAI_XX ones, but, well...

dnl Use a key which will cause the verbatim string to be put after
dnl all CONFIG_RTAI_XX symbols, but still before any Autoconf-generated
dnl symbol, hence CONFIG_RTAI___.
AH_VERBATIM(CONFIG_RTAI___,[#ifdef __IN_RTAI__])

dnl Now we can close the conditional section, right after all
dnl Autoconf-generated symbols have been listed.
AH_BOTTOM([#endif /* __IN_RTAI__ */])

AH_BOTTOM([#include <linux/config.h>])

dnl
dnl Produce automake conditionals.
dnl

dnl Whether Linux is using the Kbuild make system.
AM_CONDITIONAL(CONFIG_KBUILD,[test "$CONFIG_KBUILD" = y])

dnl CPU architecture
AM_CONDITIONAL(CONFIG_X86,[test "$CONFIG_X86" = y])
AM_CONDITIONAL(CONFIG_PPC,[test "$CONFIG_PPC" = y])
AM_CONDITIONAL(CONFIG_ARM,[test "$CONFIG_ARM" = y])
AM_CONDITIONAL(CONFIG_ARCH_SA1100,[test "$CONFIG_ARCH_SA1100" = y])
AM_CONDITIONAL(CONFIG_ARCH_CLPS711X,[test "$CONFIG_ARCH_CLPS711X" = y])
AM_CONDITIONAL(CONFIG_ARCH_PXA,[test "$CONFIG_ARCH_PXA" = y])
AM_CONDITIONAL(CONFIG_ARCH_SPC200E,[test "$CONFIG_ARCH_SPC200E" = y])
AM_CONDITIONAL(CONFIG_ARCH_SPC200C,[test "$CONFIG_ARCH_SPC200C" = y])
AM_CONDITIONAL(CONFIG_ARCH_MSE500,[test "$CONFIG_ARCH_MSE500" = y])
AM_CONDITIONAL(CONFIG_MIPS,[test "$CONFIG_MIPS" = y])
AM_CONDITIONAL(CONFIG_CRIS,[test -n "$CONFIG_ETRAX_ROOT_DEVICE"])
AM_CONDITIONAL(CONFIG_UCLINUX,[test "$CONFIG_UCLINUX" = y])
AM_CONDITIONAL(CONFIG_SMP,[test "$CONFIG_SMP" = y])

dnl Features (whether they are built-in or not)
AM_CONDITIONAL(CONFIG_RTAI_SCHED_UP,[test -n "$CONFIG_RTAI_SCHED_UP"])
AM_CONDITIONAL(CONFIG_RTAI_SCHED_MUP,[test -n "$CONFIG_RTAI_SCHED_MUP"])
AM_CONDITIONAL(CONFIG_RTAI_SCHED_SMP,[test -n "$CONFIG_RTAI_SCHED_SMP"])
AM_CONDITIONAL(CONFIG_RTAI_SCHED_LXRT,[test -n "$CONFIG_RTAI_SCHED_LXRT"])
AM_CONDITIONAL(CONFIG_RTAI_XENOMAI,[test x$CONFIG_RTAI_XENOMAI = xy])

AM_CONDITIONAL(CONFIG_RTAI_TRACE,[test -n "$CONFIG_RTAI_TRACE"])
AM_CONDITIONAL(CONFIG_RTAI_MATH,[test -n "$CONFIG_RTAI_MATH"])
AM_CONDITIONAL(CONFIG_RTAI_BITS,[test -n "$CONFIG_RTAI_BITS"])
AM_CONDITIONAL(CONFIG_RTAI_FIFOS,[test -n "$CONFIG_RTAI_FIFOS"])
AM_CONDITIONAL(CONFIG_RTAI_NETRPC,[test -n "$CONFIG_RTAI_NETRPC"])
AM_CONDITIONAL(CONFIG_RTAI_SEM,[test -n "$CONFIG_RTAI_SEM"])
AM_CONDITIONAL(CONFIG_RTAI_MSG,[test -n "$CONFIG_RTAI_MSG"])
AM_CONDITIONAL(CONFIG_RTAI_MBX,[test -n "$CONFIG_RTAI_MBX"])
AM_CONDITIONAL(CONFIG_RTAI_TBX,[test -n "$CONFIG_RTAI_TBX"])
AM_CONDITIONAL(CONFIG_RTAI_MQ,[test -n "$CONFIG_RTAI_MQ"])
AM_CONDITIONAL(CONFIG_RTAI_SHM,[test -n "$CONFIG_RTAI_SHM"])
AM_CONDITIONAL(CONFIG_RTAI_MALLOC,[test -n "$CONFIG_RTAI_MALLOC"])
AM_CONDITIONAL(CONFIG_RTAI_TASKLETS,[test -n "$CONFIG_RTAI_TASKLETS"])
AM_CONDITIONAL(CONFIG_RTAI_USI,[test -n "$CONFIG_RTAI_USI"])
AM_CONDITIONAL(CONFIG_RTAI_WD,[test -n "$CONFIG_RTAI_WD"])
AM_CONDITIONAL(CONFIG_RTAI_LEDS,[test -n "$CONFIG_RTAI_LEDS"])

AM_CONDITIONAL(CONFIG_RTAI_MATH_BUILTIN,[test x$CONFIG_RTAI_MATH = xy])
AM_CONDITIONAL(CONFIG_RTAI_BITS_BUILTIN,[test x$CONFIG_RTAI_BITS = xy])
AM_CONDITIONAL(CONFIG_RTAI_FIFOS_BUILTIN,[test x$CONFIG_RTAI_FIFOS = xy])
AM_CONDITIONAL(CONFIG_RTAI_NETRPC_BUILTIN,[test x$CONFIG_RTAI_NETRPC = xy])
AM_CONDITIONAL(CONFIG_RTAI_SEM_BUILTIN,[test x$CONFIG_RTAI_SEM = xy])
AM_CONDITIONAL(CONFIG_RTAI_MSG_BUILTIN,[test x$CONFIG_RTAI_MSG = xy])
AM_CONDITIONAL(CONFIG_RTAI_MBX_BUILTIN,[test x$CONFIG_RTAI_MBX = xy])
AM_CONDITIONAL(CONFIG_RTAI_TBX_BUILTIN,[test x$CONFIG_RTAI_TBX = xy])
AM_CONDITIONAL(CONFIG_RTAI_MQ_BUILTIN,[test x$CONFIG_RTAI_MQ = xy])
AM_CONDITIONAL(CONFIG_RTAI_SHM_BUILTIN,[test x$CONFIG_RTAI_SHM = xy])
AM_CONDITIONAL(CONFIG_RTAI_MALLOC_BUILTIN,[test x$CONFIG_RTAI_MALLOC = xy])
AM_CONDITIONAL(CONFIG_RTAI_TASKLETS_BUILTIN,[test x$CONFIG_RTAI_TASKLETS = xy])
AM_CONDITIONAL(CONFIG_RTAI_USI_BUILTIN,[test x$CONFIG_RTAI_USI = xy])
AM_CONDITIONAL(CONFIG_RTAI_LEDS_BUILTIN,[test x$CONFIG_RTAI_LEDS = xy])

dnl Non-core packages.
AM_CONDITIONAL(CONFIG_RTAI_COMEDI_LXRT,[test x$CONFIG_RTAI_COMEDI_LXRT = xy])
AM_CONDITIONAL(CONFIG_RTAI_CPLUSPLUS,[test x$CONFIG_RTAI_CPLUSPLUS = xy])
AM_CONDITIONAL(CONFIG_RTAI_SERIAL,[test x$CONFIG_RTAI_SERIAL = xy])
AM_CONDITIONAL(CONFIG_RTAI_XENOMAI_SKIN_PSOS,[test x$CONFIG_RTAI_XENOMAI_SKIN_PSOS = xy])
AM_CONDITIONAL(CONFIG_RTAI_XENOMAI_SKIN_VXWORKS,[test x$CONFIG_RTAI_XENOMAI_SKIN_VXWORKS = xy])
AM_CONDITIONAL(CONFIG_RTAI_XENOMAI_SKIN_VRTX,[test x$CONFIG_RTAI_XENOMAI_SKIN_VRTX = xy])
AM_CONDITIONAL(CONFIG_RTAI_XENOMAI_SKIN_UITRON,[test x$CONFIG_RTAI_XENOMAI_SKIN_UITRON = xy])
AM_CONDITIONAL(CONFIG_RTAI_XENOMAI_SKIN_PSE51,[test x$CONFIG_RTAI_XENOMAI_SKIN_PSE51 = xy])
AM_CONDITIONAL(CONFIG_RTAI_XENOMAI_VMLIB,[test x$CONFIG_RTAI_XENOMAI_VMLIB = xy])

AM_CONDITIONAL(CONFIG_RTAI_LAB,[test x$CONFIG_RTAI_LAB = xy])
AM_CONDITIONAL(CONFIG_RTAI_MVM,[test x$CONFIG_RTAI_MVM = xy])

AM_CONDITIONAL(CONFIG_RTAI_TESTSUITE,[test x$CONFIG_RTAI_TESTSUITE = xy])

dnl Misc compilation conditionals
AM_CONDITIONAL(CONFIG_RTAI_ADEOS,[test "$CONFIG_RTAI_ADEOS" = y])
AM_CONDITIONAL(CONFIG_RTAI_MATH_C99,[test "$CONFIG_RTAI_MATH_C99" = y])
AM_CONDITIONAL(CONFIG_RTAI_COMPAT,[test "$CONFIG_RTAI_COMPAT" = y])

dnl Documentation
AM_CONDITIONAL(CONFIG_RTAI_DOX_DOC,[test "$CONFIG_RTAI_DOX_DOC" = y])
# Automake variables related to DocBook documentation are handled in docbook.m4.

dnl Maintenance symbols and profiles
AM_CONDITIONAL(CONFIG_RTAI_MAINTAINER,[test "$CONFIG_RTAI_MAINTAINER" = y])
AM_CONDITIONAL(CONFIG_RTAI_MAINTAINER_PMA,[test "$CONFIG_RTAI_MAINTAINER_PMA" = y])
AM_CONDITIONAL(CONFIG_RTAI_MAINTAINER_PGM,[test "$CONFIG_RTAI_MAINTAINER_PGM" = y])
AM_CONDITIONAL(CONFIG_RTAI_OLD_FASHIONED_BUILD,[test "$CONFIG_RTAI_OLD_FASHIONED_BUILD" = y])

dnl
dnl Define arch-specific CFLAGS and links
dnl

if test x$CONFIG_KBUILD = x; then
   dnl The following sets RTAI_KMOD_CFLAGS to the value used by the
   dnl specified Linux tree for building kernel modules. This hack is
   dnl not needed for 2.6 and above since out-of-tree builds of modules
   dnl are fully controlled by the kbuild system, so that we don't even
   dnl need to know of the compilation flags which will be used.
   AC_MSG_CHECKING([for module compilation flags])
   kmod_cflags=`cd $srcdir/rtai-core/config/modules && make -s RTAI_LINUX_DIR=$RTAI_LINUX_DIR ARCH=$RTAI_TARGET_ARCH CC=$CC | grep '^RTAI_KMOD_CFLAGS='`
   eval $kmod_cflags
   if test "$RTAI_KMOD_CFLAGS" = ""; then
      AC_MSG_ERROR([Unable to retrieve compilation flags for kernel modules out of $RTAI_LINUX_DIR/Makefile])
   fi
   AC_MSG_RESULT([ok])
   RTAI_MODULE_EXT=.o
   RTAI_KBUILD_ENV=
   RTAI_KBUILD_CMD=
   RTAI_KBUILD_CLEAN=
else
   RTAI_MODULE_EXT=.ko
   RTAI_KBUILD_ENV='src2obj = $(patsubst %.$(1),%.o,$(filter %.$(1),$(call notdir,$(2))))'
   RTAI_KBUILD_CMD="@for src in \$^; do if test \\! -r \`basename \$\$src\`; then \$(LN_S) \$\$src; fi; done; \
		    rm -f $RTAI_LINUX_DIR/.tmp_versions/rtai_*.mod $RTAI_LINUX_DIR/.tmp_versions/*_rt.mod; \
                    \$(MAKE) -C $RTAI_LINUX_DIR CROSS_COMPILE=\$(CROSS_COMPILE) CC=$CC ARCH=@RTAI_TARGET_ARCH@ \
		    SUBDIRS=\$\$PWD M=\$\$PWD rtai_srctree=\`cd \$(top_srcdir) && pwd\` rtai_srcdir=\`cd \$(srcdir) && pwd\` V=\$(V) modules \
		    rtai_objs='\$(call src2obj,c,\$^) \$(call src2obj,S,\$^) \$(call src2obj,cc,\$^) \$(call src2obj,cpp,\$^)' rtai_target=\$(basename \$@)"
   RTAI_KBUILD_CLEAN='rm -f *.ko *.mod.c .*.cmd *.o'
fi

AC_MSG_CHECKING([for kernel module extension])
AC_MSG_RESULT([$RTAI_MODULE_EXT])

AC_MSG_CHECKING([for RTAI target architecture])

RTAI_USER_CFLAGS="-I$RTAI_LINUX_DIR/include"

case $RTAI_TARGET_ARCH in
 i386)
	RTAI_TARGET_SUBARCH=
	RTAI_KMOD_CXXFLAGS="$RTAI_KMOD_CFLAGS -fno-rtti -fno-exceptions -fno-strength-reduce -pipe"
	RTAI_USER_CFLAGS="$RTAI_USER_CFLAGS -Wall -Wstrict-prototypes -pipe"
	if test x$CONFIG_RTAI_FPU_SUPPORT = xy; then
	   RTAI_FP_CFLAGS="-ffast-math -mhard-float"
	else
	   RTAI_FP_CFLAGS="-ffast-math -msoft-float"
	fi
        ;;
 arm)
	if test "$CONFIG_ARCH_SA1100" = y; then
		RTAI_TARGET_SUBARCH=sa1100
	elif test "$CONFIG_ARCH_CLPS711X" = y; then
		RTAI_TARGET_SUBARCH=clps711x
	elif test "$CONFIG_ARCH_PXA" = y; then
        RTAI_TARGET_SUBARCH=pxa
	elif test "$CONFIG_ARCH_SPC200E" = y; then
        RTAI_TARGET_SUBARCH=spc2XX
	elif test "$CONFIG_ARCH_SPC200C" = y; then
        RTAI_TARGET_SUBARCH=spc2XXc
	elif test "$CONFIG_ARCH_MSE500" = y; then
        RTAI_TARGET_SUBARCH=mse500
	else
	   echo
	   echo "******************************************"
	   echo "Unsupported ARM sub-architecture -- Sorry."
	   echo "******************************************"
	   exit 1
	fi
	RTAI_KMOD_CXXFLAGS="$RTAI_KMOD_CFLAGS -fno-rtti -fno-exceptions -fno-strength-reduce -pipe"
	RTAI_USER_CFLAGS="$RTAI_USER_CFLAGS -Wall -Wstrict-prototypes -pipe"
	RTAI_FP_CFLAGS="-ffast-math -msoft-float"
	AC_CONFIG_LINKS(rtai-core/include/asm-arm/arch:rtai-core/include/asm-arm/arch-$RTAI_TARGET_SUBARCH)
        ;;
 ppc)
	RTAI_TARGET_SUBARCH=
	RTAI_KMOD_CFLAGS="$RTAI_KMOD_CFLAGS -I${RTAI_LINUX_DIR}/arch/ppc"
	RTAI_KMOD_CXXFLAGS="$RTAI_KMOD_CFLAGS -fno-rtti -fno-exceptions -fno-strength-reduce -pipe"
	RTAI_USER_CFLAGS="$RTAI_USER_CFLAGS -Wall -Wstrict-prototypes -pipe"
	if test x$CONFIG_RTAI_FPU_SUPPORT = xy; then
	   RTAI_FP_CFLAGS="-mhard-float"
	else
	   RTAI_FP_CFLAGS="-msoft-float"
	fi
	;;
 mips)
	RTAI_TARGET_SUBARCH=
	RTAI_KMOD_CXXFLAGS="$RTAI_KMOD_CFLAGS -fno-rtti -fno-exceptions -fno-strength-reduce -pipe"
	RTAI_USER_CFLAGS="$RTAI_USER_CFLAGS -Wall -Wstrict-prototypes -pipe"
	if test x$CONFIG_RTAI_FPU_SUPPORT = xy; then
	   RTAI_FP_CFLAGS="-mhard-float"
	else
	   RTAI_FP_CFLAGS="-msoft-float"
	fi
	;;
 cris)
	RTAI_TARGET_SUBARCH=
	RTAI_KMOD_CXXFLAGS="$RTAI_KMOD_CFLAGS -fno-rtti -fno-exceptions -fno-strength-reduce -pipe"
	RTAI_USER_CFLAGS="$RTAI_USER_CFLAGS -Wall -Wstrict-prototypes -pipe"
	RTAI_FP_CFLAGS=""
	;;
esac

if test x$CONFIG_RTAI_KMOD_DEBUG = xy; then
   RTAI_KMOD_CFLAGS="-g $RTAI_KMOD_CFLAGS"
   RTAI_KMOD_CXXFLAGS="-g $RTAI_KMOD_CXXFLAGS"
fi

if [[ $ac_cv_accepts_cxa_atexit = yes ]]; then
   RTAI_KMOD_CXXFLAGS="$RTAI_KMOD_CXXFLAGS -fno-use-cxa-atexit"
fi

dnl Ok, the following isn't pretty, but required to process the
dnl various inlining modes correctly. This boils down to:
dnl - if mode == "none", then we will always need -llxrt to be
dnl   tackled on the library deps for user-space programs.
dnl - if mode == "eager/static", then we will never need -llxrt
dnl - if mode == "conditional/extern", then we will not need -llxrt
dnl   unless the optimizer has been switched off, i.e. when the
dnl   debugging mode has been switched on.

if test $CONFIG_RTAI_LXRT_INLINE = 3; then
   RTAI_LXRT_LDADD=-llxrt
else
   RTAI_LXRT_LDADD=
   if test x$CONFIG_RTAI_USER_DEBUG = xy; then
      RTAI_USER_CFLAGS="-g $RTAI_USER_CFLAGS"
      if test $CONFIG_RTAI_LXRT_INLINE = 2; then
         RTAI_LXRT_LDADD="-llxrt"
      fi
   else
      RTAI_USER_CFLAGS="-O2 $RTAI_USER_CFLAGS"
   fi
fi

RTAI_KMOD_APP_CFLAGS=$RTAI_KMOD_CFLAGS
RTAI_KMOD_APP_CXXFLAGS=$RTAI_KMOD_CXXFLAGS
RTAI_USER_APP_CFLAGS=$RTAI_USER_CFLAGS
RTAI_KMOD_CFLAGS="$RTAI_KMOD_CFLAGS -D__IN_RTAI__"
RTAI_KMOD_CXXFLAGS="$RTAI_KMOD_CXXFLAGS -D__IN_RTAI__"
RTAI_USER_CFLAGS="$RTAI_USER_CFLAGS -D__IN_RTAI__"

AC_CONFIG_LINKS(rtai-core/include/asm:rtai-core/include/asm-$RTAI_TARGET_ARCH)

if test x$CONFIG_RTAI_OLD_FASHIONED_BUILD = xy; then
   AC_CONFIG_LINKS(rtai-core/include/rtai_config.h:rtai_config.h)
fi

if test x$RTAI_TARGET_SUBARCH = x; then
   AC_MSG_RESULT([$RTAI_TARGET_ARCH])
else
   AC_MSG_RESULT([$RTAI_TARGET_ARCH ($RTAI_TARGET_SUBARCH)])
fi

if test x$CONFIG_KBUILD = xy; then
   AC_CONFIG_LINKS(rtai-core/arch/$RTAI_TARGET_ARCH/hal/Makefile:rtai-core/arch/$RTAI_TARGET_ARCH/hal/Makefile.kbuild)
   if test -d $srcdir/rtai-core/arch/$RTAI_TARGET_ARCH/calibration; then
      AC_CONFIG_LINKS(rtai-core/arch/$RTAI_TARGET_ARCH/calibration/Makefile:rtai-core/arch/$RTAI_TARGET_ARCH/calibration/Makefile.kbuild)
   fi
   AC_CONFIG_LINKS(rtai-core/ipc/bits/Makefile:rtai-core/ipc/bits/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-core/ipc/fifos/Makefile:rtai-core/ipc/fifos/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-core/ipc/mbx/Makefile:rtai-core/ipc/mbx/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-core/ipc/mq/Makefile:rtai-core/ipc/mq/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-core/ipc/msg/Makefile:rtai-core/ipc/msg/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-core/ipc/sem/Makefile:rtai-core/ipc/sem/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-core/ipc/tbx/Makefile:rtai-core/ipc/tbx/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-core/ipc/netrpc/Makefile:rtai-core/ipc/netrpc/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-core/ipc/shm/Makefile:rtai-core/ipc/shm/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-core/leds/Makefile:rtai-core/leds/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-core/malloc/Makefile:rtai-core/malloc/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-core/tasklets/Makefile:rtai-core/tasklets/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-core/wd/Makefile:rtai-core/wd/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-core/usi/Makefile:rtai-core/usi/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-core/math/Makefile:rtai-core/math/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-core/sched/rtai/Makefile:rtai-core/sched/rtai/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-core/sched/xenomai/Makefile:rtai-core/sched/xenomai/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-core/sched/xenomai/fusion/Makefile:rtai-core/sched/xenomai/fusion/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-addons/serial/Makefile:rtai-addons/serial/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-addons/comedi/Makefile:rtai-addons/comedi/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-addons/skins/pse51/Makefile:rtai-addons/skins/pse51/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-addons/skins/uITRON/Makefile:rtai-addons/skins/uITRON/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-addons/skins/psos+/Makefile:rtai-addons/skins/psos+/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-addons/skins/vrtx/Makefile:rtai-addons/skins/vrtx/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-addons/skins/vxworks/Makefile:rtai-addons/skins/vxworks/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-testsuite/kern/latency/Makefile:rtai-testsuite/kern/latency/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-testsuite/kern/preempt/Makefile:rtai-testsuite/kern/preempt/Makefile.kbuild)
   AC_CONFIG_LINKS(rtai-testsuite/kern/switches/Makefile:rtai-testsuite/kern/switches/Makefile.kbuild)
fi

dnl
dnl Build the Makefiles
dnl

AC_SUBST(CROSS_COMPILE)
AC_SUBST(DOXYGEN_SHOW_INCLUDE_FILES)
AC_SUBST(DOXYGEN_HAVE_DOT)
AC_SUBST(DOXYGEN)
AC_SUBST(LATEX_BATCHMODE)
AC_SUBST(LATEX_MODE)
AC_SUBST(EFLTK_DIR)
AC_SUBST(COMEDI_DIR)

AC_SUBST(RTAI_BUILD_STRING)
AC_SUBST(RTAI_HOST_STRING)
AC_SUBST(RTAI_TARGET_ARCH)
AC_SUBST(RTAI_TARGET_SUBARCH)
AC_SUBST(RTAI_BUILTIN_MODLIST)
AC_SUBST(RTAI_KMOD_CFLAGS)
AC_SUBST(RTAI_KMOD_CXXFLAGS)
AC_SUBST(RTAI_USER_CFLAGS)
AC_SUBST(RTAI_KMOD_APP_CFLAGS)
AC_SUBST(RTAI_KMOD_APP_CXXFLAGS)
AC_SUBST(RTAI_USER_APP_CFLAGS)
AC_SUBST(RTAI_LXRT_LDADD)
AC_SUBST(RTAI_FP_CFLAGS)
AC_SUBST(RTAI_COMPAT_CPPFLAGS)
AC_SUBST(RTAI_LINUX_DIR)
AC_SUBST(RTAI_LINUX_VERSION)
AC_SUBST(RTAI_MODULE_DIR)
AC_SUBST(RTAI_MODULE_EXT)
AC_SUBST(RTAI_KBUILD_ENV)
AC_SUBST(RTAI_KBUILD_CMD)
AC_SUBST(RTAI_KBUILD_CLEAN)

AC_SUBST(CONFIG_RTAI_LINUXDIR)

AC_CONFIG_FILES([ \
	GNUmakefile \
	rtai-core/GNUmakefile \
	rtai-core/arch/GNUmakefile \
	rtai-core/include/GNUmakefile \
	rtai-core/ipc/GNUmakefile \
	rtai-core/sched/GNUmakefile \
	rtai-core/sched/rtai/GNUmakefile \
	rtai-core/sched/rtai/liblxrt/GNUmakefile \
	rtai-core/sched/xenomai/GNUmakefile \
	rtai-core/sched/xenomai/fusion/GNUmakefile \
	rtai-core/scripts/GNUmakefile \
	rtai-core/scripts/rtai-config \
	rtai-core/scripts/rtai-load \
        rtai-core/arch/i386/GNUmakefile \
	rtai-core/arch/i386/hal/GNUmakefile \
	rtai-core/arch/i386/calibration/GNUmakefile \
	rtai-core/include/asm-i386/GNUmakefile \
        rtai-core/arch/arm/GNUmakefile \
	rtai-core/arch/arm/hal/GNUmakefile \
	rtai-core/include/asm-arm/GNUmakefile \
        rtai-core/arch/ppc/GNUmakefile \
	rtai-core/arch/ppc/hal/GNUmakefile \
	rtai-core/include/asm-ppc/GNUmakefile \
        rtai-core/arch/mips/GNUmakefile \
	rtai-core/arch/mips/hal/GNUmakefile \
	rtai-core/include/asm-mips/GNUmakefile \
        rtai-core/arch/cris/GNUmakefile \
	rtai-core/arch/cris/hal/GNUmakefile \
	rtai-core/include/asm-cris/GNUmakefile \
   	rtai-core/ipc/bits/GNUmakefile \
	rtai-core/ipc/fifos/GNUmakefile \
	rtai-core/ipc/netrpc/GNUmakefile \
	rtai-core/ipc/shm/GNUmakefile \
	rtai-core/ipc/sem/GNUmakefile \
	rtai-core/ipc/msg/GNUmakefile \
	rtai-core/ipc/mbx/GNUmakefile \
	rtai-core/ipc/tbx/GNUmakefile \
	rtai-core/ipc/mq/GNUmakefile \
	rtai-core/math/GNUmakefile \
	rtai-core/malloc/GNUmakefile \
	rtai-core/tasklets/GNUmakefile \
	rtai-core/trace/GNUmakefile \
	rtai-core/wd/GNUmakefile \
	rtai-core/usi/GNUmakefile \
	rtai-core/leds/GNUmakefile \
	])

build_addons=$CONFIG_RTAI_CPLUSPLUS$CONFIG_RTAI_SERIAL$CONFIG_RTAI_COMEDI_LXRT
for skin in PSOS VXWORKS VRTX UITRON PSE51; do
  cfvar=CONFIG_RTAI_XENOMAI_SKIN_$skin
  eval build_addons="$build_addons\$$cfvar"
done

if test -d $srcdir/rtai-addons; then
  AC_CONFIG_FILES([ \
       rtai-addons/GNUmakefile \
       rtai-addons/cpp/GNUmakefile \
       rtai-addons/comedi/GNUmakefile \
       rtai-addons/serial/GNUmakefile \
       rtai-addons/skins/GNUmakefile \
       rtai-addons/skins/psos+/GNUmakefile \
       rtai-addons/skins/vxworks/GNUmakefile \
       rtai-addons/skins/vrtx/GNUmakefile \
       rtai-addons/skins/uITRON/GNUmakefile \
       rtai-addons/skins/pse51/GNUmakefile \
       ])
elif test \! x$build_addons = x; then
     AC_MSG_ERROR([rtai-addons package is missing])
fi

AM_CONDITIONAL(CONFIG_RTAI_ADDONS,[test \! x$build_addons = x])

if test -d $srcdir/rtai-lab; then
   AC_CONFIG_FILES([ \
        rtai-lab/GNUmakefile \
        rtai-lab/matlab/GNUmakefile \
        rtai-lab/scilab/GNUmakefile \
        rtai-lab/scilab/utility/GNUmakefile \
        rtai-lab/scilab/devices/GNUmakefile \
   ])
elif test \! x$CONFIG_RTAI_LAB = x; then
     AC_MSG_ERROR([rtai-lab package is missing])
fi

if test -d $srcdir/rtai-testsuite; then
   AC_CONFIG_FILES([ \
        rtai-testsuite/GNUmakefile \
	rtai-testsuite/kern/GNUmakefile \
	rtai-testsuite/kern/latency/GNUmakefile \
	rtai-testsuite/kern/preempt/GNUmakefile \
	rtai-testsuite/kern/switches/GNUmakefile \
	rtai-testsuite/user/GNUmakefile \
	rtai-testsuite/user/latency/GNUmakefile \
	rtai-testsuite/user/preempt/GNUmakefile \
	rtai-testsuite/user/switches/GNUmakefile \
        ])
elif test \! x$CONFIG_RTAI_TESTSUITE = x; then
     AC_MSG_ERROR([rtai-testsuite package is missing])
fi

if test -d $srcdir/rtai-compat; then
      AC_CONFIG_FILES([ \
	   rtai-compat/GNUmakefile \
	   rtai-compat/include/GNUmakefile \
      ])
elif test \! x$CONFIG_RTAI_COMPAT = x; then
     AC_MSG_ERROR([rtai-compat package is missing])
fi

if test \! x$RTAI_MAYBE_DOCDIR = x; then
      AC_CONFIG_FILES([ \
	   rtai-doc/GNUmakefile \
	   rtai-doc/doxygen/GNUmakefile \
	   rtai-doc/doxygen/Doxyfile \
	   rtai-doc/docbook/GNUmakefile \
	   rtai-doc/docbook/catalog \
	   rtai-doc/docbook/custom-stylesheets/GNUmakefile \
	   rtai-doc/docbook/custom-stylesheets/xsl/GNUmakefile \
	   rtai-doc/docbook/custom-stylesheets/xsl/common/GNUmakefile \
	   rtai-doc/docbook/custom-stylesheets/xsl/fo/GNUmakefile \
	   rtai-doc/docbook/custom-stylesheets/xsl/html/GNUmakefile \
	   rtai-doc/docbook/custom-stylesheets/xsl/html/chunk.xsl \
	   rtai-doc/docbook/docbook-test/GNUmakefile \
      ])
fi

if test x$CONFIG_RTAI_MVM = xy; then
   AC_CONFIG_SUBDIRS(rtai-sim)
fi

AC_OUTPUT()