~ubuntu-branches/ubuntu/natty/lirc/natty-proposed

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

dnl Process this file with autoconf to produce a configure script.
dnl configure.ac, (c)1999 Tom Wheeley <tw104@york.ac.uk>

AC_INIT
AC_CONFIG_SRCDIR([daemons/lircd.c])

AM_INIT_AUTOMAKE(lirc, 0.8.4a)
AM_CONFIG_HEADER(config.h)

CFLAGS="${CFLAGS--O2 -g -Wall}"

dnl Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PATH_PROG(mknod, mknod, /bin/mknod)
AC_PATH_PROG(mkfifo, mkfifo, /usr/bin/mkfifo)
AC_PATH_PROG(depmod, depmod, /sbin/depmod, $PATH:/sbin)
AC_PATH_PROG(LIBUSB_CONFIG, libusb-config)
AC_PROG_LN_S
AC_PROG_LIBTOOL
AM_PATH_PYTHON
AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != ""])

dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_TIME
AC_CHECK_HEADERS(fcntl.h limits.h sys/ioctl.h sys/time.h syslog.h unistd.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_STRUCT_TM

dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(gethostname gettimeofday mkfifo select socket strdup \
	strerror strtoul snprintf strsep vsyslog)

forkpty=""
AC_CHECK_FUNCS(forkpty)
if test "$ac_cv_func_forkpty" != yes; then
  AC_CHECK_LIB(util,forkpty,[
    forkpty="-lutil"
    AC_DEFINE(HAVE_FORKPTY)])
fi

vga_progs=
AC_CHECK_HEADER(vga.h,
  [AC_CHECK_HEADER(vgagl.h,
    [AC_CHECK_LIB(vga, vga_init,
      [AC_CHECK_LIB(vgagl, gl_setcontextvga,
        [AC_DEFINE(HAVE_LIBVGA)]
        vga_progs=smode2,,
        -lvga
      )]
    )]
  )]
)
x_progs="irxevent xmode2"
AC_PATH_XTRA
if test "$no_x" = "yes"; then
  x_progs=
fi

dnl getopt_long support
AC_CHECK_FUNCS(getopt_long,,
  [AC_CHECK_LIB(gnugetopt,getopt_long,LDFLAGS="${LDFLAGS} -lgnugetopt",
    [AC_MSG_ERROR([*** your libc doesn't provide the getopt_long function.
Therfore you need to have \"libgnugetopt\" installed to compile LIRC.
You can get a version from:
  http://www.inf.ethz.ch/~mringwal/downloads/libgnugetopt-1.2.tar.gz
Extract the package and do a \"./configure  && make && sudo make install\"
in its directory.
])]
  )]
)
	

dnl Determine default configuration based on OS
case "${host_os}" in
  darwin*)
    dnl Mac OS X configuration

    dnl PortAudio for mac os x
    portaudio_lib_other="-framework CoreAudio -framework AudioToolbox"

    dnl default devdir, on mac os x/darwin, /dev/ can not be used without kernel programming, so use a fifo somewhere else
    devdir_default="/usr/lirc/dev/"
    use_fifos="yes"
    ;;
  *)
    dnl Unix OSS configuration

    dnl PortAudio for UNIX OSS
    portaudio_lib_other="-lm -lpthread ${forkpty}"

    dnl default devdir
    devdir_default="/dev"
    use_fifos="no"
    ;;
esac

# use fifo instead of devnode (required on mac os x)
AM_CONDITIONAL(USE_FIFOS, test "$use_fifos" = "yes")


dnl look for Linux kernel source

AC_PATH_KERNEL_SOURCE

dnl here we see what drivers we could possibly even hope to run.
dnl this could be _much_ more sophisticated!  especially the lirc ones.

AC_MSG_CHECKING([for which drivers can be installed on this system])
AC_MSG_RESULT()

possible_drivers="(none) \
	(userspace) \
	(accent) \
	(bte) \
	(creative) \
	(ea65) \
	(exaudio) \
	(irlink) \
	(irreal) \
	(livedrive_midi) \
	(livedrive_seq) \
	(logitech) \
	(mediafocusI) \
	(mouseremote) \
	(mouseremote_ps2) \
	(mp3anywhere) \
	(mplay) \
	(pcmak) \
	(pcmak_usb) \
	(pctv) \
	(remotemaster) \
	(silitek) \
	(slinke) \
	(tira) \
	(uirt2) \
	(uirt2_raw) \
	(usb_uirt_raw) \
	(usbx) \
	(udp)"

if test x${no_kernel} != xyes; then
  possible_drivers="${possible_drivers} \
	(all) \
	(lirc_dev) \
	(lirc_dev lirc_atiusb) \
	(lirc_dev lirc_bt829) \
	(lirc_dev commandir lirc_cmdir) \
	(lirc_dev lirc_gpio) \
	(lirc_dev lirc_i2c) \
	(lirc_dev lirc_igorplugusb) \
	(lirc_dev lirc_ttusbir) \
	(lirc_dev lirc_imon) \
	(lirc_dev lirc_it87) \
	(lirc_dev lirc_ite8709) \
	(lirc_dev lirc_mceusb) \
	(lirc_dev lirc_mceusb2) \
	(lirc_dev lirc_parallel) \
	(lirc_dev lirc_sasem) \
	(lirc_dev lirc_serial) \
	(lirc_dev lirc_sir) \
	(lirc_dev lirc_streamzap)"
fi

AH_TEMPLATE([DAEMONIZE],
	[Define to run daemons as daemons])

AH_TEMPLATE([DEBUG],
	[Define to enable debugging output])

AH_TEMPLATE([DEVDIR],
	[device files directory])

AH_TEMPLATE([DYNCODES],
	[Define to use dynamic IR codes])

AH_TEMPLATE([HAVE_ALSA_SB_RC],	
	[Define if the ALSA library with SB RC support is installed])

AH_TEMPLATE([HAVE_FORKPTY],
	[Define if forkpty is available])

AH_TEMPLATE([HAVE_IGUANAIR],
	[Define if the iguanaIR library is installed])

AH_TEMPLATE([HAVE_LIBALSA],
	[Define if the ALSA library is installed])

AH_TEMPLATE([HAVE_LIBCARACA],
	[Define if the caraca library is installed])

AH_TEMPLATE([HAVE_LIBIRMAN],
	[Define if the libirman library is installed])

AH_TEMPLATE([HAVE_LIBIRMAN_SW],
	[Define if the software only test version of libirman is installed])

AH_TEMPLATE([HAVE_LIBPORTAUDIO],
	[Define if the portaudio library is installed])

AH_TEMPLATE([HAVE_LIBUSB],
	[Define if libusb is installed])

AH_TEMPLATE([HAVE_LIBVGA],
	[Define if the complete vga libraries (vga, vgagl) are installed])

AH_TEMPLATE([HAVE_LINUX_DEVINPUT],
	[defined if Linux input interface is available])

AH_TEMPLATE([HAVE_LINUX_HIDDEV_FLAG_UREF],
	[defined if Linux hiddev HIDDEV_FLAG_UREF flag is available])

AH_TEMPLATE([HAVE_SCSI],
	[defined if SCSI API is available])

AH_TEMPLATE([HAVE_SOUNDCARD],
	[defined if soundcard API is available])

AH_TEMPLATE([HAVE_VSYSLOG],
	[define if you have vsyslog( prio, fmt, va_arg )])

AH_TEMPLATE([HW_DEFAULT],
	[The name of the hw_* structure to use by default])

AH_TEMPLATE([LIRC_DRIVER],
	[Text string signifying which driver is configured])

AH_TEMPLATE([LIRC_DRIVER_ANY],
	[Define to include most drivers])

AH_TEMPLATE([LIRC_HAVE_DEVFS],
	[Define if devfs support is present in current kernel])

AH_TEMPLATE([LIRC_IRQ],
	[Set the IRQ for the lirc driver])

AH_TEMPLATE([LIRC_IRTTY],
	[Set the default tty used by the irman/remotemaster driver])

AH_TEMPLATE([LIRC_IT87_DIGIMATRIX],
	[Define if you want to use lirc_it87 with an Asus Digimatrix])

AH_TEMPLATE([LIRC_MAJOR],
	[Set the device major for the lirc driver])

AH_TEMPLATE([LIRC_ON_SA1100],
	[Define if you want to cross-compile for the SA1100])

AH_TEMPLATE([LIRC_PORT],
	[Set the port address for the lirc driver])

AH_TEMPLATE([LIRC_SERIAL_ANIMAX],
	[Define if you have an animax serial port receiver])

AH_TEMPLATE([LIRC_SERIAL_IGOR],
	[Define if you have an Igor Cesko receiver])

AH_TEMPLATE([LIRC_SERIAL_IRDEO],
	[Define if you have an IRdeo serial port receiver])

AH_TEMPLATE([LIRC_SERIAL_IRDEO_REMOTE],
	[Define if you have an IRdeo remote transmitter])

AH_TEMPLATE([LIRC_SERIAL_NSLU2],
	[Define if you have a Linksys NSLU2 and use CTS2+GreenLED])

AH_TEMPLATE([LIRC_SERIAL_SOFTCARRIER],
	[Define if the software needs to generate the carrier frequency])

AH_TEMPLATE([LIRC_SERIAL_TRANSMITTER],
	[Define if you have a IR diode connected to the serial port])

AH_TEMPLATE([LIRC_SIR_ACTISYS_ACT200L],
	[Define if you want to use a Actisys Act200L])

AH_TEMPLATE([LIRC_SIR_ACTISYS_ACT220L],
	[Define if you want to use a Actisys Act220L])

AH_TEMPLATE([LIRC_SIR_TEKRAM],
	[Define if you want to use a Tekram Irmate 210])

AH_TEMPLATE([LIRC_SYSLOG],
	[syslog facility to use])

AH_TEMPLATE([LIRC_IMON_LCD],
	[Define if your iMON is an LCD and not a VFD.])

AH_TEMPLATE([LIRC_TIMER],
	[Set the timer for the parallel port driver])

AH_TEMPLATE([LOCALSTATEDIR],
	[modifiable single-machine data])

AH_TEMPLATE([LONG_IR_CODE],
	[Define to use long long IR codes])

AH_TEMPLATE([MAINTAINER_MODE],
	[define in maintainer mode])

AH_TEMPLATE([SYSCONFDIR],
	[system configuration directory])

AH_TEMPLATE([USE_SYSLOG],
	[define if you want to log to syslog instead of logfile])

if test -n "${LIBUSB_CONFIG}"; then
  AC_DEFINE(HAVE_LIBUSB)
  possible_drivers="${possible_drivers} (atilibusb) (commandir)"
fi
AC_CHECK_LIB(caraca_client, caraca_init,
  AC_DEFINE(HAVE_LIBCARACA)
  possible_drivers="${possible_drivers} (caraca)"
)
AC_CHECK_HEADER(iguanaIR.h,
  AC_DEFINE(HAVE_IGUANAIR)
  possible_drivers="${possible_drivers} (iguanaIR)"
)
AC_CHECK_LIB(irman, ir_strerror,
  AC_DEFINE(HAVE_LIBIRMAN)
  possible_drivers="${possible_drivers} (irman)"
)
AC_CHECK_LIB(irman_sw, ir_strerror,
  AC_DEFINE(HAVE_LIBIRMAN_SW)
  possible_drivers="${possible_drivers} (irman_sw)"
)
dnl audio driver requires PortAudio library installed and some linker flags
AC_CHECK_HEADERS(portaudio.h,[
  AC_CHECK_LIB(portaudio, Pa_Initialize,[
    AC_DEFINE(HAVE_LIBPORTAUDIO)
    possible_drivers="${possible_drivers} (audio)"
    ],,${portaudio_lib_other}
  )]
)
dnl audio_alsa driver requires ALSA library installed and some linker flags
have_alsa=no
AC_CHECK_HEADERS(alsa/asoundlib.h,[
  AC_CHECK_LIB(asound, snd_pcm_open,[
    AC_DEFINE(HAVE_LIBALSA)
    have_alsa=yes
    possible_drivers="${possible_drivers} (audio_alsa)"
    ],,
  )]
)
dnl alsa_usb driver requires an ALSA that knows about our hwdep device
if test "$have_alsa" = "yes"; then
  AC_MSG_CHECKING(for ALSA SB RC hwdep support)
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <alsa/asoundlib.h>
]], [[
  if (snd_hwdep_info_get_iface(NULL) == SND_HWDEP_IFACE_SB_RC) {}
]])],[
    AC_MSG_RESULT(yes)
    AC_DEFINE(HAVE_ALSA_SB_RC)
    possible_drivers="${possible_drivers} (alsa_usb)"
    ],[
    AC_MSG_RESULT(no)
  ])
fi
dnl creative_infracd driver requires linux scsi api
AC_CHECK_HEADERS(scsi/sg.h,[
  AC_DEFINE(HAVE_SCSI)
  possible_drivers="${possible_drivers} (creative_infracd)"
  ]
)
dnl dev_input driver requires linux input device api
AC_CHECK_HEADERS(linux/input.h,[
  AC_DEFINE(HAVE_LINUX_DEVINPUT)
  possible_drivers="${possible_drivers} (devinput)"
  ]
)
dnl check if hiddev is available
AC_CHECK_HEADERS([linux/types.h])
AC_CHECK_HEADERS([linux/hiddev.h],[
  possible_drivers="${possible_drivers} (dvico) (asusdh) (bw6130) (macmini)"
  AC_MSG_CHECKING(for HIDDEV_FLAG_UREF support)
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <linux/types.h>
#include <linux/hiddev.h>
    ]], [[
      int flag = HIDDEV_FLAG_UREF;
    ]])],[
    AC_MSG_RESULT(yes)
    AC_DEFINE(HAVE_LINUX_HIDDEV_FLAG_UREF)
    possible_drivers="${possible_drivers} (samsung) (sb0540)"
    ],[
    AC_MSG_RESULT(no)
    ])
  ], [],
[#ifdef HAVE_LINUX_TYPES_H
#include <linux/types.h>
#endif
]
)
dnl dsp driver requires linux soundcard api
AC_CHECK_HEADERS(sys/soundcard.h,[
  AC_DEFINE(HAVE_SOUNDCARD)
  possible_drivers="${possible_drivers} (dsp)"
  ]
)
dnl i2cuser driver requires the Linux I2C API
AC_CHECK_HEADERS(linux/i2c-dev.h,[
  possible_drivers="${possible_drivers} (i2cuser)"
  ]
)

dnl here we see what driver the user wants.

AC_ARG_WITH(driver,
[  --with-driver=X         specify the driver to use, where X is one of:
                          all, none, userspace, accent, act200l,
                          act220l, adaptec, alsa_usb, animax, asusdh,
                          atilibusb, atiusb, audio, audio_alsa
                          avermedia, avermedia_vdomate, avermedia98,
                          bestbuy, bestbuy2, breakoutbox, bte, bw6130,
                          caraca, chronos, cmdir, commandir, comX, cph06x,
                          creative, creative_infracd, devinput,
                          digimatrix, dsp, dvico, ea65, exaudio,
                          flyvideo, gvbctv5pci, hauppauge,
                          hauppauge_dvb, hercules_smarttv_stereo,
                          i2cuser, igorplugusb, iguanaIR, imon,
                          imon_24g, imon_knob, imon_lcd, imon_pad,
                          imon_rsc, irdeo, irdeo_remote, irlink,
                          irman, irreal, it87, ite8709, knc_one, kworld,
                          leadtek_0007, leadtek_0010, leadtek_pvr2000,
                          livedrive_midi, livedrive_seq, logitech,
                          lptX, macmini, mceusb, mceusb2, mediafocusI,
                          mouseremote, mouseremote_ps2, mp3anywhere,
                          mplay, nslu2,packard_bell, parallel, pcmak,
                          pcmak_usb, pctv, pixelview_bt878,
                          pixelview_pak, pixelview_pro, provideo,
                          realmagic, remotemaster, sa1100, samsung,
                          sasem, sb0540, serial, silitek, sir, slinke,
                          streamzap, tekram, tekram_bt829, tira,
                          ttusbir, tuxbox, tvbox, udp, uirt2, 
                          uirt2_raw, usb_uirt_raw, usbx], 
driver=${withval},
driver="unset"
)

#START HARDWARE HEURISTIC

lirc_driver="$driver"
lircd_conf=""
lircmd_conf=""
iguanaIR_lib=""
irman_lib=""
caraca_lib=""
commandir_lib=""
portaudio_lib=""
alsa_lib=""
atilibusb_lib=""
hw_module="hw_default.o receive.o transmit.o"
HW_DEFAULT="hw_default"
kernel_module=""

if test "$driver" = "none"; then
  lirc_driver=none
  hw_module=""
  HW_DEFAULT="hw_null"
fi

if test "$driver" = "userspace" -o "$driver" = "all"; then
  AC_DEFINE(LIRC_DRIVER_ANY)
  lirc_driver=$driver
  
  any_possible_drivers=`echo ${possible_drivers} | sed -e's/ /-/g' \
			  -e's/)-(/ /g'  -e's/(//g' -e's/)//g' \
			  -e's/-$//g'`
  for any_driver in ${any_possible_drivers}; do
  case ${any_driver} in
	accent)
		hw_module="${hw_module} hw_accent.o serial.o"
		;;
	alsa_usb)
		hw_module="${hw_module} hw_alsa_usb.o"
		alsa_lib=-lasound
		;;
	asusdh)
		hw_module="${hw_module} hw_hiddev.o"
		;;
	atilibusb)
		hw_module="${hw_module} hw_atilibusb.o receive.o"
		atilibusb_lib=`${LIBUSB_CONFIG} --libs`
		CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
		;;
	audio)
		hw_module="${hw_module} hw_audio.o receive.o"
		portaudio_lib="-lportaudio ${portaudio_lib_other}"
		;;
	audio_alsa)
		hw_module="${hw_module} hw_audio_alsa.o receive.o"
		alsa_lib=-lasound
		;;
	bte)
		hw_module="${hw_module} hw_bte.o serial.o"
		;;
	bw6130)
		hw_module="${hw_module} hw_hiddev.o"
		;;
	caraca)
		hw_module="${hw_module} hw_caraca.o"
		caraca_lib=-lcaraca_client
		;;
	creative)
		hw_module="${hw_module} hw_creative.o serial.o"
		;;
	creative_infracd)
		hw_module="${hw_module} hw_creative_infracd.o"
		;;
	commandir)
		hw_module="${hw_module} hw_commandir.o receive.o"
		commandir_lib=`${LIBUSB_CONFIG} --libs`
		CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
		;;
	devinput)
		hw_module="${hw_module} hw_devinput.o"
		;;
	dsp)
		hw_module="${hw_module} hw_dsp.o receive.o"
		;;
	dvico)
		hw_module="${hw_module} hw_hiddev.o"
		;;
	ea65)
		hw_module="${hw_module} hw_ea65.o serial.o"
		;;
	exaudio)
		;;
	i2cuser)
		hw_module="${hw_module} hw_i2cuser.o receive.o"
		;;
	iguanaIR)
		hw_module="${hw_module} hw_iguanaIR.o transmit.o receive.o"
		iguanaIR_lib=-liguanaIR
		;;
	irlink)
		hw_module="${hw_module} hw_irlink.o serial.o receive.o"
		;;
	irman)
		hw_module="${hw_module} hw_irman.o serial.o"
		irman_lib=-lirman
		;;
	# There is not much sense in using 'irman_sw' with driver
	# 'any' and that would conflict with 'irman' which will
	# probably also be available.
	#
	#irman_sw)
		#hw_module="${hw_module} hw_irman.o serial.o"
		#irman_lib=-lirman_sw
		#;;
	irreal)
		#hw_module="${hw_module} hw_irreal.o serial.o receive.o transmit.o"
		;;
	lirc_dev-lirc_atiusb)
		;;
	lirc_dev-commandir-lirc_cmdir)
		;;
	lirc_dev-lirc_gpio)
		#lirc_driver="${lirc_driver} lirc_dev lirc_gpio"
		;;
	lirc_dev-lirc_i2c)
		#lirc_driver="${lirc_driver} lirc_dev lirc_i2c"
		;;
	lirc_dev-lirc_igorplugusb)
		;;
	lirc_dev-lirc_ttusbir)
		;;
	lirc_dev-lirc_imon)
		;;
	lirc_dev-lirc_it87)
		;;
	lirc_dev-lirc_ite8709)
		;;
	lirc_dev-lirc_mceusb)
		;;
	lirc_dev-lirc_mceusb2)
		;;
	lirc_dev-lirc_parallel)
		;;
	lirc_dev-lirc_sasem)
		;;
	lirc_dev-lirc_serial)
		;;
	lirc_dev-lirc_sir)
		;;
	lirc_dev-lirc_streamzap)
		;;
	lirc_flyvideo)
		;;
	livedrive_midi)
		hw_module="${hw_module} hw_livedrive_common.o hw_livedrive_midi.o"
		;;
	livedrive_seq)
		hw_module="${hw_module} hw_livedrive_common.o hw_livedrive_seq.o"
		;;
	logitech)
		hw_module="${hw_module} hw_logitech.o serial.o"
		;;
	macmini)
		hw_module="${hw_module} hw_hiddev.o"
		;;
	mediafocusI)
		;;
	mouseremote)
		hw_module="${hw_module} hw_mouseremote.o serial.o"
		;;
	mouseremote_ps2)
		hw_module="${hw_module} hw_mouseremote.o serial.o"
		;;
	mp3anywhere)
		hw_module="${hw_module} hw_mp3anywhere.o serial.o"
		;;
	mplay)
		hw_module="${hw_module} hw_mplay.o serial.o"
		;;
	pcmak*)
		hw_module="${hw_module} hw_pcmak.o serial.o"
		;;
	pctv)
		hw_module="${hw_module} hw_pinsys.o serial.o"
		;;
	remotemaster)
		hw_module="${hw_module} hw_pixelview.o serial.o"
		;;
	samsung)
		hw_module="${hw_module} hw_hiddev.o"
		;;
	sb0540)
		hw_module="${hw_module} hw_hiddev.o"
		;;
	silitek)
		hw_module="${hw_module} hw_silitek.o serial.o"
		;;
	#slinke)
		#hw_module="${hw_module} hw_slinke.o serial.o receive.o"
		#;;
	tira)
		hw_module="${hw_module} hw_tira.o"
		;;
	udp)
		hw_module="${hw_module} hw_udp.o receive.o"
		;;
	uirt2)
		hw_module="${hw_module} hw_uirt2.o serial.o"
		;;
	uirt2_raw|usb_uirt_raw)
		hw_module="${hw_module} hw_uirt2_raw.o hw_uirt2_common.o serial.o receive.o transmit.o"
		;;
	usbx)
		hw_module="${hw_module} hw_usbx.o serial.o"
		;;
  esac
  done
  #remove duplicates

  #sed segfaults when $hw_module is too long :(
  #hw_module=`echo ${hw_module}| sed \
  #			-e':again' \
  #			-e's/\(.*\)\(\<.*\) \(.*\) \2\(.*\)$/\1\2 \3\4/' \
  #			-e'tagain'`

  space_to_newline()
  { for token in $*; do echo $token; done; }
  newline_to_space()
  { echo $*; }
  
  hw_module=$(newline_to_space $(space_to_newline ${hw_module}| sort -u))

fi

if test "$driver" = "accent"; then
  lirc_driver="none"
  hw_module="hw_accent.o serial.o"
  HW_DEFAULT="hw_accent"
  lircd_conf="kanam_accent/lircd.conf.IR-100"
fi

if test "$driver" = "act200l"; then
  lirc_driver="lirc_dev lirc_sir"
  AC_DEFINE(LIRC_SIR_ACTISYS_ACT200L)
fi

if test "$driver" = "act220l"; then
  lirc_driver="lirc_dev lirc_sir"
  AC_DEFINE(LIRC_SIR_ACTISYS_ACT220L)
fi
    
if test "$driver" = "adaptec"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="adaptec/lircd.conf.AVC-2410"
#  lircmd_conf="adaptec/lircmd.conf.AVC-2410"
fi

if test "$driver" = "alsa_usb"; then
  lirc_driver="alsa_usb"
  hw_module="hw_alsa_usb.o"
  HW_DEFAULT="hw_alsa_usb"
  alsa_lib=-lasound
  lircd_conf="creative/lircd.conf.alsa_usb"
fi

if test "$driver" = "animax"; then
  lirc_driver="lirc_dev lirc_serial"
  lircd_conf="animax/lircd.conf.animax"
  lircmd_conf="animax/lircmd.conf.animax"
  AC_DEFINE(LIRC_SERIAL_ANIMAX)
fi

if test "$driver" = "asusdh"; then
  lirc_driver="$driver"
  hw_module="hw_hiddev.o"
  HW_DEFAULT="hw_asusdh"
  lircd_conf="asus/lircd.conf.asusdh"
fi

if test "$driver" = "atiusb"; then
  lirc_driver="lirc_dev lirc_atiusb"
  lircd_conf="atiusb/lircd.conf.atiusb"
fi

if test "$driver" = "atilibusb"; then
  lirc_driver="$driver"
  hw_module="hw_atilibusb.o receive.o"
  HW_DEFAULT="hw_atilibusb"
  lircd_conf="atiusb/lircd.conf.atilibusb"
  if test -n "${LIBUSB_CONFIG}"; then
    atilibusb_lib=`${LIBUSB_CONFIG} --libs`
    CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
  fi
fi

if test "$driver" = "audio"; then
  lirc_driver="audio"
  hw_module="hw_audio.o receive.o"
  HW_DEFAULT="hw_audio"
  portaudio_lib="-lportaudio ${portaudio_lib_other}"
fi

if test "$driver" = "audio_alsa"; then
  lirc_driver="audio_alsa"
  hw_module="hw_audio_alsa.o receive.o"
  HW_DEFAULT="hw_audio_alsa"
  alsa_lib=-lasound
fi

if test "$driver" = "avermedia"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="avermedia/lircd.conf.avermedia"
  lircmd_conf="avermedia/lircmd.conf.avermedia"
fi

if test "$driver" = "avermedia98"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="avermedia/lircd.conf.avermedia98"
  lircmd_conf="avermedia/lircmd.conf.avermedia98"
fi

if test "$driver" = "avermedia_vdomate"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="avermedia/lircd.conf.vdomate"
#  lircmd_conf="avermedia/lircmd.conf.vdomate"
fi

if test "$driver" = "bestbuy"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="bestbuy/lircd.conf.bestbuy"
  lircmd_conf="bestbuy/lircmd.conf.bestbuy"
fi

if test "$driver" = "bestbuy2"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="bestbuy/lircd.conf.bestbuy2"
  lircmd_conf="bestbuy/lircmd.conf.bestbuy2"
fi

if test "$driver" = "breakoutbox"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="creative/lircd.conf.breakoutbox"
fi

if test "$driver" = "bte"; then
  lirc_driver="none"
  hw_module="hw_bte.o  serial.o"
  HW_DEFAULT="hw_bte"
  lircd_conf="ericsson/lircd.conf.bte"
#  lircmd_conf="ericsson/lircmd.conf.bte"
fi

if test "$driver" = "bw6130"; then
  lirc_driver="$driver"
  hw_module="hw_hiddev.o"
  HW_DEFAULT="hw_bw6130"
  lircd_conf="remotec/lircd.conf.BW6130"
  lircmd_conf="remotec/lircmd.conf.BW6130"
fi

if test "$driver" = "caraca"; then
  lirc_driver="caraca"
  hw_module="hw_caraca.o"
  HW_DEFAULT="hw_caraca"
  caraca_lib=-lcaraca_client
  lircd_conf="caraca/lircd.conf.caraca"
#  lircmd_conf="caraca/lircmd.conf.caraca"
fi

if test "$driver" = "chronos"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="chronos/lircd.conf.chronos"
#  lircmd_conf="chronos/lircmd.conf.chronos"
fi

if test "$driver" = "cmdir"; then
  lirc_driver="lirc_dev commandir lirc_cmdir"
fi

if test "$driver" = "com1"; then
  lirc_driver="lirc_dev lirc_serial"
  port=0x3f8
  irq=4
fi

if test "$driver" = "com2"; then
  lirc_driver="lirc_dev lirc_serial"
  port=0x2f8
  irq=3
fi

if test "$driver" = "com3"; then
  lirc_driver="lirc_dev lirc_serial"
  port=0x3e8
  irq=4
fi

if test "$driver" = "com4"; then
  lirc_driver="lirc_dev lirc_serial"
  port=0x2e8
  irq=3
fi

if test "$driver" = "commandir"; then
  lirc_driver="$driver"
  hw_module="hw_commandir.o receive.o transmit.o"
  HW_DEFAULT="hw_commandir"
  lircd_conf="hauppauge/lircd.conf.hauppauge"
  lircmd_conf="hauppauge/lircmd.conf.hauppauge"
  if test -n "${LIBUSB_CONFIG}"; then
    commandir_lib=`${LIBUSB_CONFIG} --libs`
    CFLAGS="$CFLAGS `${LIBUSB_CONFIG} --cflags`"
  fi
fi

if test "$driver" = "cph03x" -o "$driver" = "cph06x"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="cph03x/lircd.conf.cph03x"
#  lircmd_conf="cph03x/lircmd.conf.cph03x"
fi

if test "$driver" = "creative"; then
  lirc_driver="none"
  hw_module="hw_creative.o serial.o"
  HW_DEFAULT="hw_creative"
  lircd_conf="creative/lircd.conf.creative"
#  lircmd_conf="creative/lircmd.conf.creative"
fi

if test "$driver" = "creative_infracd"; then
  lirc_driver="none"
  hw_module="hw_creative_infracd.o"
  HW_DEFAULT="hw_creative_infracd"
  lircd_conf="creative/lircd.conf.infracd"
fi

if test "$driver" = "devinput"; then
  lirc_driver="none"
  hw_module="hw_devinput.o"
  HW_DEFAULT="hw_devinput"
# for table.html (unset later)
  lircd_conf='<A HREF="http://linux.bytesex.org/v4l2/faq.html#lircd">generic config file for Linux input layer</A>'
fi

if test "$driver" = "digimatrix"; then
  lirc_driver="lirc_dev lirc_it87"
  lircd_conf="asus/lircd.conf.digimatrix"
  AC_DEFINE(LIRC_IT87_DIGIMATRIX)
fi

if test "$driver" = "dsp"; then
  lirc_driver="none"
  hw_module="hw_dsp.o receive.o"
  HW_DEFAULT="hw_dsp"
fi

if test "$driver" = "dvico"; then
  lirc_driver="$driver"
  hw_module="hw_hiddev.o"
  HW_DEFAULT="hw_dvico"
  lircd_conf="dvico/lircd.conf.fusionHDTV"
fi

if test "$driver" = "ea65"; then
  lirc_driver="none"
  hw_module="hw_ea65.o  serial.o"
  HW_DEFAULT="hw_ea65"
  lircd_conf="ea65/lircd.conf.ea65"
fi

if test "$driver" = "exaudio"; then
  lirc_driver="none"
#  lircd_conf="creative/lircd.conf.exaudio"
#  lircmd_conf="creative/lircmd.conf.exaudio"
fi

if test "$driver" = "flyvideo"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="life-view/lircd.conf.flyvideo"
  lircmd_conf="life-view/lircmd.conf.flyvideo"
fi

if test "$driver" = "gvbctv5pci"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="iodata/lircd.conf.gvbctv5pci"
#  lircmd_conf="iodata/lircmd.conf.gvbctv5pci"
fi

if test "$driver" = "hauppauge"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="hauppauge/lircd.conf.hauppauge"
  lircmd_conf="hauppauge/lircmd.conf.hauppauge"
fi

if test "$driver" = "hauppauge_dvb"; then
  lirc_driver="lirc_dev"
  lircd_conf="hauppauge/lircd.conf.hauppauge"
  lircmd_conf="hauppauge/lircmd.conf.hauppauge"
fi

if test "$driver" = "hercules_smarttv_stereo"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="hercules/lircd.conf.smarttv_stereo"
fi

if test "$driver" = "i2cuser"; then
  lirc_driver="none"
  hw_module="hw_i2cuser.o receive.o"
  HW_DEFAULT="hw_i2cuser"
fi

if test "$driver" = "igorplugusb"; then
  lirc_driver="lirc_dev lirc_igorplugusb"
fi

if test "$driver" = "iguanaIR"; then
  lirc_driver="iguanaIR"
  hw_module="hw_iguanaIR.o transmit.o receive.o"
  HW_DEFAULT="hw_iguanaIR"
  iguanaIR_lib=-liguanaIR
fi

if test "$driver" = "imon"; then
  lirc_driver="lirc_dev lirc_imon"
  lircd_conf="imon/lircd.conf.imon"  
fi

if test "$driver" = "imon_24g"; then
  lirc_driver="lirc_dev lirc_imon"
  lircd_conf="imon/lircd.conf.imon-2.4g"
fi

if test "$driver" = "imon_knob"; then
  lirc_driver="lirc_dev lirc_imon"
  lircd_conf="imon/lircd.conf.imon-knob"
fi

if test "$driver" = "imon_lcd"; then
  lirc_driver="lirc_dev lirc_imon"
  lircd_conf="imon/lircd.conf.imon"
  AC_DEFINE(LIRC_IMON_LCD)
fi

if test "$driver" = "imon_pad"; then
  lirc_driver="lirc_dev lirc_imon"
  lircd_conf="imon/lircd.conf.imon-pad"  
fi

if test "$driver" = "imon_rsc"; then
  lirc_driver="lirc_dev lirc_imon"
  lircd_conf="imon/lircd.conf.imon-rsc"  
fi

if test "$driver" = "irdeo"; then
  lirc_driver="lirc_dev lirc_serial"
  AC_DEFINE(LIRC_SERIAL_IRDEO)
fi

if test "$driver" = "irdeo_remote"; then
  lirc_driver="lirc_dev lirc_serial"
  AC_DEFINE(LIRC_SERIAL_IRDEO_REMOTE)
fi

if test "$driver" = "irlink"; then
  lirc_driver="none"
  hw_module="hw_irlink.o serial.o receive.o"
  HW_DEFAULT="hw_irlink"
fi

if test "$driver" = "irman"; then
  lirc_driver="irman"
  hw_module="hw_irman.o serial.o"
  HW_DEFAULT="hw_irman"
  irman_lib=-lirman
fi

if test "$driver" = "irman_sw"; then
  lirc_driver="irman_sw"
  hw_module="hw_irman.o serial.o"
  HW_DEFAULT="hw_irman"
  irman_lib=-lirman_sw
fi

if test "$driver" = "irreal"; then
  lirc_driver="none"
  hw_module="hw_irreal.o serial.o receive.o transmit.o"
  HW_DEFAULT="hw_irreal"
fi

if test "$driver" = "it87"; then
  lirc_driver="lirc_dev lirc_it87"
fi

if test "$driver" = "ite8709"; then
  lirc_driver="lirc_dev lirc_ite8709"
fi

if test "$driver" = "knc_one"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="knc_one/lircd.conf.knc_one"
#  lircmd_conf="knc_one/lircmd.conf.knc_one"
fi

if test "$driver" = "kworld"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="kworld/lircd.conf.kworld"
#  lircmd_conf="kworld/lircmd.conf.kworld"
fi

if test "$driver" = "leadtek_0007"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="leadtek/lircd.conf.RM-0007"
  lircmd_conf="leadtek/lircmd.conf.RM-0007"
fi

if test "$driver" = "leadtek_0010"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="leadtek/lircd.conf.RM-0010"
  lircmd_conf="leadtek/lircmd.conf.RM-0010"
fi

if test "$driver" = "leadtek_pvr2000"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="leadtek/lircd.conf.PVR2000"
#  lircmd_conf="leadtek/lircmd.conf.PVR2000"
fi

if test "$driver" = "livedrive_midi"; then
  lirc_driver="none"
  hw_module="hw_livedrive_common.o hw_livedrive_midi.o"
  HW_DEFAULT="hw_livedrive_midi"
  lircd_conf="creative/lircd.conf.livedrive"
#  lircmd_conf="creative/lircmd.conf.livedrive"
fi

if test "$driver" = "livedrive_seq"; then
  lirc_driver="none"
  hw_module="hw_livedrive_common.o hw_livedrive_seq.o"
  HW_DEFAULT="hw_livedrive_seq"
  lircd_conf="creative/lircd.conf.livedrive"
#  lircmd_conf="creative/lircmd.conf.livedrive"
fi

if test "$driver" = "logitech"; then
  lirc_driver="none"
  hw_module="hw_logitech.o serial.o"
  HW_DEFAULT="hw_logitech"
  lircd_conf="logitech/lircd.conf.logitech"
  lircmd_conf="logitech/lircmd.conf.logitech"
fi

if test "$driver" = "lpt1"; then
  lirc_driver="lirc_dev lirc_parallel"
  port=0x378
  irq=7
fi

if test "$driver" = "lpt2"; then
  lirc_driver="lirc_dev lirc_parallel"
  port=0x278
  irq=5
fi

if test "$driver" = "macmini"; then
  lirc_driver="$driver"
  hw_module="hw_hiddev.o"
  HW_DEFAULT="hw_macmini"
  lircd_conf="apple/lircd.conf.macmini"
fi

if test "$driver" = "mceusb"; then
  lirc_driver="lirc_dev lirc_mceusb"
  lircd_conf="mceusb/lircd.conf.mceusb"
fi

if test "$driver" = "mceusb2"; then
  lirc_driver="lirc_dev lirc_mceusb2"
  lircd_conf="mceusb/lircd.conf.mceusb"
fi

if test "$driver" = "mediafocusI"; then
  lirc_driver="none"
  lircd_conf="technisat/lircd.conf.mediafocusI"
#  lircmd_conf="technisat/lircmd.conf.mediafocusI"
fi

if test "$driver" = "mouseremote"; then
  lirc_driver="none"
  hw_module="hw_mouseremote.o serial.o"
  HW_DEFAULT="hw_mouseremote"
  lircd_conf="x10/lircd.conf.mouseremote"
  lircmd_conf="x10/lircmd.conf.mouseremote"
fi

if test "$driver" = "mouseremote_ps2"; then
  lirc_driver="none"
  hw_module="hw_mouseremote.o serial.o"
  HW_DEFAULT="hw_mouseremote_ps2"
  lircd_conf="x10/lircd.conf.mouseremote"
  lircmd_conf="x10/lircmd.conf.mouseremote"
fi

if test "$driver" = "mp3anywhere"; then
  lirc_driver="none"
  hw_module="hw_mp3anywhere.o serial.o"
  HW_DEFAULT="hw_mp3anywhere"
  lircd_conf="x10/lircd.conf.mp3anywhere"
fi

if test "$driver" = "mplay"; then
  lirc_driver="none"
  hw_module="hw_mplay.o serial.o"
  HW_DEFAULT="hw_mplay"
  lircd_conf="vlsystem/lircd.conf.mplay"
fi

if test "$driver" = "nslu2"; then
  lirc_driver="lirc_dev lirc_serial"
  AC_DEFINE(LIRC_SERIAL_NSLU2)
fi

if test "$driver" = "packard_bell"; then
  lirc_driver="lirc_dev lirc_serial"
  lircd_conf="packard_bell/lircd.conf.packard_bell"
fi

if test "$driver" = "parallel"; then
  lirc_driver="lirc_dev lirc_parallel"
fi

if test "$driver" = "pcmak" -o "$driver" = "pcmak_usb"; then
  lirc_driver="none"
  hw_module="hw_pcmak.o serial.o"
  HW_DEFAULT="hw_pcmak"
  lircd_conf="pcmak/lircd.conf.pcmak"
  lircmd_conf="pcmak/lircmd.conf.pcmak"
fi

if test "$driver" = "pctv"; then
  lirc_driver="none"
  hw_module="hw_pinsys.o serial.o"
  HW_DEFAULT="hw_pinsys"
  lircd_conf="pinnacle_systems/lircd.conf.pctv"
#  lircmd_conf="pinnacle_systems/lircmd.conf.pctv"
fi

if test "$driver" = "pixelview_bt878"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="pixelview/lircd.conf.playtv_bt878"
#  lircmd_conf="pixelview/lircmd.conf.pixelview_bt878"
fi

if test "$driver" = "pixelview_pak"; then
  lirc_driver="lirc_dev lirc_gpio"
# the config files are the same as for the PlayTV pro
  lircd_conf="pixelview/lircd.conf.playtv_pro"
  lircmd_conf="pixelview/lircmd.conf.playtv_pro"
fi

if test "$driver" = "pixelview_pro"; then
  lirc_driver="lirc_dev lirc_gpio"
  lircd_conf="pixelview/lircd.conf.playtv_pro"
  lircmd_conf="pixelview/lircmd.conf.playtv_pro"
fi

if test "$driver" = "provideo"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="provideo/lircd.conf.pv951"
#  lircmd_conf="provideo/lircmd.conf.pv951"
fi

if test "$driver" = "realmagic"; then
  lirc_driver="none"
  hw_module="hw_pixelview.o serial.o"
  HW_DEFAULT="hw_pixelview"
  lircd_conf="sigma_designs/lircd.conf.realmagic"
#  lircmd_conf="sigma_designs/lircmd.conf.realmagic"
fi

if test "$driver" = "remotemaster"; then
  lirc_driver="none"
  hw_module="hw_pixelview.o serial.o"
  HW_DEFAULT="hw_pixelview"
  lircd_conf="pixelview/lircd.conf.remotemaster"
  lircmd_conf="pixelview/lircmd.conf.remotemaster"
fi

if test "$driver" = "sa1100"; then
  lirc_driver="lirc_dev lirc_sir"
  AC_DEFINE(LIRC_ON_SA1100)
fi

if test "$driver" = "sasem"; then
  lirc_driver="lirc_dev lirc_sasem"
  lircd_conf="sasem/lircd.conf.sasem"
fi

if test "$driver" = "samsung"; then
  lirc_driver="$driver"
  hw_module="hw_hiddev.o"
  HW_DEFAULT="hw_samsung"
  lircd_conf="samsung/lircd.conf.samsung"
fi

if test "$driver" = "sb0540"; then
  lirc_driver="$driver"
  hw_module="hw_hiddev.o"
  HW_DEFAULT="hw_sb0540"
# original RM-1500 is included here
  lircd_conf="creative/lircd.conf.alsa_usb"
fi

if test "$driver" = "serial"; then
  lirc_driver="lirc_dev lirc_serial"
fi

if test "$driver" = "silitek"; then
  lirc_driver="none"
  hw_module="hw_silitek.o serial.o"
  HW_DEFAULT="hw_silitek"
  lircd_conf="silitek/lircd.conf.silitek"
  lircmd_conf="silitek/lircmd.conf.silitek"
fi

if test "$driver" = "sir"; then
  lirc_driver="lirc_dev lirc_sir"
fi

if test "$driver" = "sir_com3"; then
  lirc_driver="lirc_dev lirc_sir"
  port=0x3e8
  irq=4
fi

if test "$driver" = "slinke"; then
  echo
  echo "Please use lirc-0.6.5. The Slink-e is no longer supported."
  echo
  exit 1
  lirc_driver="none"
  hw_module="hw_slinke.o serial.o receive.o"
  HW_DEFAULT="hw_slinke"
fi

if test "$driver" = "streamzap"; then
  lirc_driver="lirc_dev lirc_streamzap"
  lircd_conf="streamzap/lircd.conf.streamzap"
fi

if test "$driver" = "tekram"; then
  lirc_driver="lirc_dev lirc_sir"
  AC_DEFINE(LIRC_SIR_TEKRAM)
fi

if test "$driver" = "tekram_bt829"; then
  lirc_driver="lirc_dev lirc_bt829"
  lircd_conf="tekram/lircd.conf.m230"
  lircmd_conf="tekram/lircmd.conf.m230"
fi

if test "$driver" = "tira"; then
  lirc_driver="none"
  hw_module="hw_tira.o serial.o"
  HW_DEFAULT="hw_tira"
fi

if test "$driver" = "ttusbir"; then
  lirc_driver="lirc_dev lirc_ttusbir"
fi

if test "$driver" = "tuxbox"; then
  lirc_driver="none"
  hw_module="hw_default.o receive.o transmit.o"
  HW_DEFAULT="hw_default"
fi

if test "$driver" = "tvbox"; then
  lirc_driver="lirc_dev lirc_i2c"
  lircd_conf="asus/lircd.conf.asus"
fi

if test "$driver" = "udp"; then
  lirc_driver="none"
  hw_module="hw_udp.o receive.o"
  HW_DEFAULT="hw_udp"
fi

if test "$driver" = "uirt2"; then
  lirc_driver="none"
  hw_module="hw_uirt2.o serial.o"
  HW_DEFAULT="hw_uirt2"
fi
if test "$driver" = "uirt2_raw"; then
  lirc_driver="none"
  hw_module="hw_uirt2_raw.o hw_uirt2_common.o serial.o receive.o transmit.o"
  HW_DEFAULT="hw_uirt2_raw"
fi
if test "$driver" = "usb_uirt_raw"; then
  lirc_driver="none"
  hw_module="hw_uirt2_raw.o hw_uirt2_common.o serial.o receive.o transmit.o"
  HW_DEFAULT="hw_usb_uirt_raw"
fi
if test "$driver" = "usbx"; then
  lirc_driver="none"
  hw_module="hw_usbx.o serial.o"
  HW_DEFAULT="hw_usbx"
  lircd_conf="adstech/lircd.conf.usbx-707"
fi

#END HARDWARE HEURISTIC

if test "$driver" = "devinput"; then
  lircd_conf=""
fi


AC_DEFINE_UNQUOTED(HW_DEFAULT, ${HW_DEFAULT})

dnl now check to see if the user is behaving himself

if test "$lirc_driver" = "unset"; then
  AC_MSG_ERROR([no driver specified, try ./configure --help])
fi

if echo ${possible_drivers} | grep "($lirc_driver)" >/dev/null 2>&1; then
  dummy=
else
  case $lirc_driver in
  irman*)
    AC_MSG_ERROR([*** you need to first install the libirman package
	(libirman-0.4.2 or better) before you can use this driver])
    ;;
  caraca*)
    AC_MSG_ERROR([*** you need to first install the caraca package
	before you can use this driver])
    ;;
  all|lirc_*)
    AC_MSG_ERROR([*** you need to have the Linux kernel source installed
	for this driver])
    ;;
  atilibusb)
    AC_MSG_ERROR([*** you need to have libusb installed for this driver.

Get it at:

  http://libusb.sourceforge.net/
])
    ;;
  audio)
    AC_MSG_ERROR([*** you need to have the PortAudio library V18 installed
to use the audio driver. You can get it at:
  http://www.inf.ethz.ch/~mringwal/downloads/portaudio_v18_with_configure.zip
Extract the package and do a \"./configure && make && sudo make install\"
in its directory.
])
    ;;
  audio_alsa)
    AC_MSG_ERROR([*** you need to have the ALSA headers and libraries
	for this driver])
    ;;
  alsa_usb)
    AC_MSG_ERROR([*** you need to have the ALSA libraries and drivers
	from at least version 1.0.9 for this driver])
    ;;
  commandir)
    AC_MSG_ERROR([*** you need to have libusb installed for this driver.

Get it at:

  http://libusb.sourceforge.net/
  
Or install these packages from your distro:

   libusb
   libusb-dev 

])
    ;;
  iguanaIR)
    AC_MSG_ERROR([*** you need to have the iguanaIR headers and
        libraries for this driver])
    ;;
  *)
    AC_MSG_ERROR([*** it is not possible to install the specified driver
	on this system])
    ;;
  esac
fi

dnl now we've checked, we can rename things for the drivers/Makefile

if test "$lirc_driver" = "none" || \
	test "$lirc_driver" = "alsa_usb" || \
	test "$lirc_driver" = "asusdh" || \
	test "$lirc_driver" = "atilibusb" || \
	test "$lirc_driver" = "audio" || \
	test "$lirc_driver" = "audio_alsa" || \
	test "$lirc_driver" = "bw6130" || \
	test "$lirc_driver" = "caraca" || \
	test "$lirc_driver" = "commandir" || \
	test "$lirc_driver" = "dvico" || \
	test "$lirc_driver" = "iguanaIR" || \
	test "$lirc_driver" = "irman" || \
	test "$lirc_driver" = "irman_sw" || \
	test "$lirc_driver" = "macmini" || \
	test "$lirc_driver" = "samsung" || \
	test "$lirc_driver" = "sb0540" || \
	test "$lirc_driver" = "userspace"; then
  lirc_driver=
elif test "$lirc_driver" = "all"; then
  lirc_driver="lirc_dev \
	lirc_atiusb \
	lirc_bt829 \
	lirc_cmdir \
	lirc_gpio \
	lirc_i2c \
	lirc_igorplugusb \
	lirc_imon \
	lirc_it87 \
	lirc_ite8709 \
	lirc_mceusb \
	lirc_mceusb2 \
	lirc_parallel \
	lirc_sasem \
	lirc_serial \
	lirc_sir \
	lirc_streamzap \
	lirc_ttusbir"
fi
if kernel_module=$(expr "$lirc_driver" : 'lirc_dev \(.*\)'); then
  :
elif test "$lirc_driver" != ""; then
  kernel_module=$lirc_driver
fi

dnl slightly more advanced options

dnl maintainer mode options

maintmode_daemons_extra=
AC_ARG_ENABLE(maintainer-mode,
[  --enable-maintainer-mode    enable maintainer specific things],
[
if test x${enableval} = xyes; then
AC_DEFINE(MAINTAINER_MODE)
maintmode_daemons_extra="lircd.simrec lircd.simsend slinke"
fi
])

dnl don't create nor destroy devices when installing and uninstalling

AC_ARG_ENABLE(sandboxed,
[  --enable-sandboxed      don't touch anything out of the install directory],
[ enable_sandboxed="${enableval}" ],
[ enable_sandboxed="no"])
AM_CONDITIONAL(SANDBOXED, test x$enable_sandboxed = xyes)

AC_ARG_WITH(devdir,
[  --with-devdir=DIR       Install device files in DIR (/dev)],
devdir=${withval},
devdir=${devdir_default})

default_moduledir=/lib/modules/`uname -r`/misc
AC_ARG_WITH(moduledir,
[  --with-moduledir=DIR    kernel modules in DIR (/lib/modules/`uname -r`/misc)], 
moduledir=${withval},
moduledir=${default_moduledir})

AC_ARG_ENABLE(long-codes,
[  --disable-long-codes    use this if your compiler won't do long long],
test x${enableval} = xyes && AC_DEFINE(LONG_IR_CODE),
AC_DEFINE(LONG_IR_CODE))

AC_ARG_ENABLE(dyncodes,
[  --enable-dyncodes       use dynamic codes],
test x${enableval} = xyes && AC_DEFINE(DYNCODES))

AC_ARG_WITH(major,
[  --with-major=value      specify the device major for the driver (61)],
lirc_major=${withval},
lirc_major=61)

AC_ARG_WITH(port,
[  --with-port=port        specify the port number for the lirc device.],
port=${withval}
)

AC_ARG_WITH(irq,
[  --with-irq=irq          specify the irq line for the lirc device.],
irq=${withval}
)

AC_ARG_WITH(timer,
[  --with-timer=value      specify the timer value for the parallel driver],
timer=${withval})

dnl I dont think libirman  will accept this at the moment
AC_ARG_WITH(tty,
[  --with-tty=file         specify the tty to use (Irman, RemoteMaster, etc.)],
irtty=${withval})

AC_ARG_WITH(soft-carrier,
[  --without-soft-carrier  use this if your serial hw generates carrier],
test x${withval} = xyes && AC_DEFINE(LIRC_SERIAL_SOFTCARRIER),
AC_DEFINE(LIRC_SERIAL_SOFTCARRIER))

AC_ARG_WITH(transmitter,
[  --with-transmitter      use this if you use a transmitter diode],
test x${withval} = xyes && AC_DEFINE(LIRC_SERIAL_TRANSMITTER))

AC_ARG_WITH(igor,
[  --with-igor             use this if you have an Igor Cesko receiver],
test x${withval} = xyes && AC_DEFINE(LIRC_SERIAL_IGOR))

AC_ARG_ENABLE(debug,
[  --enable-debug          enable debugging features],
test x${enableval} = xyes && AC_DEFINE(DEBUG)
)

AC_ARG_ENABLE(daemonize,
[  --disable-daemonize     disable daemons from daemonizing],
test x${enableval} = xyes && AC_DEFINE(DAEMONIZE),
[
AC_CHECK_FUNCS(daemon)
if test "$ac_cv_func_daemon" != yes; then
  daemon=""
  AC_CHECK_LIB(bsd,daemon,daemon="-lbsd")
  if test "$daemon" = ""; then
    AC_MSG_ERROR([*** daemon() function not available on this system and --disable-daemonize not specified])
  fi
fi
AC_DEFINE(DAEMONIZE)
])

AC_ARG_WITH(syslog,
[  --with-syslog=facility  use syslog instead of logfile],
if test -n "${withval}"; then
  facility="${withval}"
  if test "${withval}" = yes; then
    facility=LOG_DAEMON;
  elif test "${withval}" = LOG_AUTH; then
    true;
  elif test "${withval}" = LOG_AUTHPRIV; then
    true;
  elif test "${withval}" = LOG_DAEMON; then
    true;
  elif test "${withval}" = LOG_LOCAL0; then
    true;
  elif test "${withval}" = LOG_LOCAL1; then
    true;
  elif test "${withval}" = LOG_LOCAL2; then
    true;
  elif test "${withval}" = LOG_LOCAL3; then
    true;
  elif test "${withval}" = LOG_LOCAL4; then
    true;
  elif test "${withval}" = LOG_LOCAL5; then
    true;
  elif test "${withval}" = LOG_LOCAL6; then
    true;
  elif test "${withval}" = LOG_LOCAL7; then
    true;
  elif test "${withval}" = LOG_USER; then
    true;
  else
    AC_MSG_ERROR([*** invalid facility (see syslog(3) for possible facilities) ])
  fi
  AC_DEFINE(USE_SYSLOG)
fi
)

dnl if --prefix is not specified, then $prefix is still set to NONE by
dnl configure.  That's bad here where we want to expand it!
cur_prefix=$prefix
test "x${prefix}" = "xNONE" && prefix=$ac_default_prefix 
test "${sysconfdir}" = "\${prefix}/etc" && sysconfdir=/etc
test "${localstatedir}" = "\${prefix}/var" && localstatedir=/var
sysconfdir_exp=`eval "echo ${sysconfdir}"`
localstatedir_exp=`eval "echo ${localstatedir}"`
prefix=$cur_prefix

receive=""
if ! echo ${hw_module}|grep " receive.o" >/dev/null; then
	receive="receive.o"
fi

hw_module_libs="${alsa_lib} ${atilibusb_lib} ${caraca_lib} ${commandir_lib} ${iguanaIR_lib} ${irman_lib} ${portaudio_lib}"

dnl tell the Makefiles what we decided
AC_SUBST(daemon)
AC_SUBST(forkpty)
AC_SUBST(devdir)
AC_SUBST(sysconfdir)
AC_SUBST(moduledir)
AC_SUBST(lirc_major)
AC_SUBST(driver)
AC_SUBST(lirc_driver)
AC_SUBST(hw_module_libs)
AC_SUBST(vga_progs) 
AC_SUBST(x_progs)
AC_SUBST(hw_module)
AC_SUBST(receive)
AC_SUBST(irtty)
AC_SUBST(lircd_conf)
AC_SUBST(lircmd_conf)
AC_SUBST(maintmode_daemons_extra)

if test "$lirc_driver" = "lirc_dev commandir lirc_cmdir"; then
  lirc_driver="lirc_dev lirc_cmdir"
fi

dnl tell the C code what we decided
AC_DEFINE_UNQUOTED(DEVDIR, "$devdir")
AC_DEFINE_UNQUOTED(SYSCONFDIR, "$sysconfdir_exp")
AC_DEFINE_UNQUOTED(LOCALSTATEDIR, "$localstatedir_exp")
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")

AC_DEFINE_UNQUOTED(LIRC_DRIVER, "$driver")
AC_DEFINE_UNQUOTED(LIRC_MAJOR, $lirc_major)
if test "$port" != ""; then
  AC_DEFINE_UNQUOTED(LIRC_PORT, $port)
fi
if test "$irq" != ""; then
  AC_DEFINE_UNQUOTED(LIRC_IRQ, $irq)
fi
if test "$timer" != ""; then
  AC_DEFINE_UNQUOTED(LIRC_TIMER, $timer)
fi
AC_DEFINE_UNQUOTED(LIRC_IRTTY, "$irtty")
AC_DEFINE_UNQUOTED(LIRC_SYSLOG, $facility)

AH_TOP([
/* device file names - beneath DEVDIR (default /dev) */
#define DEV_LIRC	"lirc"
#define DEV_LIRCD	"lircd"
#define DEV_LIRCM	"lircm"

/* config file names - beneath SYSCONFDIR (default /etc) */
#define CFG_LIRCD	"lircd.conf"
#define CFG_LIRCM	"lircmd.conf"

/* config file names - beneath $HOME or SYSCONFDIR */
#define CFG_LIRCRC	"lircrc"

/* log files */
#define LOG_LIRCD	"lircd"
#define LOG_LIRMAND	"lirmand"

/* pid file */
#define PID_LIRCD       "lircd.pid"

/* default port number */
#define	LIRC_INET_PORT	8765
])

AH_BOTTOM([
#ifdef LIRC_HAVE_DEVFS
#define LIRC_DRIVER_DEVICE	DEVDIR "/" DEV_LIRC "/0"
#else
#define LIRC_DRIVER_DEVICE      DEVDIR "/" DEV_LIRC
#endif /* LIRC_HAVE_DEVFS */

#define LIRC_IRTTY		DEVDIR "/" "ttyS0"

#define LIRCD			DEVDIR "/" DEV_LIRCD
#define LIRCM			DEVDIR "/" DEV_LIRCM

#define LIRCDCFGFILE		SYSCONFDIR "/" CFG_LIRCD
#define LIRCMDCFGFILE		SYSCONFDIR "/" CFG_LIRCM

#define LIRCRC_USER_FILE	"." CFG_LIRCRC
#define LIRCRC_ROOT_FILE	SYSCONFDIR "/" CFG_LIRCRC

#define LOGFILE			LOCALSTATEDIR "/log/" LOG_LIRCD
#define LIRMAND_LOGFILE		LOCALSTATEDIR "/log/" LOG_LIRMAND

#define PIDFILE                 LOCALSTATEDIR "/run/" PID_LIRCD

#define LIRC_RELEASE_SUFFIX     "_UP"
])

dnl bug in automake/autoconf?
dnl SHELL=/bin/sh AC_SUBST(SHELL)

dnl write these decisions out to the Makefiles
AC_CONFIG_FILES([
  Makefile
  drivers/Makefile
  drivers/lirc_atiusb/Makefile
  drivers/lirc_bt829/Makefile
  drivers/lirc_cmdir/Makefile
  drivers/lirc_dev/Makefile
  drivers/lirc_gpio/Makefile
  drivers/lirc_i2c/Makefile
  drivers/lirc_igorplugusb/Makefile
  drivers/lirc_ttusbir/Makefile
  drivers/lirc_imon/Makefile
  drivers/lirc_it87/Makefile
  drivers/lirc_ite8709/Makefile
  drivers/lirc_mceusb/Makefile
  drivers/lirc_mceusb2/Makefile
  drivers/lirc_parallel/Makefile
  drivers/lirc_sasem/Makefile
  drivers/lirc_serial/Makefile
  drivers/lirc_sir/Makefile
  drivers/lirc_streamzap/Makefile
  daemons/Makefile
  tools/Makefile
  doc/Makefile
  doc/man/Makefile
])
AC_OUTPUT

echo
if test "$driver" = "all"; then
  echo "All kernel modules will be built."
elif test "$driver" = "mediafocusI"; then
  echo "You will have to use the MediaFocus driver from:"
  echo "http://freenet-homepage.de/mediafocus/"
elif test "$driver" = "exaudio"; then
  echo "You will have to use the Exaudio driver from:"
  echo "http://exaudio.sourceforge.net/"
elif test "$driver" = "alsa_usb"; then
  echo "You will have to use the snd-usb-audio driver from:"
  echo "http://www.alsa-project.org/"
elif test "$driver" = "hauppauge_dvb"; then
  echo "You will have to use the DVB driver from:"
  echo "http://www.linuxtv.org"
elif test "$kernel_module" = ""; then
  echo "Your hardware does not require a special LIRC kernel module."
  if test "${irtty}" != ""; then
    echo
    echo "You will have to use the suitable kernel driver to access ${irtty}."
  fi
else
  echo "You will have to use the $kernel_module kernel module."
fi
echo
echo "Now enter 'make' and 'make install' to compile and install the package."
echo